A: Java using Google's Thumbnailator tool to compress images, such as image processing

Source: Internet
Author: User

Thumbnailator is a very good picture of how to use open Source tools: Add the following jar packages to the POM
<!--picture thumbnail image compression watermark start- 

<Dependency>
<groupId>Net.coobird</groupId>
<Artifactid>Thumbnailator</Artifactid>
<version>0.4.8</version>
</Dependency><!--picture thumbnail image compression watermark end -

Then the compression and watermark only need one line of code to fix
 package Com.shallowmemory.test;import net.coobird.thumbnailator.Thumbnails; Import Net.coobird.thumbnailator.geometry.positions;import Javax.imageio.imageio;import Java.awt.image.bufferedimage;import java.io.file;import java.io.ioexception;/*** Created by HONGLINCHEN on 2017/10/31 11:00* image compression * @author honglinchen* @since JDK 1.8*/public class Imgcompress {public static void main (string[] args) throws IOException {//Compress picture The first parameter is the path after the original path is the output path after compression thumbnails.of ("C:\Users\HONGLINCHEN\Desktop\23.jpg"). Size (600,600) . outputquality (0.8f). ToFile ("C:\Users\HONGLINCHEN\Desktop\2.jpg");//Add watermark to the picture bufferedimage Watermarkimage = Imageio.read (New File ("C:\Users\HONGLINCHEN\Desktop\1.jpg"));//The first parameter is the location of the watermark, the second parameter is the cached data for the watermark picture, and the third parameter is transparency. Thumbnails.of ("C:\Users\HONGLINCHEN\Desktop\23.jpg"). Scale (0.8). Watermark (Positions.bottom_right, Watermarkimage, 0.5f). ToFile ("C:\Users\HONGLINCHEN\Desktop\3.jpg");}}  

GitHub Source:Https://github.com/moyiblog/thumbnailator

A: Java using Google's Thumbnailator tool to compress images, such as image processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.