Read image in from URL

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jck71

Read image in from URL

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Read image in from URL

Post 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.
jck71

Re: Read image in from URL

Post 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.
Post Reply