問題描述
目前正在使用 PHP 和 iMagick 開發(fā)海報(bào)打印 Web 應(yīng)用程序.
Currently working with PHP and iMagick to develop a poster printing Web application.
這是我用來測(cè)試應(yīng)用程序的上傳/圖像編輯功能的示例圖像:
This is the example image I am using to test upload/image editing features of the application:
圖像包含以下 EXIF 數(shù)據(jù):
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
然而 - iMagick,當(dāng)使用這個(gè)圖像 __construct' 時(shí),會(huì)根據(jù) [Orientation] => 自動(dòng)將其逆時(shí)針旋轉(zhuǎn) 90 度.6
(我想!).導(dǎo)致這個(gè)...
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 執(zhí)行的自動(dòng)旋轉(zhuǎn)來實(shí)現(xiàn)?
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?
非常感謝
更新:這是我想出的解決方案......它將根據(jù) EXIF 數(shù)據(jù)中的方向修復(fù)方向
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;
}
}
推薦答案
嘗試 Imagick::setImageOrientation
.試驗(yàn)可用常量.
這篇關(guān)于如何停止基于 EXIF“方向"數(shù)據(jù)的 PHP iMagick 自動(dòng)旋轉(zhuǎn)圖像的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!