您的位置:首页 > 编程语言 > PHP开发

PHP 图片 保持高宽不变压缩之后imagejpeg($source,$file,100) 仍旧失真!

2013-04-27 10:26 316 查看
图片品质前后对比 : var_dump(exif_read_data($img));查看 ,严重失真压缩比为 50%。

压缩前:

array (size=18)
'FileName' =>  '1367000585017724053.JPG' (length=23)
'FileDateTime' =>  1367029384
'FileSize' =>  67872
'FileType' =>  2
'MimeType' =>  'image/jpeg' (length=10)
'SectionsFound' =>  'ANY_TAG, IFD0, THUMBNAIL, EXIF' (length=30)
'COMPUTED' =>
array (size=7)
'html' =>  'width="300" height="300"' (length=24)
'Height' =>  300
'Width' =>  300
'IsColor' =>  1
'ByteOrderMotorola' =>  1
'Thumbnail.FileType' =>  2
'Thumbnail.MimeType' =>  'image/jpeg' (length=10)
'Orientation' =>  1
'XResolution' =>  '72/1' (length=4)
'YResolution' =>  '72/1' (length=4)
'ResolutionUnit' =>  2
'Software' =>  'Adobe Photoshop CS Windows' (length=26)
'DateTime' =>  '2013:04:26 10:56:18' (length=19)
'Exif_IFD_Pointer' =>  164
'THUMBNAIL' =>
array (size=6)
'Compression' =>  6
'XResolution' =>  '72/1' (length=4)
'YResolution' =>  '72/1' (length=4)
'ResolutionUnit' =>  2
'JPEGInterchangeFormat' =>  302
'JPEGInterchangeFormatLength' =>  5519
'ColorSpace' =>  1
'ExifImageWidth' =>  300
'ExifImageLength' =>  300

压缩之后:

array (size=8)
'FileName' =>  '1367000585108300044.jpg' (length=23)
'FileDateTime' =>  1367029385
'FileSize' =>  38802
'FileType' =>  2
'MimeType' =>  'image/jpeg' (length=10)
'SectionsFound' =>  'COMMENT' (length=7)
'COMPUTED' =>
array (size=4)
'html' =>  'width="300" height="300"' (length=24)
'Height' =>  300
'Width' =>  300
'IsColor' =>  1
'COMMENT' =>
array (size=1)
0 =>  'CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 100
' (length=58)


<?php
$img_thumb = imagecreatetruecolor($thumb_width, $thumb_height);
$bgcolor = trim($bgcolor,"#");
sscanf($bgcolor, "%2x%2x%2x", $red, $green, $blue);
$clr = imagecolorallocate($img_thumb, $red, $green, $blue);
imagefilledrectangle($img_thumb, 0, 0, $thumb_width, $thumb_height, $clr);
imagecopyresampled($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]);

图片只要经过那个函数的压缩,仍旧是失真的,图片文件大小压缩率为 50%。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息