目前正在使用 PHP 和 iMagick 开发海报打印 Web 应用程序。
这是我用来测试应用程序的上传/图像编辑功能的示例图像:
该图像包含以下 EXIF 数据:
[FileName] => 1290599108_IMG_6783.JPG
[FileDateTime] => 1290599109
[FileSize] => 4275563
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, INTEROP, MAKERNOTE
[COMPUTED] => Array
(
[html] => width="3504" height="2336"
[Height] => 2336
[Width] => 3504
[IsColor] => 1
[ByteOrderMotorola] => 0
[CCDWidth] => 22mm
[ApertureFNumber] => f/5.6
[UserComment] =>
[UserCommentEncoding] => UNDEFINED
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[Make] => Canon
[Model] => Canon EOS 30D
[Orientation] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[DateTime] => 2009:08:31 08:23:49
[YCbCrPositioning] => 2
[Exif_IFD_Pointer] => 196
[Orientation] => 6
但是 - iMagick,当使用此图像 __construct'ed 时,会根据(我认为!)自动将其逆时针旋转 90 度。导致这...
我想知道的是...
如何保持页面顶部图像的原始方向?这是否可以通过禁用 iMagick 执行的自动旋转来实现?
非常感谢
更新:这是我想出的解决方案...它将根据 EXIF 数据中的方向修复方向
public function fixOrientation() {
$exif = exif_read_data($this->imgSrc);
$orientation = $exif['Orientation'];
switch($orientation) {
case 6: // rotate 90 degrees CW
$this->image->rotateimage("#FFF", 90);
break;
case 8: // rotate 90 degrees CCW
$this->image->rotateimage("#FFF", -90);
break;
}
}