I'm using PHP to copy JPGs from a remote server to my own server. Is it best to simply use the copy()
function, or are the jpeg-specific functions better? For example:
我正在使用PHP将JPG从远程服务器复制到我自己的服务器。是否最好简单地使用copy()函数,还是更好的jpeg特定函数?例如:
$copy = copy($remote_url, $dest_file);
-OR-
$img = imagecreatefromjpeg($remote_url);
$copy = imagejpeg($img, $dest_file);
imagedestroy($img);
What would the best option be in terms of speed and memory load? Also, would there be any difference in the resulting image quality? I should add that this script is required to copy a large number of photos (typically hundreds, but sometimes it may be a couple thousand).
在速度和内存负载方面最好的选择是什么?此外,产生的图像质量会有任何差异吗?我应该补充一点,这个脚本需要复制大量的照片(通常是数百张,但有时可能是几千张)。
Thanks, Brian
1 个解决方案
#1
3
if all you want is a copy, copy() is better.
如果你想要的只是一个副本,copy()会更好。
using the gd library functions (imagecreatefromjpeg/imagejpeg) will end up re-compressing the image (probably, maybe it's smart enough not to, but probably). If you wanted to convert the images to .png or something, then you'd want to use gd (or ImageMagick)
使用gd库函数(imagecreatefromjpeg / imagejpeg)将最终重新压缩图像(可能,它可能足够聪明,但可能)。如果你想将图像转换为.png或其他东西,那么你想要使用gd(或ImageMagick)
#1
3
if all you want is a copy, copy() is better.
如果你想要的只是一个副本,copy()会更好。
using the gd library functions (imagecreatefromjpeg/imagejpeg) will end up re-compressing the image (probably, maybe it's smart enough not to, but probably). If you wanted to convert the images to .png or something, then you'd want to use gd (or ImageMagick)
使用gd库函数(imagecreatefromjpeg / imagejpeg)将最终重新压缩图像(可能,它可能足够聪明,但可能)。如果你想将图像转换为.png或其他东西,那么你想要使用gd(或ImageMagick)