Page load improvements, plus bash scripts for future image changes

This commit is contained in:
august kline 2024-08-25 22:16:44 -04:00
parent f8f4a606e8
commit 63365b0f86
37 changed files with 93 additions and 12 deletions

49
compress.sh Executable file
View File

@ -0,0 +1,49 @@
#!/bin/bash
# Directory containing the images
input_dir="./public"
output_dir="./public/tmp"
rm -rf ${output_dir}
mkdir -p ${output_dir}
for input_file in "$input_dir"/*; do
if [ -f "$input_file" ]; then
filename=$(basename "$input_file")
extension="${filename##*.}"
output_file="${output_dir}/${filename}"
case "$extension" in
jpg)
# local max=65536
if [ $(stat -f%z "${input_file}") -gt 65536 ]; then
magick "${input_file}" -resize 30% "${output_file}"
while [ $(stat -f%z "$output_file") -gt 65536 ]; do
echo "Processing JPEG file: $output_file"
magick "${output_file}" -resize 30% "${output_file}"
done
fi
mv "${output_file}" "${input_file}"
;;
gif)
if [ $(stat -f%z "$input_file") -gt 1048576 ]; then
ffmpeg -y -i "$input_file" -vf "scale=iw*0.75:ih*0.75" "${output_file}"
while [ $(stat -f%z "$output_file") -gt 1048576 ]; do
echo "Processing GIF file: $output_file"
# Compress GIF files using ffmpeg
ffmpeg -y -i "$output_file" -vf "scale=iw*0.75:ih*0.75:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32[p];[s1][p]paletteuse=dither=bayer" "${output_dir}/tmp-${filename}"
mv "${output_dir}/tmp-${filename}" "${output_file}"
done
mv "${output_file}" "${input_file}"
fi
;;
*)
echo "Skipping file: $input_file"
;;
esac
fi
done
rm -rf ${output_dir}
echo "Compression complete!"

32
filenames.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
input_dir="./public"
output_dir="./public"
mkdir -p "$output_dir"
for input_file in "$input_dir"/*.png; do
if [ -f "$input_file" ]; then
filename=$(basename "$input_file" .png)
output_file="$output_dir/$filename.jpg"
imagemagick "$input_file" "$output_file"
rm "${input_file}"
echo "Converted $input_file to $output_file"
fi
done
for input_file in "$input_dir"/*.jpeg; do
if [ -f "$input_file" ]; then
filename=$(basename "$input_file" .jpeg)
output_file="$output_dir/$filename.jpg"
mv "$input_file" "$output_file"
echo "Converted $input_file to $output_file"
fi
done
echo "Conversion complete!"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

After

Width:  |  Height:  |  Size: 943 KiB

BIN
public/augustcircle.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 MiB

After

Width:  |  Height:  |  Size: 958 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

After

Width:  |  Height:  |  Size: 761 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 607 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 MiB

BIN
public/flowers.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 831 KiB

BIN
public/georgetoilet.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 KiB

BIN
public/heron.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 KiB

BIN
public/klinefloor.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 236 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 684 KiB

BIN
public/klineoutside.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 KiB

BIN
public/klinetrain.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 MiB

After

Width:  |  Height:  |  Size: 788 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

BIN
public/mirror.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

BIN
public/ohio.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 KiB

BIN
public/sashaklinecar.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 514 KiB

BIN
public/solderkitty.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
public/sunsetkline.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

View File

@ -1,22 +1,22 @@
import backwalkgeorge from "/backwalkgeorge.jpg"; import backwalkgeorge from "/backwalkgeorge.jpg";
import georgetoilet from "/georgetoilet.png"; import georgetoilet from "/georgetoilet.jpg";
import klinefloor from "/klinefloor.jpeg"; import klinefloor from "/klinefloor.jpg";
import klinemirror from "/klinemirror.jpg"; import klinemirror from "/klinemirror.jpg";
import klineoutside from "/klineoutside.jpeg"; import klineoutside from "/klineoutside.jpg";
import klinetrain from "/klinetrain.jpeg"; import klinetrain from "/klinetrain.jpg";
import sashaklineburrito from "/sashaklineburrito.jpeg"; import sashaklineburrito from "/sashaklineburrito.jpg";
import sashaklinecar from "/sashaklinecar.jpeg"; import sashaklinecar from "/sashaklinecar.jpg";
import sunsetkline from "/sunsetkline.png"; import sunsetkline from "/sunsetkline.jpg";
import georgerasp from "/georgerasp.gif"; import georgerasp from "/georgerasp.gif";
import sunsetfourteenth from "/14thstsunrise.gif"; import sunsetfourteenth from "/14thstsunrise.gif";
import solderkitty from "/solderkitty.jpeg"; import solderkitty from "/solderkitty.jpg";
import ducklings from "/ducklings.gif"; import ducklings from "/ducklings.gif";
import fieldnotes from "/fieldnotes.gif"; import fieldnotes from "/fieldnotes.gif";
import lamp from "/lamp.gif"; import lamp from "/lamp.gif";
import ohio from "/ohio.jpeg"; import ohio from "/ohio.jpg";
import heron from "/heron.jpeg"; import heron from "/heron.jpg";
import flowers from "/flowers.jpeg"; import flowers from "/flowers.jpg";
import mirror from "/mirror.jpeg"; import mirror from "/mirror.jpg";
let background = document.getElementById("background")!; let background = document.getElementById("background")!;