Use compress_to_size to attempt to compress an image until it fits under a specific byte threshold. This function takes the input path, output path, parameters, a max_output_size in bytes, and a boolean return_smallest which determines if the smallest version should be returned.
use caesium::parameters::CSParameters;
use caesium::compress_to_size;
let mut parameters = CSParameters::new();
let input_file_path = "input.webp".to_string();
let output_file_path = "output.webp".to_string();
let max_output_size = 100_000; // 100 KB
let result = compress_to_size(input_file_path, output_file_path, &mut parameters, max_output_size, true);
assert!(result.is_ok());