public class ImageCompressor extends Object
Constructor and Description |
---|
ImageCompressor(File file)
Read original file and replace original file
|
ImageCompressor(File file,
String outPath)
Read original file and output as per outPath param
|
Modifier and Type | Method and Description |
---|---|
protected FileOutputStream |
createOutputStream(String outFile) |
void |
encode()
Workhorse method, that does the compression / encoding.
|
protected void |
encodeImage(RenderedImage img,
FileOutputStream out) |
com.sun.media.jai.codec.ImageEncodeParam |
getDefaultCompressionEncodingParam(Float quality)
Generate a default encoding param that will be used over the image.
|
com.sun.media.jai.codec.ImageEncodeParam |
getEncodeParam() |
String |
getFormat() |
String |
getOutPath() |
void |
setEncodeParam(com.sun.media.jai.codec.ImageEncodeParam encodeParam) |
void |
setFormat(String format) |
public ImageCompressor(File file)
file
- protected final void encodeImage(RenderedImage img, FileOutputStream out)
protected final FileOutputStream createOutputStream(String outFile)
public com.sun.media.jai.codec.ImageEncodeParam getDefaultCompressionEncodingParam(Float quality)
quality
- as float (0 to 1) where 0 is lowest and 1 is highest quality.ImageEncodeParam
@default JPEGEncodeParam
public void encode() throws IOException
IOException
public com.sun.media.jai.codec.ImageEncodeParam getEncodeParam()
public void setEncodeParam(com.sun.media.jai.codec.ImageEncodeParam encodeParam)
public String getOutPath()
public String getFormat()
public void setFormat(String format)
Copyright © 2018. All rights reserved.