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

Heads branding: add optimize_grayscale_bootsplash.sh and modify all Heads grayscale bootsplashes with it #1720

Closed
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
Binary file modified branding/Heads/ThePlexus-bootsplash-1024x768-DonateQrCode.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 branding/Heads/ThePlexus-bootsplash-1024x768.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 branding/Heads/ThePlexus-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions branding/Heads/optimize_grayscale_bootsplash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Function to check if an image is effectively grayscale
is_effectively_grayscale() {
local image="$1"
local colors=$(identify -format "%k" "$image")
local type=$(identify -format "%r" "$image")
[[ "$type" == *"Gray"* ]] || [[ "$colors" -le 256 ]]
}

# Function to analyze the image
analyze_image() {
local image="$1"
echo "Analyzing: $image"

identify -verbose "$image" | grep -E "Image:|Geometry:|Colorspace:|Type:|Depth:|Colors:|Filesize:"

echo "------------------------"
}

# Function to optimize the bootsplash image
optimize_bootsplash() {
local input_image="$1"
local temp_image="${input_image}.temp"

convert "$input_image" \
-colorspace Gray \
-define jpeg:extent=20KB \
-quality 98 \
-dither Riemersma \
-strip \
"$temp_image"

mv "$temp_image" "$input_image"
echo "Optimized image: $input_image"
}

# Main script
for input_image in *.jpg *.jpeg; do
# Check if the file exists
if [[ -f "$input_image" ]]; then
echo "Processing: $input_image"
analyze_image "$input_image"
if is_effectively_grayscale "$input_image"; then
echo "Optimizing effectively grayscale image: $input_image"
optimize_bootsplash "$input_image"
analyze_image "$input_image"
else
echo "Skipping non-grayscale image: $input_image"
fi
fi
done