Create image resource and get EXIF info without loading image twice

274 Views Asked by At

I have some PHP code which loads images and does some stuff to them. The images are large and slow to load (mounted SMB share), so I am trying to increase its efficiency.

I'm using imagecreatefromjpeg to load an image from a JPG, and exif_read_data to get the EXIF data from that image.

If my understanding of the below code snippet is correct, this results in PHP having to load the image twice. It's possible Linux is caching the file in memory or something so this isn't an issue, I don't know... but I'd like to know if there is any way I can avoid loading the image from disk twice and still get both an image resource I can manipulate, and the EXIF data?

$img = imagecreatefromjpeg($filename);
$exif = exif_read_data($filename);

// do stuff to the image using the exif data
0

There are 0 best solutions below