Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ImageMagick to resize images from command line in PHP

I'm using ImageMagick to generate a small thumbnail of images. convert --version shows ImageMagick 4.2.9 99/09/01.

$output = array();

$cmd = "/opt/RZmagick4/bin/convert data/test.jpg data/small.png"; // works fine
$cmd = "/opt/RZmagick4/bin/convert data/test.jpg -resize 300x200 data/small.jpg"; // does not work

exec($cmd, $output);

echo "<pre>";
print_r($output);
echo "</pre>";

Why does the second $cmd not work? Output for both is Array( ). However, there is just no output image.

like image 790
Explicat Avatar asked Nov 30 '25 04:11

Explicat


1 Answers

You should write this:

$cmd = "/opt/RZmagick4/bin/convert -resize 300x200 data/test.jpg data/small.jpg"; 
like image 84
Mahmoud Hosseini Avatar answered Dec 02 '25 17:12

Mahmoud Hosseini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!