diff options
| author | Samuel Newman <mozzius@protonmail.com> | 2025-05-06 22:50:28 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-06 22:50:28 +0300 |
| commit | 4c8fd006f6a994783a43e4744a3167db7aefc159 (patch) | |
| tree | 0b8350774438cbbc2b8c6e77b844ce6b677381d3 /src/state/gallery.ts | |
| parent | 3f7dc9a8e5c9225ef20ce996543a1c3cfa991eb7 (diff) | |
| download | voidsky-4c8fd006f6a994783a43e4744a3167db7aefc159.tar.zst | |
New Edit Profile dialog on web, use new Edit Image dialog everywhere (#8220)
Diffstat (limited to 'src/state/gallery.ts')
| -rw-r--r-- | src/state/gallery.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/state/gallery.ts b/src/state/gallery.ts index 73252dde7..3e989f030 100644 --- a/src/state/gallery.ts +++ b/src/state/gallery.ts @@ -15,6 +15,7 @@ import {nanoid} from 'nanoid/non-secure' import {POST_IMG_MAX} from '#/lib/constants' import {getImageDim} from '#/lib/media/manip' import {openCropper} from '#/lib/media/picker' +import {type PickerImage} from '#/lib/media/picker.shared' import {getDataUriSize} from '#/lib/media/util' import {isNative} from '#/platform/detection' @@ -194,7 +195,7 @@ export function resetImageManipulation( return img } -export async function compressImage(img: ComposerImage): Promise<ImageMeta> { +export async function compressImage(img: ComposerImage): Promise<PickerImage> { const source = img.transformed || img.source const [w, h] = containImageRes(source.width, source.height, POST_IMG_MAX) @@ -219,14 +220,15 @@ export async function compressImage(img: ComposerImage): Promise<ImageMeta> { ) const base64 = res.base64 - - if (base64 !== undefined && getDataUriSize(base64) <= POST_IMG_MAX.size) { + const size = base64 ? getDataUriSize(base64) : 0 + if (base64 && size <= POST_IMG_MAX.size) { minQualityPercentage = qualityPercentage newDataUri = { path: await moveIfNecessary(res.uri), width: res.width, height: res.height, mime: 'image/jpeg', + size, } } else { maxQualityPercentage = qualityPercentage |
