首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >通过php脚本生成的缩略图有错误的方向

通过php脚本生成的缩略图有错误的方向
EN

Stack Overflow用户
提问于 2019-03-18 05:00:25
回答 1查看 0关注 0票数 0

我正在使用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

EN

回答 1

Stack Overflow用户

发布于 2019-03-18 14:36:01

源图像可能包含正被剥离的exif方向标记。在调整图像大小并在之后将其写入或读取之前读取它,然后使用它在变换后将图像向右旋转。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100006461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档