PHP使用imagecopy重新采样保留EXIF数据 [英] PHP Keep exif data using imagecopyresampled

查看:97
本文介绍了PHP使用imagecopy重新采样保留EXIF数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否是一种将原始图像的exif数据保留在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] );

工作正常,但是在创建的图像中没有exif数据.

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

推荐答案

您可以捕获exif数据并将其作为该文件的元数据保存到数据库中.

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

这篇关于PHP使用imagecopy重新采样保留EXIF数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆