简体   繁体   中英

Scaling using libjpegturbo in java

I have an image that I want to re-scale the size so that the file size will be small. By using libjpegturbo class TJScalingFactor and TJCompressor , I am still unable to re-scale the image as there is no method which allow height and width to be inputted.

This problem seems to be somehow related to this question , where the OP wants to compress, decompress and compress an image to scale it. This question is also talking about scaling while decompressing, what can in fact be done with the TurboJPEG API.

This part contains background information

In fact, scaling while compressing was only introduced and implemented in the version 7 of the Independent JPEG Groups libjpeg. The developer of TurboJPEG and libjpeg-turbo has doubts about the usefulness of this new function, why he does not see any reason to implement it. Also, the project page says: "It can also optionally be configured to be API/ABI-compatible with libjpeg v7 and v8, but it does not include support for the non-standard SmartScale format introduced in libjpeg v8."

TL;DR;

Use TJCompressor to compress the image, decompress it with the wished width/height using TJDecompressor and compress it again using TJCompressor .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM