0

Good day. I am new to Imagemagick, and I just wanna ask what's wrong with this code

$cmd_for_wm = "composite -gravity southeast watermark.png image.jpg image.jpg;";    
exec($cmd_for_wm);

When I run it in the terminal, it is working well, but when I incorporated it in PHP, it doesn't work. Why?

Thanks for you in advance :) Cheers

rox
  • 9
  • 1

1 Answers1

0

I've tried your example and it does "die" silently.
This, on the other hand seems to work:

$cmd_for_wm = "composite -gravity southeast watermark.png image.jpg image.jpg;";    
passthru($cmd_for_wm);

Very curious indeed. Since the main difference between exec and passthru is the output handling. The later is used for binary data.

My take on this is that passthru correctly allows composite to output the processed image (which is binary data) into the specified file.

For a detailed explanation, please see PHP - exec() vs system() vs passthru()

Community
  • 1
  • 1
Alex Tartan
  • 6,736
  • 10
  • 34
  • 45