I am trying to lower the quality of large JPEG pictures (using PHP) and willing to loose some quality. using this code
function compress_image($source_url, $destination_url, $quality) {
$info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
//save it
imagejpeg($image, $destination_url, $quality);
//return destination file url
return $destination_url;
}
$source_photo = $file;
$dest_photo = $newfile;
$d = compress_image($source_photo, $dest_photo, 70);
but the file (output) is actully bigger in size than the original (677kb vs 639kb) but I noticed the DPI when saved on my PC was bumped to 96 DPI ? How can prevent this ? any thoughts .. I am looking to make the file size smaller