Does libjpeg allows/have routines to scale the output image?
I have an image which needs to be resized when saving to and loading from, Providing width1, height1 on input and getting width2, height2 on output, and I really cant use anything outside.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, libjpeg does support image scaling, but with some limitations.
Libjpeg version 8c and higher supports M/8 scaling where M is an integer between 1 and 16. The more commonly used libjpeg version 6b supports M of 1, 2, 4, and 8 only (i.e. power-of-2 downscaling).
Supply the scaling numerator and denominator to the decompression object using scale_num and scale_denom. See jpeg_decompress_struct in jpeglib.h. You can refer to djpeg.c for a usage example.
This is much faster, and potentially higher quality, than decoding the whole image and then downscaling.