resize-imagejs
v1.0.4
Published
Resize Image And Convert image to Base64 Or Blob
Downloads
4
Maintainers
Readme
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'
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>