[英]building tiff stack with wand
How can I achieve this with Wand library for python: 如何使用Wand库实现python:
convert *.png stack_of_multiple_pngs.tiff
? ?
In particular, how can I read every png image, pack them into a sequence and then save the image as tiff stack: 特别是,我如何读取每个png图像,将它们打包成一个序列 ,然后将图像保存为tiff堆栈:
with Image(filename='*.tiff') as img:
img.save(filename='stack_of_multiple_pngs.tiff')
I understand how to do it for gifs though, ie as described in docs. 我知道如何做到这一点的GIF ,即如文档所述。 But what about building a sequence as a list and appending every new image I read as a SingleImage()?
但是,如何将序列构建为列表并附加我以SingleImage()读取的每个新图像呢?
Having trouble figuring it out right now. 现在无法确定。
With wand
you would use Image.sequence
, not a wildcard filename *
. 使用
wand
您将使用Image.sequence
,而不是通配符文件名*
。
from wand.image import Image
from glob import glob
# Get list of all images filenames to include
image_names = glob('*.tiff')
# Create new Image, and extend sequence
with Image() as img:
img.sequence.extend( [ Image(filename=f) for f in image_names ] )
img.save(filename='stack_of_multiple_pngs.tiff')
The sequence_test.py file under the test directory will have better examples of working with the image sequence. 测试目录下的sequence_test.py文件将提供使用图像序列的更好示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.