make_icon_pngs 737 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. # -*- mode: sh -*-
  3. if [ $# == 0 ]; then
  4. echo "$0 {appiconset} {master.png}"
  5. exit 1
  6. fi
  7. appiconset="${1}"
  8. contents_json="${appiconset}/Contents.json"
  9. cutbox_icon="${2}"
  10. # Contents.json filenames are expected to be in the format {size}.png
  11. # e.g. 128.png or anything with size as the first number in the filename
  12. # 128-cutbox.png, 64icon_image.png, 512filename_anything etc.
  13. jq '.images | .[] | .filename' $contents_json \
  14. | uniq \
  15. | tr -d '"' \
  16. | \
  17. while read file; do
  18. size=$(sed -E 's/^"([0-9]+).*/\1/' <<< "$file")
  19. # Any sips compatible input image
  20. sips -Z $size "$cutbox_icon" --out "$file"
  21. # We will replace the current images with the new ones (no undo)
  22. mv -v "$file" "$appiconset"
  23. done