sharp
sharp copied to clipboard
IIIF output doesn't include "sizes" key
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 instead.
Are you using the latest version of sharp?
- [x] I am using the latest version of
sharp
as reported bynpm 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
The sizes
property is optional, please see https://github.com/libvips/libvips/discussions/2036 for related discussion.
Ah that's a really relevant thread thank you, I'd searched the issues here but didn't think of that mea culpa. And yes that 100% captures the situation as far as I can tell - optional but it makes it more compatible - and I hadn't twigged we don't do a full
folder either!
thank you really really this link -extremely useful.
Is it the feeling then that Sharp would only do this if the functionality arrived as a result of it being added upstream to libvips? It seems like Sharp has the info it would need to supply it independently if it was felt to be important doesnt it? (incidentally, I discovered that to get stop react-iiif-viewer erroring out, all you need do is add the key with an empty array as a post processing step - …"sizes":[]…
We should get this added to libvips first, then everyone benefits.
I discovered that to get stop react-iiif-viewer erroring out
That sounds like a bug in react-iiif-viewer
, as the sizes
property is optional. Perhaps you could submit a PR to fix it.
Yep cool agree on both counts!
thanks for looking at this and for the amazingly quick replies. Happy New Year
ps - if you have time, i'd be so grateful if you wouldn't mind weiging in on that thread in support of adding the feature. thanks!