OSError when using PIL to save image as TIFF with compression
<p>I am trying to change the dpi of my PNG images and convert them to TIFF using Pillow/PIL like so,</p>

<pre><code>from PIL import Image
import os

for fl in os.listdir(os.getcwd()):
    name, ext = fl.split(".")
    im = Image.open(fl)
    im.save(name + ".tiff", dpi=(500,500), compression="tiff_jpeg")

    print("Done '{}'".format(name))
</code></pre>

<p>which works fine if the <code>compression</code> kwarg is not set, but I end up with massive 100MB TIFF files from my 1MB PNGs. If I set the compression type to any of the available <a href="http://pillow.readthedocs.io/en/3.3.x/handbook/image-file-formats.html" rel="nofollow">options</a>, I end up with the following error:</p>

<pre><code>Traceback (most recent call last):

  File "&lt;ipython-input-1-3631f05e05f4&gt;", line 7, in &lt;module&gt;
    im.save(name + ".tiff", dpi=(500,500), compression="tiff_jpeg")

  File "C:\Users\Patrick\Anaconda3\lib\site-packages\PIL\Image.py", line 1687, in save
    save_handler(self, fp, filename)

  File "C:\Users\Patrick\Anaconda3\lib\site-packages\PIL\TiffImagePlugin.py", line 1457, in _save
    raise IOError("encoder error %d when writing image file" % s)

OSError: encoder error -2 when writing image file
</code></pre>

<p>In the docs for the <a href="http://pillow.readthedocs.io/en/3.3.x/reference/Image.html#PIL.Image.Image.save" rel="nofollow">Image.save</a> method it mentions that compression is only available if the libtiff library is installed which I do have.</p>

<p>Here is the versions for Python and Pillow that I'm working with:</p>

<pre><code>Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32

libtiff: 4.0.6-vc14_2 [vc14]
pillow: 3.2.0-py35_1 
</code></pre>

<p>What might be the cause of this error and what steps can I take to resolve? This is the first time I've used Pillow/PIL and am unsure of where to begin.</p>