readImageFile fails for remote images

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
Salad_Dressing
Posts: 1
Joined: 2011-11-01T23:04:38-07:00
Authentication code: 8675308

readImageFile fails for remote images

Post 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?
byron
Posts: 9
Joined: 2010-05-07T05:07:56-07:00
Authentication code: 8675308

Re: readImageFile fails for remote images

Post by byron »

Try:

Code: Select all

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