本文整理汇总了Python中wand.image.Image.type方法的典型用法代码示例。如果您正苦于以下问题:Python Image.type方法的具体用法?Python Image.type怎么用?Python Image.type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wand.image.Image
的用法示例。
在下文中一共展示了Image.type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_test_data
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import type [as 别名]
def create_test_data(self):
im = Image(filename=root('resources', 'color_circle.png'))
if self.mode == 'RGB':
im.type = 'truecolor'
elif self.mode == 'RGBA':
im.type = 'truecolormatte'
elif self.mode == 'L':
im.type = 'grayscale'
elif self.mode in 'LA':
im.type = 'grayscalematte'
else:
raise ValueError('Unknown mode: {}'.format(self.mode))
im.resize(self.size[0], self.size[1], 'catrom')
self._free_resources.append(im)
return [im]
示例2: main
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import type [as 别名]
def main():
output = PdfFileWriter()
temp = PdfFileReader(file('org.pdf','rb'))
#~ #numeracja
for i in range(0,(temp.getNumPages()-1)):
if i<10:
w = '00'+str(i)
elif i>=10 and i<100:
w = '0'+str(i)
elif i>=100 and i<1000:
w = str(i)
#wczytanie strony pdf
#~ i = 10
img = Image(filename="org.pdf[" + str(i) + "]", resolution=300)
img.type = 'bilevel';
imga = img[:(int(img.width/2)),:]
#~ print imga.make_blob()
imgb = img[(int(img.width/2)):,:]
#~ display(imga)
#~ img1 = imga[500:750,500:750]
#~ imga.save(filename="temp/temp1.png")
#~ img1 = ndimage.imread('temp/temp1.png')
#~ print image_to_string(pimage.open('temp/temp1.png'),lang='pol')
#~ img3 = ndimage.binary_erosion(img1, structure = el).astype(img1.dtype)
#~ img2 = ndimage.median_filter(img1, 20)
#~ print dir(img2)
#~ spm.imsave("temp/temp2.png",img2)
#######Histogram
#~ plt.figure('histogram szarosci')
#~ plt.hist(img1.ravel(),255) # narysujmy histogram odcieni
#~ plt.show()
########
#~ spm.imsave("temp/temp3.png",img3)
#~ #tworzenie pdf z podzielonych stron
for j in 'a','b':
if j == 'a':
imga.save(filename="temp/temp.pdf")
if j == 'b':
imgb.save(filename="temp/temp.pdf")
temp = PdfFileReader(file('temp/temp.pdf','rb'))
output.addPage(temp.getPage(0))
outputStream = file("outputa.pdf", "wb")
output.write(outputStream)
outputStream.close()
print i
return 0
示例3: pdf_to_image
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import type [as 别名]
def pdf_to_image(pdf, page=1, size=800, file_format='jpeg', quality=80):
"""Creates a image file from pdf file"""
try:
pdf.open()
except Exception as e:
raise e
else:
# do this while the pdf is open
reader = PyPDF2.PdfFileReader(pdf, strict=False)
writer = PyPDF2.PdfFileWriter()
page_content = reader.getPage(page - 1)
box = page_content.cropBox
dims = [float(a - b) for a, b in zip(box.upperRight, box.lowerLeft)]
scaleby = size / max(dims)
dims = [int(d * scaleby) for d in dims]
# resize_page(page_content, size)
writer.addPage(page_content)
outputStream = BytesIO()
writer.write(outputStream)
outputStream.seek(0)
finally:
pdf.close()
# put content of page in a new image
foreground = WandImage(
blob=outputStream,
format='pdf',
resolution=int(1.6 * 72 * scaleby),
)
# make sure the color space is correct.
# this prevents an occational bug where rgb colours are inverted
foreground.type = 'truecolormatte'
foreground.resize(*dims, 25)
# white background
background = WandImage(
width=foreground.width,
height=foreground.height,
background=Color('white')
)
background.format = file_format
background.composite(foreground, 0, 0)
background.compression_quality = quality
return background
示例4: Image
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import type [as 别名]
pages = 1
image = Image(
width = imageFromPdf.width,
height = imageFromPdf.height*pages
)
for i in range(pages):
image.composite(
imageFromPdf.sequence[i],
top = imageFromPdf.height * i,
left = 0
)
image.resize(250,250)
image.alpha_channel = False
image.format = 'png'
print(image.size)
image.background_color = Color('pink')
image.type = 'grayscale'
image.caption = file.split('.')[0]
image.save(filename = fileDirectory+file.split('.')[0]+".png")
image.clear()
image.close()
#display(image)
示例5: Image
# 需要导入模块: from wand.image import Image [as 别名]
# 或者: from wand.image.Image import type [as 别名]
# Read in the input image ... i.e., the B&W octal page.
img = Image(filename=backgroundImage)
if invert:
img.negate()
backgroundWidth = img.width
backgroundHeight = img.height
if swapColors:
print 'Swapping colors'
for i in range(0, 8):
replaceColorsInImage(images[i], Color(matchColor), Color(scanColor))
replaceColorsInImage(img, Color(scanColor), Color(matchColor))
# Make certain conversions on the background image.
img.type = 'truecolor'
img.alpha_channel = 'activate'
# Determine the range of binsource lines we need to use. We're guaranteed
# they're all in the binsource lines[] array.
if bankNumber < 4:
bankNumber = bankNumber ^ 2
startIndex = bankNumber * 4 * 8 * 4 + pageInBank * 4 * 8
endIndex = startIndex + 4 * 8
draw = Drawing()
evilColor = Color("#FF00FF")
extraColor = Color("#FF8000")
draw.stroke_color = evilColor
draw.stroke_width = 4
draw.fill_opacity = 0