lovell / lovell/sharp

IIIF output doesn't include "sizes" key

Open
#3,508 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

blocked-upstream-dependency enhancement
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: macOS 13.0
CPU: (8) arm64 Apple M1
Memory: 1.06 GB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
```

### What are the steps to reproduce?

Process an image using the "iiif" layout with default options.

### What is the expected behaviour?

info.json does not include a "sizes" key. https://iiif.io/api/image/3.0/#53-sizes

while strictly optional, absence makes it incompatible with eg react-iiif-viewer.

info.json looks like this (eg)

```
{
"@context": "http://iiif.io/api/image/2/context.json",
"@id": "https://example.com/iiif/data",
"profile": [
"http://iiif.io/api/image/2/level0.json",
{
"formats": [
"jpg"
],
"qualities": [
"default"
]
}
],
"protocol": "http://iiif.io/api/image",
"tiles": [
{
"scaleFactors": [
1,
2,
4,
8
],
"width": 512
}
],
"width": 4464,
"height": 6645
}
```

- an example generated by (the python reference implementation) Pillow is

```
{
"profile": [
"http://iiif.io/api/image/2/level0.json",
{
"qualities": [
"default"
],
"formats": [
"jpg"
]
}
],
"tiles": [
{
"width": 512,
"scaleFactors": [
1,
2,
4
],
"height": 512
}
],
"protocol": "http://iiif.io/api/image",
"sizes": [
{
"width": 212,
"height": 292
},
{
"width": 106,
"height": 146
},
{
"width": 53,
"height": 73
},
{
"width": 27,
"height": 36
},
{
"width": 13,
"height": 18
},
{
"width": 7,
"height": 9
},
{
"width": 3,
"height": 5
},
{
"width": 2,
"height": 2
},
{
"width": 1,
"height": 1
}
],
"height": 2334,
"width": 1696,
"@context": "http://iiif.io/api/image/2/context.json",
"@id": "/data/"
}
```

### Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

```
var sharp = require("sharp");

async function process() {
try {
await sharp("input.jpg")
.tile({
layout: "iiif",
id: "."
})
.toFile("data");
} catch (error) {
console.log(error);
}
}

process();
```

### Please provide sample image(s) that help explain this problem

n/a

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

Start with the sharp tile({ layout: "iiif", id: "." }) entry point and inspect the generated info.json against the IIIF Image API examples in the issue. Done means the default IIIF output includes a correct "sizes" key and remains usable with clients such as react-iiif-viewer.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend, computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.