Skip to content

Commit

Permalink
Automatically generate thumbnail sizes (#59)
Browse files Browse the repository at this point in the history
* automatically generate thumbnail sizes

* multiply instead of divide for canvases where height is larger than width

* upgrade storybook

* replace storybook styling addon

* remove unused OSD icons
  • Loading branch information
camdendotlol committed Sep 13, 2023
1 parent bd97f17 commit 91d2e89
Show file tree
Hide file tree
Showing 42 changed files with 18,699 additions and 20,337 deletions.
52 changes: 44 additions & 8 deletions editioncrafter/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,50 @@ const config = {
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
{
name: '@storybook/addon-styling',
options: {
sass: {
implementation: require('sass'),
},
},
},
"@storybook/addon-styling-webpack",
({
name: "@storybook/addon-styling-webpack",

options: {
rules: [{
test: /\.css$/,
sideEffects: true,
use: [
require.resolve("style-loader"),
{
loader: require.resolve("css-loader"),
options: {


},
},
],
},{
test: /\.s[ac]ss$/,
sideEffects: true,
use: [
require.resolve("style-loader"),
{
loader: require.resolve("css-loader"),
options: {

importLoaders: 2,
},
},
require.resolve("resolve-url-loader"),
{
loader: require.resolve("sass-loader"),
options: {
// Want to add more Sass options? Read more here: https://webpack.js.org/loaders/sass-loader/#options
implementation: require.resolve("sass"),
sourceMap: true,
sassOptions: {},
},
},
],
},],
}
})
],
framework: {
name: "@storybook/react-webpack5",
Expand Down
38,940 changes: 18,626 additions & 20,314 deletions editioncrafter/package-lock.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions editioncrafter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@storybook/addon-essentials": "^7.2.2",
"@storybook/addon-interactions": "^7.2.2",
"@storybook/addon-links": "^7.2.2",
"@storybook/addon-styling": "^1.3.6",
"@storybook/blocks": "^7.2.2",
"@storybook/react": "^7.2.2",
"@storybook/react-webpack5": "^7.2.2",
"@storybook/addon-essentials": "^7.4.1",
"@storybook/addon-interactions": "^7.4.1",
"@storybook/addon-links": "^7.4.1",
"@storybook/addon-styling-webpack": "0.0.4",
"@storybook/blocks": "^7.4.1",
"@storybook/react": "^7.4.1",
"@storybook/react-webpack5": "^7.4.1",
"@storybook/testing-library": "0.2.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
Expand Down Expand Up @@ -96,9 +96,10 @@
"react-refresh": "^0.14.0",
"redux-mock-store": "^1.5.1",
"redux-saga-test-plan": "^4.0.6",
"resolve-url-loader": "^5.0.0",
"sass": "^1.61.0",
"sass-loader": "^13.2.2",
"storybook": "^7.2.2",
"storybook": "^7.4.1",
"style-loader": "^3.3.2",
"terser-webpack-plugin": "^5.3.1",
"unfetch": "^4.1.0",
Expand Down
24 changes: 19 additions & 5 deletions editioncrafter/src/action/DocumentActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ function parseImageURLs(canvas) {
if (annotation.type !== 'Annotation') throwError(`Expected Annotation in items property of ${annotationPage.id}`);
if (annotation.motivation === 'painting') {
if (!annotation.body) throwError(`Expected body property in Annotation ${annotation.id}`);
if (!annotation.body.thumbnail) throwError(`Expected body.thumbnail property in Annotation ${annotation.id}`);
const thumbnailURL = annotation.body.thumbnail[0].id;
if (!thumbnailURL) throwError(`Unable to find thumbnail for resource: ${annotation.body.id}`);
return { imageURL: `${annotation.body.id}/info.json`, thumbnailURL };
return {
bodyId: annotation.body.id,
imageURL: `${annotation.body.id}/info.json`,
};
}
}
}
Expand Down Expand Up @@ -109,6 +109,9 @@ function parseAnnotationURLs(canvas, transcriptionTypes) {
return annos;
}

// The largest dimension for either width or height allowed in a thumbnail.
const MAX_THUMBNAIL_DIMENSION = 130;

function parseManifest(manifest, transcriptionTypes) {
const folios = [];

Expand All @@ -127,9 +130,20 @@ function parseManifest(manifest, transcriptionTypes) {
if (!canvas.id) throwError(`Expected items[${i}] to have an id property.`);
const folioID = canvas.id.substr(canvas.id.lastIndexOf('/') + 1);
const canvasLabel = parseLabel(canvas);
const { imageURL, thumbnailURL } = parseImageURLs(canvas);
const { bodyId, imageURL } = parseImageURLs(canvas);
const annotationURLs = parseAnnotationURLs(canvas, transcriptionTypes);

const ratio = canvas.width / canvas.height;

let thumbnailDimensions = [];
if (ratio > 1) {
thumbnailDimensions = [MAX_THUMBNAIL_DIMENSION, Math.round(MAX_THUMBNAIL_DIMENSION / ratio)];
} else {
thumbnailDimensions = [Math.round(MAX_THUMBNAIL_DIMENSION * ratio), MAX_THUMBNAIL_DIMENSION];
}

const thumbnailURL = `${bodyId}/full/${thumbnailDimensions.join(',')}/0/default.jpg`;

const folio = {
id: folioID,
name: canvasLabel,
Expand Down
2 changes: 1 addition & 1 deletion editioncrafter/src/component/ImageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ImageView = (props) => {
element: el,
zoomInButton: in_id,
zoomOutButton: out_id,
prefixUrl: './img/openseadragon/',
showNavigationControl: false,
zoomPerClick: 1,
});

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed editioncrafter/src/img/openseadragon/button_rest.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed editioncrafter/src/img/openseadragon/home_hover.png
Binary file not shown.
Binary file not shown.
Binary file removed editioncrafter/src/img/openseadragon/home_rest.png
Binary file not shown.
Binary file not shown.
Binary file removed editioncrafter/src/img/openseadragon/next_hover.png
Binary file not shown.
Binary file not shown.
Binary file removed editioncrafter/src/img/openseadragon/next_rest.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed editioncrafter/src/img/openseadragon/zoomin_rest.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
1 change: 0 additions & 1 deletion editioncrafter/src/scss/_imageGridView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
.imageGridComponent > ul > li {
margin-bottom: 20px;
width: 150px;
height: 220px;
}

.imageGridComponent > ul > li > figure {
Expand Down

0 comments on commit 91d2e89

Please sign in to comment.