mirror of https://github.com/VERT-sh/VERT.git
Clarify ICO size clamping comment and align error variable naming.
This commit is contained in:
parent
6a60f50672
commit
816257a1d6
|
|
@ -293,7 +293,7 @@ const magickConvert = async (
|
||||||
let fmt = to.slice(1).toUpperCase();
|
let fmt = to.slice(1).toUpperCase();
|
||||||
if (fmt === "JFIF") fmt = "JPEG";
|
if (fmt === "JFIF") fmt = "JPEG";
|
||||||
|
|
||||||
// ✅ ICO size clamp to avoid WidthOrHeightExceedsLimit
|
// ICO size clamp to avoid WidthOrHeightExceedsLimit
|
||||||
if (fmt === "ICO") {
|
if (fmt === "ICO") {
|
||||||
const max = 256;
|
const max = 256;
|
||||||
const w = img.width;
|
const w = img.width;
|
||||||
|
|
@ -310,14 +310,15 @@ const magickConvert = async (
|
||||||
|
|
||||||
const result = await new Promise<Uint8Array>((resolve, reject) => {
|
const result = await new Promise<Uint8Array>((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
// magick-wasm automatically clamps (https://github.com/dlemstra/magick-wasm/blob/76fc6f2b0c0497d2ddc251bbf6174b4dc92ac3ea/src/magick-image.ts#L2480)
|
||||||
if (compression) img.quality = compression;
|
if (compression) img.quality = compression;
|
||||||
if (!keepMetadata) img.strip();
|
if (!keepMetadata) img.strip();
|
||||||
|
|
||||||
img.write(fmt as unknown as MagickFormat, (o: Uint8Array) => {
|
img.write(fmt as unknown as MagickFormat, (o: Uint8Array) => {
|
||||||
resolve(structuredClone(o));
|
resolve(structuredClone(o));
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
reject(e);
|
reject(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue