11ty / eleventy-img

Utility to perform build-time image transformations.
https://www.11ty.dev/docs/plugins/image/
433 stars 53 forks source link

`svgCompressionSize: "br"` with remote SVG image gives error #201

Open saneef opened 7 months ago

saneef commented 7 months ago

When using remote SVG Image with svgShortCircuit: "size" and svgCompressionSize: "br", I'm getting error. Works fine with a local SVG file.

Here is the code I use to reproduce the error:

const Image = require("@11ty/eleventy-img");

(async () => {
  // const path = "./Ghostscript_Tiger.svg"; 👈 Local image works

  const path =
    "https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg";

  let metadata = await Image(path, {
    widths: [300, 450, 600],
    formats: ["avif", "webp", "svg", "jpeg"],
    svgShortCircuit: "size",
    svgCompressionSize: "br",
  });

  console.log(metadata);
})();

...and, here is the error I get:

node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "buffer" argument must be of type string or an instance of Buffer, TypedArray, DataView, or ArrayBuffer. Received type boolean (false)
    at new NodeError (node:internal/errors:405:5)
    at zlibBufferSync (node:zlib:171:13)
    at Object.syncBufferWrapper [as brotliCompressSync] (node:zlib:792:14)
    at Object.sync (â–‹â–‹â–‹â–‹â–‹/node_modules/brotli-size/dist/index.js:41:19)
    at Image.resize (â–‹â–‹â–‹â–‹â–‹/node_modules/@11ty/eleventy-img/img.js:522:36)
    at async run (â–‹â–‹â–‹â–‹â–‹/node_modules/p-queue/dist/index.js:163:29) {
  code: 'ERR_INVALID_ARG_TYPE'
}