Quickly Create App Icons by Resizing Your Main Image With a Bash Script

Quickly Create App Icons by Resizing Your Main Image With a Bash Script

I just wanted to start out by saying that this is an abridged version of my original published version from June 4, 2023 that you can find on my website here.

When I first get excited about a new app idea I like to create a new project and I enjoy creating a new app icon so I’m excited seeing it on my phone and developing the idea. That said, I hate going through and resizing the image multiple times to generate all the differently sized images that Apple requires. This is made even worse if there’s a minor design detail that needs to be corrected or even if I want to justify updating the icon as I have to go through the entire process all over again.

Thus I needed to come up with a way to make, at least, the image resizing quicker and this script solves it! I’ve saved my script in its entirety to a Github Gist which you can find here.

This script works by taking in your image file, confirming it’s a square, and then resizing it to seven unique dimensions each with its filename showing its particular size as it’s appended to the beginning of its name. As each dimension is dictated by it’s own line (so for example the 1024 by 1024 size is created with: magick “$1” -resize 1024×1024 “1024 – $1”) you can easily update the script to include new ones or remove obsolete ones. Currently the script outputs the resized image at the following seven dimensions: 1024×1024, 512×512, 256×256, 128×128, 64×64, 32×32, and 16×16.

When making my app icon I try to make an app icon at least as large as the largest size I’d need so in my case the minimum would be 1024 by 1024. Once the icon is made I call my script and pass in the app icon image’s filename createAppIcons.sh myImg.jpeg and, once executed, all the newly resized images are in the directory with my original one.

With the images made I move the finder window over to Xcode and drag each individual image over to its corresponding spot in the assets app icon window.

And with that the app icon is ready to go… and the script is ready to speed up the process the next time I need to switch it out.

Hope this helps you out and you’re having a great day!

That said, if you want more details about this script or even have it broken down and explained better than the Github Gist above then you can check out my original and longer version of this post from June 4, 2023 where explain it all in more detail including it’s background, requirements, and all the in depth information you’d need!

Leave a Reply

Your email address will not be published. Required fields are marked *