0

I have some tiff images that have between 7-8 levels. These were generated using vips. I have tried the iteration listed at this stackoverflow question. I've also tried this:

im = Image.open("E:\\tiled_pyr.tif")
for i in range(7):
    try:
        im.seek(i)
        print im.size[0]
        print im.size[1]
    except EOFError:
        # Not enough frames in im
        break

However, when I begin iterating through, I get this error:

IOError: decoder tiff_adobe_deflate not available

What I'm trying to do is crop the ptif at its highest resolution or highest level and then run some analysis on that crop.

Is this possible with PIL? Do I need something else? Thanks!

Community
  • 1
  • 1
Spatial Pariah
  • 351
  • 4
  • 17

1 Answers1

1

The libvips Python binding pyvips now works on Windows, so you can do:

import pyvips

# this will open the highest resolution layer
image = pyvips.Image.new_from_file("somefile.tif")

# crop out an area
area = image.crop(x, y, w, h)

# ... do what you like
print('average pixel value of crop is', area.avg())

See

https://pypi.python.org/pypi/pyvips

jcupitt
  • 10,213
  • 2
  • 23
  • 39