Comparing version 0.3.11 to 0.3.12
@@ -5,5 +5,6 @@ "use strict"; | ||
const annotationBoilerplate = require('./boilerplate/annotation'); | ||
const imageServiceBoilerplate = require('./boilerplate/imageservice'); | ||
const chalk = require('chalk'); | ||
const config = require('./config'); | ||
const imageServiceBoilerplate = require('./boilerplate/imageservice'); | ||
const Jimp = require("jimp"); | ||
const urljoin = require('url-join'); | ||
@@ -162,3 +163,3 @@ const Directory_1 = require("./Directory"); | ||
}); | ||
this._annotateFiles(canvasJson, paintableFiles); | ||
await this._annotateFiles(canvasJson, paintableFiles); | ||
} | ||
@@ -169,3 +170,3 @@ } | ||
// therefore, just annotate that file onto the canvas. | ||
this._annotateFiles(canvasJson, [this.filePath]); | ||
await this._annotateFiles(canvasJson, [this.filePath]); | ||
} | ||
@@ -178,4 +179,4 @@ if (!canvasJson.items[0].items.length) { | ||
} | ||
_annotateFiles(canvasJson, files) { | ||
files.forEach((file) => { | ||
async _annotateFiles(canvasJson, files) { | ||
await Promise.all(files.map(async (file) => { | ||
file = Utils_1.Utils.normaliseFilePath(file); | ||
@@ -204,4 +205,14 @@ const extName = extname(file); | ||
canvasJson.items[0].items.push(annotationJson); | ||
// if it's an image, get the width and height and add to the annotation body and canvas | ||
if (defaultPaintingExtension.type.toLowerCase() === Types_1.Types.IMAGE) { | ||
const image = await Jimp.read(file); | ||
const width = image.bitmap.width; | ||
const height = image.bitmap.height; | ||
canvasJson.width = Math.max(canvasJson.width || 0, width); | ||
canvasJson.height = Math.max(canvasJson.height || 0, height); | ||
annotationJson.body.width = width; | ||
annotationJson.body.height = height; | ||
} | ||
} | ||
}); | ||
})); | ||
} | ||
@@ -208,0 +219,0 @@ async _getInfo() { |
{ | ||
"name": "biiif", | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"description": "A CLI to build IIIF collections", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
53500
976