fast_image_resize
fast_image_resize copied to clipboard
Invalid buffer length issue
[1] assertion left == right
failed: Invalid buffer length: expected 181600 got 136200 for 200x227 image
[1] left: 181600
[1] right: 136200
let src_image = ImageReader::new(std::io::Cursor::new(file_data))
.with_guessed_format()
.unwrap()
.decode()
.unwrap();
let src_aspect_ratio = src_image.width() as f32 / src_image.height() as f32;
let dst_width = 200_f32;
let dst_height = dst_width / src_aspect_ratio;
let dst_width = dst_width as u32;
let dst_height = dst_height.round() as u32;
let mut dst_image = Image::new(dst_width, dst_height, src_image.pixel_type().unwrap());
resizer.resize(&src_image, &mut dst_image, None).unwrap();
let mut result_buf = BufWriter::new(Vec::new());
let written_image_error = PngEncoder::new(&mut result_buf)
.write_image(
dst_image.buffer(),
dst_width,
dst_height,
ExtendedColorType::Rgba8,
)
.err();
This happens when I try to iterate over incoming images to resize them one by one. But when done one at a time the resize works fine.
Please help me with this. Thank you :)
Note: I'm using AXUM 7.5 with axum_typed_multipart to get the images