Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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

- to get the same clarity as the python & Obj-C samples, I'd probably be approaching the same length.



Author here, the bash version is too beautiful: compact and clean! I will include it in the article if you're ok!


Sure.


You could easily make a quick slugify with `tr`:

    10a11
    >     name=$(echo $name | tr -cd '[:blank:][:alnum:]' | tr -s '[:blank:]' '-' | tr '[:upper:]' '[:lower:]')


You may be able to use sips instead of imagemagick.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: