feat: Compress avatar images before upload (#1751)
* compress avatar images before upload * move compressImage to dedicated file * Update ImageUpload.js
This commit is contained in:
17
app/utils/compressImage.js
Normal file
17
app/utils/compressImage.js
Normal file
@ -0,0 +1,17 @@
|
||||
// @flow
|
||||
import Compressor from "compressorjs";
|
||||
|
||||
type Options = Omit<Compressor.Options, "success" | "error">;
|
||||
|
||||
export const compressImage = async (
|
||||
file: File | Blob,
|
||||
options?: Options
|
||||
): Promise<Blob> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
new Compressor(file, {
|
||||
...options,
|
||||
success: resolve,
|
||||
error: reject,
|
||||
});
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user