Clarify ICO size clamping comment and align error variable naming.

This commit is contained in:
Mailo 2025-11-24 16:58:18 +01:00
parent 6a60f50672
commit 816257a1d6
1 changed files with 4 additions and 3 deletions

View File

@ -293,7 +293,7 @@ const magickConvert = async (
let fmt = to.slice(1).toUpperCase();
if (fmt === "JFIF") fmt = "JPEG";
// ICO size clamp to avoid WidthOrHeightExceedsLimit
// ICO size clamp to avoid WidthOrHeightExceedsLimit
if (fmt === "ICO") {
const max = 256;
const w = img.width;
@ -310,14 +310,15 @@ const magickConvert = async (
const result = await new Promise<Uint8Array>((resolve, reject) => {
try {
// magick-wasm automatically clamps (https://github.com/dlemstra/magick-wasm/blob/76fc6f2b0c0497d2ddc251bbf6174b4dc92ac3ea/src/magick-image.ts#L2480)
if (compression) img.quality = compression;
if (!keepMetadata) img.strip();
img.write(fmt as unknown as MagickFormat, (o: Uint8Array) => {
resolve(structuredClone(o));
});
} catch (e) {
reject(e);
} catch (error) {
reject(error);
}
});