Skip to content

Instantly share code, notes, and snippets.

@tkafka
Created July 19, 2024 12:53
Show Gist options
  • Save tkafka/24b2c3f5ccb874517b3b3c71e1123dbf to your computer and use it in GitHub Desktop.
Save tkafka/24b2c3f5ccb874517b3b3c71e1123dbf to your computer and use it in GitHub Desktop.
#!/bin/bash
# Directory of PNG images to process
DIRECTORY="./fastlane/screenshots"
# Check if mogrify command is available
if ! command -v mogrify &>/dev/null; then
echo "mogrify could not be found. Please install ImageMagick (brew install imagemagick)."
exit 1
fi
# Loop through all PNG images in the specified directory
find "$DIRECTORY" -type f -name '*.png' ! -type l | while read -r image; do
echo "Removing transparency from $image ..."
# Remove transparency by setting a black background and then flattening the image
mogrify -format png -background black -alpha remove -alpha off "$image"
done
echo "All images processed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment