Skip to content

TIF Compression with CMYK images seems to be not working #401

Description

@ignaciordc

I load a CMYK image, which I know had no compression,
It is ok, for I can visualize it.
Then, I try to save it compressed, and get an IOError

If I enable debuging setting Image.DEBUG=1 I get some more info

The error occurs in
TIFFWriteScanline: ECI2002_ccitt.tif: Must set "PlanarConfiguration before writing data.
Traceback (most recent call last):
"PIL\Image.py", line 1464, in save
save_handler(self, fp, filename)
"PIL\TiffImagePlugin.py", line 1073, in _save
raise IOError("encoder error %d when writing image file" % s)
IOError: encoder error -2 when writing image file

Info from the file

  • compression: raw
  • photometric_interpretation: 5
  • planar_configuration: 1
  • fill_order: 1
  • size: (3509, 4677)
    format key: ('II', 5, 1, 1, (8, 8, 8, 8), ())
  • raw mode: CMYK
  • pil mode: CMYK
    tiles: [('raw', (0, 0, 3509, 4677), 182, ('CMYK', 0, 1))]

Code I am executing
im=Image.open("ECI2002.tif")
im.show()
im.save("ECI2002_ccitt.tif",compression="tiff_ccitt")

Activity

  1. wiredfool commented on Nov 6, 2013

    @wiredfool
    Member

    I don't think that tiff_ccitt will work with non b/w images. The CCITT compression modes (like group3 and 4) are black and white only.

    On the other hand, it doesn't look like libtiff saving works with anything that requires BitsPerSample to be more than one element, and there's also a missing PlanarConfiguration tag.

  2. wiredfool commented on Nov 6, 2013

    @wiredfool
    Member

    Check out this branch for a WIP fix: https://github.com/wiredfool/Pillow/tree/libtiff-save2

  3. ignaciordc commented on Nov 6, 2013

    @ignaciordc
    Author

    I´ll do that, thanks.

    2013/11/6 wiredfool [email protected]

    Check out this branch for a WIP fix:
    https://github.com/wiredfool/Pillow/tree/libtiff-save2

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/401#issuecomment-27843250
    .

  4. added a commit that references this issue on Sep 24, 2023
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

    BugAny unexpected behavior, until confirmed feature.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions