tags:

views:

261

answers:

3

I have a PHP file which I have used mod rewrite to make a .jpg extension. I want to grab an image from a url

example: http://msn.com/lol.gif

take the data and then display it in my .jpg with jpeg headers, so as far as the user is concerned it is a normal image. Is this possible and if so can anyone give me some pointers?

+2  A: 

If you use a combination of curl and PHP's image manipulation methods, which you can learn about here, will get you to what you are looking for.

alxp
A: 

Depending on you needs (do you need to manipulate the image?), you can just open the remote file and output it to the browser.

Check out the documentation on the readfile function and the http wrapper.

Tim Lytle
+2  A: 

using php GD library:

header('Content-type: image/jpeg');
$pic = imagecreatefromgif($url);
Imagejpeg($pic);
ImageDestroy($pic);

Using Imagick Library:

header('Content-type: image/jpeg');
$image = new Imagick($url);
$image->setImageFormat( "jpg" );
echo $image;
Luis Melgratti