โค้ด: เลือกทั้งหมด
public function imagerotate($file) {
$image = imagecreatefromstring(file_get_contents($file));
$exif = exif_read_data($file);
print_r($exif); exit;
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$image = imagerotate($image, 90, 0);
break;
case 3:
$image = imagerotate($image, 180, 0);
break;
case 6:
$image = imagerotate($image, -90, 0);
break;
}
}
}
คือ ค่าที่เช็ค ระหว่างภาพกลับหัว กับ ภาพปกติได้ค่า
[Orientation] => 1
ตลอด ทำให้มันเช็คไม่ได้ว่าภาพนี้กลับหัวหรือป่าว
ภาพปกติได้ค่า
Array
(
[FileName] => php8825.tmp
[FileDateTime] => 1458494440
[FileSize] => 123018
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
[COMPUTED] => Array
(
[html] => width="397" height="599"
[Height] => 599
[Width] => 397
[IsColor] => 1
[ByteOrderMotorola] => 1
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[Orientation] => 1
[XResolution] => 2400/1
[YResolution] => 2400/1
[ResolutionUnit] => 2
[Software] => Microsoft Windows Photo Viewer 6.1.7600.16385
[DateTime] => 2016:03:21 00:20:30
[Exif_IFD_Pointer] => 2252
[UndefinedTag:0xEA1C] =>
[THUMBNAIL] => Array
(
[Compression] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[JPEGInterchangeFormat] => 4426
[JPEGInterchangeFormatLength] => 10443
)
ภาพกลับหัว
Array
(
[FileName] => php6126.tmp
[FileDateTime] => 1458494626
[FileSize] => 123785
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
[COMPUTED] => Array
(
[html] => width="397" height="599"
[Height] => 599
[Width] => 397
[IsColor] => 1
[ByteOrderMotorola] => 1
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[Orientation] => 1
[XResolution] => 2400/1
[YResolution] => 2400/1
[ResolutionUnit] => 2
[Software] => Microsoft Windows Photo Viewer 6.1.7600.16385
[DateTime] => 2016:03:21 00:07:02
[Exif_IFD_Pointer] => 2252
[UndefinedTag:0xEA1C] =>
[THUMBNAIL] => Array
(
[Compression] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[JPEGInterchangeFormat] => 4426
[JPEGInterchangeFormatLength] => 10739
)
)