How to make your own icon packs

You need:

[ul]
[li] montage.exe - grab it from a portable version of ImageMagick ftp://ftp.imagemagick.org/pub/ImageMagick/binaries/
e.g. ImageMagick-7.0.3-7-portable-Q16-x64.zip
You can just extract the montage.exe directly, no need for anything else

[/li]
[li] (optional) zip.exe - get it from Info-zip ftp://ftp.info-zip.org/pub/infozip/win32/
e.g. zip231xn-x64.zip
You only need zip.exe from here.

[/li]
[li] Attached doicons.bat

[/li]
[li] Various icons you want to use from wherever you want:
e.g. flaticon.com/packs/interface-icon-assets
Rename them to match Directory Opus icon names if you want to use them to override standard icons by default[/li][/ul]


Instructions:

[ul]

[li] Put montage.exe, zip.exe, doicon.bat and your icons somewhere useful on your machine, so you have:
montage.exe
zip.exe
doicons.bat

  • bunch of icons

    [/li]
    [li] Use doicon.bat file in the same location, and run it like this:
    doicon.bat sourcefiles destinationname
    for example
    doicon.bat *.png MyAmazingIcons

    [/li]
    [li] Watch with amazement as your icons get squished into a 22x22 version and a 32x32 version and wrapped up into a Directory Opus .dis file

    [/li]
    [li] If you didn't bother getting zip.exe then you will receive:
    MyAmazingIcons.xml
    MyAmazingIcons-22.png
    MyAmazingIcons-32.png
  • you'll need to zip these up yourself and rename the resulting zip file to .dis, which Directory Opus can then use

    [/li]
    [li] Import into Directory Opus

    [/li]
    [li] PROFIT!![/li][/ul]


    Hope this comes in useful to someone!

    [ul]
    [li] 2016-11-23 Fixed error where zipped file would contain paths, and added a 1px border around the tiles[/li]
    [li] 2016-11-23 Updated batch file so that it doesn't include the -22.png and -32.png inside themselves.[/li][/ul]
    doicon.zip (840 Bytes)

Nice idea, but it adds lines for "test-22.png" and "test-32.png" to "test.xml" and "test-22.png" will appear as an icon in "test-32.png". Montage.exe should probably create these images outside the source folder.

Very true, I'll update

Edit: I've fixed this

You can run the batch from a button type "MSDOS batch function". This button code requires montage.exe and optionally zip.exe located in a path thats present in the PATH environment variable of windows. Otherwise you'll have to provide the path to montage.exe in line 8 and 9 and for zip.exe in line 47. Montage exe will create the images in %temp% and they are moved to sourcepath when writing the XML was finished. You will be asked for the required values for files and the name of the iconset by a dialog.

[code]@externalonly
@runmode hide
@set files = {dlgstring|Select files:|*.png}
@set name = {dlgstring|Enter name of Iconset:}
cd {sourcepath}
chcp 65001
@echo off
setlocal EnableDelayedExpansion

montage {$files} -geometry 20x20+1+1 -tile 16 -background transparent %temp%\{$name}-22.png
montage {$files} -geometry 30x30+1+1 -tile 16 -background transparent %temp%\{$name}-32.png

echo. > {$name}.tmp
set row=1
set col=1
for %%i in ({$files}) do (  
    echo         ^<icon row="!row!" col="!col!" name="%%~ni"/^>                           >> {$name}.tmp
    set /A col=col+1
    if !col! GTR 16 (
        set col=1
        set /A row=row+1
    )
)
echo. >> {$name}.tmp

echo ^<?xml version="1.0" encoding="UTF-8"?^>                                             > {$name}.xml
echo ^<iconset name="{$name}"^>                                             	      >> {$name}.xml
echo ^<display_name^>{$name}^</display_name^>                                             >> {$name}.xml
echo      ^<copyright^>^</copyright^>                                                     >> {$name}.xml
echo      ^<artist^>^</artist^>                                                           >> {$name}.xml

echo      ^<set filename="{$name}-22.png" height="22" size="small" width="22"^>           >> {$name}.xml
type {$name}.tmp >> {$name}.xml
echo      ^</set^>                                                                        >> {$name}.xml

echo      ^<set filename="{$name}-32.png" height="32" size="large" width="32"^>           >> {$name}.xml
type {$name}.tmp >> {$name}.xml
echo     ^</set^>                                                                         >> {$name}.xml

echo ^</iconset^>                                                                         >> {$name}.xml

del {$name}.tmp

move %temp%\{$name}-22.png {sourcepath}
move %temp%\{$name}-32.png {sourcepath}

if exist zip.exe (
zip {$name}.dis {$name}-22.png {$name}-32.png {$name}.xml
del {$name}-22.png
del {$name}-32.png
del {$name}.xml
)
goto :eof

[/code]

Nicely done - I'm using my version to quickly re-generate the same icon set with minor changes without having to select the PNGs or re-enter the icon set name.

You could put montage.exe and zip.exe in a /dopusdata/Tools subfolder then you'd be able to find them via that alias.

Also, will "cd {sourcepath}" work if the path is on a different drive?

I think since DOpus 11 the default working folder for functions called by toolbar buttons is /system (\Windows\system32). cd {sourcepath} is needed to make the command working on the current active tab. It should work everywhere if the tool you called supports this.
There's an advanced option in Preferences=>Miscellaneous=>Advanced which allows changing the default working folder to {sourcepath}: def_func_cd_sourcedir

I think Tenebrous was asking if you wanted to use "cd {sourcepath}" or "cd /D {sourcepath}" since the DOS CD command (unlike the Opus CD command) can't change both drive and folder at once unless /D is specified.

In this particular case, it may not matter. Even with a DOS Batch button type and @externalonly specified, if the cd command before any other external commands in the batch file (ignoring any Opus @modifiers and any other cd commands), then Opus will handle it specially, and it does not matter if it has /D or not. If it was lower down then you would need the /D if you were changing to another drive.

(In normal buttons, when not using the DOS Batch type, you shouldn't use /D at all.)

Yeah that's what I meant, and you're right since the cd is so high that's fine - I had forgotten/not known that Opus had a special CD.

The button code I provided above produced invalid XML files if an icon name contained german Umlauts like ü or ä. DOpus didn't show the resulting iconsets. I added the line chcp 65001 to the code to make it working correctly.

Will still go wrong with other languages, of course.

Using JScript or VBScript instead of DOS batch would avoid the problem, since they use Unicode.

Here we go:
button type: script function. zip.exe isn't needed because DOpus can do that.[code]Option Explicit
Function OnClick(data)
Dim all, archive, cmd, col, files, i, name, objStream, objOutputFile, row, text
files = DOpus.Dlg.GetString("Select files:","*.png")
name = DOpus.Dlg.GetString("Enter name of Iconset:")
Set cmd = data.Func.Command
Set text = DOpus.FSUtil.Resolve(cmd.sourcetab.path & "" & name & ".xml")
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
row=1
col=1

objStream.WriteText "<?xml version=" & """" & "1.0" & """" & " encoding=" & """" & "UTF-8" & """" & "?>" & vbCrLf &_
    "<iconset name=" & """" & name & """" & ">" & vbCrLf & vbTab &_
    "<display_name>" & name & "</display_name>" & vbCrLf & vbTab &_
    "<copyright></copyright>" & vbCrLf & vbTab &_
    "<artist></artist>" & vbCrLf & vbCrLf & vbTab &_
    "<set filename=" & """" & name & "-22.png" & """" &" height=" & """" & "22" & """ size=" & """" & "small" & """ width =" & """" & "22" & """" & ">" & vbCrLf

For i=0 To cmd.sourcetab.all.count -1
    objStream.WriteText vbTab & vbTab & "<icon row=" & """" & row & """" & " col=" & """" & col & """" & " name=" & """" & cmd.sourcetab.all(i).name_stem & """" & "/>" & vbCrLf
    col=col+1
    If col > 16 Then 
		col=1
    	row=row+1
	End If
Next
row=1
col=1

objStream.WriteText  vbTab & "</set>" & vbCrLf & vbCrLf & vbTab &_
	"<set filename=" & """" & name & "-32.png" & """" &" height=" & """" & "32" & """ size=" & """" & "large" & """ width =" & """" & "32" & """" & ">" & vbCrLf

For i=0 To cmd.sourcetab.all.count -1
    objStream.WriteText vbTab & vbTab & "<icon row=" & """" & row & """" & " col=" & """" & col & """" & " name=" & """" & cmd.sourcetab.all(i).name_stem & """" & "/>" & vbCrLf
    col=col+1
    If col > 16 Then 
		col=1
    	row=row+1
	End If
Next
objStream.WriteText vbTab & "</set>" & vbCrLf & "</iconset>"
objStream.SaveToFile text,2
objStream.Close

cmd.SetModifier "runmode","hide"
cmd.AddLine("CD {sourcepath}")
cmd.AddLine("Select " & files)
cmd.AddLine("montage {allfile} -geometry 20x20+1+1 -tile 16 -background transparent " & name & "-22.png")
cmd.AddLine("montage {allfile} -geometry 30x30+1+1 -tile 16 -background transparent " & name & "-32.png")
cmd.AddLine("Copy MOVE TO {sourcepath} " & """" & name & ".xml" &"""" & " ARCHIVE=.dis CreateFolder " & """" & name & """")
cmd.AddLine("Copy MOVE TO {sourcepath} " & """" & name & "-22.png" & """" & " ARCHIVE=.dis CreateFolder " & """" & name & """")
cmd.AddLine("Copy MOVE TO {sourcepath} " & """" & name & "-32.png" & """" & " ARCHIVE=.dis CreateFolder " & """" & name & """")
cmd.AddLine("Select DESELECTNOMATCH " & name & ".dis MAKEVISIBLE")
cmd.Run

End Function[/code]

1 Like

Can someone please help me? I have wanted to make icon packages for years but didnt know such a tool exists. Its awsome!
For some reason montage puts multiple icons of the same icon. A package with 6 icons ends up with over 20.... Thanks so much! I just realized it only happens when using .ico files. With .png it works fine

What does your attempt look like so far? If you drag the zip file to the post editor here, it will attach it for us to look at.

(Docs on icon sets are here if you need them. The tools this thread is about just automate the process.)