CMYK per-channel byte order TIFF crashes gm

2013-01-30
2013-03-27
  • Matt Walkenhorst

    Hi Bob,

    It's been a while since this but GraphicksMagick is still an awesome tool.

    I have an issue that is perhaps related to the issue described in the above link using 1.3.17-Q8. If I try to use a tiff file as a source that is CMYK, has some transparency and is saved with per-channel byte order and attempt to convert that image to an RGB image, gm.exe crashes.

    example command-line:

    "C:\Program Files (x86)\GraphicsMagick-1.3.17-Q8\gm.exe" convert -debug coder "CMYK-trans-pcbo.tif"[0] -colorspace RGB  "RGB-trans-pcbo.tif" > output.txt 2>&1
    

    produces the following output.txt before the process crashes:

    12:07:13 0:01 0.000u 28444 constitute.c/ReadImage/1594/Coder:
      Invoking "TIFF" decoder (Tagged Image File Format) subimage=0 subrange=1
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1424/Coder:
      Geometry: 320x240
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1426/Coder:
      PlanarConfiguration: separate
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1430/Coder:
      Samples per pixel: 5
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1432/Coder:
      Sample format: Unsigned integer
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1441/Coder:
      Bits per sample: 8
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1443/Coder:
      Min sample value: 0
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1445/Coder:
      Max sample value: 255
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1459/Coder:
      Photometric: SEPARATED
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1461/Coder:
      Compression: LZW
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1463/Coder:
      Byte swapped: false
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1466/Coder:
      Bit fill order: MSB2LSB
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1471/Coder:
      Rows per strip: 240
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1525/Coder:
      ICC ICM embedded profile with length 557168 bytes
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1538/Coder:
      Photoshop embedded profile with length 4438 bytes
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1561/Coder:
      XMP embedded profile with length 15981 bytes
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1614/Coder:
      Extra sample 1 contains ASSOCIATED alpha
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1670/Coder:
      Image has a matte channel of type: Associated
    12:07:13 0:01 0.000u 28444 tiff.c/ReadTIFFImage/1888/Coder:
      Using scanline SEPARATED read method with 8 bits per sample
    12:07:13 0:01 0.000u 28444 constitute.c/ReadImage/1605/Coder:
      Returned from "TIFF" decoder: cache=present monochrome=False grayscale=False class=DirectClass colorspace=CMYK
    12:07:13 0:01 0.000u 28444 constitute.c/WriteImage/2191/Coder:
      Invoking "TIF" encoder (Tagged Image File Format): cache=present adjoin=True type=Undefined monochrome=False grayscale=False class=DirectClass colorspace=RGB
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/3454/Coder:
      Using native endian byte order
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/3470/Coder:
      Opening TIFF file "RGB-trans-pcbo.tif" using open flags "w".
    12:07:13 0:01 0.000u 28444 tiff.c/CompressionSupported/414/Coder:
      TIFFIsCODECConfigured says support for LZW compression is configured.
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/3627/Coder:
      Image characteristics: cmyk=n, gray=n, mono=n, opaque=n, palette=n
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4032/Coder:
      Using RGB photometric, 4 samples per pixel, 8 bits per sample, format Unsigned
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4082/Coder:
      Using MSB2LSB bit fill order
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4095/Coder:
      Separate image planes
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4339/Coder:
      Requesting predictor 2
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4389/Coder:
      Using LZW compression
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4393/Coder:
      Image depth 8 bits
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4397/Coder:
      Rows per strip: 25 (8000 bytes/strip)
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4419/Coder:
      Resolution 72x72 pixels per inch
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4466/Coder:
      XMP embedded profile with length 15981 bytes
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4480/Coder:
      ICC ICM embedded profile with length 557168 bytes
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4498/Coder:
      Photoshop embedded profile with length 4438 bytes
    12:07:13 0:01 0.000u 28444 tiff.c/WriteNewsProfile/3336/Coder:
      TIFFSetField(tiff=0x01F3F8A0,tag=34377,length=4438,data=0x01E119C8)
    12:07:13 0:01 0.000u 28444 tiff.c/WriteTIFFImage/4686/Coder:
      Using scanline RGB write method with 8 bits per sample (320 bytes/scanline)
    

    A source file that demonstrates the issue is here.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-01-30

    Thanks for the interesting image file.  On a Unix system here, I am not immediately seeing the crash but I am seeing distorted output in the white part of the image, which means something is definitely wrong.  The image displays fine so the issue must be in the writer.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-02-02

    The fix for this was trivially easy.  It was due to a typo on my part.  The fix is in Mercurial as changeset 13861:1a2d7a38363f and will be in the next development snapshot and next release.  Thanks for reporting it.

     
  • Matt Walkenhorst

    Thank you for fixing this, Bob.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2013-02-08

    It seems that the GraphicsMagick test suite needs to be improved in order to find issues like this.

     

Log in to post a comment.