From 129f49bcc7404debe93053378801d6b3f0a05520 Mon Sep 17 00:00:00 2001 From: Matthew Remmel Date: Mon, 15 Sep 2025 08:40:02 -0400 Subject: [PATCH] Compress profile pictures on upload --- src/app/editor/index.ts | 19 ++---------- src/lib/components/InputPicture.svelte | 10 +++--- src/lib/components/InputProfilePicture.svelte | 10 +++--- src/lib/html.ts | 31 +++++++++++++++++++ 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/app/editor/index.ts b/src/app/editor/index.ts index 8c3e030b..b3a36334 100644 --- a/src/app/editor/index.ts +++ b/src/app/editor/index.ts @@ -17,6 +17,7 @@ import {Editor, MentionSuggestion, WelshmanExtension} from "@welshman/editor" import {makeMentionNodeView} from "./MentionNodeView" import ProfileSuggestion from "./ProfileSuggestion.svelte" import {pushToast} from "@app/util/toast" +import {stripExifData} from "@src/lib/html" export const getBlossomServer = () => { const userUrls = getTagValues("server", getListTags(userBlossomServers.get())) @@ -73,23 +74,7 @@ export const makeEditor = async ({ let file: Blob = attrs.file if (!file.type.match("image/(webp|gif)")) { - const {default: Compressor} = await import("compressorjs") - - file = await new Promise((resolve, _reject) => { - new Compressor(file, { - maxWidth: 1024, - maxHeight: 1024, - success: resolve, - error: e => { - // Non-images break compressor - if (e.toString().includes("File or Blob")) { - return resolve(file) - } - - _reject(e) - }, - }) - }) + file = await stripExifData(file) } const {ciphertext, key, nonce, algorithm} = await encryptFile(file) diff --git a/src/lib/components/InputPicture.svelte b/src/lib/components/InputPicture.svelte index 9165c3a0..e0d811ad 100644 --- a/src/lib/components/InputPicture.svelte +++ b/src/lib/components/InputPicture.svelte @@ -1,6 +1,6 @@