Class PngCompressor

java.lang.Object
com.idrsolutions.image.JDeliImage
com.idrsolutions.image.png.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.

  • Field Summary

    Fields inherited from class com.idrsolutions.image.JDeliImage

    bb
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    compress(InputStream inputStream, OutputStream outputStream)
    Compress a 24/32 bit image into 8 bit palette image;
    static void
    main(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 Details

    • PngCompressor

      public PngCompressor()
  • Method Details

    • 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,

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

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