Skip to content

Commit

Permalink
Fixed issue when getting image services from resources without width/…
Browse files Browse the repository at this point in the history
…height
  • Loading branch information
stephenwf committed Nov 3, 2021
1 parent f94255a commit 4fd3266
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
31 changes: 31 additions & 0 deletions __tests__/get-image-services.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { getImageServices } from '../src';

describe('getImageServices', () => {
test('It can work when a resource has no height/width', () => {
expect(
getImageServices({
id:
'https://api.bl.uk/image/iiif/ark:/81055/vdc_100113995491.0x000001/full/max/0/default.jpg',
type: 'Image',
format: 'image/jpg',
service: [
{
protocol: 'http://iiif.io/api/image',
width: 2294,
height: 3004,
tiles: [
{
scaleFactors: [1, 2, 4, 8],
width: 256,
},
],
id:
'https://api.bl.uk/image/iiif/ark:/81055/vdc_100113995491.0x000001',
type: 'ImageService2',
profile: 'level2',
},
],
})
).toHaveLength(1);
});
});
49 changes: 49 additions & 0 deletions __tests__/image-service-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,53 @@ describe('image service loader', () => {
).toEqual(true);
});
});

describe('sbb', () => {
const sbbInfo = {
'@context': 'http://iiif.io/api/image/2/context.json',
'@id':
'https://iiif-content.crossasia.org/xasia/dllm+dllm_0005978+233695',
'@type': 'iiif:Image',
protocol: 'http://iiif.io/api/image',
width: 1741,
height: 2381,
sizes: [
{ width: 150, height: 100 },
{
width: 600,
height: 400,
},
{ width: 2400, height: 4000 },
{ width: 1722, height: 2304 },
],
tiles: [
{ width: 256, scaleFactors: [1] },
{
width: 512,
scaleFactors: [2, 4],
},
{ width: 1024, scaleFactors: [8, 16] },
],
logo: {
'@id': 'https://iiif-content.crossasia.org/xasia/logo',
service: {
'@context': 'http://iiif.io/api/image/2/context.json',
'@id': 'https://iiif-content.crossasia.org/xasia/logo',
profile: 'http://iiif.io/api/image/2/level2.json',
},
},
profile: [
'http://iiif.io/api/image/2/level2.json',
{
formats: ['jpg', 'png', 'webp', 'tif'],
qualities: ['color', 'gray'],
supports: [
'canonicalLinkHeader',
'rotationArbitrary',
'profileLinkHeader',
],
},
],
};
});
});
6 changes: 1 addition & 5 deletions src/utility/get-image-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ export function getImageServices(resource: IIIFExternalWebResource): Service[] {
const totalServices = services.length;
const imageServices = [];
for (let i = 0; i < totalServices; i++) {
if (
isImageService((services as Service[])[i]) &&
resource.width &&
resource.height
) {
if (isImageService((services as Service[])[i])) {
imageServices.push(services[i]);
}
}
Expand Down

0 comments on commit 4fd3266

Please sign in to comment.