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?

4

3 回答 3

2

如果您结合使用 curl 和 PHP 的图像处理方法(您可以在此处了解) ,您将获得所需的内容。

于 2009-01-10T02:47:01.733 回答
2

使用 php GD 库:

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

使用 imagick 库:

header('Content-type: image/jpeg');
$image = new Imagick($url);
$image->setImageFormat( "jpg" );
echo $image;
于 2009-01-10T04:43:08.470 回答
0

根据您的需要(您需要处理图像吗?),您可以打开远程文件并将其输出到浏览器。

查看有关readfile函数和http wrapper的文档。

于 2009-01-10T04:42:42.497 回答