Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 1 | #!/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 | |
| 24 | use File::Temp; |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 25 | use Getopt::Long; |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 26 | |
| 27 | # list of icons for strip |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 28 | # 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 Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 31 | my @iconlist = ( |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 32 | "./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 | ); |
| 65 | my @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 Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 77 | ); |
| 78 | |
| 79 | |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 80 | my $help; |
| 81 | my $do_viewers; |
| 82 | my $tangopath=""; |
| 83 | my $size; |
| 84 | my @list = @iconlist; |
| 85 | my $output = "tango_icons"; |
| 86 | |
| 87 | GetOptions ( 'v' => \$do_viewers, |
| 88 | 't|tango-path=s' => \$tangopath, |
| 89 | 'o|output=s' => \$output, |
| 90 | 'h|help' => \$help, |
| 91 | ); |
| 92 | |
| 93 | if($#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 Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 102 | exit(); |
| 103 | } |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 104 | |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 105 | |
| 106 | $size = $ARGV[0]; |
| 107 | |
| 108 | if ($do_viewers) { |
| 109 | $output .= "_viewers"; |
| 110 | @list = @iconlist_viewers; |
| 111 | } |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 112 | # temporary files |
| 113 | my $alphatemp = File::Temp->new(SUFFIX => ".png"); |
| 114 | my $alphatempfname = $alphatemp->filename(); |
| 115 | my $exporttemp = File::Temp->new(SUFFIX => ".png"); |
| 116 | my $exporttempfname = $exporttemp->filename(); |
| 117 | my $tempstrip = File::Temp->new(SUFFIX => ".png"); |
| 118 | my $tempstripfname = $tempstrip->filename(); |
| 119 | |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 120 | my $newoutput = "$output.$size.bmp"; |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 121 | |
| 122 | if(-e $newoutput) { |
| 123 | die("output file $newoutput does already exist!"); |
| 124 | } |
| 125 | |
| 126 | print "Creating icon strip as $newoutput\n\n"; |
| 127 | |
| 128 | my $count; |
| 129 | $count = 0; |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 130 | |
| 131 | foreach(@list) { |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 132 | 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 Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 137 | `convert -size $s xc:"#ff00ff" -alpha transparent $exporttempfname` |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 138 | } |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 139 | elsif(m/\./) { |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 140 | # icon is inside the Rockbox tree |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 141 | $file = $_ . ".svg"; |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 142 | `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file` |
| 143 | } |
| 144 | else { |
| 145 | # icon is inside the tango tree |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 146 | if ($tangopath eq "") { |
| 147 | print "Path to tango sources needed but not given!\n"; |
| 148 | exit(1); |
| 149 | } |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 150 | $file = "$tangopath/scalable/" . $_ . ".svg"; |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 151 | #~ `inkscape --export-png=$exporttempfname --export-width=$size --export-height=$size $file` |
| 152 | `cp $file tango-svg/`; |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 153 | } |
| 154 | if($count != 0) { |
| 155 | `convert -append $tempstripfname $exporttempfname $tempstripfname`; |
| 156 | } |
| 157 | else { |
| 158 | `convert $exporttempfname $tempstripfname`; |
| 159 | } |
| 160 | $count++; |
| 161 | } |
Thomas Martitz | b907f2f | 2011-11-26 16:01:11 +0000 | [diff] [blame] | 162 | print "Converting result ...\n"; |
| 163 | `convert $tempstripfname $newoutput`; |
| 164 | print "Done!\n"; |
Dominik Riebeling | 9d1c286 | 2011-05-31 21:08:29 +0000 | [diff] [blame] | 165 | |