by

I’ve made some improvements to the assets command of the popular TiCons CLI and Website. You can now generate image assets for Classic and Alloy apps, widgets, and themes and use any file or folder as input.

Website

On the website you’ll notice a new Assets output type and tab. You can not combine Assets with the other two output options. If your input filename has a @2x or @3x TiCons will auto-detect its density. For other filenames you need to select the original (input) density under the Assets tab. Use the Global tab to determine what assets densities will be generated.

CLI

The CLI is always one step ahead of the website and allows you to generate the missing densities for all images in your project or a specific folder. Until this version you needed to run it from the root of your app or pass the path of a high DPI asset in the project.

With this new version both the input and output can also be an asset (folder) of an Alloy widget or theme. It can even be some random folder. Just specify the original (input) density with --orig-dpi. If you use a single file as input and it has @2x or @3x in the filename TiCons can auto-detect the DPI.

Examples

Use the highest DPI available app assets and generate the others:

ticons assets

Do the same for assets of a theme:

ticons assets app/themes/my/assets

Or a widget:

ticons assets app/widgets/my/assets

Use a folder of xxhdpi images (with no @2x in their filenames) on your desktop and output to a theme under some project:

ticons assets ~/Desktop/src/images ~/projects/flashlight/app/themes/red/assets --orig-dpi @2x

NOTE: As you can see you can now also use @2x, @3x and even retina or retina-hd as DPI aliases.