How to resize an image without loading it into memory?

I would like to check the size of the image, and then reduce it if the width exceeds a given threshold. When I upload a 6MB JPEG image using ImageIO.read (), BufferedImage allocates about 45 MB of heap space. Is there a way to make the firmware resize without loading all the data into memory? I tried passing the ImageIO.read () object to a File object, thinking that it would transfer data from disk, but that doesn't help.

+5
source share
3 answers

Check out im4java and JMagick , both using ImageMagick's extremely efficient external image management tool . Im4Java calls the command line application (runs in a separate process), and JMagick calls it within the same process through the JNI.

If I do simple manipulations with images (resizing, scaling, rotating, etc.), I would prefer ImageMagick to do this for me. It will be faster, more reliable, and consume less memory than anything you could implement in a similar period of time.

Hope this helps!

+3
source

jmagick , ( , , imagemagick ..).

, imgscalr (http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library). , java- , Apache 2.0. (..) , Java2D.

+3

ImageInfo, , . , . 45MB - . ?

+1
source

All Articles