
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
@atlas-viewer/iiif-image-api
Advanced tools
A series of helpers for working with the IIIF Image API.
Check out the Compliance version for more information. This library supports detection of levels 0 to 2 up to IIIF Image API 3.0.
This library is a toolbox to be used as a part of a larger application or library. The documentation is still in progress, but there are typescript definitions shipped so you can explore the API in your IDE or editor.
This is the primary part of the library. It uses all the components to create a single image service loading library.
import { ImageServiceLoader } from '@atlas-viewer/iiif-image-api';
const loader = new ImageServiceLoader();
loader.loadService({
id: 'http://some-service/some-path',
width: 1000,
height: 1000,
}).then(service => {
// full image service available
// service
});
loader.getThumbnailFromResource(
// Content resource.
{
id: 'http://some-service/some-image/default.jpg',
width: 1000,
height: 2000,
service: [
{
id: 'http://some-service/some-path',
type: 'Service',
profile: 'level0',
}
]
},
// Thumbnail options.
{
maxWidth: 200,
maxHeight: 200,
preferFixedSize: true,
},
// Dereference image service.
true
);
The following profiles will be matched and mapped to the conformance level in IIIF:
Takes in an image service object and returns true if it is a supported image service.
import { isImageService } from '@atlas-viewer/iiif-image-api';
isImageService({
id: 'http://some-service/some-path',
type: 'Service',
profile: 'level0',
}); // true
Normalises an image service endpoint to ensure it has the info.json
appended.
import { canonicalServiceUrl } from '@atlas-viewer/iiif-image-api';
canonicalServiceUrl('http://some-service/some-path'); // http://some-service/some-path/info.json
Given a list of image sizes and a height and width, this returns the scale of each size in the same order as the input.
import { extractFixedSizeScales } from '@atlas-viewer/iiif-image-api';
extractFixedSizeScales(1000, 2000, [
{ width: 100, height: 200 },
{ width: 500, height: 1000 }
]); // [ 10, 2 ]
The opposite operation to extractFixedSizeScales
returning a list of sizes from a list of scales.
import { extractFixedSizeScales } from '@atlas-viewer/iiif-image-api';
extractFixedSizeScales(1000, 2000, [10, 2]);
// returns:
// [ { width: 100, height: 200 }, { width: 500, height: 1000 } ]
Given a service, this will return an object giving the constraints for generating images from the service using the profile and the max width and max height properties if they are available. If the service contains tiles, it will use the definition of the tiles.
The return value used across this library is for describing an image candidate that can be used to create a real image.
import { getCustomSizeFromService } from '@atlas-viewer/iiif-image-api';
getCustomSizeFromService({
id: 'http://some-service/some-path',
profile: 'image2',
tiles: [
{ width: 256, height: 256 },
{ width: 512, height: 512 },
]
});
const returns = [
{
id: 'http://some-service/some-path',
type: 'variable',
minHeight: 0,
minWidth: 0,
maxHeight: 256,
maxWidth: 256,
},
{
id: 'http://some-service/some-path',
type: 'variable',
minHeight: 0,
minWidth: 0,
maxHeight: 512,
maxWidth: 512,
}
];
This takes in a content resource – usually in the body of an annotation or thumbnail property in IIIF Presentation manifest – and tries to find the size of that resource. This is only an indication of the size of a resource and shouldn't be used as a source of truth. Internally this is used to detect potentially very large images and avoid rendering them.
import { getFixedSizeFromImage } from '@atlas-viewer/iiif-image-api';
// Normal image resources.
getFixedSizeFromImage({
id: 'http://some-service/some-path/image.jpg',
type: 'Image',
width: 100,
height: 200,
});
const returns = {
id: 'http://some-service/some-path/image.jpg',
type: 'fixed',
width: 100,
height: 200,
};
// Unknown size.
getFixedSizeFromImage('http://some-service/some-path/image.jpg');
const returns = {
id: 'http://some-service/some-path/image.jpg',
type: 'unknown',
};
FAQs
A series of helpers for working with the IIIF Image API.
We found that @atlas-viewer/iiif-image-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.