if ("jpg".equals(type) || "jpeg".equals(type)) {
// JPEG
encoder = new JPGEncoder();
// the quality value does mean something here and can be specified:
if (quality >= 0.0 && quality <= 1.0) {
JPGOptions options = new JPGOptions();
options.setQuality(Math.round(quality * 100));
source.setOptions(options);
}
} else if ("png".equals(type)) {
// PNG
encoder = new PNGEncoder();
// the alpha parameter does mean something here:
((PNGEncoder) encoder).setAlpha(new Boolean(alpha));
PNGOptions options = new PNGOptions();
// TODO: Use quality for CompressionType control, similar to ImageIOWrapper (?)
options.setCompressionType(PNGOptions.COMPRESSION_MAX);
source.setOptions(options);
}
// if no encoder was found, return false. let jimi handle this in the functions bellow
if (encoder == null) return false;
encoder.encodeImages(new JimiImageEnumeration(source), out);