mirror of https://github.com/VERT-sh/VERT.git
Merge branch 'pr/184'
This commit is contained in:
commit
fc6475febc
|
|
@ -293,6 +293,21 @@ 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
|
||||||
|
if (fmt === "ICO") {
|
||||||
|
const max = 256;
|
||||||
|
const w = img.width;
|
||||||
|
const h = img.height;
|
||||||
|
|
||||||
|
if (w > max || h > max) {
|
||||||
|
const scale = max / Math.max(w, h);
|
||||||
|
const newW = Math.max(1, Math.round(w * scale));
|
||||||
|
const newH = Math.max(1, Math.round(h * scale));
|
||||||
|
|
||||||
|
img.resize(newW, newH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
// magick-wasm automatically clamps (https://github.com/dlemstra/magick-wasm/blob/76fc6f2b0c0497d2ddc251bbf6174b4dc92ac3ea/src/magick-image.ts#L2480)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue