Reputation: 18389
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?
Upvotes: 1
Views: 428
Reputation: 12060
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;
Upvotes: 2
Reputation: 17624
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.
Upvotes: 0