`svgCompressionSize: "br"` with remote SVG image gives error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 467
- Forks
- 65
- PR merge metrics
- No merged PRs in 30d
Description
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'
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the compression path reported in img.js:522 and inspect how brotli-size receives data for remote versus local SVG images. Reproduce the example with the remote Wikimedia URL, compare it with the local SVG case, and confirm that remote SVG processing with svgShortCircuit: "size" and svgCompressionSize: "br" completes without the boolean buffer error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100