#开启php配置
function adjustPicOrientation($full_filename){
$exif = exif_read_data($full_filename);
if($exif && isset($exif['Orientation'])) {
$orientation = $exif['Orientation'];
if($orientation != 1){
$img = imagecreatefromjpeg($full_filename);
$mirror = false;
$deg = 0;
switch ($orientation) {
case 2:
$mirror = true;
break;
case 3:
$deg = 180;
break;
case 4:
$deg = 180;
$mirror = true;
break;
case 5:
$deg = 270;
$mirror = true;
break;
case 6:
$deg = 270;
break;
case 7:
$deg = 90;
$mirror = true;
break;
case 8:
$deg = 90;
break;
}
if ($deg) $img = imagerotate($img, $deg, 0);
if ($mirror) $img = _mirrorImage($img);
imagejpeg($img, $full_filename, 95);
}
}
return $full_filename;
}
function _mirrorImage ( $imgsrc)
{
$width = imagesx ( $imgsrc );
$height = imagesy ( $imgsrc );
$src_x = $width -1;
$src_y = 0;
$src_width = -$width;
$src_height = $height;
$imgdest = imagecreatetruecolor ( $width, $height );
if ( imagecopyresampled ( $imgdest, $imgsrc, 0, 0, $src_x, $src_y, $width, $height, $src_width, $src_height ) )
{
return $imgdest;
}
return $imgsrc;
}
array (size=21)
‘FileName’ => string ‘2.jpg’ (length=5)
‘FileDateTime’ => int 1513667197
‘FileSize’ => int 2704297
‘FileType’ => int 2
‘MimeType’ => string ‘image/jpeg’ (length=10)
‘SectionsFound’ => string ‘ANY_TAG, IFD0, THUMBNAIL, EXIF’ (length=30)
‘COMPUTED’ =>
array (size=7)
‘html’ => string ‘width=”4032” height=”3024”’ (length=26)
‘Height’ => int 3024
‘Width’ => int 4032
‘IsColor’ => int 1
‘ByteOrderMotorola’ => int 1
‘Thumbnail.FileType’ => int 2
‘Thumbnail.MimeType’ => string ‘image/jpeg’ (length=10)
‘Orientation’ => int 6
‘XResolution’ => string ‘72/1’ (length=4)
‘YResolution’ => string ‘72/1’ (length=4)
‘ResolutionUnit’ => int 2
‘YCbCrPositioning’ => int 1
‘Exif_IFD_Pointer’ => int 102
‘THUMBNAIL’ =>
array (size=6)
‘Compression’ => int 6
‘XResolution’ => string ‘72/1’ (length=4)
‘YResolution’ => string ‘72/1’ (length=4)
‘ResolutionUnit’ => int 2
‘JPEGInterchangeFormat’ => int 286
‘JPEGInterchangeFormatLength’ => int 12566
‘ExifVersion’ => string ‘0221’ (length=4)
‘ComponentsConfiguration’ => string ‘�’ (length=4)
‘FlashPixVersion’ => string ‘0100’ (length=4)
‘ColorSpace’ => int 1
‘ExifImageWidth’ => int 4032
‘ExifImageLength’ => int 3024
‘SceneCaptureType’ => int 0`
“`
‘Orientation’ => int 6
旋转了270