Metadata: expose `chromaSubsampling` for AVIF
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
## Possible bug
### Is this a possible bug in a feature of sharp, unrelated to installation?
- [x] Running `npm install sharp` completes without error.
- [x] Running `node -e "require('sharp')"` completes without error.
If you cannot confirm both of these, please open an [installation issue](https://github.com/lovell/sharp/issues/new?labels=installation&template=installation.md) instead.
### Are you using the latest version of sharp?
- [x] I am using the latest version of `sharp` as reported by `npm view sharp dist-tags.latest`.
If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of `sharp` that is not the latest, please open an issue against that package instead.
### What is the output of running `npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp`?
```
System:
OS: Windows 10 10.0.22621
CPU: (8) x64 Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz
Memory: 11.85 GB / 31.68 GB
Binaries:
Node: 18.14.0 - ~\scoop\apps\volta\current\appdata\tools\image\node\18.14.0\node.EXE
Yarn: 1.22.19 - ~\scoop\apps\volta\current\appdata\tools\image\yarn\1.22.19\bin\yarn.CMD
npm: 9.3.1 - ~\scoop\apps\volta\current\appdata\tools\image\node\18.14.0\npm.CMD
npmPackages:
sharp: ^0.31.3 => 0.31.3
```
### What are the steps to reproduce?
- put JS below and put images at the same directory
- Run the JS
- Check the output
### What is the expected behaviour?
```js
await sharp("./image.avif").metadata()
await sharp("./lossy.webp").metadata()
```
should include `chromaSubsampling` field like JPEG. That of Lossy WebPs is always `"4:2:0"`. Most AVIF use YUV (4:2:0 or 4:4:4).
### Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
```js
import sharp from "sharp";
import YAML from "yaml";
/**
* @param type {string}
* @param img {import("sharp").Sharp}
*/
async function printMeta(type, img) {
const { icc: _icc, iptc: _iptc, ...meta } = await img.metadata();
console.log(`${type} meta:\n\n${YAML.stringify(meta)}`);
}
await printMeta("AVIF", sharp("./avif.avif"));
await printMeta("WebP", sharp("./webp.webp"));
```
### Please provide sample image(s) that help explain this problem
- https://e-port.co.jp/wp/wp-content/uploads/b83a40e6b68e9e09c7318f59899df563.jpg.webp
- https://cdn.glitch.com/f4525b23-4268-473b-a57c-bdb57f3f7494%2FIMG_5666.avif?v=1599083333763 (from https://avif-support-test.glitch.me/)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the sharp metadata() entry point and trace how the existing JPEG chromaSubsampling value is obtained. Compare the AVIF and lossy WebP metadata paths using the supplied image examples. Done means metadata exposes chromaSubsampling for AVIF and lossy WebP with the expected subsampling values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100