Class PngCompressor

  • public class PngCompressor
    extends com.idrsolutions.image.JDeliImage
    This class is provided in order to offer command-line access for compressing PNG files.

    It also exposes static helper methods for Java developers to use.

    Command Line Instructions:

         java [options] -jar jdeli.jar compresspng [pngfile [pngfile ...]]


    1. -Doverwrite=true (overwrite input files - by default is "false")
    2. -Dverbose=true (print status messages - by default is "false")

    Example 1:

         java -jar jdeli.jar compresspng file.png

    Example 2 (multiple files):

         java -jar jdeli.jar compresspng file1.png file2.png

    Example 3 (with overwrite option):

         java -Doverwrite=true -jar jdeli.jar compresspng /directory/*.png

    Example 4 (with verbose option):

         java -Dverbose=true -jar jdeli.jar compresspng /directory/*.png

    The output filename is the same as the input name except that _compressed will be appended to the name. E.g. file.png will become file_compressed.png This can be changed to overwrite the existing file by setting the overwrite setting to true.

    • Constructor Detail

      • PngCompressor

        public PngCompressor()
    • Method Detail

      • compress

        public static void compress​(InputStream inputStream,
                                    OutputStream outputStream)
                             throws IOException
        Compress a 24/32 bit image into 8 bit palette image;

        This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream,

        inputStream - PNG file as InputStream
        outputStream - Compressed PNG file as OutputStream
        IOException - Input or output exception has occurred
      • main

        public static void main​(String[] args)
        For instructions, see main Javadoc for class
        args - For instructions, see main Javadoc for class