setcolorimage differences with command line

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
neohunter
Posts: 4
Joined: 2011-12-05T07:20:24-07:00
Authentication code: 8675308

setcolorimage differences with command line

Post by neohunter »

hi, i think i found a bug on imagemagick after many testing, im runing this command on bash:

Code: Select all

convert -colorspace RGB -interlace none testcard.pdf test1.jpg 
it gives me a perfect image, if i dont put the -colorspace RGB the colors look so bright, it looks bad

now im trying to do the same from php with this:

Code: Select all

$pdf='testcard.pdf';
$im = new imagick($pdf.'[0]');
$im->setColorSpace( imagick::COLORSPACE_RGB );
$im->setImageColorSpace( imagick::COLORSPACE_RGB );
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
But the result is the same as if i run the command line without -colorspace RGB, the colors sucks.

It show works the same, right?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: setcolorimage differences with command line

Post by magick »

You need to set the image colorspace before you call new imagick($pdf.'[0]').
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: setcolorimage differences with command line

Post by el_supremo »

Your code isn't the same as the command line. See if this works:

Code: Select all

$pdf='testcard.pdf';
$im->setColorSpace( imagick::COLORSPACE_RGB );
$im->setImageColorSpace( imagick::COLORSPACE_RGB );
$im = new imagick($pdf.'[0]');
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
I'm also fairly sure that you don't need setImageColorSpace.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
neohunter
Posts: 4
Joined: 2011-12-05T07:20:24-07:00
Authentication code: 8675308

Re: setcolorimage differences with command line

Post by neohunter »

Mmmm thats not valid PHP code, i cant execute a method on $im if is not created yet, also the method is not static, so i cant call it like:

Code: Select all

imagick::setColorSpace( imagick::COLORSPACE_RGB );
maybe i can use loadImage or something to create the $im without the image. i will try.
neohunter
Posts: 4
Joined: 2011-12-05T07:20:24-07:00
Authentication code: 8675308

Re: setcolorimage differences with command line

Post by neohunter »

Yay! this make the trick:

Code: Select all

$im = new imagick();
$im->setColorSpace( imagick::COLORSPACE_RGB );
$im->readImage( $pdf.'[0]' );
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
i have to create the imagick without file.

Thanks ;)
Post Reply