Add Image resource + fake controllers

This commit is contained in:
2023-10-03 15:27:10 +02:00
parent e401f3253b
commit 2e39e6256d
6 changed files with 104 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
import IIIFResource from './IIIFResource.js';
import Image from './Image.js';
/**
* @implements IIIFResource
*/
@@ -29,6 +30,12 @@ class Canvas {
setLabel(label) {
this.label = label;
}
/**
* @param {Image} image Add an image to the canvas
*/
addImage(image) {
this.images.push(image.toObject());
}
/**
* Add a thumbnail object
* @todo Support multiple thumbs?
@@ -52,6 +59,7 @@ class Canvas {
"@id" : this.id,
"@type" : this.type,
"label" : this.label,
"images" : this.images,
"thumbnail" : this.thumbnail
}
}

39
src/Image.js Normal file
View File

@@ -0,0 +1,39 @@
import IIIFResource from './IIIFResource.js';
/**
* @implements IIIFResource
*/
class Image {
/**
* @var {string} id A URL pointing to the image resource
*/
id = '';
type = 'dctypes:Image';
format = 'image/jpeg';
height = 0;
width = 0;
service = {};
constructor(height, width) {
this.height = height;
this.width = width;
}
/**
* Object representation of
* image resource
* @returns {object}
*/
toObject() {
return {
resource : {
"@id" : this.id,
"@type" : this.type,
format: this.format,
service : this.service,
height: this.height,
width: this.width,
}
}
}
}
export default Image;

View File

@@ -28,6 +28,9 @@ class Manifest {
this.id = `${this.BASE_URL}/iiif/${idParam}/manifest` ;
}
/**
* Object representation of this
* manifest
*
* @todo Implement
* @returns {object}
*/