#icons #icns #ico #cli #command-line-tool

yanked icon-pie

A simple command-line tool for generating application icons

0.1.4-beta Sep 6, 2019
0.1.3-beta Aug 29, 2019
0.1.0-alpha Oct 21, 2019

#8 in #icns

Download history 7/week @ 2024-09-23 36/week @ 2024-12-02 129/week @ 2024-12-09

165 downloads per month

Custom license

4.5MB
469 lines

Contains (Zip file, 1.5MB) distribution/icon-baker.tar

IconPie

Crate Minimum rustc version

A simple command-line tool to generate application icons from raster graphics or vector graphics images.

Quickly combine multiple images and create professional-looking icons for most versions of Windows, macOS, iOS & Linux.

Features

  • Simple interface.
  • Sane defaults for the domain of icon composition.
  • Supports outputting to stdout, allowing for piping.
  • Available as a single executable.

Overview

An icon consists of a set of entries. An entry is simply an image that has a particular size. For example, this is an icon that has a 32x32 entry, a 64x64 entry and a 128x128 entry:

Concepts

What does it do?

Notice that, in the example above, most entries are basically the same picture re-scaled to multiple sizes. IconPie simply automates the process of re-scaling the picture and combining those re-scaled entries into an icon.

How does it do it?

Re-scaling

When re-scaling pictures, IconPie preserves their original aspect-ratios. It also ensures that the all re-scaled images are square, by adding transparent borders if necessary. If the picture presents a transparent background, the transparency is preserved in the re-scaled images.

Adding Transparent Borders

Interpolation

For raster graphics (jpeg, png, ...), IconPie uses nearest-neighbor interpolation by default, optimizing for small-resolution images.

Furthermore, when using nearest-neighbor interpolation, it only up-scales images on an integer scale, preserving as much detail as possible.

Default Resample

You can choose to opt-out of the default interpolation scheme for raster graphics by specifying a resampling filter with the -r flag, as described in the Usage section.

For vector graphics (svg), IconPie always uses linear interpolation regardless of any specified resampling filter.

Usage

The formal docopt syntax for using IconPie is as follows:

$ icon-pie ((-e <file path> <size>... [-r (nearest | linear | cubic)])... (-ico | -icns | -png) [<output path>]) | -h | --help | -v | --version

  • -e <options> Specify an entry's source image, target sizes and resampling filter (optional).
  • -r <filter> Specify a resampling filter: nearest, linear or cubic. Defaults to nearest.
  • -ico [<output path>] Outputs to an .ico file. If no output path is specified the app outputs to stdout.
  • -icns [<output path>] Outputs to an .icns file. If no output path is specified the app outputs to stdout.
  • -png [<output path>] Outputs a .png sequence as a .tar file. If no output path is specified the app outputs to stdout.
  • -h, --help Help.
  • -v, --version Display version information.

Examples

Let's say you have the following files saved at your file system.

Source Files

We'll walk trought some practical examples of IconPie usage.

Simple Usage

Take big.svg, resize it to 32x32, 64x64 and 128x128. Then save it at icon.ico.

$ icon-pie -e big.svg 32 64 128 -ico icon.ico

Example 1

Sampling From Multiple Files

Take small.png, resize it to 32x32 and 64x64. Then take big.svg and resize it 128x128. Then combine the re-scaled entries in icon.icns.

$ icon-pie -e small.png 32 64 -e big.svg 128 -icns icon.icns

Example 2

Specifying a Resampling Filter

Take small.png, resize it to 32x32 and 64x64 using linear interpolation. Then take big.svg and resize it 128x128. Then combine the re-scaled entries in icon.tar as a png sequence.

$ icon-pie -e small.png 32 64 -r linear -e big.svg 128 -png icon.tar

Example 3

Support

Icon Formats

This are the file formats IconPie can output to:

  • ico
  • icns
  • png sequence (tar)

Icns Support

OSType Description Supported?
ICON 32×32 1-bit entry No
ICN# 32×32 1-bit entry with 1-bit mask No
icm# 16×12 1-bit entry with 1-bit mask No
icm4 16×12 4-bit entry No
icm8 16×12 8-bit entry No
ics# 16×16 1-bit mask No
ics4 16×16 4-bit entry No
ics8 16x16 8-bit entry No
is32 16×16 24-bit entry Yes
s8mk 16x16 8-bit mask Yes
icl4 32×32 4-bit entry No
icl8 32×32 8-bit entry No
il32 32x32 24-bit entry Yes
l8mk 32×32 8-bit mask Yes
ich# 48×48 1-bit mask No
ich4 48×48 4-bit entry No
ich8 48×48 8-bit entry No
ih32 48×48 24-bit entry Yes
h8mk 48×48 8-bit mask Yes
it32 128×128 24-bit entry Yes
t8mk 128×128 8-bit mask Yes
icp4 16x16 32-bit png/jp2 entry png only
icp5 32x32 32-bit png/jp2 entry png only
icp6 64x64 32-bit png/jp2 entry png only
ic07 128x128 32-bit png/jp2 entry png only
ic08 256×256 32-bit png/jp2 entry png only
ic09 512×512 32-bit png/jp2 entry png only
ic10 512x512@2x "retina" 32-bit png/jp2 entry png only
ic11 16x16@2x "retina" 32-bit png/jp2 entry png only
ic12 32x32@2x "retina" 32-bit png/jp2 entry png only
ic13 128x128@2x "retina" 32-bit png/jp2 entry png only
ic14 256x256@2x "retina" 32-bit png/jp2 entry png only

Image Formats

This are the formats IconPie can use as input:

Format Supported?
png All supported color types
jpeg Baseline and progressive
gif Yes
bmp Yes
ico Yes
tiff Baseline(no fax support), lzw, PackBits
webp Lossy(Luma channel only)
pnm pbm, pgm, ppm, standard pma
svg Limited

Svg Support

IconPie uses the nsvg crate to rasterize svg files. According to the authors of the crate:

Like NanoSVG, the rasterizer only renders flat filled shapes. It is not particularly fast or accurate, but it is a simple way to bake vector graphics into textures.

The author of icon-pie is inclined to search for alternatives to nsvg if inquired to. Help would be appreciated.

License

Licensed under MIT license(LICENSE-MIT or http://opensource.org/licenses/MIT).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.

Dependencies

~16–24MB
~384K SLoC