Skip to content

Failed to execute 'toBlob' on 'HTMLCanvasElement': Tainted canvases may not be exported #2

Description

@devakone

On some browser versions (Chrome/Brave), the compression leads to:

DOMException: Failed to execute 'toBlob' on 'HTMLCanvasElement': Tainted canvases may not be exported.

This is due to a CORS security issue as explained here:
https://stackoverflow.com/questions/46984372/todataurl-on-htmlcanvaselement-tainted-canvases-may-not-be-exported

In the code for Photo.js the fix would be to

   // Create an object URL which points to the File/Blob image data
    const objectUrl = URL.createObjectURL(this.data)
    const img = new window.Image()
   // Fix CORS error
    img.crossOrigin = 'anonymous';
    await loadImageElement(img, objectUrl)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions