Extract tiff image layers in to PNG files

Can you please give sample code for
extract tiff image layers in to PNG files

The Pillow library will probably do it.

This SO article is part of the way there:

If you want to do it with Pillow, the ImageSequence class is probably what you’re looking for. From StackOverflow:

from PIL import Image, ImageSequence

im = Image.open("multipage.tif")

for i, page in enumerate(ImageSequence.Iterator(im)):
    page.save("page%d.png" % i)

I’ve not tried this, but let me know if you run into troubles. Or if it works, for that matter.

1 Like