本文整理汇总了Python中kivy.uix.image.Image.open方法的典型用法代码示例。如果您正苦于以下问题:Python Image.open方法的具体用法?Python Image.open怎么用?Python Image.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.image.Image
的用法示例。
在下文中一共展示了Image.open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import open [as 别名]
def build(self):
ikon=content[3]
s = ScatterPlane(scale=.5)
filename=join(imdir, 'background.png')
print filename[:-1]
filename2=join(imdir,content[1][:-1])
print filename2
im=Image(source=filename2,size=(1920,1090))
img=Image.open(filename2)
exif_data=img._getexif();
s.add_widget(im)
return s
示例2: select_to
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import open [as 别名]
def select_to(self,*args):
try:
print args[1][0]
iw = Image.open(args[1][0])
iw.save('Yellow_Rose.jpg')
gray = iw.convert('1')
gray.save('Yellow_Rose.jpg')
self.img3.source = 'Yellow_Rose.jpg'
self.img4.source = 'Yellow_Rose.jpg'
self.img.source = 'Yellow_Rose.jpg'
self.img.reload()
self.img3.reload()
self.img4.reload()
except:
pass
示例3: on_touch_down
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import open [as 别名]
def on_touch_down(self, touch):
super(CalibrationScreen, self).on_touch_down(touch)
# Normalized position on the image.
# First get the coordinates clicked, 0, 0 starts at the bottom left of the image (determined by image_offset).
normalized_pos = [touch.x - self.image_offset[0], touch.y - self.image_offset[1]]
# Get the location clicked IN PERCENTAGE of the image's size:
normalized_pos[0] = normalized_pos[0] / self.image_dimensions[0]
normalized_pos[1] = normalized_pos[1] / self.image_dimensions[1]
# Check if image was clicked and selection in progress, basically if percentage is above 100 or below 0
# we're calculating based on 0-1 where 1 is 100%. If self.selection is -1, no selection was made and
# nothing happens.
if(self.selection == -1 or
normalized_pos[0] > 1 or normalized_pos[0] < 0 or
normalized_pos[1] > 1 or normalized_pos[1] < 0):
# Selection is not turned on OR the user clicked outside the image. Do NADA!
return
# Open the image that was clicked, we're gonna get them pesky pixels
img = Image.open('calibImage.jpg')
# The percentage times the image's width and height, where da pixel at?
img_x = normalized_pos[0] * img.width
img_y = normalized_pos[1] * img.height
# Invert the y coordinate inside the image:
img_y = img.height - img_y
# Grab color values of the clicked pixel.
r, g, b = img.getpixel((img_x, img_y))
# Depending on action, set min or max.
if self.selection == 0:
CURRENT_COLOR.set_min([b, g, r])
self.r_min = r / 255
self.g_min = g / 255
self.b_min = b / 255
if self.selection == 1:
CURRENT_COLOR.set_max([b, g, r])
self.r_max = r / 255
self.g_max = g / 255
self.b_max = b / 255
# Resets select action.
self.selection = -1
self.current_action_string = 'No action selected'
self.update_color_string()
示例4: update_icon
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import open [as 别名]
def update_icon(self, online=True):
offline = '_offline'
if online:
offline = ''
self.icon_wid.source = 'data/icon' + offline + '.png'
try:
upload_count = len(glob.glob('offline/*.json'))
if upload_count > 0:
img = Image.open('data/icon' + offline + '.png')
draw = ImageDraw.Draw(img)
draw.ellipse((50, 65, 95, 95), fill=(165, 208, 101, 0))
font = ImageFont.truetype("data/verdanab.ttf", 24)
posx = 65
if upload_count > 9:
posx = 55
draw.text((posx, 65), str(upload_count), (255, 255, 255), font=font)
img.save('data/icon2' + offline + '.png')
self.icon_wid.source = 'data/icon2' + offline + '.png'
self.icon_wid.reload()
except:
traceback.print_exc(file=sys.stdout)
示例5: guardar_informe
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import open [as 别名]
#.........这里部分代码省略.........
# INFORME CALCÚLE ______________________________________________________
sheet.write_merge(0,4,0,13,'',estilobg)
sheet.write_merge(5,7,0,0,'',estilobg)
sheet.write_merge(5,7,13,13,'',estilobg)
sheet.write_merge(8,35,0,13,'',estilobg)
sheet.write_merge(0,0,0,13,u'INFORME SOFTWARE CALCÚLE, ESCÚCHE Y PREVÉNGA',estilo)
sheet.write_merge(1,1,0,13,'Fecha: '+ fecha_hora + ' - >>> Página 2/4 <<<',estilo12)
sheet.write_merge(3,3,0,13,u'ESTIMACIÓN DE PÉRDIDA AUDITIVA H Y H\'',estilo12)
sheet.write(5,1,'Frec. (Hz)',estilo11)
sheet.write(6,1,'H',estilo11)
sheet.write(7,1,'H\'',estilo11)
for i,x in enumerate(frecuencias):
sheet.write(5,i+2,frecuencias[i],estilo1) # Freq
sheet.write(6,i+2,h[i],estilo2) # H
sheet.write(7,i+2,h_prima[i],estilo2) # H'
# ancho columnas
sheet.col(0).width = 256*7 # una pulgada
sheet.col(1).width = 256*13 # 256 * Nro caracteres
sheet.col(2).width = 256*6
sheet.col(3).width = 256*6
sheet.col(4).width = 256*6
i=5
while i < 14:
sheet.col(i).width = 256*7
i+=1
ancho = 605
alto = 454
imagen = Image.open(os.path.join('images', 'H_y_Hprima_octavs.png')).resize((ancho,alto),Image.ANTIALIAS).convert('RGB').save(os.path.join('images', 'H_y_Hprima_octavs.bmp'))
sheet.insert_bitmap(os.path.join('images', 'H_y_Hprima_octavs.bmp'),9,1)
# INFORME ESCÚCHE __________________________________________________________________
sheet1.write_merge(0,39,0,13,'',estilobg)
sheet1.write_merge(0,0,0,13,u'INFORME SOFTWARE CALCÚLE, ESCÚCHE Y PREVÉNGA',estilo)
sheet1.write_merge(1,1,0,13,'Fecha: '+ fecha_hora + ' - >>> Página 3/4 <<<',estilo12)
global directorio_audio
audio_seleccionado= directorio_audio
sheet1.write_merge(3,3,0,13,'Audio: '+ os.path.basename(audio_seleccionado),estilo21)
sheet1.write_merge(5,5,0,13,u'FORMA DE ONDA',estilo12)
sheet1.write_merge(12,12,0,13,u'ESPÉCTRO',estilo12)
alto1= 95
ancho1= 296 + 100
imagen1 = Image.open(os.path.join('images', 'forma_de_onda.png')).resize((ancho1,alto1),Image.ANTIALIAS).convert('RGB').save(os.path.join('images', 'forma_de_onda.bmp'))
sheet1.insert_bitmap(os.path.join('images', 'forma_de_onda.bmp'),6,3)
ancho11= ancho + 165
imagen11 = Image.open(os.path.join('images', 'espectros.png')).resize((ancho11,alto),Image.ANTIALIAS).convert('RGB').save(os.path.join('images', 'espectros.bmp'))
sheet1.insert_bitmap(os.path.join('images', 'espectros.bmp') ,13,1)
sheet1.col(0).width = 256*7 # una pulgada
sheet1.col(1).width = 256*13 # 256 * Nro caracteres
sheet1.col(2).width = 256*6
sheet1.col(3).width = 256*6
sheet1.col(4).width = 256*6
i=5
while i < 14:
sheet1.col(i).width = 256*7
i+=1
示例6: next_image
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import open [as 别名]
def next_image(self, *largs): # whatever = None):
print "Showing next image"
global iCurrentIndex
global iShownLength
if (iCurrentIndex == (iShownLength - 1)) or (iShownLength == 0):
strRandom = random.choice(self.photos)
EventLoop.window.title = str(len(self.photos)) + '/' + str(intCount) + ' Loading:' + strRandom
try:
#comment out the exception to try loading by setting image source
raise Exception("Processing with PIL")
img.source = strRandom
except Exception:
try:
global strCache
global bBuildCache
global strFileName
strCached = ""
strFileName = os.path.basename(strRandom)
if (os.path.isdir(strCache)) and (os.path.isfile(strCache + strFileName)):
strCached = strCache + strFileName
elif (os.path.isdir(strCache)) and (bBuildCache == True):
print "Adding image to cache..."
from PIL import Image
im = Image.open(strRandom)
imgWidth, imgHeight = im.size
bResized = False
#wndWidth, wndHeight =
if imgHeight > sngHeight:
bResized = True
sngChange = sngHeight / imgHeight
imgHeight = int(sngHeight)
imgWidth = int(imgWidth * sngChange)
if imgWidth > sngWidth:
bResized = True
sngChange = sngWidth / imgWidth
imgWidth = int(sngWidth)
imgHeight = int(imgHeight * sngChange)
szNew = imgWidth, imgHeight
#if bResized:
#set to true to save all images to the cache
if True:
im=im.resize(szNew, Image.ANTIALIAS)
if not (strCache == ""):
if not os.path.exists(strCache):
os.makedirs(strCache)
strCached = strCache + os.path.basename(strRandom)
if (not os.path.isfile(strCached)):
try:
im.save(strCached)
except Exception as e:
print "save cache file problem: " + e.message
strCached = ""
else:
print "save cache file found"
#else:
# im.save(strTemp)
if not strCached == "":
#img.source = strCached
try:
self.shown.remove(strCached)
except:
print "error removing image from cache"
self.shown.append(strCached)
iShownLength = len(self.shown)
iCurrentIndex = iShownLength - 1
else:
#img.source = strRandom
try:
self.shown.append(strRandom)
except:
print "error removing image from cache"
self.shown.append(strRandom)
iShownLength = len(self.shown)
iCurrentIndex = iShownLength - 1
#img.reload()
except Exception as e:
print "Error(" + e.message + ") loading image " + strRandom
#continue with the logic
self.photos.remove(strRandom)
if len(self.photos) < 1:
self.photos = glob.glob(strDir + "*.jpg")
#global bReschedule
else:
iCurrentIndex += 1
self.show_current_image()