Skip to content

Instantly share code, notes, and snippets.

@AnonymerNiklasistanonym
Created February 9, 2024 07:43
Show Gist options
  • Save AnonymerNiklasistanonym/5e51d2dc0712696b0599a1e39da2bc13 to your computer and use it in GitHub Desktop.
Save AnonymerNiklasistanonym/5e51d2dc0712696b0599a1e39da2bc13 to your computer and use it in GitHub Desktop.
Replace certain rectangles on images with transparent areas
#!/usr/bin/env bash
# Replace certain rectangles on an osu! skin with transparent areas
# Based on: https://stackoverflow.com/a/64823099
# Used skin: https://drive.google.com/file/d/1pEWOl8hRefi9ZGCitIrKaso-K7jBgj9b/view (- Project HKttyCatz V1.0.0 -.osk)
for filename in ./scorebar-bg*.png; do
WIDTH=$(identify -format '%w' "$filename")
HEIGHT=$(identify -format '%h' "$filename")
if [[ "$filename" == *@2x* ]]; then
MULTIPLIER=2
else
MULTIPLIER=1
fi
echo "process [1] $filename: ${WIDTH}x${HEIGHT} (x$MULTIPLIER)"
convert "$filename" \( +clone -alpha extract -fill black -draw "rectangle $((10 * $MULTIPLIER)),$((50 * $MULTIPLIER)) $((92 * $MULTIPLIER)),$((115 * $MULTIPLIER))" \) -alpha off -compose copyalpha -composite "$filename"
done
# x1 1366x768: 10,50 92,115
# x2 2732x1536
for filename in ./scorebar-colour-*.png; do
WIDTH=$(identify -format '%w' "$filename")
HEIGHT=$(identify -format '%h' "$filename")
if [[ "$filename" == *@2x* ]]; then
MULTIPLIER=2
else
MULTIPLIER=1
fi
echo "process [2] $filename: ${WIDTH}x${HEIGHT} (x$MULTIPLIER)"
convert "$filename" \( +clone -alpha extract -fill black -draw "rectangle $((10 * $MULTIPLIER)),$((30 * $MULTIPLIER)) $((90 * $MULTIPLIER)),$((100 * $MULTIPLIER))" \) -alpha off -compose copyalpha -composite "$filename"
done
# x1 495x175: 10,30 90,100
# x2 990x350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment