I have an SVG in the browser
<svg>
<image width="100" height="100" xlink:href="data:image/gif;base64,R0l...">
</svg>
Can I check somehow if the gif is animated?
I have tried some NPM packages:
https://www.npmjs.com/package/is-animated
https://www.npmjs.com/package/animated-gif-detector
But they seem to requite access to buffers that are not available in the browser.
Here is some code that does not work:
import isAnimated from "is-animated";
export function prepareImages(xml: Document) {
xml.querySelectorAll("image").forEach((image) => {
const hrefData = image.href.baseVal;
const base64Data = hrefData.replace(/^data:.+?base64,/, "");
const binaryData = atob(base64Data);
const bufferData = new Buffer(binaryData, "binary");
const animated = isAnimated(bufferData);
}
I get this error:
prepareImages.ts:8 Uncaught (in promise) ReferenceError: Buffer is not defined