How can I use the imagemagick library to implement the imagecopyresampled function in the GD library? I folded the two pictures and read the English documents. I am looking for a shortcut. even if I tell a method name to study it myself, thank you!
Reply to discussion (solution)
// Open the file $ imgA = "phpcn_logo.gif"; $ imgB = "phpchina.gif"; $ sourceImg = imagecreatefromgif ($ imgA); $ targetImg = imagecreatefromgif ($ imgB ); // get the file size $ sourceSize = getimagesize ($ imgA); $ targetSize = getimagesize ($ imgB); // merge images imagecopyresized ($ targetImg, $ sourceImg, 0, 0, 0, 0, 0, $ targetSize [0], $ targetSize [1], $ sourceSize [0], $ sourceSize [1]); // Save the result $ r = imagegif ($ targetImg, "c.gif"); if ($ r) {echo "success" ;}else {echo "failed ";}
// Open the file $ imgA = "phpcn_logo.gif"; $ imgB = "phpchina.gif"; $ sourceImg = imagecreatefromgif ($ imgA); $ targetImg = imagecreatefromgif ($ imgB ); // get the file size $ sourceSize = getimagesize ($ imgA); $ targetSize = getimagesize ($ imgB); // merge images imagecopyresized ($ targetImg, $ sourceImg, 0, 0, 0, 0, 0, $ targetSize [0], $ targetSize [1], $ sourceSize [0], $ sourceSize [1]); // Save the result $ r = imagegif ($ targetImg, "c.gif"); if ($ r) {echo "success" ;}else {echo "failed ";}
Don't use the GD Library. I have implemented this because the speed is too slow and I want to change to imagemagick.
It has already been implemented, and the document has been read and spam, so I won't talk about code.
$image = new Imagick('05.png');$imagepng = new Imagick('16.png');$imagepng->setImageFormat("png");$image->compositeImage($imagepng, $imagepng->getImageCompose(), 0, 0);$imagepng->destroy();header("Content-Type: image/png");echo $image;$image->destroy();
Use imagick directly.
$cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", 'SouthEast', '+10+10', 100, '16.png', '05.png', '05.png'); exec($cmd);
Use imagick directly.
$cmd = sprintf("composite -gravity %s -geometry %s -dissolve %s '%s' %s %s", 'SouthEast', '+10+10', 100, '16.png', '05.png', '05.png'); exec($cmd);
Thank you. I want to output it directly. I don't know if it is feasible to directly use shell. In addition, it may be possible to port it to iis in the future. I still want to use extended insurance.