0

How can I achieve this with Wand library for 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:

with Image(filename='*.tiff') as img:
    img.save(filename='stack_of_multiple_pngs.tiff')

I understand how to do it for gifs though, i.e. as described in docs. But what about building a sequence as a list and appending every new image I read as a SingleImage()?

Having trouble figuring it out right now.

See also

Community
  • 1
  • 1
Yauhen Yakimovich
  • 13,635
  • 8
  • 60
  • 67

1 Answers1

2

With wand you would use Image.sequence, not a wildcard filename *.

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.

emcconville
  • 23,800
  • 4
  • 50
  • 66