【发布时间】:2012-04-23 17:16:20
【问题描述】:
前段时间,我写了一个方法,可以从在线社区上传的图片中读取 EXIF 数据。从图片中获得方向后,我将文件旋转到正确的方向。我的脚本只有一小部分:
public function rotate($sourceFile, $targetFile, $orienation)
{
switch($orienation){
case 3: $degrees = '180'; break;
case 6: $degrees = '90'; break;
case 8: $degrees = '270'; break;
default: $degrees = '0';
}
$file = $sourceFile . DS . $targetFile;
$rotate = GlobalConfig::BIN_IMAGICK_CONVERT . ' -rotate ' . $degrees . ' ' . $file . ' ' . $file;
exec($rotate);
}
我的脚本正在运行。但我的问题是,其他大个子喜欢什么 facebook,处理上传图片的旋转?因为我的解决方案肯定不是最好的。
【问题讨论】:
-
您是在问“执行旋转操作的最佳方式是什么”或“确定图像方向的最佳方式是什么”?
-
注意可以使用原生的ImageMagickphp扩展
-
如果
if ($degrees),至少我会包装exec()- 将图像旋转0度是没有意义的......
标签: php image upload rotation exif