本文整理汇总了Python中PythonMagick.Image.depth方法的典型用法代码示例。如果您正苦于以下问题:Python Image.depth方法的具体用法?Python Image.depth怎么用?Python Image.depth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PythonMagick.Image
的用法示例。
在下文中一共展示了Image.depth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NumpytoIM
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import depth [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: pdf2images
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import depth [as 别名]
def pdf2images(name):
np = getPdfNumPages(name)
for p in range(np):
i = Image()
i.density('200')
i.quality(100)
i.depth(24)
#i.backgroundColor(
#i.channel(
i.read(name + '[' + str(p) + ']')
i.write(name + str(p) + defaultImageExtension)
示例3: pdf2jpg
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import depth [as 别名]
def pdf2jpg(pdf,temp):
#Generate the path for the jpg file. Need to use a temp directory in case
#pdf location is read only.
pdf = str(pdf)
base = os.path.basename(pdf)
basefile = os.path.splitext(base)
jpg = temp + basefile[0] + ".jpg"
#jpg = str(jpg.replace("\\","\\\\"))
jpg = str(jpg)
pdf = str(pdf)
img = PMImage()
img.density('300')
img.depth(24)
img.read(pdf)
img.write(jpg)
img = Image.open(jpg)
rgbimg = Image.new("RGBA", img.size)
rgbimg.paste(img)
rgbimg.save(jpg)
return jpg
示例4: convertMGtoPIL
# 需要导入模块: from PythonMagick import Image [as 别名]
# 或者: from PythonMagick.Image import depth [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