I can have CMYK to RGB or CGI scripts but not both!!

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
halcongris

I can have CMYK to RGB or CGI scripts but not both!!

Post by halcongris »

A bit of a nightmare! With ImageMagick 6.2.5, Apache 2.0.50 and ActivePerl 5.8.8 I can convert a PDF CMYK into a jpeg RGB with no problems as a standalone Perl script but it won't run as a CGI. As soon as I include the line "use Image::Magick " the server returns a "bad headers" message.

If I switch to ImageMagick 6.3.2 the CGI script runs fine but the jpeg produced is incorrect - the blacks disappear and the other colours get messed up.

Any ideas as to how to have the best of both worlds?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: I can have CMYK to RGB or CGI scripts but not both!!

Post by magick »

You are creating a CMYK JPEG image but you most likely want a RGB JPEG image. Specify RGB before the image is read or use two color profiles to make the conversion (e.g. one sRGB and one Swop). The most convenient method from the command line:
  • convert -colorspace rgb cmyk.pdf rgb.pdf
halcongris

Re: I can have CMYK to RGB or CGI scripts but not both!!

Post by halcongris »

But the program works perfectly with IM 6.2.5:
use Image::Magick;
$newsport = Image::Magick->new();
$newsport->Read(filename=>"pdf:LG01.pdf");
$newsport->Resize(width=>200,height=>286,filter=>Lanczos);
$newsport->Write(filename=>"jpg:test03K.jpg",colorspace=>RGB);

But it doesn't work with 6.3.2 and 6.2.5 won't run as CGI script.
Is there a bug in 6.3.2 colour handling?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: I can have CMYK to RGB or CGI scripts but not both!!

Post by magick »

6.2.5 did not automatically converted CMYK PDF images to RGB. However, this is not what all users want. Some users want CMYK PDF's to remain in the CMYK colorspace. The fix is simply to change your script:
  • newsport = Image::Magick->new(colorspace=>'RGB');
    $newsport->Read(filename=>"pdf:LG01.pdf");
halcongris

Re: PDF now converts but TIF causes web browsers to complain

Post by halcongris »

Many thanks for your help. The script now converts PDF to JPG fine but when it converts a TIF to JPG, the resulting image looks OK in a PaintShop Pro or GIMP but a browser such as Firefox complains that there are errors in the image. Any clues?
RXGX

Re: I can have CMYK to RGB or CGI scripts but not both!!

Post by RXGX »

If the JPG has errors, bring it into your graphics program and check the color profile. Most likely, it's still CMYK.
Post Reply