diff --git a/.github/workflows/png_file_checks.yml b/.github/workflows/png_file_checks.yml new file mode 100644 index 000000000..86cd93527 --- /dev/null +++ b/.github/workflows/png_file_checks.yml @@ -0,0 +1,26 @@ +name: png_file_checks + +# Check whether all png files are in a valid format +on: + push: + paths: + - '**.png' + - '.github/workflows/**.yml' + pull_request: + paths: + - '**.png' + - '.github/workflows/**.yml' + +jobs: + png_optimized: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + sudo apt-get update + sudo apt install -y optipng + + - name: Check whether all png files are optimized + run: | + ./util/ci/check_png_optimized.sh diff --git a/games/devtest/mods/testabms/textures/testabms_after_node.png b/games/devtest/mods/testabms/textures/testabms_after_node.png index dab87594b..2a1efd53e 100644 Binary files a/games/devtest/mods/testabms/textures/testabms_after_node.png and b/games/devtest/mods/testabms/textures/testabms_after_node.png differ diff --git a/games/devtest/mods/testabms/textures/testabms_wait_node.png b/games/devtest/mods/testabms/textures/testabms_wait_node.png index a9bd9a36f..67ef96b6e 100644 Binary files a/games/devtest/mods/testabms/textures/testabms_wait_node.png and b/games/devtest/mods/testabms/textures/testabms_wait_node.png differ diff --git a/games/devtest/mods/testnodes/textures/testnodes_attachedwr_bottom.png b/games/devtest/mods/testnodes/textures/testnodes_attachedwr_bottom.png index 1a2e1e90e..9318c9454 100644 Binary files a/games/devtest/mods/testnodes/textures/testnodes_attachedwr_bottom.png and b/games/devtest/mods/testnodes/textures/testnodes_attachedwr_bottom.png differ diff --git a/games/devtest/mods/testnodes/textures/testnodes_attachedwr_side.png b/games/devtest/mods/testnodes/textures/testnodes_attachedwr_side.png index 382e2dafa..7701dc9e2 100644 Binary files a/games/devtest/mods/testnodes/textures/testnodes_attachedwr_side.png and b/games/devtest/mods/testnodes/textures/testnodes_attachedwr_side.png differ diff --git a/games/devtest/mods/testnodes/textures/testnodes_attachedwr_top.png b/games/devtest/mods/testnodes/textures/testnodes_attachedwr_top.png index 39ea67b8b..70976ca15 100644 Binary files a/games/devtest/mods/testnodes/textures/testnodes_attachedwr_top.png and b/games/devtest/mods/testnodes/textures/testnodes_attachedwr_top.png differ diff --git a/games/devtest/mods/testnodes/textures/testnodes_sign3d.png b/games/devtest/mods/testnodes/textures/testnodes_sign3d.png index e4ad9479f..d37a0de7e 100644 Binary files a/games/devtest/mods/testnodes/textures/testnodes_sign3d.png and b/games/devtest/mods/testnodes/textures/testnodes_sign3d.png differ diff --git a/games/devtest/mods/testtools/textures/testtools_particle_clip.png b/games/devtest/mods/testtools/textures/testtools_particle_clip.png index 5fb9ad09a..773e55e50 100644 Binary files a/games/devtest/mods/testtools/textures/testtools_particle_clip.png and b/games/devtest/mods/testtools/textures/testtools_particle_clip.png differ diff --git a/textures/base/pack/cdb_update_cropped.png b/textures/base/pack/cdb_update_cropped.png index 8161dd7e4..2285c8ffc 100644 Binary files a/textures/base/pack/cdb_update_cropped.png and b/textures/base/pack/cdb_update_cropped.png differ diff --git a/textures/base/pack/checkbox_16.png b/textures/base/pack/checkbox_16.png index 567151860..fa84ff0e3 100644 Binary files a/textures/base/pack/checkbox_16.png and b/textures/base/pack/checkbox_16.png differ diff --git a/textures/base/pack/checkbox_32.png b/textures/base/pack/checkbox_32.png index 00208a0f1..bc6b2721b 100644 Binary files a/textures/base/pack/checkbox_32.png and b/textures/base/pack/checkbox_32.png differ diff --git a/textures/base/pack/server_view_clients.png b/textures/base/pack/server_view_clients.png index 87b569f93..120067074 100644 Binary files a/textures/base/pack/server_view_clients.png and b/textures/base/pack/server_view_clients.png differ diff --git a/util/ci/check_png_optimized.sh b/util/ci/check_png_optimized.sh new file mode 100755 index 000000000..856262797 --- /dev/null +++ b/util/ci/check_png_optimized.sh @@ -0,0 +1,31 @@ +#!/bin/bash -e + +# Only warn if decrease is more than 3% +optimization_requirement=3 + +git ls-files "*.png" | sort -u | ( + optimized=1 + temp_file=$(mktemp) + echo "Optimizing png files:" + while read file; do + # Does only run a fuzzy check without -o7 -zm1-9 since it would be too slow otherwise + decrease=($(optipng -nc -strip all -out "$temp_file" -clobber "$file" |& \ + sed -n 's/.*(\([0-9]\{1,\}\) bytes\? = \([0-9]\{1,\}\)\.[0-9]\{2\}% decrease).*/\1 \2/p')) + if [[ -n "${decrease[*]}" ]]; then + if [ "${decrease[1]}" -ge "$optimization_requirement" ]; then + echo -en "\033[31m" + optimized=0 + else + echo -en "\033[32m" + fi + echo -e "Decrease: ${decrease[0]}B ${decrease[1]}%\033[0m $file" + fi + done + rm "$temp_file" + + if [ "$optimized" -eq 0 ]; then + echo -e "\033[1;31mWarning: Could optimized png file(s) by more than $optimization_requirement%.\033[0m" \ + "Apply 'optipng -o7 -zm1-9 -nc -strip all -clobber '" + exit 1 + fi +)