2

I want to compress image before uploading it to PHP Server using vanilla javascript. I currently use PHP Compression however I was wondering whether it can be compressed in clients side browser so that it might save time uploading the images. I will be using fetch API to interact with the server.

I have read the following answers in stack overflow.

Compressing an image before sending it to the Server How to compress image size in JavaScript?

Also I want to make it using Vanilla Javascript and does not want to depend upon libraries.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • You could try gzipping (https://www.gnu.org/software/gzip) it, and measuring what the binary looks like at the other end. For myself, I decided against compression. I figured that the image compression inherent in the image file format itself is about as good as you are going to get – ControlAltDel Nov 21 '19 at 18:35
  • I think this might help you: [How to compress an image via Javascript in the browser?](https://stackoverflow.com/questions/14672746/how-to-compress-an-image-via-javascript-in-the-browser) – David Porcel Nov 21 '19 at 18:40

0 Answers0