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


Python Image.magick方法代码示例

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


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

示例1: NumpytoIM

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import magick [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: convert_photo_to_jpeg

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import magick [as 别名]
    def convert_photo_to_jpeg(photo_path):
        print 'Converting %s to JPEG...' % (photo_path,)
        image = Image(photo_path)
        image.magick("jpeg")
        image.quality(100)
        (_, file_name) = os.path.split(photo_path)
        file_name = convert_local_filename_to_flickr(file_name)
        file_name = os.path.join(tempfile.mkdtemp('.flickrsmartsync'), file_name)
        image.write(file_name)

        print 'Done converting photo!'
        return file_name
开发者ID:d98ama,项目名称:flickrsmartsync,代码行数:14,代码来源:__init__.py

示例3: walk_menu

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import magick [as 别名]
def walk_menu(entry):
    if isinstance(entry, xdg.Menu.Menu) and entry.Show is True:
        map(walk_menu, entry.getEntries())
    elif isinstance(entry, xdg.Menu.MenuEntry) and entry.Show is True:
        # byte 1 signals another entry
        conn.sendall('\x01')
        img_path = icon_attr(entry.DesktopEntry).encode('utf-8')
        if img_path and os.path.isfile(img_path):
            try:
                # Create an empty image and set the background color to
                # transparent. This is important to have transparent background
                # when converting from SVG
                img = Image()
                img.backgroundColor(Color(0, 0, 0, 0xffff))
                img.read(img_path)
                # scale the image to 48x48 pixels
                img.scale(Geometry(48, 48))
                # ensure the image is converted to ICO
                img.magick('ICO')
                b = Blob()
                img.write(b)
                # icon length plus data
                conn.sendall(struct.pack('i', len(b.data)))
                conn.sendall(b.data)
            except Exception:
                conn.sendall(struct.pack('i', 0))
        else:
            conn.sendall(struct.pack('i', 0))

        name = entry.DesktopEntry.getName()
        # name length plus data
        conn.sendall(struct.pack('i', len(name)))
        conn.sendall(name)

        command = re.sub(' -caption "%c"| -caption %c',
                ' -caption "%s"' % name, entry.DesktopEntry.getExec())
        command = re.sub(' [^ ]*%[fFuUdDnNickvm]', '', command)
        if entry.DesktopEntry.getTerminal():
                command = 'xterm -title "%s" -e %s' % (name, command)

        # command length plus data
        conn.sendall(struct.pack('i', len(command)))
        conn.sendall(command)
开发者ID:tarruda,项目名称:dot-files,代码行数:45,代码来源:file_shortcut_generator_client.py

示例4: pad_image_to_x480

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import magick [as 别名]
def pad_image_to_x480(file):
    from PythonMagick import Image, CompositeOperator
    fname = file.split(".")[0]
    ext = file.split(".")[-1]
    outfile = os.path.join(destdir, fname + "_" + "l" + ".jpg")

    ## Make BG layer
    bgimg = Image('400x480', 'white')

    ## Open Primary image 
    img = Image(file)
    img.backgroundColor("white")
    img.sample('350x432')

    # Composite + Save Primary over bg, padding primary with white of bg
    type = img.type
    img.composite(bgimg, 0, 0, CompositeOperator.DstOverCompositeOp)
    img.magick('JPG')
    img.type = type
    img.quality(100)
    img.write(outfile)
开发者ID:relic7,项目名称:prodimages,代码行数:23,代码来源:get_event_images_by_categoryid.py

示例5: convertMGtoPIL

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import magick [as 别名]
def convertMGtoPIL(magickimage):
    'works with grayscale and color'
    img = PMImage(magickimage)  # make copy
    img.depth = 8        #  this takes 0.04 sec. for 640x480 image
    img.magick = "RGB"
    w, h = img.columns(), img.rows()
    blb=Blob()
    img.write(blb)
    data = blb.data
    
    # convert string array to an RGB Pil image
    pilimage = Image.fromstring('RGB', (w, h), data)
    return pilimage
开发者ID:rsignell-usgs,项目名称:bottom_photos,代码行数:15,代码来源:unsharp.py


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