Skip to content

Commit

Permalink
support image manifests generated using biiif
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Nov 19, 2017
1 parent 6b893b9 commit 0a9b106
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 3 files
+6 −0 manifests.json
+ uv-3.0.0.zip
+27 −3 uv/uv.js
5 changes: 5 additions & 0 deletions src/UVComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export default class UVComponent extends _Components.BaseComponent implements IU

// presentation 3

this._extensions[manifesto.MediaType.jpg().toString()] = {
type: OpenSeadragonExtension,
name: 'uv-seadragon-extension'
};

this._extensions[manifesto.MediaType.pdf().toString()] = {
type: PDFExtension,
name: 'uv-pdf-extension'
Expand Down
34 changes: 28 additions & 6 deletions src/extensions/uv-seadragon-extension/DownloadDialogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class DownloadDialogue extends BaseDownloadDialogue {
const $label: JQuery = this.$wholeImageHighResButton.find('label');
let mime: string | null = this.getCanvasMimeType(this.extension.helper.getCurrentCanvas());

if (mime){
if (mime) {
mime = Utils.Files.simplifyMimeType(mime);
} else {
mime = '?';
Expand All @@ -225,15 +225,25 @@ export class DownloadDialogue extends BaseDownloadDialogue {
const size: Size | null = this.getCanvasComputedDimensions(this.extension.helper.getCurrentCanvas());

if (!size) {
this.$wholeImageHighResButton.hide();
// if there is no image service, allow the image to be downloaded directly.
if (canvas.externalResource && !canvas.externalResource.hasServiceDescriptor()) {
const label: string = String.format(this.content.wholeImageHighRes, '?', '?', mime);
$label.text(label);
$input.prop('title', label);
this.$wholeImageHighResButton.show();
} else {
this.$wholeImageHighResButton.hide();
}
} else {
const label: string = hasNormalDimensions ?
String.format(this.content.wholeImageHighRes, size.width, size.height, mime) :
String.format(this.content.wholeImageHighRes, size.height, size.width, mime);
$label.text(label);
$input.prop('title', label);

this.$wholeImageHighResButton.data('width', size.width);
this.$wholeImageHighResButton.data('height', size.height);

this.$wholeImageHighResButton.show();
}

Expand Down Expand Up @@ -483,6 +493,7 @@ export class DownloadDialogue extends BaseDownloadDialogue {

getCanvasHighResImageUri(canvas: Manifesto.ICanvas): string {
const size: Size | null = this.getCanvasComputedDimensions(canvas);

if (size) {
const width: number = size.width;
let uri: string = canvas.getCanonicalImageUri(width);
Expand All @@ -495,6 +506,9 @@ export class DownloadDialogue extends BaseDownloadDialogue {
}

return uri;
} else if (canvas.externalResource && !canvas.externalResource.hasServiceDescriptor()) {
// if there is no image service, return the dataUri.
return <string>canvas.externalResource.dataUri;
}
return '';
}
Expand All @@ -513,20 +527,28 @@ export class DownloadDialogue extends BaseDownloadDialogue {
return null;
}

getCanvasDimensions(canvas: Manifesto.ICanvas): Size {
getCanvasDimensions(canvas: Manifesto.ICanvas): Size | null {

// externalResource may not have loaded yet
if (canvas.externalResource.data) {
return new Size((<Manifesto.IExternalImageResourceData>canvas.externalResource.data).width, (<Manifesto.IExternalImageResourceData>canvas.externalResource.data).height);
const width: number | undefined = (<Manifesto.IExternalImageResourceData>canvas.externalResource.data).width;
const height: number | undefined = (<Manifesto.IExternalImageResourceData>canvas.externalResource.data).height;
if (width && height) {
return new Size(width, height);
}
}

return new Size(0, 0);
return null;
}

getCanvasComputedDimensions(canvas: Manifesto.ICanvas): Size | null {
const imageSize: Size = this.getCanvasDimensions(canvas);
const imageSize: Size | null = this.getCanvasDimensions(canvas);
const requiredSize: Size | null = canvas.getMaxDimensions();

if (!imageSize) {
return null;
}

if (!requiredSize) {
return imageSize;
}
Expand Down

0 comments on commit 0a9b106

Please sign in to comment.