Skip to content

Instantly share code, notes, and snippets.

@martinpeck
Last active July 29, 2020 15:57
Show Gist options
  • Save martinpeck/45e326ddca3e653a4bb9bd4693bcce18 to your computer and use it in GitHub Desktop.
Save martinpeck/45e326ddca3e653a4bb9bd4693bcce18 to your computer and use it in GitHub Desktop.
Some Useful Scripts for iMessage Sticker Creation

These two scripts can help when building assets for iMessage sticker packs.

WARNING

  • Both scripts worked at the time I authored them, for my very specific needs (taking 1024x1024 PNG original art files, and resizing them on my MacBook).
  • Both scripts use convert which is installed as part of ImageMagik. https://apple.stackexchange.com/questions/335635/where-is-the-convert-command-in-macos
  • The AppStore requirements change frequently (as new devices are launched) and I've not updated these scripts in a very long time

build_icons.sh

Generates the icons required for the App Store

build_icons.sh should be run with a single parameter, which is the path to a 1024 x 1024 sized PNG file. It will generate the various icon sizes that the Apple Store wants.

resize.sh

Generates resized sticker assets.

resize.sh assumes that it's being run in a folder that has a subfolder, called 1024. Within the 1024 folder it expects to find 1024x1024 PNG files. It will then create 2 additional subfolders, filled with resized images.

License

Copyright 2020 Martin Peck

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#!/bin/bash
# takes src.png (assume 1024x1024) and creates the icons required for an iMessage sticker pack
# run on mac: sh build_icons.sh src.png
convert $1 -resize 1024x768^ -background white -gravity center -extent 1024x768 messages-app-store-1024x768.png # aspect ratio 1.333
convert $1 -resize 96x72^ -background white -gravity center -extent 96x72 messages-32x24@3x.png # aspect ratio 1.333
convert $1 -resize 64x48^ -background white -gravity center -extent 64x48 messages-32x24@2x.png # aspect ratio 1.333
convert $1 -resize 81x60^ -background white -gravity center -extent 81x60 messages-27x20@3x.png # aspect ratio 1.353
convert $1 -resize 54x40^ -background white -gravity center -extent 54x40 messages-27x20@2x.png # aspect ratio 1.350
convert $1 -resize 148x110^ -background white -gravity center -extent 148x110 messages-ipad-pro-74x55@2x.png # aspect ratio 1.345
convert $1 -resize 134x100^ -background white -gravity center -extent 134x100 messages-ipad-67x50@2x.png # aspect ratio 1.340
convert $1 -resize 58x58^ -background white -gravity center -extent 58x58 ipad-settings-29x29@2x.png # aspect ratio 1.000
convert $1 -resize 180x135^ -background white -gravity center -extent 180x135 messages-iphone-60x45@3x.png # aspect ratio 1.333
convert $1 -resize 120x90^ -background white -gravity center -extent 120x90 messages-iphone-60x45@2x.png # aspect ratio 1.333
convert $1 -resize 87x87^ -background white -gravity center -extent 87x87 iphone-settings-29x29@3x.png # aspect ratio 1.000
convert $1 -resize 58x58^ -background white -gravity center -extent 58x58 iphone-settings-29x29@2x.png # aspect ratio 1.000
#!/bin/bash
mkdir -p 408
for f in ./1024/*.png
do
filename=$(basename "$f")
convert $f -resize 408x408 ./408/${filename%.png}_408.png
done
mkdir -p 618
for f in ./1024/*.png
do
filename=$(basename "$f")
convert $f -resize 618x618 ./618/${filename%.png}_618.png
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment