本文整理匯總了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