1

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?

0

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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;

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.