Resize as a sub-process. Use the area flag (^
), or ignore aspect ratio (!
) if needed (see examples)
$dim = "{$w}x{$h}^";
$job = "convert \( $img_in -resize {$dim} \) test_images/leak_1.jpg "
. " -compose softlight -gravity center -composite $img_out";
$ok = exec($job);
Although the background image is known, it might be wise to collect the dimensions at run time, and build out error handling.
$dim = exec("convert -ping -format '%wx%h^' test_images/leak_1.jpg info:-");
// Do error handle for overlay
$job = "convert \( $img_in -resize {$dim} \) test_images/leak_1.jpg "
. " -compose softlight -gravity center -composite $img_out";
$ok = exec($job);