Thumbnailator Google is an excellent open-source Java library picture processing. The treatment effect is far better than the Java API. Providing existing image files and the image of the object from the API to simplify the processing of the class, two or three lines of code to generate the processed image from the existing image, and allows fine-tuning of image generation mode, to be written while maintaining the minimal amount of code. Also supports all pictures in a directory of batch processing operations.
Processing operations supported: image scaling, cropping area, watermark, rotate, keeping the ratio.
Also worth mentioning is that, Thumbnailator still constantly updated, how kind, I feel very secure now!
Thumbnailator official website: http://code.google.com/p/thumbnailator/
Here we describe how to use the next Thumbnailator
Use Address:
http://blog.csdn.net/chenleixing/article/details/44685817
http://www.qzblog.net/blog/220
http://blog.csdn.net/wangpeng047/article/details/17610451
Thumbnail archive jar package
<!-- 图片缩略图 --> <dependency> <groupId>net.coobird</groupId> <artifactId>thumbnailator</artifactId> <version>0.4.8</version> </dependency>
The size specified image to zoom (will follow the original aspect ratio)
// the image to the specified size reduction and discharge (will follow the picture aspect ratio) // Here the picture is pressed into a 400 × 500 thumbnail Thumbnails.of (fromPic) .size (400,500) .toFile (toPic) ; // changed to 400 * 300, following the original proportions shrink or put a certain height 400 *
For reducing and enlarging the specified ratio
// for scale reduction and enlargement Thumbnails.of (fromPic) .scale (0.2f) .toFile (toPic); // scaled Thumbnails.of (fromPic) .scale (2f) ; // scaled
Image dimensions remain unchanged, the compressed image file size
// change the picture size, the compressed image file size outputQuality achieve, parameter 1 is the highest quality Thumbnails.of (fromPic) .scale (1f) .outputQuality (0.25f) .toFile (toPic);
See full details
Original Path: https://www.cnblogs.com/miskis/p/5500822.html