If we encode a WebP animation with many frames, caching all frames into a Vec and then adding them all to the encoder at once is not a good approach. This could potentially lead to excessive memory usage.
It is better to consume each frames after they are added.
API BREAKING CHANGE
AnimEncoder::add_frame() should return a Result.
(AnimEncoder::encode maybe should rename to AnimEncoder::finish, I'm not sure.)
In addition I update the example code to create a more complex and beautiful animation.
BTW, the animation decoder should return a iterator instead of a vector for the same reason.
Sorry to disturb you. If you are free, I hope you can review and merge this submission to follow up with the latest version (0.25) of the image library.
@jaredforth
If we encode a WebP animation with many frames, caching all frames into a Vec and then adding them all to the encoder at once is not a good approach. This could potentially lead to excessive memory usage.
It is better to consume each frames after they are added.
API BREAKING CHANGE
AnimEncoder::add_frame()
should return a Result. (AnimEncoder::encode
maybe should rename toAnimEncoder::finish
, I'm not sure.)In addition I update the example code to create a more complex and beautiful animation.
BTW, the animation decoder should return a iterator instead of a vector for the same reason.