Skip to content

Commit

Permalink
Merge pull request #222 from ssciwr/webp
Browse files Browse the repository at this point in the history
Use webp format for images
  • Loading branch information
lkeegan authored Jan 13, 2025
2 parents d38f72e + d171eb2 commit 4d4b583
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 87 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
with:
node-version: 22
cache: "pnpm"
- run: sudo apt-get update -yy && sudo apt-get install -yy webp
- run: pnpm install
- run: pnpm run build
- uses: JamesIves/[email protected]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Initial setup:
- linux/macOS: `curl -fsSL https://get.pnpm.io/install.sh | sh -`
- install website dependencies
- `pnpm install`
- the [cwebp](https://developers.google.com/speed/webp/download) binary is also needed to convert image files
- ubuntu: `sudo apt install webp`

To build from source, start local http-server, open website in browser, monitor & re-build modified source files:

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"npm-run-all": "4.1.5",
"shelljs": "0.8.5",
"svgdom": "0.1.19",
"tiff-to-png": "2.0.2",
"ts-loader": "9.5.1",
"typescript": "5.7.2",
"typescript-eslint": "^8.19.0",
Expand Down
11 changes: 0 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 14 additions & 11 deletions scripts/build-images.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import fs from "fs";
import ConvertTiff from "tiff-to-png";
import { glob } from "glob";
import shell from "shelljs";
import path from "path";
import { execSync } from "child_process";

const image_dir = "./dist/fileadmin/templates/iwr_vis";
const image_dir = "./dist/fileadmin/templates/iwr_vis/";
fs.mkdirSync(image_dir, { recursive: true });

// convert tif images to png & write to dist/fileadmin/iwr_vis folder
const tifImageFiles = await glob("**/img/*.tif");
const converter = new ConvertTiff();
converter.convertArray(tifImageFiles, image_dir).then(console.log);
// convert all image files to webp & write to image folder
const images = await glob("**/img/*.*");

// just copy any jpg or png images to image_dir
shell.cp("./src/img/*.jpg", image_dir);
shell.cp("./src/img/*.jpeg", image_dir);
shell.cp("./src/img/*.png", image_dir);
for (const image of images) {
const output = path.format({
root: image_dir,
name: path.parse(image).name,
ext: ".webp",
});
console.log(`${image} --> ${output}`);
execSync(`cwebp ${image} -o ${output} -quiet`);
}
128 changes: 64 additions & 64 deletions src/data/data.json

Large diffs are not rendered by default.

Binary file modified src/img/Bärnighausen-sw.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/img/Gutheil_sw.tif
Binary file not shown.
Binary file modified src/img/Herrmann.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/img/Jäger_sw.tif
Binary file not shown.
Binary file modified src/img/Koppe.tif
Binary file not shown.
Binary file modified src/img/Nieser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/img/Plehn.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/img/Scheichl_sw.tif
Binary file not shown.
Binary file modified src/img/Schnörr_sw.tif
Binary file not shown.

0 comments on commit 4d4b583

Please sign in to comment.