File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1
- import imageCompression from 'browser-image-compression' ;
2
1
import { DefaultSettings } from '@onlook/constants' ;
3
- import { normalizePath } from './folder ' ;
2
+ import imageCompression from 'browser-image-compression ' ;
4
3
import { isImageFile } from './file' ;
4
+ import { normalizePath } from './folder' ;
5
5
6
6
// Browser-side image compression
7
- export async function compressImageInBrowser ( file : File ) : Promise < string | undefined > {
7
+ export async function compressImageInBrowser (
8
+ file : File ,
9
+ compressionOptions ?: {
10
+ maxSizeMB ?: number ;
11
+ maxWidthOrHeight ?: number ;
12
+ quality ?: number ;
13
+ }
14
+ ) : Promise < string | undefined > {
8
15
const options = {
9
- maxSizeMB : 2 ,
10
- maxWidthOrHeight : 2048 ,
16
+ maxSizeMB : compressionOptions ?. maxSizeMB ?? 0.2 ,
17
+ maxWidthOrHeight : compressionOptions ?. maxWidthOrHeight ?? 512 ,
18
+ quality : compressionOptions ?. quality ?? 0.6 ,
11
19
} ;
12
20
13
21
try {
You can’t perform that action at this time.
0 commit comments