는이 방식의 하나 인 PHP의 화상 압축 :특정 파일 크기 제한 이하로 이미지를 압축하는 방법이 있습니까?
<?php
function compress($source, $destination, $quality) {
$info = getimagesize($source);
if ($info['mime'] == 'image/jpeg')
$image = imagecreatefromjpeg($source);
elseif ($info['mime'] == 'image/gif')
$image = imagecreatefromgif($source);
elseif ($info['mime'] == 'image/png')
$image = imagecreatefrompng($source);
imagejpeg($image, $destination, $quality);
return $destination;
}
$source_img = 'source.jpg';
$destination_img = 'destination .jpg';
$d = compress($source_img, $destination_img, 90);
?>
그러나,이 특정 품질을 지정하여 압축 할 만하다. 현재 이미지 업로드 기능을 사용 중입니다. 평상시와 같이 하드 파일 크기 제한을 설정하는 대신 업로드 된 이미지를 파일 크기 제한보다 크기 때문에 파일 크기 제한보다 작게 압축하려고합니다. 내가 할 수있는 방법이 있습니까 WITH 시도하고 오류가 있습니까?
나는 그렇게 생각하지 않는다. – Manav