'ReactJS reduce image file size without losing aspect ratio after user selects it in an input

I've been searching everywhere without luck.

A simple way to reduce the width of an image picked with a simple <input type="file" /> without it losing it's aspect ratio.

I am using jquery to select the image before uploading like so: $('#image')[0] but I need a way to reduce the image width before uploading to reduce the file size and data being sent to the server and of course received when users download the image when visiting the website.



Solution 1:[1]

If you still need it you can use this library. It worked for me, because it lets you resize width, height and file size, obviously with a image quality loss. Compress.js library

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Miguel