Open ghmendonca opened 11 months ago
You can resize it while preserving aspect ratio. For example if you want to make it 50% of its original size do something like this:
let (width, height) = image.dimensions();
let new_width = ((width as f32) * 0.5) as u32;
let new_height = ((height as f32) * 0.5) as u32;
image.resize(new_width, new_height, ResizeAlgorithm::Bicubic);
That works when you want to scale the images, not resize to an exact width or height. I ended up using image-rs code to calculate the new width and height. But it would be cool if this library could add that code internally so people don't have to implement that themselves
Ah, I see
This would be a nice addition, I'll consider this for v0.11
Right now the
resize
function does not preserve the image aspect ratio and there is no way to do that right now. The image crate has methods to achieve this, like resize, resize_to_fill, resize_exact, thumbnail and thumbnail_exact.This is a big feature missing, and I would love to have methods similar to these listed. I love
ril
because compared to theimage
crate, it already includes all the dependencies and the API is amazing, so adding these methods will be a really good addition!