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


Python Image.type方法代码示例

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


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

示例1: convert_image

# 需要导入模块: from calibre.utils.magick import Image [as 别名]
# 或者: from calibre.utils.magick.Image import type [as 别名]
    def convert_image(url,data,sizes,grayscale,
                      removetrans,imgtype="jpg",background='#ffffff'):
        export = False
        img = Image()
        img.load(data)

        owidth, oheight = img.size
        nwidth, nheight = sizes
        scaled, nwidth, nheight = fit_image(owidth, oheight, nwidth, nheight)
        if scaled:
            img.size = (nwidth, nheight)
            export = True

        if normalize_format_name(img.format) != imgtype:
            export = True

        if removetrans and img.has_transparent_pixels():
            canvas = Image()
            canvas.create_canvas(int(img.size[0]), int(img.size[1]), str(background))
            canvas.compose(img)
            img = canvas
            export = True

        if grayscale and img.type != "GrayscaleType":
            img.type = "GrayscaleType"
            export = True

        if export:
            return (img.export(convtype[imgtype]),imgtype,imagetypes[imgtype])
        else:
            logger.debug("image used unchanged")
            return (data,imgtype,imagetypes[imgtype])
开发者ID:iceshipping,项目名称:FanFicFare,代码行数:34,代码来源:story.py

示例2: convert_image

# 需要导入模块: from calibre.utils.magick import Image [as 别名]
# 或者: from calibre.utils.magick.Image import type [as 别名]
    def convert_image(url, data, sizes, grayscale, removetrans, imgtype="jpg", background="#ffffff"):
        export = False
        img = Image()
        img.load(data)

        owidth, oheight = img.size
        nwidth, nheight = sizes
        scaled, nwidth, nheight = fit_image(owidth, oheight, nwidth, nheight)

        if normalize_format_name(img.format) == "gif" and GifInfo(StringIO(data), CHECK_IS_ANIMATED).frameCount > 1:
            raise exceptions.RejectImage("Animated gifs come out purely--not going to use it.")

        if scaled:
            img.size = (nwidth, nheight)
            export = True

        if normalize_format_name(img.format) != imgtype:
            export = True

        if removetrans and img.has_transparent_pixels():
            canvas = Image()
            canvas.create_canvas(int(img.size[0]), int(img.size[1]), unicode(background))
            canvas.compose(img)
            img = canvas
            export = True

        if grayscale and img.type != "GrayscaleType":
            img.type = "GrayscaleType"
            export = True

        if export:
            return (img.export(convtype[imgtype]), imgtype, imagetypes[imgtype])
        else:
            logger.debug("image used unchanged")
            return (data, imgtype, imagetypes[imgtype])
开发者ID:PlushBeaver,项目名称:FanFicFare,代码行数:37,代码来源:story.py

示例3: postprocess_html

# 需要导入模块: from calibre.utils.magick import Image [as 别名]
# 或者: from calibre.utils.magick.Image import type [as 别名]
 def postprocess_html(self, soup, first):
     #process all the images
     for tag in soup.findAll(lambda tag: tag.name.lower()=='img' and tag.has_key('src')):
         iurl = tag['src']
         img = Image()
         img.open(iurl)
         if img < 0:
             raise RuntimeError('Out of memory')
         img.type = "GrayscaleType"
         img.save(iurl)
     return soup
开发者ID:arpan-chavda,项目名称:calibre_recipes,代码行数:13,代码来源:Seniors'+Blog_1003.py


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