Merge lp:~mvo/archive-index/app-install-mvo into lp:archive-index/app-install

Proposed by Michael Vogt
Status: Merged
Merged at revision: 5
Proposed branch: lp:~mvo/archive-index/app-install-mvo
Merge into: lp:archive-index/app-install
Diff against target: 113 lines (+57/-5)
2 files modified
postprocess-app-metadata (+11/-1)
utils/package-metadata (+46/-4)
To merge this branch: bzr merge lp:~mvo/archive-index/app-install-mvo
Reviewer Review Type Date Requested Status
Jjed Approve
Review via email: mp+70271@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

I played with pngcrush as well but did not manage to get a real reduction of the size:

+ if ! pngcrush $new_name ../icons/$new_name; then
+ echo " pngcrunch!, copying instead"
+ cp $new_name ../icons/

For each converted svg, xpm and all exisiting pngs. I compared the two dirs:

20428 icons
18852 icons-pngcrunch-reduced

That is not really great for the amount of time that pngcrush churns.

Revision history for this message
Michael Vogt (mvo) wrote :

I added a resize now for bigger icons to the target size, that gained another megabyte for size 128 and for size 64 brought the uncompressed size down to 14 mb for the icons.

7. By Michael Vogt

resize all big icons to target size

8. By Michael Vogt

utils/package-metadata: set size to 64px, use pngcrush after everything is finished

Revision history for this message
Michael Vogt (mvo) wrote :

I added a targetsize of 64px and added pngcrush (does not gain much, but every bit counts) and this brings the size down to 7.8mb compressed with gzip. This is comparable to the old size, but we have 300 icons more :) So all in all I think this is a clear winner now.

Revision history for this message
Jjed (jjed) wrote :

Thanks for this. Have merged with a dependency sanity check, will repropose my new-extract branch once I resolve the ardour namespace collision problem.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'postprocess-app-metadata'
2--- postprocess-app-metadata 2011-06-29 16:33:50 +0000
3+++ postprocess-app-metadata 2011-08-03 18:01:44 +0000
4@@ -13,7 +13,10 @@
5 Option("-c", "--config-dir", dest="config_dir", default="config/",
6 help="directory with ArchiveCache blacklists and transforms"),
7 Option("-o", "--output-dir", dest="out_dir", default="output/",
8- help="directory where extract-app-metadata outputed"))
9+ help="directory where extract-app-metadata outputed"),
10+ Option("-v", "--verbose", default=False, action="store_true",
11+ help="show more output to stdout"),
12+ )
13
14
15 def postprocess_metadata(config_dir, out_dir):
16@@ -100,4 +103,11 @@
17 parser.print_usage()
18 print("extraneous arguments: {0}".format(" ".join(args)))
19 sys.exit(1)
20+
21+ # create output on stdout
22+ if opts.verbose:
23+ log = logging.getLogger()
24+ handler = logging.StreamHandler()
25+ log.addHandler(handler)
26+
27 postprocess_metadata(opts.config_dir, opts.out_dir)
28
29=== modified file 'utils/package-metadata'
30--- utils/package-metadata 2011-06-29 16:33:50 +0000
31+++ utils/package-metadata 2011-08-03 18:01:44 +0000
32@@ -1,5 +1,7 @@
33 #!/bin/bash
34
35+set -e
36+
37 echo "running package-metadata...."
38
39 # we need this to create PNGS from scalables
40@@ -8,29 +10,69 @@
41 exit 1
42 fi
43
44+SIZE=64
45+
46 cd output/icons/
47 SVGS=`file -Nz * | grep "SVG" | cut -d ":" -f 1`
48+XPMS=`file -Nz * | grep "X pixmap image" | cut -d ":" -f 1`
49 SVGS_WC=`echo $SVGS | wc -w`
50+XPMS_WC=`echo $XPMS | wc -w`
51 ICONS_WC=`ls | wc -w`
52
53 echo "$SVGS_WC out of $ICONS_WC output icons are scalable"
54+echo "$XPMS_WC out of $ICONS_WC output icons are xpms"
55 echo "converting to PNGs..."
56
57 # don't delete SVGs while converting
58 mkdir -p ../backup/
59-mv $SVGS ../backup/
60+if [ -n "$SVGS" ]; then
61+ mv $SVGS ../backup/
62+fi
63+if [ -n "$XPMS" ];then
64+ mv $XPMS ../backup/
65+fi
66 cd ../backup/
67
68+# conver the svgs
69 for svg in $SVGS; do
70 echo " * $svg"
71- rsvg -w 128 $svg ../icons/${svg%%.svg*}.png
72- if [ $? -ne 0 ]; then
73+ if ! rsvg -w $SIZE $svg ../icons/${svg%%.svg*}.png; then
74 echo " failed!, copying instead"
75 cp $svg ../icons/
76 fi
77 done
78
79-cd ..
80+# convert the xpms
81+for xpm in $XPMS; do
82+ echo " * $xpm"
83+ if ! convert $xpm ../icons/${xpm%%.xpm*}.png; then
84+ echo " failed!, copying instead"
85+ cp $xpm ../icons/
86+ fi
87+done
88+cd ..
89+
90+# resize all the big ones to our target size
91+cd icons
92+for png in *.png; do
93+ w=$(identify -format "%[fx:w]" $png)
94+ #h=$(identify -format "%[fx:h]")
95+ if [ "$w" -gt $SIZE ]; then
96+ echo " * resizing $png from width $w to $SIZE"
97+ mv $png ../backup
98+ if ! convert -resize $SIZE ../backup/$png $png; then
99+ echo " resize failed, copying"
100+ cp ../backup/$png $png
101+ fi
102+ fi
103+done
104+cd ..
105+
106+# and run pngcrush
107+mkdir -p icons-reduced
108+pngcrush -q -d icons-reduced icons/*.png
109+mv icons-reduced/*.png icons/
110+
111 echo "done compressing. now archive everything"
112 DATE=`date '+%Y%m%d'`
113 tar czf ../archive-metadata-$DATE.tar.gz desktop/ icons/

Subscribers

People subscribed via source and target branches

to all changes: