Skip to content
Snippets Groups Projects
Select Git revision
  • c8d769cd489b566ff78bebecdfe1abfaa698344b
  • main default protected
  • export
  • 28-conversion-tests
  • extraction
  • exploration
  • exploration-old
  • 2-encoding-fix
  • main-old
9 results

README.md

Blame
  • To learn more about this project, read the wiki.
    ManifestoCanvas.js 937 B
    /**
     * ManifestoCanvas - adds additional, testable logic around Manifesto's Canvas
     * https://iiif-commons.github.io/manifesto/classes/_canvas_.manifesto.canvas.html
     */
    export default class ManifestoCanvas {
      /**
       * @param {ManifestoCanvas} canvas
       */
      constructor(canvas) {
        this.canvas = canvas;
      }
    
      /**
       */
      get canonicalImageUri() {
        return this.canvas.getCanonicalImageUri();
      }
    
      /**
       */
      get aspectRatio() {
        return this.canvas.getWidth() / this.canvas.getHeight();
      }
    
      /**
       */
      get imageInformationUri() {
        return `${
          this.canvas.getImages()[0].getResource().getServices()[0].id.replace(/\/$/, '')
        }/info.json`;
      }
    
      /**
       * Creates a canonical image request for a thumb
       * @param {Number} height
       */
      thumbnail(height = 150) {
        const width = Math.floor(height * this.aspectRatio);
        return this.canonicalImageUri.replace(/\/full\/.*\/0\//, `/full/${width},/0/`);
      }
    }