我正在使用PHP脚本自动生成文件夹中所有图片的缩略图。原始照片似乎在我的浏览器中正确旋转,但缩略图不是。以下脚本有什么问题?
function make_thumb($src,$dest,$desired_width) {
/* read the source image */
$source_image = imagecreatefromjpeg($src);
$width = imagesx($source_image);
$height = imagesy($source_image);
/* find the "desired height" of this thumbnail, relative to the desired width */
$desired_height = floor($height*($desired_width/$width));
/* create a new, "virtual" image */
$virtual_image = imagecreatetruecolor($desired_width,$desired_height);
/* copy source image at a resized size */
imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
/* create the physical thumbnail image to its destination */
imagejpeg($virtual_image,$dest);
}
我假设它与原始文件中设置的方向值有关,但不是我创建的缩略图,但我不知道如何复制它。
注意我不能使用exif_read_data
发布于 2019-03-18 14:36:01
源图像可能包含正被剥离的exif方向标记。在调整图像大小并在之后将其写入或读取之前读取它,然后使用它在变换后将图像向右旋转。
https://stackoverflow.com/questions/-100006461
复制相似问题