Things should be simple to use
Just put in resizer image before uploading it to server.
const veryBigImage = document.getElementById('input').files[0];
const resizedImage = await resize(veryBigImage, someOptionsObject)
With npm:
npm install @supersimplethings/resize-image-in-browser
With yarn:
yarn add @supersimplethings/resize-image-in-browser
type Resize = (file: File, options?: Options) => Promise<dataURL|Blob|File>
interface Options {
maxWidth?: number (1024) // in pixels // Aspect ratio will be saved
maxHeight?: number (768) // in pixels // Smaller one dimension would be applied
output?: Output (jpeg)
format?: Format (dataURL)
quality?: number (1.0) // from 0.1 to 1.0 (only 'jpeg')
}
enum Format {
png = 'png',
jpeg = 'jpeg',
webp = 'webp',
bmp = 'bmp'
}
enum Output {
dataURL = 'dataURL',
File = 'File',
Blob = 'Blob'
}
MIT