Why does the PIL module ImageDraw.Draw exit without an error when I try to draw on a tiff?

Question:

I’m trying to open a TIF using PIL and create a draw object. Opening the image works just fine but when creating the draw object, the program stalls for about 2 seconds then exits without an error.

My system is Windows 10. I created an anaconda environment with:

  • python=3.9.15
  • pillow=9.0.1

I ran the following commands:

>>> import os
>>> from PIL import Image, ImageDraw
>>> img_path = os.path.join('path', 'to', 'image.tif')
>>> os.path.isfile(img_path)
True
>>> im = Image.open(img_path)
>>> draw = ImageDraw.Draw(im)

The ImageDraw.Draw causes the program to exit without any error.

One image on which I had this problem is accessible via WeTransfer. I had this problem using multiple tifs, I also tried changing the file extension to tiff and it didn’t work. I converted the tifs to pngs and the code worked just fine.

Asked By: Gabriel Steinberg

||

Answers:

I figured it out. Updating the conda package to pillow=9.2.0 didn’t work so I used pip instead to download pillow=9.3.0 (pip install Pillow). That solved my problem.

Answered By: Gabriel Steinberg