I'm trying to compress images with this method: Setting jpg compression level with ImageIO in Java.
The solution works fine, but I use ObjectOutputStream instead of FileImageOutputStream, when I set the ObjectOutputStream as the writer output I get an java.lang.IllegalArgumentException: Illegal output type!
exception. I need to use ObjectOutputStream.
This works perfectly ImageIO.write(img, "jpg", outstream);
.