Page 1 of 1

readImageFile fails for remote images

Posted: 2011-11-02T00:07:18-07:00
by Salad_Dressing
Hi,

I'm new to PHP Imagick although I've used Image Magick on the Windows CLI before.

I have managed to install Imagick 6.6.2-Q8 x86 on my development server (Windows 7 Professional 64-bit). As I understand this is the latest imagick version compiled with VC9. I also installed the VC9 builds of the php_imagick.dll with the appropriate entry in php.ini.

My server setup:
  • XAMPP for Windows 1.7.7
    Apache 2.2.21 (Win32)
    PHP 5.3.8 (VC9)
    MySQL 5.5.16
    Imagick 6.6.2-10 Q8
What Works:
When I get a file handle using $handle = fopen($filename, 'rb') and then use $image->readImageFile($handle) with a localhost image ("f7_avatars/berries.JPG") then Imagick functions perfectly, loading the bitmap, getImageWidth, getImageHeight, cropImage, resizeImage, setImageCompression, stripImage and writeImage (BTW - after trying GD, Imagick's resize quality is amazing!).

My Problem:
When I use a remote URL for the same code ("http://www.domain.com/folder/image.JPG"), then I get the error: Invalid CRT parameters detected. Even when I try to point to the localhost file using this syntax ("http://localhost/f7_avatars/berries.JPG") then I end up with this same error.

Can anyone please help me with this?

Re: readImageFile fails for remote images

Posted: 2011-12-10T05:56:32-07:00
by byron
Try:

Code: Select all

$blob = file_get_contents("http://your_host/berries.JPG");
$image = new imagick();
$image->readImageBlob("$blob");