Unhandled image colorspace #2727

Closed
michaelrsweet opened this Issue Feb 28, 2008 · 4 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Feb 28, 2008

Version: 1.3.6
CUPS.org User: twaugh.redhat

The JCS_YCCK colourspace is not handled correctly by the CUPS image filter when processing JPEG images. Example file, with filter output, attached.

Collaborator

michaelrsweet commented Feb 28, 2008

CUPS.org User: twaugh.redhat

Original bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=166460

Collaborator

michaelrsweet commented Feb 28, 2008

CUPS.org User: mike

The problem is that Adobe incorrectly writes CMYK JPEG files as RGBW, in violation of the JPEG specification. You can't even use the JPEG output from Photoshop directly on the PostScript printer for this reason...

Unfortunately, the current check for this in image-jpeg.c doesn't seem to work with current versions of Photoshop. Will see if I can make the code detect this more reliably...

Collaborator

michaelrsweet commented Feb 28, 2008

CUPS.org User: mike

Fixed in Subversion repository.

Collaborator

michaelrsweet commented Feb 28, 2008

"str2727.patch":

Index: image-jpeg.c

--- image-jpeg.c (revision 7354)
+++ image-jpeg.c (working copy)
@@ -47,8 +47,8 @@
struct jpeg_error_mgr jerr; /* Error handler info /
cups_ib_t *in, /
Input pixels /
*out; /
Output pixels */

  • char header[16]; /* Photoshop JPEG header */
  • int psjpeg; /* Non-zero if Photoshop JPEG */
  • jpeg_saved_marker_ptr marker; /* Pointer to marker data */
  • int psjpeg = 0; /* Non-zero if Photoshop CMYK JPEG /
    static const char *cspaces[] =
    { /
    JPEG colorspaces... */
    "JCS_UNKNOWN",
    @@ -61,23 +61,30 @@

/*

  • * Read the first 16 bytes to determine if this is a Photoshop JPEG file...

- */

  • fread(header, sizeof(header), 1, fp);

- rewind(fp);

- psjpeg = memcmp(header + 6, "Photoshop ", 10) == 0;

  • /*

    • Read the JPEG header...
      */

    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_decompress(&cinfo);

  • jpeg_save_markers(&cinfo, JPEG_APP0 + 14, 0xffff); /* Adobe JPEG */
    jpeg_stdio_src(&cinfo, fp);
    jpeg_read_header(&cinfo, 1);

  • /*

  • * Parse any Adobe APPE data embedded in the JPEG file. Since Adobe doesn't

  • * bother following standards, we have to invert the CMYK JPEG data written by

  • * Adobe apps...

  • */

  • for (marker = cinfo.marker_list; marker; marker = marker->next)
  • if (marker->marker == (JPEG_APP0 + 14) && marker->data_length >= 12 &&
  •    !memcmp(marker->data, "Adobe", 5) && marker->data[11] == 2)
    
  • {
  •  fputs("DEBUG: Adobe CMYK JPEG detected (inverting color values)\n",
    
  •   stderr);
    
  •  psjpeg = 1;
    
  • }

cinfo.quantize_colors = 0;

fprintf(stderr, "DEBUG: num_components = %d\n", cinfo.num_components);

michaelrsweet added this to the Stable milestone Mar 17, 2016

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