Page 1 of 1

CMYK pdf -> RGB jpg color loss

Posted: 2007-03-14T11:28:27-07:00
by nate12o6
i have magickWand setup for php and when i convert a vector cmyk pdf to rgb jpg i lose a few colors making the final image look horrable. When i convert these images on the command line it looks just fine. I only get the problem when using magickwand. I have looked around and saw some stuff about having to use profiles(i am not an image export so im not 100% sure what a profile is although i tried) so this is my php source:


Code: Select all

<?php
  $max_x = $_GET['x'];
  $max_y = $_GET['y'];

  $filename = $_GET['src'];
  
  if( $image = NewMagickWand() )  {	
	MagickReadImage( $image, $filename );	
	MagickSetImageColorspace( $image, MW_RGBColorspace );
	MagickStripImage( $image );
	MagickProfileImage( $image, 'SWAP', 'USWebCoatedSWOP.icc');	
	MagickProfileImage( $image, 'RGB', 'AdobeRGB1998.icc');

	$cur_x = MagickGetImageWidth( $image );
    $cur_y = MagickGetImageHeight( $image );

    if ($cur_x >= $cur_y) {
       $cur_rat = ($max_x * 1.000) / ($cur_x * 1.000);
	   $x = $max_x;	 
	   $y = ($cur_y * 1.000) * $cur_rat;
    }
    else {
       $cur_rat = ($max_y * 1.000) / ($cur_y * 1.000);
	   $y = $max_y;	 
	   $x = $cur_x * $cur_rat;
    }	
	//echo MagickGetImageProfile( $image, "rgb" );

    header( 'Content-Type: image/jpg' );	
	if(MagickGetImageWidth( $image ) > $x && MagickGetImageHeight( $image ) > $y)
	{
		MagickResizeImage( $image, $x, $y, MW_SincFilter, 1 );
	}		
	MagickSetImageFormat( $image, 'jpg' );
	//MagickSetImageType( $image, MW_OptimizeType);			
    MagickEchoImageBlob( $image );
  } else {
    echo "Error in MagickReadImage()";
    echo MagickGetExceptionString($image);
  }
?>
the profiles that i added dont look to make any difrence. I got them off my windows machine and figured i would just give it a try. If anyone could lead me in the right direction i would very much apreciate it. Thanks!

converted with command line: convert -colorspace RGB thumb.pdf thumb.jpg
Image

converted with magickWand:
Image