3 ms·
Decided to give it a shot in bash. #!/bin/bash set -eu curl -s "https://raw.githubusercontent.com/manbolo/appicon/master/mask.png" >"icon_mas
by gatehouse 12y ago
Decided to give it a shot in bash.
#!/bin/bash
set -eu
curl -s "https://raw.githubusercontent.com/manbolo/appicon/master/mask.png" >"icon_mask.png"
for app_id in "$@"
do
metadata=$(curl -s "http://itunes.apple.com/us/lookup?id=$app_id")
icon_url=$(echo $metadata | jq -r ".results[0].artworkUrl512")
name=$(echo $metadata | jq -r ".results[0].trackCensoredName")
icon_base="icon_$name"
curl -s "$icon_url" >"$icon_base.png"
convert "$icon_base.png" "icon_mask.png" -compose copy-opacity -composite "$icon_base.png"
for size in 1024 512 120 114 60 57
do
convert "$icon_base.png" -resize "${size}x${size}" "${icon_base}_${size}x${size}.png"
done
done
rm icon_mask.png
Run like
./appicon.bash 400274934 598581396
Notes
- didn't replicate the slugify
- dependencies: imagemagick, jq
- here without spaces: http://pastebin.com/yBPwHwdk http://pastebin.com/yBPwHwdk
- to get the same clarity as the python & Obj-C samples, I'd probably be approaching the same length.
- yesbabyyes 12y agoYou could easily make a quick slugify with `tr`: 10a11 > name=$(echo $name | tr -cd '[:blank:][:alnum:]' | tr -s '[:blank:]' '-' | tr '[:upper:]' '[:lower:]')
- jicea 12y agoAuthor here, the bash version is too beautiful: compact and clean! I will include it in the article if you're ok!
- gatehouse 12y agoSure.
- js2 12y agoYou may be able to use sips instead of imagemagick.