Apache Ant task for creating optimized PNG images using OptiPNG.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is optipng-ant-task, an Apache Ant task for optimizing PNG images.
Under the hood this task uses (and requires) OptiPNG, see:


This Ant task has been tested with the following combination of software:

   - J2SE 5.0 and Java SE 6 (source code uses Java 5-features)
   - Ant 1.7.1
   - OptiPNG 0.6.3

This software is available under the terms of a BSD-style license, see
the accompanied LICENSE file.

This task comes as a collection of Java source files that can be built with
Ant. To compile the Java classes, run all available unit tests and build the
JAR file run:


Note that this already requires 'optipng' on the PATH. The result will be a
JAR file:


If you don't have 'optipng' installed and still want to build the JAR file,
just execute:

   ant jar

This will skip the execution of the available unit tests.

Example usage of the task in an Ant build file:

   <taskdef name="optipng"
       classpath="lib/optipng-ant-task.jar" />

   <optipng dir="src/htdocs" todir="build/htdocs" />

Although all parameters are optional, the task supports various:

   process   - flag that indicates if the input files should be processed at
               all; there are 3 possible modes:

                  "yes" - the files must be processed by OptiPNG, if at least
                          one file could not be processed, then this task will
                          fail (alternative is "true");

                  "no"  - the files must not be processed by OptiPNG but must
                          instead just be copied as-is, unchanged (alternative
                          is "false");

                  "try" - attempt to process all matching file(s), when a file
                          fails to be processed, then copy the original file

   dir       - the source directory, to read PNG image files from, defaults to
               the project base directory;

   todir     - the destination directory, to write the generated CSS files to,
               defaults to the source directory;

   overwrite - when set this flag forces each existing output file to be
               overwritten, even if it is newer than the respective source
               file; defaults to 'no';

   command   - the command to execute, by default the task uses 'optipng';

   timeOut   - the time-out in milliseconds for executing a single command,
               defaults to 60000 (meaning 60 seconds);

   includes  - the files in the source directory to include, defaults to all
               files, although only those that end in '.png' will actually
               be optimized or copied;

   excludes  - the files to exclude, even if they are matched by the includes;

and other parameters inherited from the MatchingTask, see:


If you want to file a bug report or a feature request, please do so here:


This software has been developed by:

   Ernst de Haan      -  ernst@pensioenpage.com
   PensioenPage B.V.  -  https://www.pensioenpage.com/