Category Archives: taskdef

OptiPNG Ant Task

>OptiPNG is a tool for optimizing PNG images. And now, there’s an Ant task for executing it from an Ant build file:

Mini-HOWTO for Linux/UNIX/Mac OS X systems, assuming you already have Apache Ant installed:

  1. download OptiPNG source code from SourceForge (TAR GZ file)
  2. execute: ./configure
  3. execute: make
  4. execute: sudo make install
    (enter your password if required); the command optipng is now installed in /usr/local/bin/
  5. download the optipng-ant-task source code from – take the latest version available (you can choose between a ZIP and a TAR GZ file)
  6. unpack the download file, this will create a new directory with an odd name like: znerd-optipng-ant-task-604de975b4cc4a1a2766e385c91b749318af038e (you may want to rename it to optipng-ant-task or so)
  7. in that directory, execute: ant
    this will compile the classes, run the available unit test and build the JAR file

Then you can use the Ant task from your own build file, for example as follows:

<taskdef name="optipng" classname="com.pensioenpage.jynx.optipng.OptiPNGTask" classpath="lib/optipng-ant-task.jar" />
<optipng dir="src/htdocs" todir="build/htdocs" />

Leave a comment

Posted by on 8 September 2009 in ant, optipng, png, task, taskdef