Java backend implements image compression technology and java backend Image Compression

Source: Internet
Author: User

Java backend implements image compression technology and java backend Image Compression

Today I want to talk about the image compression technology. Why do we need to use image compression? Isn't it enough to upload images? Yes, this can be said a few years ago, because a few years ago there was not such a large concurrency, nor is it so concerned about performance.

 

Nowadays, there are many mobile phones. Many people access networks or apps through their mobile phones. When calling interfaces, they will certainly browse images more or less, especially when they are disconnected from wifi, you can see that many software displays a thumbnail, which is a compressed image. After you click it, it will be enlarged, as shown below:

This approach can minimize the image display pressure on the mobile phone end, because an image may be several hundred kb or several megabytes for the uploader, in this way, the pressure on the mobile phone end will be relatively high, but it will also consume a lot of traffic, so in today's mobile Internet, we must do a good job of such image compression processing.

 

No, this will save a lot of traffic after compression.

 

I have encountered two types of Image Compression currently. The first one is not mentioned. It is implemented using java swing. It is not recommended. The second one is recommended, that is, the thumbnailator component, which is very practical, and has been updating

 

Add the following configuration in pom:

<!-- image util -->

<dependency>

    <groupId>net.coobird</groupId>

   <artifactId>thumbnailator</artifactId>

   <version>${thumbnailator.version}</version>

</dependency>

 

Proportional scaling by length and width

 

In addition, this component also provides functions such as image quality improvement or reduction, watermarking and rotation. If you are interested, you may wish to have a try!

 

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.