How to Manage and Automate Your Mobile Image Assets
Mobile device resolution has become an increasing point of interest for the consumer. As a result, phone manufacturers have been packing in more pixels into smaller screens. We are now seeing 5″ phones with the same rendered pixel count as our 27″ monitors. This makes the experience of using our devices uber-crisp, but also makes managing the assets necessary to scale these applications more time consuming. This post will explore techniques to save time and effort when creating assets.
Why this is Necessary
Not long ago, most computers, tablets, and phones had a similar pixel density. This allowed designers to use the same assets within each application without looking different. Once larger, higher density screens became popular, more assets were necessary. A maintenance nightmare was born.
Creating the three assets for iOS and four assets for Android can be time consuming and tedious. That pales in comparison to naming and routing files into their desired directories. A variety of ways exist to automate resizing images, moving files and renaming filenames. Most fall short in one way or another either being too specific to a process or being inflexible.
Pixels (px) have long been the way to measure layouts on the web and for mobile, with a pixel per inch ratio of 72:1. With the advent of these high density displays we are now passing 216:1 as a standard. Mobile operating systems now use complex algorithms to determine the density of a display, utilizing and resizing the graphics on the fly for that specific device, creating a new measurement called the device pixel, or dp.
Each mobile operating system has different naming and directory structures for assets. Apple’s iOS uses filenames with ‘@2x’ and ‘@3x’ suffixes to specify high-density graphics. Google’s Android OS uses a directory structure where the assets divide into ‘drawable-mdpi’, ‘drawable-hdpi’, ‘drawable-xhdpi’, ‘drawable-xxhdpi’, and ‘drawable-xxxhdpi’ folders, with each assets sharing a common filename.
Houston We Have Vectors
You may be thinking, why not just stick with vector formats? Both iOS and Android support vector graphics, iOS with PDFs, and Android with SVG. One thing to consider is the built in scaling that occurs across devices. Scaling can result in undesirable pixel rendering. If this is the case, it maybe be easier to control with scaled raster images.
The goal of this workflow is to make it as easy to generate one hundred scaled and routed assets as it was to generate one. The initial generation and future revisions of the assets are now automated. The basis for this workflow is consolidating all of the assets into a single file. This allows the software to do the heavy lifting of sizing, naming, and routing the new files. Designers now also have an overview of all of the visual assets, allowing them to globally control colors, padding, and aesthetics.
Android & iOS Asset Workflow
The following details how to better automate your design workflow. Simplify the generation of a full asset library to a few clicks while following standard iOS and Android naming conventions.
- Mac OSX
- Adobe Illustrator (CS6/CC)
- Adobe Photoshop (CS6/CC)
Installing Scripts and Services
- Download and open the zip file from our designer’s GitHub Page
- Move the JSX files to Applications > Photoshop > Presets > Scripts
- Open the ATN files to install in Photoshop
- Relaunch Photoshop
- Open the Services files to install them
Here are some brief descriptions of what these files are doing:
- Create Android Launcher Icons
Takes a 1024 x 1024 PNG and creates all associated app icons using Android’s naming conventions
- Create iOS Launcher Icons
Takes a 1024 x 1024 PNG and creates all associated app icons using iOS naming conventions
- PS Rename Layers
Renames the Photoshop layer based on the asset’s filename
- Create Android Assets
Takes a XXXHDPI image and creates M/H/X/XX/XXXHDPI assets using Android naming conventions and file structure
- Create iOS Assets
Takes a 3x image and creates 1/2/3x assets using iOS naming conventions
- AI MultiExporter
Adds ability to export Illustrator artboards as PDF files (for using vector assets on iOS)
Mobile Asset Automator
- Contains two actions which run the layer renaming script, then either one of the Android or iOS specific asset assembly scripts
- Contains two actions that will create Android or iOS specific app/launcher icons
- Remove Asset Prefix
Removes the ‘assets_’ prefix from the initial 3x assets created from Illustrator
- Remove Orignal Asset
Removes the original asset files from the directory
- iOS Consolidator
Moves all files from subdirectories into root directory
- Android Consolidator
Merges the subdirectories within a directory that share the same name
Initial Asset Setup & Automation
- Create or merge your assets into a single Illustrator document using multiple Artboards
- Save this file as ‘assets.eps’
- The name is actually important, as we will use a script to remove this prefix from the images
- Rename each Artboard based on the desired asset name
- File > Export to a new directory named ‘assets’, using ‘Format: PNG’ and select ‘Use Artboards’
- Select ‘Resolution: Other’
- For iOS set to ‘216 PPI’ (3x 72dpi)
- Android set to ‘288 PPI’ (4x 72dpi)
- Right/Control click on the parent ‘assets’ directory and run Service > Strip Asset Prefix
- This will remove the ‘assets_’ prefix from all your images
- File > Automate > Batch
- Select ‘Set: Asset Automator’, ‘Action: Create iOS Assets’ or ‘Create Android Assets’, ‘Source: Folder’, select your ‘assets’ directory containing your assets
- Press OK
- This will run the scripts on all your assets in your folder, creating a directory for each with the proper name associated to each
- Right click on the parent directory and run Service > Cleanup Original Assets
- With the original assets removed, the resized assets remain in the directory.
Wrapping them up
Consolidating your assets into a single directory may be desirable. Developers can replace the whole asset directory instead of individual assets one by one.
- Right/Control click on the parent directory and run Service > iOS Consolidator
- This moves all the assets into the root directory and removes the empty subdirectories
- Select all the asset directories within the parent directory
- Right/Control click on the selected directories and run Service > Android Consolidator
- Select a destination for the consolidated files
- Trash original directory
And that’s it, you now have a full set of assets ready for production.
To generate our home screen application assets, we need a single 1024px x 1024px PNG file named ‘app-icon.png’.
- Actions > Mobile Asset Automator > Create Android Launcher Icons or Create iOS App Icons
- Select app-icon.png and click Open
This will create and structure your application icons in the same location as your app-icon.png file.
Original Sources & Scripts
Rename Photoshop Layer as Filename
Export Layer as iOS 3x, 2x, 1x assets
Export Layer as Android XXHDPI, XHDPI, HDPI, MDPI, and LDPI assets
Consolidate Images using Automator Merge Folders AppleScript