Skip to content

Error while loading a gif #2564

@Geam

Description

@Geam

Issue or Feature

Hello, I encounter a problem while loading a gif, I'm not sure why as the image seems ok to me.
It's a 1x1 pixel loaded by leaflet that seems to be valid.

$ file input.gif
input.gif: GIF image data, version 89a, 1 x 1
$ identify input.gif 
input.gif GIF 1x1 1x1+0+0 8-bit sRGB 2c 26B 0.000u 0:00.000

Steps to Reproduce

Here's a minimal reproducible code.

import {Image} from "canvas";

const img = new Image();
img.onload = () => {
  console.log("onload");
};
img.onerror = (err) => {
  console.log("err", err);
}
img.src = Buffer.from("R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=", "base64");
err Error: error while reading from input stream
    at setSource (/home/bob/test/code/js/jsdom_image/node_modules/canvas/lib/image.js:95:13)
    at Image.set (/home/bob/test/code/js/jsdom_image/node_modules/canvas/lib/image.js:65:7)
    at file:///home/bob/test/code/js/jsdom_image/index.js:33:11
    at new Promise (<anonymous>)
    at createImage (file:///home/bob/test/code/js/jsdom_image/index.js:8:27)
    at file:///home/bob/test/code/js/jsdom_image/index.js:41:1
    at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:661:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

Your Environment

OS: KDE Neon 24.04 (an ubuntu derivative distribution)
npm: 11.11.0
node: v24.14.1
Canvas: v3.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions