I have a php script where the user can upload images.
I want to make the script lower the image quality (jpeg) if the file size is bigger than ‘X’ kbytes.
Something like this:
if( $_FILES['uploaded_img']['size'] > $file_size_limit ){
// code that lowers the quality of the uploaded image but keeps the image width and height
}
What is the best approach for this?
ps: I don’t want to change image width and height.
Sure you can. Do something like this.
This will accept any image format supported by PHP GD (Assuming that it’s installed on your server. Most likely is). If the image is less than the limit, it will just upload the original image to the path you specify.