Skip to content

Commit

Permalink
feat(images): support multi-page jpg reps for tif files (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Kerr authored Apr 17, 2020
1 parent f9f2c6b commit 206350e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/viewers/image/ImageLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const VIEWERS = [
EXT: ['tif', 'tiff'],
ASSET: '{page}.png',
},
{
NAME: 'MultiImage',
CONSTRUCTOR: MultiImageViewer,
REP: 'jpg',
EXT: ['tif', 'tiff'],
ASSET: '{page}.jpg',
},
{
NAME: 'Image',
CONSTRUCTOR: ImageViewer,
Expand Down
58 changes: 58 additions & 0 deletions src/lib/viewers/image/__tests__/ImageLoader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,62 @@ describe('lib/viewers/image/ImageLoader', () => {
expect(determinedRep.properties.dimensions).to.equal('2048x2048');
});
});

describe('determineViewer', () => {
it('it should return the MultiImage viewer for a tif file with a jpg representation', () => {
const file = {
extension: 'tif',
representations: {
entries: [
{
representation: 'jpg',
properties: {
dimensions: '1024x1024',
paged: 'false',
},
},
{
representation: 'jpg',
properties: {
dimensions: '2048x2048',
paged: 'true',
},
},
],
},
};

const determinedViewer = ImageLoader.determineViewer(file);
expect(determinedViewer.NAME).to.equal('MultiImage');
expect(determinedViewer.REP).to.equal('jpg');
});

it('it should return the MultiImage viewer for a tif file with a png representation', () => {
const file = {
extension: 'tif',
representations: {
entries: [
{
representation: 'jpg',
properties: {
dimensions: '1024x1024',
paged: 'false',
},
},
{
representation: 'png',
properties: {
dimensions: '2048x2048',
paged: 'true',
},
},
],
},
};

const determinedViewer = ImageLoader.determineViewer(file);
expect(determinedViewer.NAME).to.equal('MultiImage');
expect(determinedViewer.REP).to.equal('png');
});
});
});

0 comments on commit 206350e

Please sign in to comment.