Sugar-iconify

From OLPC
Revision as of 04:10, 21 March 2008 by Eben (talk | contribs) (New page: The <tt>sugar-iconify.py</tt> script converts SVGs into the format required for Sugar icons, adding the necessary stroke and fill entities. This is a Python scri...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The sugar-iconify.py script converts SVGs into the format required for Sugar icons, adding the necessary stroke and fill entities. This is a Python script, and as such requires Python to run.

Usage
sugar-iconify.py [-deghpv] [-s stroke_hex] [-f fill_hex] [-m | -i ] -[o directory] input.svg
Description
This script will create Sugar-compatible SVG icons from input.svg by adding the appropriate stroke and fill entities. It has two primary modes of operation: single-icon and icon set. For additional information about creating an SVG suitable for passing as the input to this script, see the tutorial on Making Sugar Icons.
Single-icon: The default operation creates a single sugar icon — for instance an activity icon — from the input SVG. By default, the Sugarized icon will be written to a new file named input.sugar.svg, optionally in the output directory specified with -o. By invoking the -i option, the input file will be overwritten in place.
When run, the script attempts to determine the proper hex values for the stroke and fill entities, and asks for confirmation before proceeding. You can preemptively accept this guess with -g, but do so with caution as the proper values cannot be determined with 100% confidence; we strongly recommend against using this in conjunction with the -i option. Should the script be unable to determine the proper entities, you can specify the correct stroke and fill hex values to replace using the -s and -f flags, respectively. Finally, for activity icons, you may find it convenient to apply the recommended default stroke and fill colors (#666666, #FFFFFF) to the output SVG with -d, which will make your icon match the visual style of uninstantiated activities within the UI, as well as the others posted on the wiki.
Icon sets: Activity developers may require many icons for placement in toolbars and elsewhere in their activities. To make the process of creating and exporting large numbers of icons, this script provides a multiple-export feature. When the -m option is passed, the script will export an entire set of icons from a single input SVG — one for each top level group within it. The resulting files will each contain all of the appropriate stroke and fill entities, and assume the name of the id given to the group that defined it.
In some cases, you may desire to update a single icon, or a subset of the icons defined within a given SVG. To do so, pass a pattern to the script with -p, and only those icons which match the pattern will be exported.
Options
-s    [hex] Hex value to replace with stroke entity
-f    [hex] Hex value to replace with fill entity
-d    Apply default color entities (#666666, #FFFFFF) to output
-e    Do not insert entities for strokes and fills
-g    Automatically accept guesses for stroke and fill entities
-h    Display this help message
-i    Modify input file in place, overwriting it; overridden by -m
-m    Multiple export; export top level groups as separate icons
-o    [directory] The preferred output directory
-p    [pattern] Only export icons whose name contains pattern
-v    Verbose
Examples
To do a simple single activity icon conversion, automatically applying the suggested default colors to the output:
      sugar-iconify.py -d activity-hello_world.svg
If the script cannot infer the proper stroke and fill values (and assuming your icon has red stroke, green fill):
      sugar-iconify.py -d -s '#FF0000' -f '#00FF00' activity-hello_world.svg
To export an icon set, resulting in a separate icon for each top level layer/group in input.svg:
      sugar-iconify.py -m toolbar_icons.svg
By adding the -p flag, you can export a subset of the total icon set by name (eg. edit-copy, edit-paste, edit-...):
     sugar-iconify.py -m -p edit toolbar_icons.svg
For detailed feedback about the entity replacements being made, add -v:
     sugar-iconify.py -dv input.svg
To overwrite the input file, use -i; otherwise the output file will be named input.sugar.svg:
     sugar-iconify.py -di input.svg