imtae-resizer
v1.0.6
Published
Resize image volume before sending to server
Downloads
2
Readme
imtae-resizer
Resize image volume before sending to server.
Installation
npm install imtae-resizer --save
or
yarn add imtae-resizer
Usage
|Params| | |---|---| |(Essential) files|Files uploaded by the user. ex) evt.target.files of the input tag change event.| |(Optional) maxWidth|Based on this value, the image size is modified to fit the ratio. The default value for maxWidth is 600.|
import imtaeResizer from 'imtae-resizer';
imtaeResizer(files, maxWidth).then(result => {
// Before
console.log(files);
// After
console.log(result);
});
Example
create-react-app
import React from 'react';
import imtaeResizer from 'imtae-resizer';
function App() {
const resizeImg = files => {
imtaeResizer(files, 800).then(result => {
// ...
});
}
return (
<div className="App">
<input
type="file"
multiple
onChange={evt => resizeImg(evt.target.files)}
/>
</div>
);
}
export default App;