views:

254

answers:

1

Hello,

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:

$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

+2  A: 

if all you want is a copy, copy() is better.

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)

timdev