用于android 4.1.2的php中图像方向校正不一致

时间:2014-11-14 08:48:39

标签: php android orientation exif

尝试使用热门代码从Android上传图像后,在php中修复图像方向:

http://snipplr.com/view/76539/

function image_fix_orientation($path){
	$image = imagecreatefromjpeg($path);
	$exif = exif_read_data($path);
 
	if (!empty($exif['Orientation'])) {
		switch ($exif['Orientation']) {
			case 3:
				$image = imagerotate($image, 180, 0);
				break;
			case 6:
				$image = imagerotate($image, -90, 0);
				break;
			case 8:
				$image = imagerotate($image, 90, 0);
				break;
		}
		imagejpeg($image, $path);
	}
}

它适用于android 2

android 4.1.2.的行为不一致 此代码无法更正android 4.1.2.拍摄的图像。

但是这段代码确实:

   

 function image_fix_orientation($path){
    	$image = imagecreatefromjpeg($path);
    	//$exif = exif_read_data($path);
     
    	//if (!empty($exif['Orientation'])) {
    	//	switch ($exif['Orientation']) {
    	//		case 3:
    	//			$image = imagerotate($image, 180, 0);
    	//			break;
    	//		case 6:
    	//			$image = imagerotate($image, -90, 0);
    	//			break;
    	//		case 8:
    	//			$image = imagerotate($image, 90, 0);
    	//			break;
    	//	}
    		imagejpeg($image, $path);
    	}
    }

对于这个版本,似乎没有imagerotate()是必须的.​​.只是createimagefromjpeg()> imagejpeg()

有解决方案吗?或者我应该只更改此版本的代码???你知道为什么会这样吗?

请帮忙, 多伦

0 个答案:

没有答案
相关问题