Permalink
Browse files

Losslessly minimize PNGs as part of build process

Minimize PNGs w/ optipng, advpng, and advdef (these 3 tools compress
better than pngcrush). These 3 tools can be found in the Debian/Ubuntu
packages: optipng advancecomp
  • Loading branch information...
1 parent f7c59b8 commit 5cb3d0c562d485f29cda147e8716924c3fba9ed7 @samatjain committed Oct 25, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 Makefile
View
14 Makefile
@@ -97,7 +97,7 @@ CSSFILES = ${CSSTHEMEFILES} ${CSSSTRUCTUREFILES}
# By default, this is what get runs when make is called without any arguments.
# Min and un-min CSS and JS files are the only things built
-all: init js min css cssmin notify
+all: init js min css cssmin notify images imagesmin
# Build the normal CSS file.
css: init
@@ -113,6 +113,14 @@ cssmin: init css
@@java -jar build/yuicompressor-2.4.6.jar --type css ${OUTPUT}/${CSS} >> ${OUTPUT}/${CSSMIN}
@@java -jar build/yuicompressor-2.4.6.jar --type css ${OUTPUT}/${CSSSTRUCTURE} >> ${OUTPUT}/${CSSSTRUCTUREMIN}
+images: init
+ @@cp -R css/themes/${CSSTHEME}/images ${OUTPUT}/
+
+imagesmin: images
+ @@find ${OUTPUT} -name '*png' -exec optipng -o3 {} \;
+ @@find ${OUTPUT} -name '*png' -exec advpng -z -4 {} \;
+ @@find ${OUTPUT} -name '*png' -exec advdef -z -4 {} \;
+
# Build the normal JS file
js: init
# Build the JavaScript file
@@ -142,11 +150,11 @@ pull:
@@git pull --quiet
# Zip the 4 files and the theme images into one convenient package
-zip: init js min css cssmin
+zip: init js min css cssmin images imagesmin
@@mkdir -p ${DIR}
@@cp ${OUTPUT}/*.js ${DIR}/
@@cp ${OUTPUT}/*.css ${DIR}/
- @@cp -R css/themes/${CSSTHEME}/images ${DIR}/
+ @@cp -R ${OUTPUT}/images ${DIR}/
@@zip -rq ${OUTPUT}/${DIR}.zip ${DIR}
@@rm -fr ${DIR}

0 comments on commit 5cb3d0c

Please sign in to comment.