I've got a bunch of images that I'm loading from a aws3 link. I'm putting them in an array called images
. After doing so, I'm merging them and I want to resize them so they're nicely displayed. However, when i run the following code:
$remote_image = file_get_contents($imageurls[$i]);
file_put_contents("/tmp/remote_image.jpg", $remote_image);
$img = new Imagick("/tmp/remote_image.jpg");
$img->readImageFile("/tmp/remote_image.jpg");
$img->resizeImage(320,240,Imagick::FILTER_LANCZOS,0);
imagecopymerge($dest, $images[$i], 6, 245, 0, 0, 183, 156, 100);
$img->destroy();
I get the error readImageFile expectes parameter to be resource, string given.
how can i resize the images before/after merge into the width and height given in imagecopymerge
?
Normally you would create a handle for the file:
...
$image = '/tmp/remote_image.jpg';
$handle = fopen($image, 'rb');
$img = new Imagick();
$img->readImageFile($handle);
...