当前位置: 首页>>代码示例>>Python>>正文


Python Image.open方法代码示例

本文整理汇总了Python中lib.pil.Image.open方法的典型用法代码示例。如果您正苦于以下问题:Python Image.open方法的具体用法?Python Image.open怎么用?Python Image.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.pil.Image的用法示例。


在下文中一共展示了Image.open方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
	def __init__(self, im):

		data = None
		colortable = None

		# handle filename, if given instead of image name
		if hasattr(im, "toUtf8"):
			# FIXME - is this really the best way to do this?
			im = unicode(im.toUtf8(), "utf-8")
		if Image.isStringType(im):
			im = Image.open(im)

		if im.mode == "1":
			format = QImage.Format_Mono
		elif im.mode == "L":
			format = QImage.Format_Indexed8
			colortable = []
			for i in range(256):
				colortable.append(rgb(i, i, i))
		elif im.mode == "P":
			format = QImage.Format_Indexed8
			colortable = []
			palette = im.getpalette()
			for i in range(0, len(palette), 3):
				colortable.append(rgb(*palette[i:i+3]))
		elif im.mode == "RGB":
			data = im.tostring("raw", "BGRX")
			format = QImage.Format_RGB32
		elif im.mode == "RGBA":
			try:
				data = im.tostring("raw", "BGRA")
			except SystemError:
				# workaround for earlier versions
				r, g, b, a = im.split()
				im = Image.merge("RGBA", (b, g, r, a))
			format = QImage.Format_ARGB32
		else:
			raise ValueError("unsupported image mode %r" % im.mode)

		# must keep a reference, or Qt will crash!
		self.__data = data or im.tostring()

		QImage.__init__(self, self.__data, im.size[0], im.size[1], format)

		if colortable:
			self.setColorTable(colortable)
开发者ID:TheArchives,项目名称:blockBox,代码行数:48,代码来源:ImageQt.py

示例2: _load_pilfont

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
	def _load_pilfont(self, filename):

		file = open(filename, "rb")

		for ext in (".png", ".gif", ".pbm"):
			try:
				fullname = os.path.splitext(filename)[0] + ext
				image = Image.open(fullname)
			except:
				pass
			else:
				if image and image.mode in ("1", "L"):
					break
		else:
			raise IOError("cannot find glyph data file")

		self.file = fullname

		return self._load_pilfont_data(file, image)
开发者ID:TheArchives,项目名称:blockBox,代码行数:21,代码来源:ImageFont.py

示例3: loadImageSeries

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
def loadImageSeries(filelist=None):
	" create a list of Image.images for use in montage "
	if filelist == None or len(filelist) < 1:
		return

	imglist = []
	for img in filelist:
		if not os.path.exists(img):
			print "unable to find %s" % img
			continue
		try:
			im = Image.open(img).convert2byte()
		except:
			if not isSpiderImage(img):
				print img + " is not a Spider image file"
			continue
		im.info['filename'] = img
		imglist.append(im)
	return imglist
开发者ID:TheArchives,项目名称:blockBox,代码行数:21,代码来源:SpiderImagePlugin.py

示例4: load

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
	def load(self):

		if len(self.tile) != 1 or self.tile[0][0] != "iptc":
			return ImageFile.ImageFile.load(self)

		type, tile, box = self.tile[0]

		encoding, offset = tile

		self.fp.seek(offset)

		# Copy image data to temporary file
		outfile = tempfile.mktemp()
		o = open(outfile, "wb")
		if encoding == "raw":
			# To simplify access to the extracted file,
			# prepend a PPM header
			o.write("P5\n%d %d\n255\n" % self.size)
		while 1:
			type, size = self.field()
			if type != (8, 10):
				break
			while size > 0:
				s = self.fp.read(min(size, 8192))
				if not s:
					break
				o.write(s)
				size = size - len(s)
		o.close()

		try:
			try:
				# fast
				self.im = Image.core.open_ppm(outfile)
			except:
				# slightly slower
				im = Image.open(outfile)
				im.load()
				self.im = im.im
		finally:
			try: os.unlink(outfile)
			except: pass
开发者ID:TheArchives,项目名称:blockBox,代码行数:44,代码来源:IptcImagePlugin.py

示例5: close

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
 def close(self):
     # finish decoding
     if self.decoder:
         # get rid of what's left in the buffers
         self.feed("")
         self.data = self.decoder = None
         if not self.finished:
             raise IOError("image was incomplete")
     if not self.image:
         raise IOError("cannot parse this image")
     if self.data:
         # incremental parsing not possible; reopen the file
         # not that we have all data
         try:
             fp = _ParserFile(self.data)
             self.image = Image.open(fp)
         finally:
             self.image.load()
             fp.close()  # explicitly close the virtual file
     return self.image
开发者ID:katerberg-zz,项目名称:blockBox,代码行数:22,代码来源:ImageFile.py

示例6: feed

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
    def feed(self, data):
        # collect data

        if self.finished:
            return

        if self.data is None:
            self.data = data
        else:
            self.data = self.data + data

            # parse what we have
        if self.decoder:

            if self.offset > 0:
                # skip header
                skip = min(len(self.data), self.offset)
                self.data = self.data[skip:]
                self.offset = self.offset - skip
                if self.offset > 0 or not self.data:
                    return

            n, e = self.decoder.decode(self.data)

            if n < 0:
                # end of stream
                self.data = None
                self.finished = 1
                if e < 0:
                    # decoding error
                    self.image = None
                    raise_ioerror(e)
                else:
                    # end of image
                    return
            self.data = self.data[n:]

        elif self.image:

            # if we end up here with no decoder, this file cannot
            # be incrementally parsed.  wait until we've gotten all
            # available data
            pass

        else:

            # attempt to open this file
            try:
                try:
                    fp = _ParserFile(self.data)
                    im = Image.open(fp)
                finally:
                    fp.close()  # explicitly close the virtual file
            except IOError:
                pass  # not enough data
            else:
                flag = hasattr(im, "load_seek") or hasattr(im, "load_read")
                if flag or len(im.tile) != 1:
                    # custom load code, or multiple tiles
                    self.decode = None
                else:
                    # initialize decoder
                    im.load_prepare()
                    d, e, o, a = im.tile[0]
                    im.tile = []
                    self.decoder = Image._getdecoder(im.mode, d, a, im.decoderconfig)
                    self.decoder.setimage(im.im, e)

                    # calculate decoder offset
                    self.offset = o
                    if self.offset <= len(self.data):
                        self.data = self.data[self.offset :]
                        self.offset = 0

                self.image = im
开发者ID:katerberg-zz,项目名称:blockBox,代码行数:77,代码来源:ImageFile.py

示例7: load_default

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
def load_default():
	"Load a default font."
	from StringIO import StringIO
	import base64
	f = ImageFont()
	f._load_pilfont_data(
		 # courB08
		 StringIO(base64.decodestring('''
UElMZm9udAo7Ozs7OzsxMDsKREFUQQoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAA//8AAQAAAAAAAAABAAEA
BgAAAAH/+gADAAAAAQAAAAMABgAGAAAAAf/6AAT//QADAAAABgADAAYAAAAA//kABQABAAYAAAAL
AAgABgAAAAD/+AAFAAEACwAAABAACQAGAAAAAP/5AAUAAAAQAAAAFQAHAAYAAP////oABQAAABUA
AAAbAAYABgAAAAH/+QAE//wAGwAAAB4AAwAGAAAAAf/5AAQAAQAeAAAAIQAIAAYAAAAB//kABAAB
ACEAAAAkAAgABgAAAAD/+QAE//0AJAAAACgABAAGAAAAAP/6AAX//wAoAAAALQAFAAYAAAAB//8A
BAACAC0AAAAwAAMABgAAAAD//AAF//0AMAAAADUAAQAGAAAAAf//AAMAAAA1AAAANwABAAYAAAAB
//kABQABADcAAAA7AAgABgAAAAD/+QAFAAAAOwAAAEAABwAGAAAAAP/5AAYAAABAAAAARgAHAAYA
AAAA//kABQAAAEYAAABLAAcABgAAAAD/+QAFAAAASwAAAFAABwAGAAAAAP/5AAYAAABQAAAAVgAH
AAYAAAAA//kABQAAAFYAAABbAAcABgAAAAD/+QAFAAAAWwAAAGAABwAGAAAAAP/5AAUAAABgAAAA
ZQAHAAYAAAAA//kABQAAAGUAAABqAAcABgAAAAD/+QAFAAAAagAAAG8ABwAGAAAAAf/8AAMAAABv
AAAAcQAEAAYAAAAA//wAAwACAHEAAAB0AAYABgAAAAD/+gAE//8AdAAAAHgABQAGAAAAAP/7AAT/
/gB4AAAAfAADAAYAAAAB//oABf//AHwAAACAAAUABgAAAAD/+gAFAAAAgAAAAIUABgAGAAAAAP/5
AAYAAQCFAAAAiwAIAAYAAP////oABgAAAIsAAACSAAYABgAA////+gAFAAAAkgAAAJgABgAGAAAA
AP/6AAUAAACYAAAAnQAGAAYAAP////oABQAAAJ0AAACjAAYABgAA////+gAFAAAAowAAAKkABgAG
AAD////6AAUAAACpAAAArwAGAAYAAAAA//oABQAAAK8AAAC0AAYABgAA////+gAGAAAAtAAAALsA
BgAGAAAAAP/6AAQAAAC7AAAAvwAGAAYAAP////oABQAAAL8AAADFAAYABgAA////+gAGAAAAxQAA
AMwABgAGAAD////6AAUAAADMAAAA0gAGAAYAAP////oABQAAANIAAADYAAYABgAA////+gAGAAAA
2AAAAN8ABgAGAAAAAP/6AAUAAADfAAAA5AAGAAYAAP////oABQAAAOQAAADqAAYABgAAAAD/+gAF
AAEA6gAAAO8ABwAGAAD////6AAYAAADvAAAA9gAGAAYAAAAA//oABQAAAPYAAAD7AAYABgAA////
+gAFAAAA+wAAAQEABgAGAAD////6AAYAAAEBAAABCAAGAAYAAP////oABgAAAQgAAAEPAAYABgAA
////+gAGAAABDwAAARYABgAGAAAAAP/6AAYAAAEWAAABHAAGAAYAAP////oABgAAARwAAAEjAAYA
BgAAAAD/+gAFAAABIwAAASgABgAGAAAAAf/5AAQAAQEoAAABKwAIAAYAAAAA//kABAABASsAAAEv
AAgABgAAAAH/+QAEAAEBLwAAATIACAAGAAAAAP/5AAX//AEyAAABNwADAAYAAAAAAAEABgACATcA
AAE9AAEABgAAAAH/+QAE//wBPQAAAUAAAwAGAAAAAP/7AAYAAAFAAAABRgAFAAYAAP////kABQAA
AUYAAAFMAAcABgAAAAD/+wAFAAABTAAAAVEABQAGAAAAAP/5AAYAAAFRAAABVwAHAAYAAAAA//sA
BQAAAVcAAAFcAAUABgAAAAD/+QAFAAABXAAAAWEABwAGAAAAAP/7AAYAAgFhAAABZwAHAAYAAP//
//kABQAAAWcAAAFtAAcABgAAAAD/+QAGAAABbQAAAXMABwAGAAAAAP/5AAQAAgFzAAABdwAJAAYA
AP////kABgAAAXcAAAF+AAcABgAAAAD/+QAGAAABfgAAAYQABwAGAAD////7AAUAAAGEAAABigAF
AAYAAP////sABQAAAYoAAAGQAAUABgAAAAD/+wAFAAABkAAAAZUABQAGAAD////7AAUAAgGVAAAB
mwAHAAYAAAAA//sABgACAZsAAAGhAAcABgAAAAD/+wAGAAABoQAAAacABQAGAAAAAP/7AAYAAAGn
AAABrQAFAAY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nAAIAAYAAP////cABgAAApwAAAKjAAkABgAA////
+gAGAAACowAAAqoABgAGAAAAAP/6AAUAAgKqAAACrwAIAAYAAP////cABQAAAq8AAAK1AAkABgAA
////9wAFAAACtQAAArsACQAGAAD////3AAUAAAK7AAACwQAJAAYAAP////gABQAAAsEAAALHAAgA
BgAAAAD/9wAEAAACxwAAAssACQAGAAAAAP/3AAQAAALLAAACzwAJAAYAAAAA//cABAAAAs8AAALT
AAkABgAAAAD/+AAEAAAC0wAAAtcACAAGAAD////6AAUAAALXAAAC3QAGAAYAAP////cABgAAAt0A
AALkAAkABgAAAAD/9wAFAAAC5AAAAukACQAGAAAAAP/3AAUAAALpAAAC7gAJAAYAAAAA//cABQAA
Au4AAALzAAkABgAAAAD/9wAFAAAC8wAAAvgACQAGAAAAAP/4AAUAAAL4AAAC/QAIAAYAAAAA//oA
Bf//Av0AAAMCAAUABgAA////+gAGAAADAgAAAwkABgAGAAD////3AAYAAAMJAAADEAAJAAYAAP//
//cABgAAAxAAAAMXAAkABgAA////9wAGAAADFwAAAx4ACQAGAAD////4AAYAAAAAAAoABwASAAYA
AP////cABgAAAAcACgAOABMABgAA////+gAFAAAADgAKABQAEAAGAAD////6AAYAAAAUAAoAGwAQ
AAYAAAAA//gABgAAABsACgAhABIABgAAAAD/+AAGAAAAIQAKACcAEgAGAAAAAP/4AAYAAAAnAAoA
LQASAAYAAAAA//gABgAAAC0ACgAzABIABgAAAAD/+QAGAAAAMwAKADkAEQAGAAAAAP/3AAYAAAA5
AAoAPwATAAYAAP////sABQAAAD8ACgBFAA8ABgAAAAD/+wAFAAIARQAKAEoAEQAGAAAAAP/4AAUA
AABKAAoATwASAAYAAAAA//gABQAAAE8ACgBUABIABgAAAAD/+AAFAAAAVAAKAFkAEgAGAAAAAP/5
AAUAAABZAAoAXgARAAYAAAAA//gABgAAAF4ACgBkABIABgAAAAD/+AAGAAAAZAAKAGoAEgAGAAAA
AP/4AAYAAABqAAoAcAASAAYAAAAA//kABgAAAHAACgB2ABEABgAAAAD/+AAFAAAAdgAKAHsAEgAG
AAD////4AAYAAAB7AAoAggASAAYAAAAA//gABQAAAIIACgCHABIABgAAAAD/+AAFAAAAhwAKAIwA
EgAGAAAAAP/4AAUAAACMAAoAkQASAAYAAAAA//gABQAAAJEACgCWABIABgAAAAD/+QAFAAAAlgAK
AJsAEQAGAAAAAP/6AAX//wCbAAoAoAAPAAYAAAAA//oABQABAKAACgClABEABgAA////+AAGAAAA
pQAKAKwAEgAGAAD////4AAYAAACsAAoAswASAAYAAP////gABgAAALMACgC6ABIABgAA////+QAG
AAAAugAKAMEAEQAGAAD////4AAYAAgDBAAoAyAAUAAYAAP////kABQACAMgACgDOABMABgAA////
+QAGAAIAzgAKANUAEw==
''')), Image.open(StringIO(base64.decodestring('''
#.........这里部分代码省略.........
开发者ID:TheArchives,项目名称:blockBox,代码行数:103,代码来源:ImageFont.py

示例8: load

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
		self.mode = 'RGBA'
		self.size = self.icns.bestsize()
		self.info['sizes'] = self.icns.itersizes()
		# Just use this to see if it's loaded or not yet.
		self.tile = ('',)

	def load(self):
		Image.Image.load(self)
		if not self.tile:
			return
		self.load_prepare()
		# This is likely NOT the best way to do it, but whatever.
		im = self.icns.getimage(self.size)
		self.im = im.im
		self.mode = im.mode
		self.size = im.size
		self.fp = None
		self.icns = None
		self.tile = ()
		self.load_end()


Image.register_open("ICNS", IcnsImageFile, lambda x: x[:4] == 'icns')
Image.register_extension("ICNS", '.icns')

if __name__ == '__main__':
	import os, sys
	im = Image.open(open(sys.argv[1], "rb"))
	im.save("out.png")
	os.startfile("out.png")
开发者ID:TheArchives,项目名称:blockBox,代码行数:32,代码来源:IcnsImagePlugin.py

示例9: DisplayViewer

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
			command = "(%s %s; rm -f %s)&" % (command, file, file)
			os.system(command)
			return 1

	# implementations

	class DisplayViewer(UnixViewer):
		def get_command_ex(self, file, **options):
			command = executable = "display"
			return command, executable

	if which("display"):
		register(DisplayViewer)

	class XVViewer(UnixViewer):
		def get_command_ex(self, file, title=None, **options):
			# note: xv is pretty outdated.  most modern systems have
			# imagemagick's display command instead.
			command = executable = "xv"
			if title:
				# FIXME: do full escaping
				command = command + " -name \"%s\"" % title
			return command, executable

	if which("xv"):
		register(XVViewer)

if __name__ == "__main__":
	# usage: python ImageShow.py imagefile [title]
	print show(Image.open(sys.argv[1]), *sys.argv[2:])
开发者ID:TheArchives,项目名称:blockBox,代码行数:32,代码来源:ImageShow.py

示例10: isSpiderImage

# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import open [as 别名]
Image.register_save("SPIDER", _save_spider)

if __name__ == "__main__":

	if not sys.argv[1:]:
		print "Syntax: python SpiderImagePlugin.py Spiderimage [outfile]"
		sys.exit()

	filename = sys.argv[1]
	if not isSpiderImage(filename):
		print "input image must be in Spider format"
		sys.exit()

	outfile = ""
	if len(sys.argv[1:]) > 1:
		outfile = sys.argv[2]

	im = Image.open(filename)
	print "image: " + str(im)
	print "format: " + str(im.format)
	print "size: " + str(im.size)
	print "mode: " + str(im.mode)
	print "max, min: ",
	print im.getextrema()

	if outfile != "":
		# perform some image operation
		im = im.transpose(Image.FLIP_LEFT_RIGHT)
		print "saving a flipped version of %s as %s " % (os.path.basename(filename), outfile)
		im.save(outfile, "SPIDER")
开发者ID:TheArchives,项目名称:blockBox,代码行数:32,代码来源:SpiderImagePlugin.py


注:本文中的lib.pil.Image.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。