Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flair validation + fixes #14191

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/flair.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Validate Flair

on:
push:
paths:
- 'public/flair/**'
pull_request:
paths:
- 'public/flair/**'

jobs:
validate-flair:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./bin/validate-flair public/flair/img/
50 changes: 50 additions & 0 deletions bin/validate-flair
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash -e

if [ -z "$1" ]; then
echo "Usage: $0 <path/to/flair/dir>"
exit 1
fi

exit_code=0

for img_file in "$1"/*; do
if [[ ! "$img_file" =~ \.webp$ ]]; then
echo "Not a WEBP: $img_file"
exit_code=1
continue
fi

dimensions=$(identify -format "%wx%h" "$img_file")

width=$(echo "$dimensions" | cut -d 'x' -f 1)
height=$(echo "$dimensions" | cut -d 'x' -f 2)

if [ "$width" -ne "$height" ]; then
echo "Not square: $img_file ($dimensions)"
exit_code=1

echo "Converting to square..."
max_dimension=$((width > height ? width : height))
convert "$img_file" -gravity center -background transparent -extent "${max_dimension}x${max_dimension}" "$img_file"
fi

if [ "$width" -lt 60 ] || [ "$width" -gt 100 ]; then
echo "Not between 60-100px: $img_file ($dimensions)"
exit_code=1

echo "Resizing to 100px..."
convert "$img_file" -resize 100x100 "$img_file"
fi

# animated WEBPs contain the string "ANMF" in the file
if grep -q "ANMF" "$img_file"; then
echo "Animated: $img_file"
exit_code=1
fi
done

if [ "$exit_code" -eq 0 ]; then
echo "✅ Images are OK"
fi

exit $exit_code
Binary file modified public/flair/img/activity.chess.webp
Binary file not shown.
Binary file modified public/flair/img/activity.lichess-horsey.webp
Binary file not shown.
Binary file modified public/flair/img/activity.lichess.webp
Binary file not shown.
Binary file modified public/flair/img/activity.shogi-bigsby.webp
Binary file not shown.
Binary file modified public/flair/img/activity.shogi-king.webp
Binary file not shown.
Binary file modified public/flair/img/nature.octopus-howard.webp
Binary file not shown.
Binary file modified public/flair/img/nature.xmas-tree.webp
Binary file not shown.
Binary file modified public/flair/img/objects.xmas-bell.webp
Binary file not shown.
Binary file modified public/flair/img/objects.xmas-candle.webp
Binary file not shown.
Binary file modified public/flair/img/objects.xmas-hat.webp
Binary file not shown.
Binary file modified public/flair/img/symbols.esperanto.webp
Binary file not shown.
Binary file modified public/flair/img/travel-places.earth-blue.webp
Binary file not shown.
Binary file modified public/flair/img/travel-places.wooden-ship.webp
Binary file not shown.
Loading