问题描述
目前正在使用PHP和iMagick开发海报打印Web应用程序。
Currently working with PHP and iMagick to develop a poster printing Web application.
这是我用来测试应用程序的上传/图像编辑功能的示例图像:
This is the example image I am using to test upload/image editing features of the application:
该图片包含以下EXIF数据:
The image contains the following EXIF data:
[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
然而 - 当使用此图像进行__construct时,iMagick会自动将其旋转90度CCW根据 [Orientation] => 6
(我想!)。结果导致...
However - iMagick, when __construct'ed with this image, automatically rotates it an additional 90 degrees CCW as per [Orientation] => 6
(I think!). Resulting in this...
我想知道的是...
如何保持图像的原始方向在页面顶部看到了什么?这可以通过禁用iMagick执行的自动旋转来实现吗?
How can I maintain the original orientation of the image seen at the top of the page? And is this possible through disabling the auto-rotation performed by iMagick?
非常感谢
UPDATE :这是我提出的解决方案......它将根据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;
}
}
推荐答案
尝试。试用。
这篇关于如何根据EXIF'orientation'数据停止PHP iMagick自动旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!