MagickResizeImage and imagecreatetruecolor

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
Carlos82

MagickResizeImage and imagecreatetruecolor

Post by Carlos82 »

I want to integrate ImageMagick with GD, manipulating with MagickWand. How can I convert from ImageMagick to GD format?

$dst_img = imagecreatetruecolor($dst_width, $dst_height);


$magick_wand = NewMagickWand();

MagickReadImage( $magick_wand, $src_img );

MagickResizeImage( $magick_wand, $dst_width, $dst_height, MW_LanczosFilter, 1.0 );

$dst_img = $magick_wand; <----------- It fails here

Thanks.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickResizeImage and imagecreatetruecolor

Post by magick »

Looks like you'll need to write blob in a well-known format with GD (e.g. PNG) and then read it as a blob with MagickWand for PHP.
Carlos82

Re: MagickResizeImage and imagecreatetruecolor

Post by Carlos82 »

So if I read with GD, I must pass it to MagickWand reading as blob?

Read with GD:
$imagecreatefrom = 'imagecreatefrom' . $default_formats[$sizes[2]];
$src_img = @$imagecreatefrom($source)

Then read as blob:
$MagickReadImageBlob( $magick_wand, $src_img );

Process with MagickWand:
MagickResizeImage( $magick_wand, $dst_width, $dst_height, MW_LanczosFilter, 1.0 );

And then back to GD:
$dst_img = MagickGetImageBlob( $magick_wand );

It doesn't work.

Thanks.
Post Reply