CMYK PDF -> Hi Res JPG trouble

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
hankr

CMYK PDF -> Hi Res JPG trouble

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post 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.
hankr

Re: CMYK PDF -> Hi Res JPG trouble

Post 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.
Last edited by hankr on 2007-04-10T14:51:57-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: CMYK PDF -> Hi Res JPG trouble

Post 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.
hankr

Re: CMYK PDF -> Hi Res JPG trouble

Post 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?
Last edited by hankr on 2007-02-04T21:09:52-07:00, edited 2 times in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: CMYK PDF -> Hi Res JPG trouble

Post by magick »

Yes and yes.
hankr

Re: CMYK PDF -> Hi Res JPG trouble

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: CMYK PDF -> Hi Res JPG trouble

Post by magick »

Its possible the problem is with Ghostscript which ImageMagick uses to render PDF images. We're using Ghostscript 8.54.
hankr

Re: CMYK PDF -> Hi Res JPG trouble

Post 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.
Post Reply