如何检测照片的拍摄角度,以及如何像查看桌面应用程序一样自动旋转以显示网站?

如何检测照片的拍摄角度,以及如何像查看桌面应用程序一样自动旋转以显示网站?,第1张

如何检测照片的拍摄角度,以及如何像查看桌面应用程序一样自动旋转以显示网站?

为此,必须从JPEG文件读取EXIF信息。您可以使用

exif
PHP扩展名或使用
PEL

基本上,您必须读取

Orientation
文件中的标志。这是一个使用
exif
PHP扩展并
WideImage
用于图像处理的示例。

<?php$exif = exif_read_data($filename);$ort = $exif['Orientation'];$image = WideImage::load($filename);// GD doesn't support EXIF, so all information is removed.$image->exifOrient($ort)->saveToFile($filename);class WideImage_Operation_ExifOrient{    function execute($img, $orientation)  {    switch ($orientation) {      case 2:        return $img->mirror();        break;      case 3:        return $img->rotate(180);        break;      case 4:        return $img->rotate(180)->mirror();        break;      case 5:        return $img->rotate(90)->mirror();        break;      case 6:        return $img->rotate(90);        break;      case 7:        return $img->rotate(-90)->mirror();        break;      case 8:        return $img->rotate(-90);        break;      default: return $img->copy();    }  }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4918208.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存