fer0an Posted July 25, 2010 Share Posted July 25, 2010 hello anyone can help me to reduce image file size(reduce quality of images) using php ? Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/ Share on other sites More sharing options...
cs.punk Posted July 25, 2010 Share Posted July 25, 2010 $im = imagecreatefromjpeg('image.jpeg'); // original image imagejpeg($im, 'new_image.jpeg', 60); // save to new image, third value is quality (0-100) if not specified its the default (75) Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1090917 Share on other sites More sharing options...
fer0an Posted July 26, 2010 Author Share Posted July 26, 2010 thank you for code how I can save to path I want? for example save on my server/images/ Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1091148 Share on other sites More sharing options...
cs.punk Posted July 26, 2010 Share Posted July 26, 2010 imagejpeg($im, 'server/images/new_image.jpeg', 60); Depending if server is a directory within the directory your script is executing in. If its one up for example just add in '../server/images/new_image.jpeg' Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1091161 Share on other sites More sharing options...
fer0an Posted July 26, 2010 Author Share Posted July 26, 2010 thank you now I want find the extension of file and before I saved image , first find extenstion with this code: function get_file_extension($file_name) { return substr(strrchr($file_name,'.'),1); } get_file_extenstion($image); how I can check it for create new file? Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1091167 Share on other sites More sharing options...
cs.punk Posted July 26, 2010 Share Posted July 26, 2010 $ext = strtolower(strrchr($file_name,'.')); if ($ext == ".jpeg" || $ext == ".jpg") {// file is of jpeg extension } Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1091179 Share on other sites More sharing options...
fer0an Posted October 31, 2010 Author Share Posted October 31, 2010 hello now I want resize my images to width = 180 and hight = 220. can anyone help me? thank you Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1128664 Share on other sites More sharing options...
fer0an Posted November 1, 2010 Author Share Posted November 1, 2010 anyone can help me? Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1128863 Share on other sites More sharing options...
cs.punk Posted November 24, 2010 Share Posted November 24, 2010 Wow it's been a long time! Just google it or search the forum as it's quite common. Quote Link to comment https://forums.phpfreaks.com/topic/208837-reduce-image-file-size-using-php/#findComment-1138861 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.