image-square-resizer
js-utility for crop and resize image
Build It Yourself/Run the Demos
Build: npm install && npm run build
Demos: npm install && npm start
imager square resizer
Steps:
- make it square (if width > heigh, crop from left and right sides proportionally)
- resize if width/height > N px
Init
import imageSqResizer from './image-square-resizer.js'
let resizer1 = new imageSqResizer(
'image-input',
300,
null
);
let resizer2 = new imageSqResizer(
'image-input',
50,
(dataUrl) =>
document.getElementById('image-output').src = dataUrl;
);
let resizer3 = new imageSqResizer(
'image-input',
50
);
Get blob
let formData = new FormData();
formData.append('files[0]', resizer1.blob);
Get dataUrl
document.getElementById('image-output').src = resizer2.dataUrl;
View Page
License
image-square-resizer is MIT licensed.