Scaling using libjpegturbo in java

1.5k Views Asked by At

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.

1

There are 1 best solutions below

0
On

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.