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


Python Image.size方法代码示例

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


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

示例1: NumpytoIM

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import size [as 别名]
def NumpytoIM(img, usm=None, verbose=False):
    if verbose:
        print "Converting numpy array to ImageMagick"

    out_img = PMImage()
    if img.dtype == 'uint16':
        out_img.depth(16)
    else:
        out_img.depth(8)
    out_img.magick('RGB')
    h,w,c = img.shape
    size_str = str(w)+'x'+str(h)
    out_img.size(size_str)

    b = Blob()
    b.data = img.tostring()
    out_img.read(b)
    out_img.magick('PNG')

    # Check if USM sharpening should be used
    if usm != None:
        if verbose:
            print "Running unsharp mask filter"
        r,s,a,t = (usm)
        out_img.unsharpmask(r,s,a,t)

    return out_img
开发者ID:giulioungaretti,项目名称:ArtScope,代码行数:29,代码来源:halostack.py

示例2: thumbnail

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import size [as 别名]
    def thumbnail(self, infile, outfile, size, quality, no_upscale=False):
        #image = Image(infile)
        #image.resize(size)
        #image.write(outfile)

        quality = str(quality)
        if infile.endswith('.gif') or no_upscale:
            size = size+'>'
        resize = run(['/usr/bin/convert', '-interlace', "Plane", '-quality', quality, '-strip',  '-thumbnail', size, infile, outfile])
        image = Image(outfile)

        return { 'width': image.size().width(), \
                 'height': image.size().height() }
开发者ID:abach,项目名称:photongx,代码行数:15,代码来源:worker.py

示例3: resize

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import size [as 别名]
    def resize(self, req, width, height):
        file_path = req.cfg.attachments_path + '/' + self.webname()
        if self.mime_type.startswith('image') \
                and guess_extension(self.mime_type) in _image_exts:

            img = Image(file_path.encode('utf-8'))
            img.fileName(
                'image.'+self.file_name.encode('utf-8').split('.')[-1])
            size = img.size()

            blob = Blob()
            if width > size.width() and height > size.height():
                img.write(blob)
            else:
                img.scale(Geometry(width, height))
                img.write(blob)
            return blob.data
        elif guess_extension(self.mime_type) == '.svg':
            with open(file_path.encode('utf-8'), 'rb') as svg:
                return svg.read()
        else:
            req.log_error(self.mime_type)
            return None
开发者ID:ondratu,项目名称:morias,代码行数:25,代码来源:attachments.py

示例4: PMImage

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import size [as 别名]
# Set the named file as first entry in the image list
# This file will be the base for alignment and intensity normalization
if base_image is not None:
    idx = frames.index(base_image)
    f = frames.pop(idx)
    frames.insert(0,f)

if verbose:
    print "%s will be used as base image" % frames[0]

# Determine image size
base_img_fname = frames[0]
if verbose:
    print "Reading %s" % base_img_fname
img = PMImage(base_img_fname)
w,h = img.size().width(), img.size().height()
if img.monochrome():
    c = 1
else:
    c = 3

print "Detected image size is %d x %d (width x height)" % (w,h)

print "%s will be used as base image" % frames[0]
img = IMtoNumpy(img,pre_usm,verbose=verbose)

# Get data used for aligning images
align_ref_data = None
if align_ref_loc is not None:
    xc = align_ref_loc[0]
    yc = align_ref_loc[1]
开发者ID:giulioungaretti,项目名称:ArtScope,代码行数:33,代码来源:halostack.py


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