DEV Community

Cover image for Quickly Create App Icons by Resizing Your Main Image With a Bash Script
Kyra
Kyra

Posted on • Originally published at simplykyra.com

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 1024x1024 "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: 1024x1024, 512x512, 256x256, 128x128, 64x64, 32x32, and 16x16.

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.

Image shows three windows including the terminal, finder window, and preview with all the newly created images opened in it.

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.

Image shows the finder window overlapping with Xcode so I can easily drag and drop each one.

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!

$150K MiniMax AI Agent Challenge — Build Smarter, Remix Bolder, Win Bigger!

Join the $150k MiniMax AI Agent Challenge — Build your first AI Agent 🤖

Developers, innovators, and AI tinkerers, build your AI Agent and win $150,000 in cash. 💰

Read more →

Top comments (0)

Developer-first embedded dashboards

Developer-first embedded dashboards

Embed in minutes, load in milliseconds, extend infinitely. Import any chart, connect to any database, embed anywhere. Scale elegantly, monitor effortlessly, CI/CD & version control.

Get early access

Join the Real-Time AI Agents Challenge: $5,000 in Prizes!

Put yourself at the forefront of AI agent development and build with n8n's automation platform combined with Bright Data's web data infrastructure.

Check out the challenge

DEV is bringing live events to the community. Dismiss if you're not interested. ❤️