如果方向非空,我使用以下代码旋转上传的jpeg图像。
if(isset($_FILES["temp_image"]))
{
$temp_image = $this->imageupload->file_upload(TEMP_IMAGES_UPLOAD_PATH, 'temp_image');
$path = base_url().TEMP_IMAGES_UPLOAD_DISPLAY_PATH.$temp_image;
$exif = exif_read_data($path, "FILE,COMPUTED,ANY_TAG,IFD0,THUMBNAIL,COMMENT,EXIF", true);
if(!empty($exif['Orientation']))
{
switch($exif['Orientation'])
{
case 8:
$temp_image = imagerotate($temp_image,90,0);
break;
case 3:
$temp_image = imagerotate($temp_image,180,0);
break;
case 6:
$temp_image = imagerotate($temp_image,-90,0);
break;
}
}
$name = $temp_image;
$ilock_wb[] = array('Record'=>array('path'=>$path, 'name'=>$name));
}
但是当我打印$exif
时,我得到的是下面的类型数组,而不是#34; Orientation"
我的输出像
Array
(
[FILE] => Array
(
[FileName] => 2848C457-0482-495A-8756-038C9B79805033997765.JPG
[FileDateTime] => 0
[FileSize] => 25834
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => COMMENT
)
[COMPUTED] => Array
(
[html] => width="640" height="480"
[Height] => 480
[Width] => 640
[IsColor] => 1
)
[COMMENT] => Array
(
[0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v80), quality = 50
)
)
并且一些图片上传时没有得到数组。我该如何解决?