Search code examples
phpurlimagemagickimagick

How to properly open image from remote URL with PHP5+Imagick?


I tried this code:

$image = new Imagick();
$f = fopen('http://www.url.com/image.jpg', 'rb');
$image = readImageFile($f);

but it doesn't work. Also, I believe it's not the best way to do it and I want the code to include best practices (now matter how ridiculous it sounds). On the same server, this code, using GD library, works just fine.

 $im = imagecreatefromjpeg('http://www.url.com/image.jpg');

Did I miss something in Imagick manual?


Solution

  • try replacing:

    $image = readImageFile($f)
    

    with

    $image->readImageFile($f);