php exif_read_data orientation,PHP read_exif_data和调整方向

如果方向关闭,我正在使用以下代码旋转上载的jpeg图像。从iPhone和Android上传的图像只有问题。

if(move_uploaded_file($_FILES['photo']['tmp_name'], $upload_path . $newfilename)){

chmod($upload_path . $newfilename, 0755);

$exif = exif_read_data($upload_path . $newfilename);

$ort = $exif['IFD0']['Orientation'];

switch($ort)

{

case 3: // 180 rotate left

$image->imagerotate($upload_path . $newfilename, 180, -1);

break;

case 6: // 90 rotate right

$image->imagerotate($upload_path . $newfilename, -90, -1);

break;

case 8:    // 90 rotate left

$image->imagerotate($upload_path . $newfilename, 90, -1);

break;

}

imagejpeg($image, $upload_path . $newfilename, 100);

$success_message = 'Photo Successfully Uploaded';

}else{

$error_count++;

$error_message = 'Error: Upload Unsuccessful
Please Try Again';

}

我从jpeg读取EXIF数据的方式有问题吗?它没有像预期的那样旋转图像。

这是我运行var_dump($ exif)时发生的情况;

array(41) {

["FileName"]=> string(36) "126e7c0efcac2b76b3320e6187d03cfd.JPG"

["FileDateTime"]=> int(1316545667)

["FileSize"]=> int(1312472)

["FileType"]=> int(2)

["MimeType"]=> string(10) "image/jpeg"

["SectionsFound"]=> string(30) "ANY_TAG, IFD0, THUMBNAIL, EXIF"

["COMPUTED"]=> array(8) {

["html"]=> string(26) "width="2048" height="1536""

["Height"]=> int(1536)

["Width"]=> int(2048)

["IsColor"]=> int(1)

["ByteOrderMotorola"]=> int(1)

["ApertureFNumber"]=> string(5) "f/2.8"

["Thumbnail.FileType"]=> int(2)

["Thumbnail.MimeType"]=> string(10) "image/jpeg" }

["Make"]=> string(5) "Apple"

["Model"]=> string(10) "iPhone 3GS"

["Orientation"]=> int(6)

["XResolution"]=> string(4) "72/1"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值