Polysize is a JavaScript class for resizing images using HTML5 Canvas.
I developed Polysize and Polysize-Node when working for a client that received a lot of images from users. We wanted to resize images before they were uploaded to improve real and perceived performance. The code was open-sourced and is now free to adopt for your own projects.
This project is no longer actively maintained but is still a useful tool.
Example Usage
const handleFileInputChange = event => {
const file = event.target.files[0];
// Create a 150px avatar from the given file
new Polysize(file, 150, img => {
// Do something with img
console.log('150px image element >>', img);
});
};