[GIS] Opening TIFF image in PIL (Python)

geotiff-tiffpythonpython-imaging-library

I'm new to Python and trying to work with TIFF images using the following code:

from PIL import Image
import numpy 

im = Image.open('LakeEx.tif') 
imarray = numpy.array(im) 
imarray.shape 
im.show()

and I got this error:

"ValueError: tile cannot extend outside image"

Is there any specific criteria to the TIFF file to work with Python: size, bit,… etc?

Best Answer

The problem is that PIL wants to see a ".tiff" at the end of the file name. You have ".tif". The solution is to rename your file to "LakeEx.tiff".