// If compression is true, use JPEG compression. Otherwise, use the lossless format.
if (args.containsKey(COMPRESSION) && Boolean.parseBoolean((String) args.get(COMPRESSION)))
{
// We use DefineBitsJPEG3, because it supports an alpha channel
DefineBitsJPEG3 defineBits = new DefineBitsJPEG3();
int imageSize = image.getWidth() * image.getHeight();
byte[] alphaData = new byte[imageSize];
int[] pixels = image.getPixels();
BufferedImage bufferedImage = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);