On 23/07/2020 16:33, Lloyd wrote:
We tried boost gil resize example to experiment with scaling down a jpeg image file. For some images, this causes the size of the file to increase. We are using bilinear_sampler algorithm.
Our aim to reduce the input image size so as to save storage/network bandwidth. Quality can be compromised to a certain extent. Which algorithm/method should we use?
Re-saving a JPEG file is pretty much always guaranteed to reduce quality, no matter what settings you use.
The code fragment is given below:-
boost::gil::rgb8_image_t img; boost::gil::read_and_convert_image(InStream, img, T()); float width = (float)(img.width() * Ratio) / 100; float height = (float)(img.height() * Ratio) / 100; boost::gil::rgb8_image_t resizedImg(width, height); boost::gil::resize_view(const_view(img), view(resizedImg), boost::gil::bilinear_sampler()); boost::gil::write_view(OutStream, boost::gil::const_view(resizedImg), T());
Probably the important part is what your T() is.
When calling write_view, you can specify a JPEG quality explicitly via
something like image_write_info