Mariusz Jucha
Mariusz Jucha

Reputation: 93

PHP Keep exif data using imagecopyresampled

I'm wondering if is a way to keep exif data of original image in image created by imagecopyresampled function. My code:

$randomName = Functions::generate_random_string(10);
$img = imagecreatefromjpeg($_FILES["file"]["tmp_name"]);
$imageSize = getimagesize($_FILES["file"]["tmp_name"]);
$ratio = 1 / ($imageSize[0] / $imageSize[1]);
$newWidth = 2560;
$newHeight = round($newWidth * $ratio);
$tmp_img = imagecreatetruecolor( $newWidth, $newHeight );
imagecopyresampled( $tmp_img, $img, 0, 0, 0, 0, $newWidth, $newHeight, $imageSize[0], $imageSize[1] );

Works fine but in created image there is no exif data.

Upvotes: 0

Views: 1136

Answers (1)

Brian H.
Brian H.

Reputation: 505

You can capture the exif data and save it to the database as meta data for the file.

Upvotes: 1

Related Questions