onurzorluer / react-image-file-resizer

Resize Local Images with React 🌄 🌅
MIT License
317 stars 41 forks source link

Add support for "file" outputType #45

Closed OverStruck closed 3 years ago

OverStruck commented 3 years ago

Currently the module only support blob or base64 for outputType.

This commit adds support for a 3rd option: file which will return a File JavaScript object.

This is useful for resizing images that are meant to be uploaded as files.

I.e. this can be used to send a file to a flask app that uses FileStorage class.

Example:

const resizeFile = file => new Promise(resolve => {
    Resizer.imageFileResizer(file, 1000, 1000, "jpeg", 100, 0,
        file =>  resolve(file),
        "file"
    );
});

The returned File object will have the same name as the original image.

This also addresses some concerns such as issue #19 and #38

onurzorluer commented 3 years ago

@all-contributors please add @OverStruck for code and maintenance

allcontributors[bot] commented 3 years ago

@onurzorluer

I've put up a pull request to add @OverStruck! :tada: