whatwg / whatwg/html

Add concrete algorithm options like 'bilinear' and 'bicubic' to ctx.imageSmoothingQuality

Open
#7,697 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs implementer interest topic: canvas
Dominant language
HTML
Stars
9.4k
Forks
3.2k
PR merge metrics
PR metrics pending

Description

I recently ran into a problem where a machine learning model expected images to be resized with bicubic interpolation (else lower accuracy), but there doesn't seem to be a way to specify a particular interpolation algorithm for a canvas context. The solution in the meantime for me will probably be to find a Rust implementation and port it to JS via wasm, but it would be great if this weren't necessary.

It seems plausible that there would be other types of use cases that would also need to use a particular resize algorithm, and I figure that the common resize algorithms will already exist "behind" the current low, medium, high settings anyway, so it might be easy enough on the implementer side of things to make it worth pursuing this.

Any thoughts on this?

Edit: I suppose this would also apply to createImageBitmap's resizeQuality option, which I've just discovered.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the canvas context's imageSmoothingQuality and createImageBitmap's resizeQuality entry points, then read the seven-comment discussion for the intended algorithm names and compatibility constraints. Done means the issue has a settled specification direction for exposing concrete interpolation choices in both options.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
computer-graphics, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.