Page 1 of 1

CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-02T10:56:54-07:00
by hankr
I want to convert a PDF to high resolution JPG. The command line I finally got working with:

Code: Select all

convert -density 300 -colorspace RGB cover.pdf -profile USWebCoatedSWOP.icc cover.jpg
However, when I try to do that with magickwand, the MagickSetResolution forces a GRAY colorspace before even reading the image and I can't seem to set it back, and everything is horked. *without* setting the resolution, everything is fine.

Here is the code I am running:

Code: Select all

        if( $isPdf ) {
            MagickSetImageUnits( $magickWand, MW_PixelsPerInchResolution );
            MagickSetResolution( $magickWand, 300, 300 );
        }
        MagickReadImage( $magickWand, $sourceFile );
        if( MagickGetImageColorspace( $magickWand ) == MW_CMYKColorspace ) {
                MagickRemoveImageProfile( $magickWand, "ICC" );
                MagickSetImageProfile( $magickWand, 'ICC', file_get_contents( 'USWebCoatedSWOP.icc' ) );
                MagickProfileImage($magickWand, 'ICC', file_get_contents( 'srgb.icm' ) );
                MagickSetImageColorspace( $magickWand, MW_RGBColorspace );
        }
Which works as long as I don't call MagickSetResolution.

Any thoughts?

Thanks.

Posted: 2007-02-03T14:19:36-07:00
by magick
Post a complete working example and a URL to one of your PDF images. We need to reproduce the problem before we can offer a solution.

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T09:24:17-07:00
by hankr
Here is a complete working test, including test file. You can access it from a URL or from the command line. The line to uncomment has a note above it in the source. That simple change creates the right size file, but the colorspace turns to gray *prior* to the read file. Where as not setting the resolution, there is not colorspace data set. I have tried setting the colorspace and profile and anything else I can figure.

Thanks so much for taking a look.

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T09:51:35-07:00
by magick
Which version of ImageMagick are you using? We tried your script with the latest release and it worked fine. It returned a 5292x2625 RGB JPEG image as expected.

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T20:51:30-07:00
by hankr
I have tried with:
* PHP 5.0.4, IM 6.2.2 with MagickWand 0.1.3 (Fedora 4), x86_64
* PHP 5.1.4, IM 6.2.9 with MagickWand 0.1.8 (Centos 4.4), x86_64
I could understand 6.2.2/013 being iffy, but I would think 6.2.9 and 0.1.8 should be recent enough.

You uncommented the line with MagickSetResolution? Did you look at the resultant jpg and it looked identical to the PDF?

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T21:03:16-07:00
by magick
Yes and yes.

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T21:07:04-07:00
by hankr
What PHP, IM, MagickWand versions are you running?

I just upgraded to IM 6.3.2 and MagickWand 0.1.9 and am still seeing the same. This is a 99% stock Centos box, with only the PHP and ImageMagick updated. I used the fedora RPM's from ftp://ftp.imagemagick.net/pub/ImageMagi ... -2.src.rpm and had to change freetype2-devel to freetype-devel in the pre-req's. That's it. Anything dangerous in that?

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T21:43:15-07:00
by magick
Its possible the problem is with Ghostscript which ImageMagick uses to render PDF images. We're using Ghostscript 8.54.

Re: CMYK PDF -> Hi Res JPG trouble

Posted: 2007-02-04T21:55:53-07:00
by hankr
Ugh, this is the likely beast. I just tried it on a Fedora Core 6 machine with 8.15 and got the same result. Any chance you have GS 8.15 floating around somewhere since that is the most recent build for Fedora, Suse, and likely RHEL5? I have tried upgrading ghostscript before, but the experience produced problematic output.