Color Difference Between JPG and EPS rendered.

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
cranky

Color Difference Between JPG and EPS rendered.

Post by cranky »

Someone pointed this out to me:

Generated from EPS:
Image Image

Generated from a JPG (created by Illustrator):
Image Image

The code I use for making the thumbnail from a EPS:

Code: Select all

$blob = file_get_contents("test.eps");
$magick_wand=NewMagickWand();
MagickReadImageBlob($magick_wand, $blob);
$wand = NewMagickWand();
MagickSetResolution( $wand, 300, 300 );
MagickReadImageBlob($wand, $blob);
$new_wand = MagickTransformImage($wand, NULL, '50x');
MagickSetImageFormat($new_wand, 'jpg') ;
MagickWriteImage($new_wand, "file.jpg");
DestroyMagickWand($new_wand);
DestroyMagickWand($wand);
Any ideas why there is the color difference between the two methods? I assume the JPG version is the "correct" one. Any insight would be much appreciated!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Color Difference Between JPG and EPS rendered.

Post by magick »

The original images are in the CMYK colorspace. To properly convert to RGB try first
  • convert -colorspace rgb image.eps -quality 92 image.jpg
If that does not produce a satisfactory result, use color profiles (i.e. the -profile option with two profiles, one SWOP and one sRGB).
cranky

Re: Color Difference Between JPG and EPS rendered.

Post by cranky »

To update this thread - I am trying to add ICC profiles so that CMYK keep their proper colors. I found some resources online, but can not seem to get it to apply the profiles properly. Here is what I have - any ideas on why the profiles are not showing up properly? Thanks!!

Code: Select all

$wand = NewMagickWand();
MagickSetResolution( $wand, 300, 300 );
MagickReadImage($wand, "$original_file.eps");
if( MagickGetImageColorspace( $wand ) == MW_CMYKColorspace ) {
	MagickRemoveImageProfile( $wand, "ICC" );
	MagickSetImageProfile( $wand, 'ICC', file_get_contents( 'USWebCoatedSWOP.icc' ) );
	MagickProfileImage($wand, 'ICC', file_get_contents( 'sRGB.icm' ) );
	MagickSetImageColorspace( $wand, MW_RGBColorspace );
}
$new_wand = MagickTransformImage($wand, NULL, '50x');
MagickSetImageFormat($new_wand, 'jpg') ;
MagickStripImage($new_wand);
MagickWriteImage($new_wand, "final_image.jpg");
DestroyMagickWand($new_wand);
DestroyMagickWand($wand);
The goal is to make Image (created by ImageMagick from EPS) look like Image (created by Photoshop). The original EPS is CMYK.
Post Reply