How do you create a thumbnail image out of a JPEG in Java?

后端 未结 13 2340
日久生厌
日久生厌 2020-11-29 16:51

Can someone please help with some code for creating a thumbnail for a JPEG in Java.

I\'m new at this, so a step by step explanation would be appreciated.

13条回答
  •  忘掉有多难
    2020-11-29 17:26

    I know this is a pretty old post. I have been looking for a solution to generate the thumbnail so end up using this

    Thumbnails.of(originalImage).scale(0.25).asBufferedImage();
    

    if you are using for mobile would suggest to set the scale to 0.45

    Thumbnails.of(originalImage).scale(0.45).asBufferedImage();
    

    https://github.com/coobird/thumbnailator

    This is certainly much faster using the Graphics2D as have tested the both options.

提交回复
热议问题