Optimizing images using ImageJ

In this quick tip I’ll show how to optimise images on the fly using ImageJ, looks simple but it took some time because of the input stream creation after the optimisation. I googled it but all the codes that I found were producing empty OutputStreams, until I finally realise that I could use ImageIO to produce the correct ImageWriter and ImageOutputStream.

Forget about Rendition I wrote this code to be used into Adobe AEM, you can replace getRenditionInputStream to anything that returns an InputStream.

Since I used maven, this is the necessary dependency

And the repository


Leave a Reply