We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I was happy, that pThumb (with the help of ImageMagick) is able to create JPGs from PDFs – even from CMYK PDFs. In the case of the latter, the output bitmap is also in CMYK. But the result looks a little like "colors who had way to much coffee": Everything is way to saturated. Browsers just don't know how to handle CMYK JPGs. So I need to generate RGB JPGs.

    Since ImageMagick knows colorspaces, I tried convert -density 72 -colorspace rgb cmyk-x4.pdf cmyk-x4-rgb.jpg at the shell and got a nice RGB JPG with correct colors out of my CMYK PDF-X/4 (and PDF-X/3). Kewl.

    But how do I use the ImageMagick parameter -colorspace rgb with pThumb? Just passing &colorspace=rgb does not work. Any ideas?

    cheers
    Oliver

    P.S.: Safari shows a CMYK JPG with colors being OK, if the source had been a PDF-X/3 (CMYK). But that is not really helping me. ;-)
      MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
      http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
    • Good question.

      There isn't a way to force pThumb to do color space conversions. However if you've got things set up right it will do them automatically.

      First, do you have pThumb set to use Resizer or phpThumb? I don't know for sure what phpThumb will do with color spaces, probably nothing (i.e. CMYK stays in CMYK). Resizer however will automatically take the following steps with CMYK images:


      1. If the image has an embedded color profile, use that. Otherwise assume Adobe US Web Uncoated.
      2. Attempt to convert it to RGB (sRGB profile). However see the requirements below.
      3. Strip the profile, whether or not step 2 was successful. This makes the image smaller (some profiles are over 1MB!) and web browsers will assume sRGB anyway.

      Converting from CMYK to RGB requires:

      • imagick (PHP extension for ImageMagick). Resizer needs this to use ImageMagick at all.
      • ImageMagick >= 6.5.7. Some hosts (*ahem* MODX Cloud) offer only a quite ancient version of ImageMagick which doesn't support conversions.
      • ImageMagick compiled with the lcms (Little Color Management System) delegate. You can check this with convert -list configure | grep DELEGATES. If you've got it you'll see lcms in the list.

      If your server meets all these requirements Resizer should automatically do the conversion. I'd start by testing with a jpeg. That'll be simpler than a PDF. Give it a CMYK jpeg with an embedded profile and see whether it comes out RGB.

      Second, are you using a standard monitor or a wide-gamut one? Most monitors display roughly sRGB but some specialty ones will do Adobe 1998 or even larger. As far as I remember, Safari is the only browser that will display correct color on a wide-gamut monitor when the images lack an embedded profile. Otherwise you get overly saturated colors, especially in the reds. If you don't know whether you're monitor's wide gamut, it's probably not.
        Extras :: pThumbResizerimageSlimsetPlaceholders
      • Thanks you, jgrant, for your detailed answer!

        Quote from: jgrant at Aug 21, 2014, 01:42 AM

        There isn't a way to force pThumb to do color space conversions. However if you've got things set up right it will do them automatically.
        Would be a great feature to be able to use also ImageMagick parameters! Collect them and pass them over. ;-)

        And I would love to see pThumb with an optional "resizer" parameter not only with a system wide... ;-)

        OK, back to the dirty work:

        Quote from: jgrant at Aug 21, 2014, 01:42 AM

        First, do you have pThumb set to use Resizer or phpThumb? I don't know for sure what phpThumb will do with color spaces, probably nothing (i.e. CMYK stays in CMYK).

        Without Resizer, I get CMYK PDF >> CMYK JPG #medium fail# ;-)

        And now it gets funny.

        With Resizer, I get CMYK JPG >> RGB JPG #win#
        With Resizer, I get CMYK PDF >> error #fail#

        Resizer can convert CMYK JPGs to RGB but cannot handle PDFs! If I turn him off, I get me PDFs processed but the result is a CMYK JPG.

        I am doomed. ;-)

        Quote from: jgrant at Aug 21, 2014, 01:42 AM

        If your server meets all these requirements Resizer should automatically do the conversion. I'd start by testing with a jpeg. That'll be simpler than a PDF. Give it a CMYK jpeg with an embedded profile and see whether it comes out RGB.

        The JPG get a profile called "sRGB IEC61966-2-1 black scaled".

        I would love to use Resizer, but he does not know how to handle PDFs, neither RGB nor CMYK PDFs.


        Quote from: jgrant at Aug 21, 2014, 01:42 AM

        Second, are you using a standard monitor or a wide-gamut one?
        A wide-gamut one: NEC 2080UX+. Actually, two. ;-)

        Thanks for your help!
        Oliver
          MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
          http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver
        • Quote from: mindeffects at Aug 22, 2014, 03:52 PM
          Would be a great feature to be able to use also ImageMagick parameters! Collect them and pass them over. ;-)

          Unfortunately it's not so simple. Only phpThumb runs ImageMagick's convert command through a shell, and even then not for everything and not in all cases. (Plus phpThumb would have to be modified in order to do this.) Resizer works completely in PHP—using either the GD, imagick or gmagick API—so there are no command-line parameters to begin with.

          And I would love to see pThumb with an optional "resizer" parameter not only with a system wide... ;-)

          Good news on this one. There's already a &useResizer property which will override the system default. Like so:
          [[pthumb? &input=`[[*someImageTV]]` &options=`h=150&w=150` &useResizer=`0`]]


          Thanks for testing with jpegs and pdfs. When I get a chance I'll see what's going on with pdfs and if there's a way to make Resizer work with them. Seems like it should, huh!

            Extras :: pThumbResizerimageSlimsetPlaceholders
          • Nice! Didn't know about the "&useResizer" option.
            I often use output chaining with a "notempty" check before, but I can find a workaround for that. Or is there a possibility to use the "&options" for that? One $input string to rule them all, you know. ;-)

            A nice little side effect of the "PDFX3 to JPG" capeabilities of pThumb (ImageMagick): The rendenring algorythm produces better results then Photoshop, because newer CS version have a flaw in rendering flattened PDFs. Those "thin white lines" between the segmented areas are visible which makes PDFX3 unusable as a source for generating thumbs from PDFs using Photoshop. pThumbs renders the PDFX3 segments nicely, without any white lines. Great!
            Sadly, the CMYK2RGB conversion via "-colorspace rgb" is not available via pThumb and IM. Chaining IM and Resizer would be a solutions but performance would suffer when it comes to larger PDF files — and it lacks some elegance. ;-)
              MINDEFFECTS – DESIGN for PRINT, WEB and MEDIA
              http://twitter.com/mindeffects · http://www.facebook.com/mindeffects · http://www.youtube.com/mindeffects/ · skype://mindeffects_oliver