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


Python ImageCheck.is_image方法代码示例

本文整理汇总了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
开发者ID:rhelmer,项目名称:zamboni,代码行数:14,代码来源:tasks.py

示例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))
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:15,代码来源:test_tasks.py

示例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))
开发者ID:j-barron,项目名称:zamboni,代码行数:16,代码来源:test_tasks.py

示例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
开发者ID:AALEKH,项目名称:zamboni,代码行数:16,代码来源:tasks.py

示例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)
开发者ID:Sancus,项目名称:zamboni,代码行数:18,代码来源:tasks.py

示例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()
开发者ID:BavarianTomcat,项目名称:zamboni,代码行数:7,代码来源:test_helpers.py


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