webp icon indicating copy to clipboard operation
webp copied to clipboard

feat: consume frame after added, for reducing memory usage

Open meowtec opened this issue 2 years ago • 1 comments

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.

meowtec avatar Nov 04 '23 08:11 meowtec

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

langyo avatar Mar 28 '24 13:03 langyo