Skip to content

Save compressed TIFF only accepts float values for dpi #1765

Description

@temp56817906847

There is a trap in setting the resolution for compressed TIFF images.

# pillow v3.1.1

import PIL.Image
im = PIL.Image.new('CMYK', (100, 100))

dpi = 100.0  # works
dpi = 100  # fails

im.save('test.tif', format='TIFF',
        dpi=(dpi, dpi),
        compression='tiff_lzw',
        #compression='tiff_deflate',
        #compression='tiff_adobe_deflate'
        )

Integers fail silently resulting in the resolution value missing from the saved file. Floats work as expected.

Activity

  1. radarhere commented on Sep 7, 2018

    @radarhere
    Member

    Just to note here, the reason that compression triggers the error is that compression causes libtiff to be used, and Pillow does not correctly convert the integer dpi when passing it to libtiff.

  2. radarhere commented on Sep 7, 2018

    @radarhere
    Member

    #2288 is a PR to fix this and a larger swathe of issues. However, since that is not complete, I have created #3338 as a PR to just fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions