> php教程 > php手册 > PHP 图片 保持高宽不变压缩之后imagejpeg($source,$file,100) 仍

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

WBOY
풀어 주다: 2016-06-06 19:49:25
원래의
952명이 탐색했습니다.

图片品质前后对比 : var_dump(exif_read_data($img));查看 ,严重失真压缩比为 50%。 压缩前: array (size=18) 'FileName' = string '1367000585017724053.JPG' (length=23) 'FileDateTime' = int 1367029384 'FileSize' = int 67872 'FileType' = int 2 '

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


<strong>压缩前:</strong>
로그인 후 복사
<strong>array</strong> <em>(size=18)</em>
  'FileName' <span>=></span> <small>string</small> <span>'1367000585017724053.JPG'</span> <em>(length=23)</em>
  'FileDateTime' <span>=></span> <small>int</small> <span>1367029384</span>
  'FileSize' <span>=></span> <small>int</small> <span>67872</span>
  'FileType' <span>=></span> <small>int</small> <span>2</span>
  'MimeType' <span>=></span> <small>string</small> <span>'image/jpeg'</span> <em>(length=10)</em>
  'divsFound' <span>=></span> <small>string</small> <span>'ANY_TAG, IFD0, THUMBNAIL, EXIF'</span> <em>(length=30)</em>
  'COMPUTED' <span>=></span> 
    <strong>array</strong> <em>(size=7)</em>
      'html' <span>=></span> <small>string</small> <span>'width="300" height="300"'</span> <em>(length=24)</em>
      'Height' <span>=></span> <small>int</small> <span>300</span>
      'Width' <span>=></span> <small>int</small> <span>300</span>
      'IsColor' <span>=></span> <small>int</small> <span>1</span>
      'ByteOrderMotorola' <span>=></span> <small>int</small> <span>1</span>
      'Thumbnail.FileType' <span>=></span> <small>int</small> <span>2</span>
      'Thumbnail.MimeType' <span>=></span> <small>string</small> <span>'image/jpeg'</span> <em>(length=10)</em>
  'Orientation' <span>=></span> <small>int</small> <span>1</span>
  'XResolution' <span>=></span> <small>string</small> <span>'72/1'</span> <em>(length=4)</em>
  'YResolution' <span>=></span> <small>string</small> <span>'72/1'</span> <em>(length=4)</em>
  'ResolutionUnit' <span>=></span> <small>int</small> <span>2</span>
  'Software' <span>=></span> <small>string</small> <span>'Adobe Photoshop CS Windows'</span> <em>(length=26)</em>
  'DateTime' <span>=></span> <small>string</small> <span>'2013:04:26 10:56:18'</span> <em>(length=19)</em>
  'Exif_IFD_Pointer' <span>=></span> <small>int</small> <span>164</span>
  'THUMBNAIL' <span>=></span> 
    <strong>array</strong> <em>(size=6)</em>
      'Compression' <span>=></span> <small>int</small> <span>6</span>
      'XResolution' <span>=></span> <small>string</small> <span>'72/1'</span> <em>(length=4)</em>
      'YResolution' <span>=></span> <small>string</small> <span>'72/1'</span> <em>(length=4)</em>
      'ResolutionUnit' <span>=></span> <small>int</small> <span>2</span>
      'JPEGInterchangeFormat' <span>=></span> <small>int</small> <span>302</span>
      'JPEGInterchangeFormatLength' <span>=></span> <small>int</small> <span>5519</span>
  'ColorSpace' <span>=></span> <small>int</small> <span>1</span>
  'ExifImageWidth' <span>=></span> <small>int</small> <span>300</span>
  'ExifImageLength' <span>=></span> <small>int</small> <span>300</span>
로그인 후 복사
<strong>压缩之后:</strong>
로그인 후 복사
<strong>array</strong> <em>(size=8)</em>
  'FileName' <span>=></span> <small>string</small> <span>'1367000585108300044.jpg'</span> <em>(length=23)</em>
  'FileDateTime' <span>=></span> <small>int</small> <span>1367029385</span>
  'FileSize' <span>=></span> <small>int</small> <span>38802</span>
  'FileType' <span>=></span> <small>int</small> <span>2</span>
  'MimeType' <span>=></span> <small>string</small> <span>'image/jpeg'</span> <em>(length=10)</em>
  'divsFound' <span>=></span> <small>string</small> <span>'COMMENT'</span> <em>(length=7)</em>
  'COMPUTED' <span>=></span> 
    <strong>array</strong> <em>(size=4)</em>
      'html' <span>=></span> <small>string</small> <span>'width="300" height="300"'</span> <em>(length=24)</em>
      'Height' <span>=></span> <small>int</small> <span>300</span>
      'Width' <span>=></span> <small>int</small> <span>300</span>
      'IsColor' <span>=></span> <small>int</small> <span>1</span>
  'COMMENT' <span>=></span> 
    <strong>array</strong> <em>(size=1)</em>
      0 <span>=></span> <small>string</small> <span>'CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 100
'</span> <em>(length=58)</em>
로그인 후 복사




<?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%。


관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿