I was wondering if anyone can teach me how to optimize an image when a user uploads? I would like to reduce the size quality of the image so when I show it on my page, it will load faster.
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Take a look to http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php, examples are very easy to follow.
Added: I recomend you to keep the source image in its original size and create the resized one in a different folder.
Added: According to documentation, the function
imagecopyresampledused by the class, does some kind of optimization:_imagecopyresampled() copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity. _
Anyway, if you want more fine tune, as @mingos said, you can use ImageMagick, it’s a bit harder, but there is a lot of samples here: http://www.imagemagick.org/Usage/