note 112902 added to function.imagecreatefromjpeg
| From: | jan at recreatie-zorg dot nl | Date: | Mon, 05 Aug 2013 10:20:27 +0000 |
| Subject: | note 112902 added to function.imagecreatefromjpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195869@lists.php.net to get a copy of this message | ||
This function does not honour EXIF orientation data. Pictures that are rotated using EXIF, will
show up in the original orientation after being handled by imagecreatefromjpeg(). Below is a
function to create an image from JPEG while honouring EXIF orientation data.
<?php
function imagecreatefromjpegexif($filename)
{
$img = imagecreatefromjpeg($filename);
$exif = exif_read_data($filename);
if ($img && $exif && isset($exif['Orientation']))
{
$ort = $exif['Orientation'];
if ($ort == 6 || $ort == 5)
$img = imagerotate($img, 270, null);
if ($ort == 3 || $ort == 4)
$img = imagerotate($img, 180, null);
if ($ort == 8 || $ort == 7)
$img = imagerotate($img, 90, null);
if ($ort == 5 || $ort == 4 || $ort == 7)
imageflip($img, IMG_FLIP_HORIZONTAL);
}
return $img;
}
?>
----
Server IP: 83.137.20.135
Probable Submitter: 62.212.129.214
----
Manual Page -- http://php.net/manual/en/function.imagecreatefromjpeg.php
Edit -- https://master.php.net/note/edit/112902
Del: integrated -- https://master.php.net/note/delete/112902/integrated
Del: useless -- https://master.php.net/note/delete/112902/useless
Del: bad code -- https://master.php.net/note/delete/112902/bad+code
Del: spam -- https://master.php.net/note/delete/112902/spam
Del: non-english -- https://master.php.net/note/delete/112902/non-english
Del: in docs -- https://master.php.net/note/delete/112902/in+docs
Del: other reasons-- https://master.php.net/note/delete/112902
Reject -- https://master.php.net/note/reject/112902
Search -- https://master.php.net/manage/user-notes.php