Skip to content

Commit

Permalink
Merge branch 'rollback' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
martimpassos committed Jul 16, 2024
2 parents 599dde1 + 6e31195 commit 5957b84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
16 changes: 4 additions & 12 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,16 @@ class TropiiifyPlugin {
manifest.addLabel(item.label);
});
if (index === 0) {
const {
path: imagePath,
checksum,
width,
height,
mimetype,
} = item.photo[0];
const { checksum, width, height } = item.photo[0];
const ratio = Math.max(width, height) / 300;
const newWidth = Math.round(width / ratio);
const newHeight = Math.round(height / ratio);
collection.addThumbnail({
id: `${item.baseId}/${checksum}/full/${Math.round(
newWidth
)},${Math.round(newHeight)}/0/default${
path.extname(imagePath) || ".jpg"
}`,
)},${Math.round(newHeight)}/0/default.jpg`,
type: "Image",
format: mimetype,
format: "image/jpeg",
width: newWidth,
height: newHeight,
});
Expand Down Expand Up @@ -235,7 +227,7 @@ class TropiiifyPlugin {
"full",
`${width},${height}`,
"0",
`default${path.extname(photo.path) || ".jpg"}`
"default.jpg"
);
fs.promises
.mkdir(path.dirname(destination), { recursive: true })
Expand Down
24 changes: 6 additions & 18 deletions src/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,9 @@ class Resource {
});
//props.latitude && props.longitude && manifest.addNavPlace(latitude, longitude)
manifest.addThumbnail({
id: `${this.baseId}/${
this.photo[0].checksum
}/full/${thumbWidth},${thumbHeight}/0/default${
path.extname(this.photo[0].path) || ".jpg"
}`,
id: `${this.baseId}/${this.photo[0].checksum}/full/${thumbWidth},${thumbHeight}/0/default.jpg`,
type: "Image",
format: this.photo[0].mimetype,
format: "image/jpeg",
width: thumbWidth,
height: thumbHeight,
});
Expand Down Expand Up @@ -134,23 +130,15 @@ class Resource {
const canvasId = `${this.baseId}/canvas/${canvasIndex + 1}`; //0266-full-canvas-annotation/canvas-x
const annPageId = `${canvasId}/annopage-1`; //0266-full-canvas-annotation/canvas-x/annopage-1",
const paintingAnnId = `${annPageId}/anno-1`; //0266-full-canvas-annotation/canvas-x/annopage-1/anno-1
const paintingBodyId = `${this.baseId}/${
photo.checksum
}/full/${midWidth},${midHeight}/0/default${
path.extname(photo.path) || ".jpg"
}`;
const paintingBodyId = `${this.baseId}/${photo.checksum}/full/${midWidth},${midHeight}/0/default.jpg`;
manifest.createCanvas(canvasId, (canvas) => {
canvas.width = photo.width;
canvas.height = photo.height;
canvas.addLabel(photo.label || "");
canvas.addThumbnail({
id: `${this.baseId}/${
photo.checksum
}/full/${thumbWidth},${thumbHeight}/0/default${
path.extname(photo.path) || ".jpg"
}`,
id: `${this.baseId}/${photo.checksum}/full/${thumbWidth},${thumbHeight}/0/default.jpg`,
type: "Image",
format: photo.mimetype,
format: "image/jpeg",
width: thumbWidth,
height: thumbHeight,
});
Expand All @@ -162,7 +150,7 @@ class Resource {
body: {
id: paintingBodyId,
type: "Image",
format: photo.mimetype,
format: "image/jpeg",
width: midWidth,
height: midHeight,
service: [
Expand Down

0 comments on commit 5957b84

Please sign in to comment.