IconTools (extract single icons from iconset, html reference page)

I'm (constantly) working on my own iconset and found that a few tools would be very helpful for this.
(Note: Requires ImageMagick – see below.)

This script offers a) the one-click extraction and naming of all single icons from an iconset and b) the generation of an html page as an iconset reference including names and positions. Multiple sets in one .xml file and alternative "dark" icons are supported, but image formats other than PNG aren't.

:one: Extracting single icons

Since I'm designing the icons as one complete set in Inkscape, the export is just one image to embed in the DOpus iconset. However, sometimes I need the individual icons as well (eg. for use in dialog buttons) – and exporting them one by one is a pain. So this script allows you to do that more painlessly.

The command is: GenerateIcons MODE single XMLFILE "c:\\path\\file.xml"

The corresponding .png file must be present in the same folder. The script won't work on files inside a .zip/.dis file.

This will ask you to select a set from the .xml file and then create a subdirectory called "single" and in it all the individual icons with the names from the .xml, overwriting any existing files.

Depending on the number of icons, your system's speed etc. this may take a few seconds. Be patient; a popup will inform you when it's done. :smiley:

:two: Generating an HTML reference file

Another thing I keep needing is a lookup feature: What is that icon called? What row/column is it in? Or what does the "whatever" icon look like in that iconset? I know I can use dopus to achieve that but I wanted a simpler solution.
Using the amazing Fluent Style Icon Set by @skinz as an example, this is what that looks like:


(Note the extra info at the mouse position.)
...or with an active search:

The command for this: GenerateIcons MODE html XMLFILE {filepath$}

To change the background colors (eg. to match the ones in your own setup):
GenerateIcons MODE html XMLFILE {filepath$} COLORDARK #123456 COLORLIGHT #abcdef

This will create an .html file with the same name as the iconset. Open it in the browser, hover over an icon to see its data or use the search bar to, well, search. :wink:

:three: Installation

a) Download the script and install it as usual:

IconTools.osp (5.7 KB)

Note that it is not mandatory for the included template file (IconTools_template.html) to be residing in the Script Addins folder. Any other location (eg. User Data) is fine, just update the configuration.

b) Download and install ImageMagick. It's free and open source. There's quite a (confusing) choice on the download page; they offer a portable version as well in case you're like me and don't like installers. (I went with the Portable Win64 static at 8 bits-per-pixel component option.)
This tool has amazing capabilities but the learning curve is quite steep...

c) In DOpus, configure the script: It needs the locations of magick.exe and the template file.

d) Set up your buttons.

e) That's it. I hope. :thinking:


The "infrasctructure" around my scripts has grown over the years and it's not easy to extract just one stand-alone script, so I had to uglify :smile: it in a few places and to add a few helpers at the end of the file.
Note that the script extends JScript classes by adding polyfills: String.trim(), String.endsWith(), Array.forEach()

I'm sure the script offers lots of room for improvement and I might continue working on it, but for now it does what I need. I'd be happy if it helped someone else too...

5 Likes

Looks interesting.
Looking at the captures, for a moment I thought you had managed to emulate tooltips in a dialog. :smile:

Since the goal of the script is to 'extract' individual images from a DOpus iconset, the most logical thing for me would be to simply pass the path to a iconset, instead of having to manually decompress it first (this process should be handled internally by the script). Could you add that feature?

I wish... :smile: No, that was one of the reasons why I went the html way.

The in-iconset-handling has been on my list for a while, but it's not really a feature I've ever needed since all my iconsets are unpacked anyway. Before I started to add features I thought I'd see if anybody would even be interested at all.There is, apparently. :wink:
I'd like to add .ico output as well and an option to set the output path. But I think first I need to streamline the process of extracting stand-alone scripts from my collected works. I published this kind of spontaneously today.
I'll see what I can do...