Page 1 of 1

setcolorimage differences with command line

Posted: 2011-12-05T07:55:23-07:00
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?

Re: setcolorimage differences with command line

Posted: 2011-12-05T08:34:14-07:00
by magick
You need to set the image colorspace before you call new imagick($pdf.'[0]').

Re: setcolorimage differences with command line

Posted: 2011-12-05T08:35:41-07:00
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

Re: setcolorimage differences with command line

Posted: 2011-12-05T08:52:17-07:00
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.

Re: setcolorimage differences with command line

Posted: 2011-12-05T08:54:32-07:00
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 ;)