johnhenry Posted January 7, 2012 Share Posted January 7, 2012 I am trying to use the GD library functions to reduce the size and ppi of images. Unfortunately my server does not support imagick, which can do this, but I have worked out a way to do the job, except that the process always makes the image 75 ppi. I would rather have some control over the pixel density. Can anyone suggest an answer please? Here is my code...... <?php $filename = 'my.jpg'; $size_multiple = .5;//change to suit dimensions wanted header('Content-type: image/jpeg'); list($width, $height) = getimagesize($filename); $new_width = $width * $size_multiple; $new_height = $height * $size_multiple; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 100); ?> Link to comment https://forums.phpfreaks.com/topic/254540-is-there-a-function-to-reduce-ppi-to-anything-other-than-75/ Share on other sites More sharing options...
QuickOldCar Posted January 7, 2012 Share Posted January 7, 2012 I think you mean dpi. did you try and lower the quality? <?php $filename = 'my.jpg'; $size_multiple = .5;//change to suit dimensions wanted header('Content-type: image/jpeg'); list($width, $height) = getimagesize($filename); $new_width = $width * $size_multiple; $new_height = $height * $size_multiple; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 70);//<-- the number change here ?> Link to comment https://forums.phpfreaks.com/topic/254540-is-there-a-function-to-reduce-ppi-to-anything-other-than-75/#findComment-1305276 Share on other sites More sharing options...
johnhenry Posted January 7, 2012 Author Share Posted January 7, 2012 Thanks I'll try that. Link to comment https://forums.phpfreaks.com/topic/254540-is-there-a-function-to-reduce-ppi-to-anything-other-than-75/#findComment-1305320 Share on other sites More sharing options...
QuickOldCar Posted January 7, 2012 Share Posted January 7, 2012 dpi is controlled in the image header information there is a function made by someone to change the dpi if wanted to, but i would think it get fuzzy if go lower default browser dpi is 72 and 96 I believe http://www.php.net/manual/en/function.imagejpeg.php#83347 Link to comment https://forums.phpfreaks.com/topic/254540-is-there-a-function-to-reduce-ppi-to-anything-other-than-75/#findComment-1305321 Share on other sites More sharing options...
johnhenry Posted January 7, 2012 Author Share Posted January 7, 2012 I gave that a try but it make no difference at all. I did mean ppi BTW. I am beginning to think that there is no solution to this problem. Link to comment https://forums.phpfreaks.com/topic/254540-is-there-a-function-to-reduce-ppi-to-anything-other-than-75/#findComment-1305323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.