Page 1 of 1

Read image in from URL

Posted: 2009-02-06T18:17:11-07:00
by jck71
Hi - I'm really hoping someone can help. I've got on well with ImageMagick so far, but now I've hit a brick wall.

My script works sucessfully on an image that is on my server, but I now need to get it to take an image from a URL, instead of a local file. What I'm actually needing to do is to open a list of URL's, and crunch through each, one at a time, but I can work on the bigger picture later. So my question is:

How do I get it read a URL (for example http://www.mysite.com/img/photo.jpg) instead of a local file.

An extract from my script here - just for reference, in case it helps:
################################
use Image::Magick;
my $image = Image::Magick->new(magick=>'JPEG');
my $x = $image->Read('image1.jpg');
$x = $image->Resize(geometry=>'320x');
$image->Crop(height=>'212', gravity=>'Center');
$image->Annotate(x=>'200', y=>'197', font=>'kai.ttf', pointsize=>12, fill=>'white', text=>'MyText');
$x = $image->Write('temp1.jpg');
################################
I hope I've explained the question right, but to clarify, on Line 3 instead of Read('image1.jpg'), I want to read a URL - but simply replacing this with a URL doesn't work.

Can anyone help? Be really appreciated if you can.

Many thanks

Re: Read image in from URL

Posted: 2009-02-06T18:25:00-07:00
by magick
How do I get it read a URL (for example http://www.mysite.com/img/photo.jpg) instead of a local file.
Try
It requires libxml2 to work. Type
  • identify -list configure
to verify.

Re: Read image in from URL

Posted: 2009-02-07T05:01:55-07:00
by jck71
You're brilliant! Thank you, it now grabs the image from URL as intended. Such a small amendment, but I might as well have been a million miles away!

Now to add the foreach loops and I'm sorted.

Thanks ever so much for taking the time to post your reply, much appreciated.