UNPKG

resize-imagejs

Version:

Resize Image And Convert image to Base64 Or Blob

44 lines (35 loc) 901 B
Resize Image And Convert image to Base64 Or Blob resizeImage(file, options) file -> image * options (Object) - width: optional [number] - height: optional [number] - type: default: 'blob', optional: 'base64'、'blob' ```javascript import resizeImage from 'resize-imagejs' handleClassFileChange = e => { const file = e.target.files[0] if (file) { resizeImage(file, { width: 200, height: 200, type: 'blob' }).then(blob => { const fd = new FormData() fd.append('file', blob) ... }) } } <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="./dist/resize-imagejs.umd.js"></script> </head> <body> <script> console.log(window.resizeImagejs) </script> </body> </html> ```