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' ;
21import { DefaultSettings } from '@onlook/constants' ;
3- import { normalizePath } from './folder ' ;
2+ import imageCompression from 'browser-image-compression ' ;
43import { isImageFile } from './file' ;
4+ import { normalizePath } from './folder' ;
55
66// 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 > {
815 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 ,
1119 } ;
1220
1321 try {
You can’t perform that action at this time.
0 commit comments