Skip to content

[p5.js 2.0+ Bug Report]: loadImage cannot load SVG files #8921

@gfrancine

Description

@gfrancine

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • WebGPU
  • p5.strands
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

p5.js version

2.3.0

Web browser and version

No response

Operating system

No response

Steps to reproduce this

This code snippet works perfectly fine with v1.11.13 but not v2.0.0 onwards including the latest version:

let svg; 

async function setup() {
  svg = await loadImage("image.svg");
  createCanvas(windowWidth, windowHeight);
}

function draw() {
  background(220);
  image(svg, 0, 0, 100,100);
}

On >v2.0, it throws this error:

InvalidStateError: The source image could not be decoded.

🌸 p5.js says: It looks like there was a problem loading your image. Try checking if the file path (path...) is correct, hosting the file online, or running a local server.

Sketch: https://editor.p5js.org/gracefrancine/sketches/mnwQeZC4t

Happy to help work on a fix if needed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions