-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preparation of a large number of images in a loop #20
Comments
Move these lines inside of for-loop: let mut result_buffer: Vec<u8> = Vec::new();
let mut buf_writer = BufWriter::new( &mut result_buffer );
let mut encoder = JpegEncoder::new_with_quality( &mut buf_writer, 100 ); |
Is there a way to avoid creating new instances in the loop? |
Your question is irrelevant to the |
Thank you, let me modify my question, if the encoder and the resizer holds the logic of how to process images: Is there a way to create only one instance of these two, to use in +100 resize & encode ops. in loop? |
You can reuse the memory buffer that is used for let mut dst_buffer: Vec<u8> = Vec:new();
for variation in variations {
...
let dst_buf_size = ...;
dst_buffer.resize(dst_buf_size, 0);
let mut dst_image = fr::Image::from_slice_u8(
dst_width,
dst_height,
&mut dst_buffer,
src_image.pixel_type(),
).unwrap();
...
} I think that creating an instance of But, in any case, to store 100+ result images you must create 100+ vectors. |
Thank you! |
Hello, I want to prepare a large number of images in a loop using your library. I have an application as below for performance optimization, but I am encountering errors. Which path should we follow?
The text was updated successfully, but these errors were encountered: