本文整理汇总了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
示例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() }
示例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
示例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]