• Stars
    star
    111
  • Rank 314,510 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command-Line version of TiCons for generating icons and splash screens for Titanium & Alloy projects.

TiCons CLI Appcelerator Alloy

Command-line and CommonJS module version of TiCons to generate icons and splash screens (aka launch images) for Appcelerator Titanium & Alloy apps.

NOTE: In Titanium 5.0 the DefaultIcon.png was introduced. See DefaultIcon for how TiCons handles this.

Prerequisites

Install npm

As global CLI:

[sudo] npm install -g ticons

As a dependency in your projects package.json:

{
  "name": "your-project",
  "dependencies": {
    "ticons": "*"
  }
}

Quick Start

TiCons can be used both as CLI and CommonJS module.

CLI

Hit ticons -h for full usage, but thanks to Smart Defaults this will work in most cases:

  • Detects if the CWD contains a classic or Alloy project, what platforms are targeted and then generates required icons using iphone/iTunesArtwork@2x as input:

    ~/myproject $ ticons icons
    
  • Detects if the CWD contains a classic or Alloy project, what platforms are targeted, if the app is locked to one orientation and then generates required splashes using [email protected] as input. If Android is targetted, 9-Patch images will be generated and the required theme.xml created for you if missing.

    ~/myproject ticons splashes
    
  • Detects if the CWD contains a classic or Alloy project, what platforms are targeted and then generates missing asset densities iphone/images as input. If both iOS and Android MDPI are targetted, images is used for both iOS and Android MDPI.

    ~/myproject ticons assets
    

You can specify diferent input (ticons icons myIcon.png) and options to override the defaults for fine-tune the results to your liking.

Module

For the module use the full option names as properties in the first argument. Specify a callback that accepts an error and result as the second argument.

var ticons = require('ticons');

ticons.icons({
	input: 'icon.png',
	outputDir: 'foo',
	platforms: ['ipad','android'],
	classic: true
}, function (err, output) {
	
	if (err) {
		throw err;
	}
	
	console.log('generated files: ' + output.join(', '));
});

Smart defaults

If the outputDir (or -d or CWD if missing) contains a project, TiCons will figure out lots of smart defaults:

  • If the project is classic instead of Alloy.
  • What platforms are targetted (<deployment-targets>).
  • If the app is locked to one orientation (UISupportedInterfaceOrientations etc.).
  • The SDK version used (for DefaultIcon).

In the CLI, you can add the trace (-t) option to see exactly what configuration is used based on your options and the smart defaults.

Splashes

Storyboard Launch Screens

Since 0.21 TiCons can also generate LaunchLogo*.png files that Titanium can use to generate storyboard launch images. Since Titanium falls back to DefaultIcon*.png for this you only need these if you want it to be different from your app icon. Just add the --storyboard option to have TiCons generate Launch Logos instead of regular splash images.

9-Patch

By default TiCons generated 9-Patch splashes for Android. You can disable this using --no-nine (-n) option.

Understand that TiCons will fit your input image inside the not-long-port-? dimensions and then add 9-Patch black pixels to indicate that only the outer most line of pixels on each side should be stretched. For best results use a square image of 1600x1600 pixels that includes the minimal amount of padding, making sure that the outer most pixels are all of the same color.

Since 0.6.0 the generated images are named background.9.png so that if you don't use a custom theme and build against Titanium 3.3.0.GA or later the splash will automatically be loaded. If you're using a custom theme, please see the docs on how to use the generated splash background. Also make sure the assets android directory does not contain any old splashes, because else they will take precendece.

Cropping

By default on all platforms and on all with --no-nine, the input image will be first resized to cover the target dimension and then cropped to fit exactly. For best results use a 2208x2208 image that has its main artwork in the center 1100x1100 pixels. Anything outside of that box might be cropped depending on the width/height ratio of the target splashes.

Containing

Since 0.10.0 if you give --width <width> and --height <height> then TiCons will try not to crop that area, taken from the centre of the input image. This will let you protect the main content (logo) of the image. Depending on the size of your input image, it might not be possible to both contain this content as well as fit in the input image. In that case, it will give a warning telling you what the size of the input image needs to be and then continue to still crop as usual.

Filling

Use --no-crop (-c) to resize the input image to fit instead of cover the target dimension. The remaining area is then filled by repeating the outer most lines of pixels on each side, basically simulating 9-Patch, but then for all platforms. For best results, see the best practice for 9-Patch and use an image of at least 2208x2208 pixels.

Locale

You can use the locale (-l) option to specify a 2-letter locale. Only splashes supporting locale paths will be generated when you use this option.

Fix or not to Fix

By default, some errors in the Appcelerator specs related to iOS and Android splash screen dimensions are fixed. Use -no-fix to disable this.

Icons

Radius

If you use the iTunesArtwork@2x as input for Android and other platforms icons, you might want to round the corners a bit as only iOS does this for you. Simply pass a percentage between 0 and 50 to --radius (-r). Seems like 18 is about what it was for iOS6.

DefaultIcon

Since Titanium 5.0 you no longer need to provide all required iOS icon sizes. A single DefaultIcon.png in the root of your project will do. In Titanium 5.1 support for Windows was added. You can have a platform specific DefaultIcon-ios.png or DefautlIcon-windows.png as well, since for iOS it needs to be 24-bit (no alpha).

TiCons will automatically generate the right icons based on the sdk-version option. It defaults to the SDK version found in your tiapp.xml or else the latest. If you have only iOS or Windows as the target platforms for your project/TiCons it will add the platform-specific suffix to the filename.

Assets

The assets command is assumes the following directories:

  • iphone/images for iOS Retina (@2x) and HD Retina (@3x).
  • images for iOS non-retina, Android MDPI and other platforms.
  • android/images/res-* for other Android densities.

Just run ticons assets in your project root and it will use (HD) Retina images or Android xxxhdpi or xxhdpi images to generate the others, unless the target image is newer, a 9-patch version is found or the target dpi is higher then the input.

You can also point to a specific image or directory by adding an argument like ticons assets Resources/images/iphone. TiCons will try to determine the input dpi based on the location.

Use any input and output

Since 0.22 you can now set the exact input DPI with the --orig-dpi option, the input file or folder no longer needs to be under the output and if the output path ends with Resources or assets, TiCons will work relative to that. This allows you to use any input and write to any output, e.g.:

ticons assets ./my-hires-images ./app/widgets/my-widget/assets --orig-dpi @3x

Widgets

You can also run ticons assets in a widget root, which will cause TiCons to read the target platforms from widget.json instead of tiapp.xml.

Roadmap

Feel free to fork and contribute towards resolving requests.

Tests Travis

  1. Install node.js.
  2. Install grunt: [sudo] npm install -g grunt-cli
  3. Clone the repo: git clone https://github.com/fokkezb/ticons-cli.git && cd ticons-cli && npm install
  4. Run tests: grunt test

Issues

Please report issues and features requests in the repo's issue tracker.

License

Distributed under MIT License.

More Repositories

1

UTiL

Collection of utility scripts for Titanium (Alloy).
JavaScript
220
star
2

RESTe

A simple JavaScript REST / API helper for Titanium
JavaScript
125
star
3

nl.fokkezb.drawer

[UNMAINTAINED] An Alloy widget wrapping the NappDrawer module for Facebook-like sliding side menus.
JavaScript
84
star
4

ti-html2as

HTML 2 AttributedString converter for Titanium
JavaScript
64
star
5

tn

Appcelerator & Titanium CLI wrapper to save you keystrokes.
JavaScript
64
star
6

nl.fokkezb.form

[UNMAINTAINED] Alloy TableView Form Widget
JavaScript
43
star
7

AlloyXL

JavaScript
31
star
8

com.jasonkneen.slidemenu

Slide menu for iOS and Android
JavaScript
29
star
9

TiTh

Titanium Alloy theme switcher with theme-based tiapp.xml support
JavaScript
29
star
10

ti-i18n

CLI to manage internationalizing your Titanium app
JavaScript
24
star
11

TiCh

TiCh(ange)- change TiApp.xml properties via the CLI for building multiple apps from one codebase
JavaScript
21
star
12

todo-app

Simple Todo app for Titanium
JavaScript
19
star
13

nl.fokkezb.toast

Another toast message widget for Titanium Alloy
JavaScript
18
star
14

nl.fokkezb.colorpick

iOS ColorPicker wrapper for Titanium
Objective-C
17
star
15

kueue

javascript background task / queue manager
JavaScript
14
star
16

magicpie

MagicPie wrapper for Titanium
Objective-C
13
star
17

installr

CLI for installrapp.com
JavaScript
12
star
18

ti-stealth

Remove console logging from your Titanium apps.
JavaScript
12
star
19

TiCons-Server

Server wrapper for the TiCons CLI and NPM Package
HTML
11
star
20

appc-npm

Package components for Appcelerator Titanium, Alloy and Arrow projects for distribution via NPM.
JavaScript
10
star
21

com.jasonkneen.tabdemo

Direct replacement for Titanium TabGroup for Android using the Alloy "module" attribute
JavaScript
10
star
22

mocx

A JavaScript Backbone helper for Titanium Alloy
JavaScript
8
star
23

TiExpansionFiles

An Android module that supports Play Store expansion (OBB/ZIP) files, downloading and direct reading of compressed files.
Java
6
star
24

com.jasonkneen.tabfonts

Alloy widget to add custom fonts / text colors to TabGroup Icons
JavaScript
6
star
25

com.jasonkneen.dynamicTSS

Widget for Titanium ALloy MVC Framework for Dynamic Portrait / Landscape TSS styling
JavaScript
6
star
26

nl.fokkezb.color

An Titanium Alloy color picker widget
JavaScript
5
star
27

TiStore

Utils for iOS AppStore Search API
JavaScript
4
star
28

ti-code-fetch-atom

Code Fetch Atom Plugin that look up templates in http://github.com/jasonkneen/ti-code-templates
JavaScript
2
star
29

ti-code-templates

Repo of templates used for http://github.com/jasonkneen/ti-code-fetch-atom
JavaScript
2
star
30

com.jasonkneen.fileDownload

Alloy Widget to provide file download and progress bar
JavaScript
2
star
31

TiMote

Executing code in a Titanium app that is hosted externally
JavaScript
2
star
32

cargo

Simple Object Manager for Javascript, written for Titanium projects
JavaScript
1
star
33

ti.geolocation

Example of an iOS implementation of geolocation, background geolocation.
JavaScript
1
star