Skip to content

Document saving LZW-compressed TIFF files #659

Closed

Description

@jondo

This works, but it is missing in the docs.

Activity

  1. wiredfool commented on May 13, 2014

    @wiredfool
    Member

    Actually, that's ... not quite right.

    First, there are two flags, READ_LIBTIFF and WRITE_LIBTIFF, which are (currently) only used for testing. Setting READ_LIBTIFF before a write is a noop.

    Second, it may be a bug that we're not setting tiff_lzw to use libtiff by default. There is LZW and packbits support in old PIL code, but IIRC, it's somewhat broken. (It my be broken by not being called, testing is required ).

    Third, the changes in Pillow postdate that question about PIL by a good 3 years, and the libtiff support was only merged last year.

  2. jondo commented on May 13, 2014

    @jondo
    Author

    Sorry, of course I meant WRITE_LIBTIFF. That's what I currently use to activate LZW compression.
    When I do not set it, I get an uncompressed file with a compression tag value of COMPRESSION_LZW.
    So I think this line should have "tiff_lzw" added.

  3. wiredfool commented on May 15, 2014

    @wiredfool
    Member

    Ref #431. Should check there to see if packbits is returning the same thing. If so, we should just run any compression through libtiff.

  4. jondo commented on May 19, 2014

    @jondo
    Author

    Yes, without WRITE_LIBTIFF the compression = 'packbits' saves an uncompressed file that has the PackBits tag set.

    Tested with:

    from PIL import Image, TiffImagePlugin
    
    img = Image.new('L', (300, 300))
    img.putpixel((150,150), 255)
    
    img.save('uncompressed.tiff')
    TiffImagePlugin.WRITE_LIBTIFF = True
    img.save('correct.tiff', compression = 'packbits')
    TiffImagePlugin.WRITE_LIBTIFF = False
    img.save('wrongCompressionTag.tiff', compression = 'packbits')
    
  5. wiredfool commented on May 19, 2014

    @wiredfool
    Member

    Right then, I think that's answered. Time to run the writes through libtiff.

  6. added a commit that references this issue on May 20, 2014
    edd75ce
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

    Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions