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


Python Image.scale方法代码示例

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


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

示例1: finish_response

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
    def finish_response(self, app_iter):
        if not self.scale:
            self.start_response(self.status, self.headers)
            self.output = app_iter
            return

        CONTENT_LENGTH.delete(self.headers)
        inBuffer = StringIO()
        try:
            for s in app_iter:
                self.logger.debug("Writing %d bytes into image buffer." % len(s))
                inBuffer.write(s)
        finally:
            if hasattr(app_iter, 'close'):
                app_iter.close()

        rawImg = Blob()
        rawImg.data = inBuffer.getvalue()
        inBuffer.close()
        image = Image(rawImg)
        self.logger.debug("Scaling image to %s" % self.scaled_size)
        image.scale(self.scaled_size[0])
        image.write(self.outbuffer)

        content_length = self.outbuffer.length()
        CONTENT_LENGTH.update(self.headers, content_length)
        CACHE_CONTROL.update(self.headers, s_maxage=CACHE_CONTROL.ONE_HOUR)
        self.start_response(self.status, self.headers)
开发者ID:bhagemeier,项目名称:swift-image-scaling,代码行数:30,代码来源:image_scaler.py

示例2: rsr2png

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
def rsr2png(rsrfile):
	rsr2pct(rsrfile)
	pictfile = os.path.splitext(rsrfile)[0]+".pct"
	try:
		thumb = Image(str(pictfile))
	except:
		print pictfile
		raise
	thumb.opacity(100)
	thumb.scale(91,91)
	thumb.write(str(os.path.splitext(rsrfile)[0]+".png"))
开发者ID:netpete,项目名称:dmilo,代码行数:13,代码来源:rsrconvert.py

示例3: manipula_img

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
 def manipula_img(self, img_r, nmsuc):
     """Procesa la imagen adquirida en formato xwd y la trasforma en jpg"""
     image_final = self.dir_tmp + nmsuc + ".jpg"
     contador = 0
     if path.exists(image_final):
         contador += 1
         image_final = self.dir_tmp + nmsuc + "_" + str(contador) + ".jpg"
         if path.exists(image_final):
             image_final = self.comprueba_nombre(image_final, nmsuc)
     img = Image(img_r)
     img.scale("1024x768")
     img.write(image_final)
     exe(image_final, nmsuc)
开发者ID:jbnkuma,项目名称:remote_screenshot,代码行数:15,代码来源:capturescreen_puesto.py

示例4: thumb

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
    def thumb(self, req):
        if self.mime_type.startswith('image') \
                and guess_extension(self.mime_type) in _image_exts:

            file_path = req.cfg.attachments_path + '/' + self.webname()
            img = Image(file_path.encode('utf-8'))

            width, height = req.cfg.attachments_thumb_size.get()
            img.scale(Geometry(width, height))

            thumb_path = req.cfg.attachments_thumb_path + '/' + self.webname()
            if not exists(dirname(thumb_path)):
                makedirs(dirname(thumb_path))
            img.write(thumb_path.encode('utf-8'))
开发者ID:ondratu,项目名称:morias,代码行数:16,代码来源:attachments.py

示例5: walk_menu

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

示例6: resize

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

示例7: Image

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
from PythonMagick import Image
bilde= Image("8x8","#33FFCC")
x=y=0
for i in range(0,4):
    bilde.pixelColor(i,1, "#993300")
for i in range(0,4):
    bilde.pixelColor(i,7, "#993300")
for i in range (2,4):
    bilde.pixelColor(i,3,"#993300")
for i in range (2,4):
    bilde.pixelColor(i,5,"#993300")
bilde.pixelColor(4,2, "#993300")
bilde.pixelColor(4,4, "#993300")
bilde.pixelColor(4,6, "#993300")
bilde.scale("200x200")
bilde.write("236.png")
开发者ID:reinispro,项目名称:datormaciba2014-2015,代码行数:18,代码来源:236.py

示例8: range

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
from PythonMagick import Image
photo=Image("9x9", "#E65C00")
x=y=0
for i in range(1,7):
    photo.pixelColor(4,i,'#0404B4')
for i in range(3,6):
    photo.pixelColor(i,2,'#0404B4')
for i in range(2,7):
    photo.pixelColor(i,3,'#0404B4')
for i in range(2,7):
    photo.pixelColor(i,0,'#0404B4')
for i in range(3,6):
    photo.pixelColor(i,7,'#0404B4')
for i in range(2,5):
    photo.pixelColor(8,i,'#0404B4')
for i in range(2,5):
    photo.pixelColor(0,i,'#0404B4')
for i in range(5,7):
    photo.pixelColor(i/3,i,'#0404B4')
photo.pixelColor(1,1, '#0404B4')
photo.pixelColor(7,1, '#0404B4')
photo.pixelColor(7,5, '#0404B4')
photo.pixelColor(6,6, '#0404B4')

photo.scale("200x200")
photo.write("238.png")
开发者ID:reinispro,项目名称:datormaciba2014-2015,代码行数:28,代码来源:238.py

示例9:

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
bilde.pixelColor(3,6, "#22ff44")
bilde.pixelColor(4,3, "#22ff44")
bilde.pixelColor(4,6, "#22ff44")
bilde.pixelColor(5,4, "#22ff44")
bilde.pixelColor(5,5, "#22ff44")
bilde.pixelColor(5,6, "#22ff44")
bilde.pixelColor(5,7, "#22ff44")
bilde.pixelColor(5,8, "#22ff44")
bilde.pixelColor(5,9, "#22ff44")
bilde.pixelColor(7,3, "#22ff44")
bilde.pixelColor(7,4, "#22ff44")
bilde.pixelColor(7,5, "#22ff44")
bilde.pixelColor(7,6, "#22ff44")
bilde.pixelColor(7,7, "#22ff44")
bilde.pixelColor(7,8, "#22ff44")
bilde.pixelColor(7,9, "#22ff44")
bilde.pixelColor(8,3, "#22ff44")
bilde.pixelColor(8,6, "#22ff44")
bilde.pixelColor(8,9, "#22ff44")
bilde.pixelColor(9,3, "#22ff44")
bilde.pixelColor(9,6, "#22ff44")
bilde.pixelColor(9,9, "#22ff44")
bilde.pixelColor(10,3, "#22ff44")
bilde.pixelColor(10,9, "#22ff44")

# 12x12 pixels palielina lidz 300x300
bilde.scale("300x300")

# Objektu 'bilde' ieraksata failaa
bilde.write("233.png")
开发者ID:easydors,项目名称:datormaciba,代码行数:32,代码来源:233.py

示例10:

# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import scale [as 别名]
bilde.pixelColor( 7,3, "#eeff23")
bilde.pixelColor( 6,2, "#eeff23")

bilde.pixelColor( 5,1, "#eeff23")
bilde.pixelColor( 4,1, "#eeff23")
bilde.pixelColor( 3,1, "#eeff23")
bilde.pixelColor( 2,2, "#eeff23")
bilde.pixelColor( 1,3, "#eeff23")
bilde.pixelColor( 2,10, "#eeff23")
bilde.pixelColor( 7,2, "#eeff23")

bilde.pixelColor( 8,3, "#eeff23")
bilde.pixelColor( 9,4, "#eeff23")
bilde.pixelColor( 10,5, "#eeff23")






# 3x3 pixels palielina liidz 200x200
bilde.scale ("500x500")

#Objektu 'bilde' ieraksta failaa
bilde.write("233.png") 





开发者ID:dmitriydoronin,项目名称:Dmitrij141REB169,代码行数:27,代码来源:233.py


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