mirror of
https://github.com/outline/outline.git
synced 2026-12-03 18:10:36 +03:00
20 lines
355 B
TypeScript
20 lines
355 B
TypeScript
import Compressor from "compressorjs";
|
|
|
|
type Options = {
|
|
maxWidth?: number;
|
|
maxHeight?: number;
|
|
};
|
|
|
|
export const compressImage = async (
|
|
file: File | Blob,
|
|
options?: Options
|
|
): Promise<Blob> => {
|
|
return new Promise((resolve, reject) => {
|
|
new Compressor(file, {
|
|
...options,
|
|
success: resolve,
|
|
error: reject,
|
|
});
|
|
});
|
|
};
|