How to compress a large photo with php file?

tal7080

New member
Hello,

I have a website that all what is doing is uploading images i just wonder if there is any way to upload 5mb file and compress it to like 200k without effect the quality of the picture and also to keep the same original size of the picture i know there is some php code that doing it but i am not sure how there is anyone can give me advice?

Thanks
tal
 
You won't be able to "compress" by simply zipping the file since most picture/video formats are binary and are already designed to efficiently use minimal space. Your options are to change formats or change the picture format image compression. In both cases, you'll lose some quality.

As for compressing, you aren't going to do it at upload via a php script. Prior to upload, the user will need to do the compression before contacting the server. If you are hosting the image, your php script could kick off a backend server process to compress the image format, but that wouldn't make a lot of sense since you generally won't want to do that for every request for the file (unless you come up with a caching policy to minimize server processing).
 
You won't be able to "compress" by simply zipping the file since most picture/video formats are binary and are already designed to efficiently use minimal space. Your options are to change formats or change the picture format image compression. In both cases, you'll lose some quality.

As for compressing, you aren't going to do it at upload via a php script. Prior to upload, the user will need to do the compression before contacting the server. If you are hosting the image, your php script could kick off a backend server process to compress the image format, but that wouldn't make a lot of sense since you generally won't want to do that for every request for the file (unless you come up with a caching policy to minimize server processing).
 
Back
Top