本文整理汇总了Python中amo.utils.ImageCheck.is_image方法的典型用法代码示例。如果您正苦于以下问题:Python ImageCheck.is_image方法的具体用法?Python ImageCheck.is_image怎么用?Python ImageCheck.is_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amo.utils.ImageCheck
的用法示例。
在下文中一共展示了ImageCheck.is_image方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_persona_image
# 需要导入模块: from amo.utils import ImageCheck [as 别名]
# 或者: from amo.utils.ImageCheck import is_image [as 别名]
def save_persona_image(src, full_dst, **kw):
"""Creates a PNG of a Persona header/footer image."""
log.info("[[email protected]] Saving persona image: %s" % full_dst)
img = ImageCheck(storage.open(src))
if not img.is_image():
log.error("Not an image: %s" % src, exc_info=True)
return
with storage.open(src, "rb") as fp:
i = Image.open(fp)
with storage.open(full_dst, "wb") as fp:
i.save(fp, "png")
return True
示例2: check_icons
# 需要导入模块: from amo.utils import ImageCheck [as 别名]
# 或者: from amo.utils.ImageCheck import is_image [as 别名]
def check_icons(self, webapp):
manifest = webapp.get_manifest_json()
biggest = max([int(size) for size in manifest["icons"]])
icon_dir = webapp.get_icon_dir()
for size in amo.ADDON_ICON_SIZES:
if not size <= biggest:
continue
icon_path = os.path.join(icon_dir, "%s-%s.png" % (str(webapp.id), size))
with open(icon_path, "r") as img:
checker = ImageCheck(img)
assert checker.is_image()
eq_(checker.img.size, (size, size))
示例3: check_icons
# 需要导入模块: from amo.utils import ImageCheck [as 别名]
# 或者: from amo.utils.ImageCheck import is_image [as 别名]
def check_icons(self, webapp, file_obj=None):
manifest = webapp.get_manifest_json(file_obj)
biggest = max([int(size) for size in manifest['icons']])
icon_dir = webapp.get_icon_dir()
for size in amo.APP_ICON_SIZES:
if not size <= biggest:
continue
icon_path = os.path.join(icon_dir, '%s-%s.png'
% (str(webapp.id), size))
with open(icon_path, 'r') as img:
checker = ImageCheck(img)
assert checker.is_image()
eq_(checker.img.size, (size, size))
示例4: _check_image
# 需要导入模块: from amo.utils import ImageCheck [as 别名]
# 或者: from amo.utils.ImageCheck import is_image [as 别名]
def _check_image(im_path, abs_url):
valid = True
img_format = ''
with open(im_path, 'rb') as fp:
im = ImageCheck(fp)
if not im.is_image():
valid = False
log.error('image at %s is not an image' % abs_url)
if im.is_animated():
valid = False
log.error('image at %s is animated' % abs_url)
if valid:
img_format = im.img.format
return valid, img_format
示例5: save_persona_image
# 需要导入模块: from amo.utils import ImageCheck [as 别名]
# 或者: from amo.utils.ImageCheck import is_image [as 别名]
def save_persona_image(src, dst, img_basename, **kw):
"""Creates a JPG of a Persona header/footer image."""
log.info('[[email protected]] Saving persona image: %s' % dst)
img = ImageCheck(storage.open(src))
if not img.is_image():
log.error('Not an image: %s' % src, exc_info=True)
return
try:
with storage.open(src) as fp:
i = Image.open(fp)
with storage.open(os.path.join(dst, img_basename), 'wb') as fp:
i.save(fp)
return True
except Exception, e:
log.error('Error saving persona image: %s' % e)
示例6: test_junk
# 需要导入模块: from amo.utils import ImageCheck [as 别名]
# 或者: from amo.utils.ImageCheck import is_image [as 别名]
def test_junk(self):
img = ImageCheck(open(__file__, 'rb'))
assert not img.is_image()
img = ImageCheck(open(get_image_path('non-animated.gif')))
assert img.is_image()