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 ...]]
     

    Options:

    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 Summary

      Constructors 
      Constructor Description
      PngCompressor()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void compress​(java.io.InputStream inputStream, java.io.OutputStream outputStream)
      Compress a 24/32 bit image into 8 bit palette image;
      static void main​(java.lang.String[] args)
      For instructions, see main Javadoc for class
      • Methods inherited from class com.idrsolutions.image.JDeliImage

        optimiseImage
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PngCompressor

        public PngCompressor()
    • Method Detail

      • compress

        public static void compress​(java.io.InputStream inputStream,
                                    java.io.OutputStream outputStream)
                             throws java.io.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,

        Parameters:
        inputStream - PNG file as InputStream
        outputStream - Compressed PNG file as OutputStream
        Throws:
        java.io.IOException - Input or output exception has occurred
      • main

        public static void main​(java.lang.String[] args)
        For instructions, see main Javadoc for class
        Parameters:
        args - For instructions, see main Javadoc for class