blob: 8cd0ece2d3fb3a4ff7abd9a2f441ff5863883be3 [file] [log] [blame]
Dominik Riebeling9d1c2862011-05-31 21:08:29 +00001#!/usr/bin/perl -w
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10# Copyright (C) 2011 Dominik Riebeling
11#
12# All files in this archive are subject to the GNU General Public License.
13# See the file COPYING in the source tree root for full license agreement.
14#
15# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16# KIND, either express or implied.
17
18
19# This script is to generate an iconset (iconstrip bmp file) from Tango icons.
20# It should be usable for other iconsets that are provided as svg images. For
21# those adjusting the paths to the icons might need adjustment.
22# To be run from the icons/ folder in a Rockbox checkout.
23
24use File::Temp;
Thomas Martitzb907f2f2011-11-26 16:01:11 +000025use Getopt::Long;
Dominik Riebeling9d1c2862011-05-31 21:08:29 +000026
27# list of icons for strip
Thomas Martitzb907f2f2011-11-26 16:01:11 +000028# Use relative paths to point to icons in the tree, relative to the icons/ folder
29# (must start with . or ..)
30# Other are treated relatively to the tango sources tree
Dominik Riebeling9d1c2862011-05-31 21:08:29 +000031my @iconlist = (
Thomas Martitzb907f2f2011-11-26 16:01:11 +000032 "./tango-svg/audio-x-generic", # Icon_Audio
33 "./tango-svg/folder", # Icon_Folder
34 "./tango-svg/format-indent-more", # Icon_Playlist
35 "./new_icons-svg/media-playback-start-green", # Icon_Cursor ###
36 "./tango-svg/preferences-desktop-wallpaper", # Icon_Wps
37 "./tango-svg/media-flash", # Icon_Firmware ###
38 "./tango-svg/preferences-desktop-font", # Icon_Font
39 "./tango-svg/preferences-desktop-locale", # Icon_Language
40 "./tango-svg/preferences-system", # Icon_Config
41 "./tango-svg/software-update-available", # Icon_Plugin
42 "./tango-svg/bookmark-new", # Icon_Bookmark
43 "./tango-svg/start-here", # Icon_Preset
44 "./tango-svg/go-jump", # Icon_Queued
45 "./tango-svg/go-next", # Icon_Moving
46 "./tango-svg/input-keyboard", # Icon_Keyboard
47 "./tango-svg/go-previous", # Icon_Reverse_Cursor
48 "./tango-svg/help-browser", # Icon_Questionmark
49 "./tango-svg/document-properties", # Icon_Menu_setting
50 "./tango-svg/applications-other", # Icon_Menu_functioncall
51 "./tango-svg/list-add", # Icon_Submenu
52 "./tango-svg/preferences-system", # Icon_Submenu_Entered
53 "./tango-svg/media-record", # Icon_Recording
54 "./new_icons-svg/face-shout", # Icon_Voice ###
55 "./tango-svg/preferences-desktop", # Icon_General_settings_menu
56 "./tango-svg/emblem-system", # Icon_System_menu
57 "./tango-svg/media-playback-start", # Icon_Playback_menu
58 "./tango-svg/video-display", # Icon_Display_menu
59 "./tango-svg/network-receive", # Icon_Remote_Display_menu
60 "./tango-svg/network-wireless", # Icon_Radio_screen ###
61 "./tango-svg/system-file-manager", # Icon_file_view_menu
62 "./tango-svg/utilities-system-monitor", # Icon_EQ
63 "../docs/logo/rockbox-clef" # Icon_Rockbox
64);
65my @iconlist_viewers = (
66 "./tango-svg/applications-graphics", # bmp
67 "./tango-svg/applications-multimedia", # mpeg
68 "./tango-svg/applications-other", # ch8, tap, sna, tzx, z80
69 "./tango-svg/audio-x-generic", # mp3, mid, rmi, wav
70 "./tango-svg/format-justify-left", # txt, nfo
71 "./tango-svg/text-x-generic-template", # ss
72 "./mint-x-svg/applications-games", # gb, gbc
73 "./tango-svg/image-x-generic", # jpg, jpe, jpeg
74 "./tango-svg/format-indent-more", # m3u
75 "./mint-x-svg/gnome-glchess", # pgn
76 "./tango-svg/dialog-information", # zzz
Dominik Riebeling9d1c2862011-05-31 21:08:29 +000077);
78
79
Thomas Martitzb907f2f2011-11-26 16:01:11 +000080my $help;
81my $do_viewers;
82my $tangopath="";
83my $size;
84my @list = @iconlist;
85my $output = "tango_icons";
86
87GetOptions ( 'v' => \$do_viewers,
88 't|tango-path=s' => \$tangopath,
89 'o|output=s' => \$output,
90 'h|help' => \$help,
91 );
92
93if($#ARGV != 0 or $help) {
94 print "Usage: $0 [-v] [-t <path to iconset>] [-o <output prefix>] SIZE\n";
95 print "\n";
96 print "\t-v\tGenerate viewer icons\n";
97 print "\t-t\tPath to source of tango iconset if required\n";
98 print "\t-t\tPath to source of tango iconset if required\n";
99 print "\t-o\tUse <output prefix> instead of \"tango_icons\" for the output filename\n";
100 print "\n";
101 print "\tSIZE can be in the form of NN or NNxNN and will be used for the output filename\n";
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000102 exit();
103}
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000104
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000105
106$size = $ARGV[0];
107
108if ($do_viewers) {
109 $output .= "_viewers";
110 @list = @iconlist_viewers;
111}
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000112# temporary files
113my $alphatemp = File::Temp->new(SUFFIX => ".png");
114my $alphatempfname = $alphatemp->filename();
115my $exporttemp = File::Temp->new(SUFFIX => ".png");
116my $exporttempfname = $exporttemp->filename();
117my $tempstrip = File::Temp->new(SUFFIX => ".png");
118my $tempstripfname = $tempstrip->filename();
119
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000120my $newoutput = "$output.$size.bmp";
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000121
122if(-e $newoutput) {
123 die("output file $newoutput does already exist!");
124}
125
126print "Creating icon strip as $newoutput\n\n";
127
128my $count;
129$count = 0;
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000130
131foreach(@list) {
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000132 print "processing $_ ...\n";
133 my $file;
134 if(m/^$/) {
135 # if nothing is defined make it empty / transparent
136 my $s = $size . "x" . $size;
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000137 `convert -size $s xc:"#ff00ff" -alpha transparent $exporttempfname`
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000138 }
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000139 elsif(m/\./) {
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000140 # icon is inside the Rockbox tree
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000141 $file = $_ . ".svg";
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000142 `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file`
143 }
144 else {
145 # icon is inside the tango tree
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000146 if ($tangopath eq "") {
147 print "Path to tango sources needed but not given!\n";
148 exit(1);
149 }
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000150 $file = "$tangopath/scalable/" . $_ . ".svg";
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000151 #~ `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file`
152 `cp $file tango-svg/`;
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000153 }
154 if($count != 0) {
155 `convert -append $tempstripfname $exporttempfname $tempstripfname`;
156 }
157 else {
158 `convert $exporttempfname $tempstripfname`;
159 }
160 $count++;
161}
Thomas Martitzb907f2f2011-11-26 16:01:11 +0000162print "Converting result ...\n";
163`convert $tempstripfname $newoutput`;
164print "Done!\n";
Dominik Riebeling9d1c2862011-05-31 21:08:29 +0000165