本文整理汇总了Python中lib.pil.Image.isStringType方法的典型用法代码示例。如果您正苦于以下问题:Python Image.isStringType方法的具体用法?Python Image.isStringType怎么用?Python Image.isStringType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.pil.Image
的用法示例。
在下文中一共展示了Image.isStringType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: grabclipboard
# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import isStringType [as 别名]
def grabclipboard():
debug = 0 # temporary interface
data = Image.core.grabclipboard(debug)
if Image.isStringType(data):
import BmpImagePlugin, StringIO
return BmpImagePlugin.DibImageFile(StringIO.StringIO(data))
return data
示例2: __init__
# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import isStringType [as 别名]
def __init__(self, profile):
# accepts a string (filename), a file-like object, or a low-level
# profile object
if Image.isStringType(profile):
self._set(core.profile_open(profile), profile)
elif hasattr(profile, "read"):
self._set(core.profile_fromstring(profile.read()))
else:
self._set(profile) # assume it's already a profile
示例3: _getink
# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import isStringType [as 别名]
def _getink(self, ink, fill=None):
if ink is None and fill is None:
if self.fill:
fill = self.ink
else:
ink = self.ink
else:
if ink is not None:
if Image.isStringType(ink):
ink = ImageColor.getcolor(ink, self.mode)
if self.palette and not Image.isNumberType(ink):
ink = self.palette.getcolor(ink)
ink = self.draw.draw_ink(ink, self.mode)
if fill is not None:
if Image.isStringType(fill):
fill = ImageColor.getcolor(fill, self.mode)
if self.palette and not Image.isNumberType(fill):
fill = self.palette.getcolor(fill)
fill = self.draw.draw_ink(fill, self.mode)
return ink, fill
示例4: setink
# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import isStringType [as 别名]
def setink(self, ink):
# compatibility
if warnings:
warnings.warn(
"'setink' is deprecated; use keyword arguments instead",
DeprecationWarning, stacklevel=2
)
if Image.isStringType(ink):
ink = ImageColor.getcolor(ink, self.mode)
if self.palette and not Image.isNumberType(ink):
ink = self.palette.getcolor(ink)
self.ink = self.draw.draw_ink(ink, self.mode)
示例5: __init__
# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import isStringType [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)
示例6: __init__
# 需要导入模块: from lib.pil import Image [as 别名]
# 或者: from lib.pil.Image import isStringType [as 别名]
def __init__(self, fp=None, filename=None):
Image.Image.__init__(self)
self.tile = None
self.readonly = 1 # until we know better
self.decoderconfig = ()
self.decodermaxblock = MAXBLOCK
if Image.isStringType(fp):
# filename
self.fp = open(fp, "rb")
self.filename = fp
else:
# stream
self.fp = fp
self.filename = filename
try:
self._open()
except IndexError, v: # end of data
if Image.DEBUG > 1:
traceback.print_exc()
raise SyntaxError, v