{"id":15650690,"url":"https://github.com/blaind/webp-animation","last_synced_at":"2025-08-21T20:32:23.871Z","repository":{"id":42029218,"uuid":"355967631","full_name":"blaind/webp-animation","owner":"blaind","description":"A high-level Rust wrapper for decoding and encoding WebP animations","archived":false,"fork":false,"pushed_at":"2024-05-07T11:50:56.000Z","size":98,"stargazers_count":36,"open_issues_count":7,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-07T18:33:49.584Z","etag":null,"topics":["rust","webp"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blaind.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-08T15:51:51.000Z","updated_at":"2024-11-22T07:39:16.000Z","dependencies_parsed_at":"2024-10-03T12:37:19.714Z","dependency_job_id":"69bbc27d-9a5e-42ef-8092-fc35a95ef420","html_url":"https://github.com/blaind/webp-animation","commit_stats":{"total_commits":36,"total_committers":6,"mean_commits":6.0,"dds":"0.13888888888888884","last_synced_commit":"abe766438fc0418d88d2664fa510a328b4922277"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fwebp-animation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fwebp-animation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fwebp-animation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blaind%2Fwebp-animation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blaind","download_url":"https://codeload.github.com/blaind/webp-animation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230532448,"owners_count":18240792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","webp"],"created_at":"2024-10-03T12:35:30.763Z","updated_at":"2024-12-20T04:07:37.732Z","avatar_url":"https://github.com/blaind.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webp-animation \u0026emsp; [![Build Status]][actions] [![Latest Version]][crates.io] [![Docs Version]][docs] [![Lines of Code]][github]\n\n[Build Status]: https://img.shields.io/github/actions/workflow/status/blaind/webp-animation/ci.yml?branch=main\n[actions]: https://github.com/blaind/webp-animation/actions?query=branch%3Amain\n[Latest Version]: https://img.shields.io/crates/v/webp-animation.svg\n[crates.io]: https://crates.io/crates/webp-animation\n[Lines of Code]: https://tokei.rs/b1/github/blaind/webp-animation?category=code\n[github]: https://github.com/blaind/webp-animation\n[Docs Version]: https://docs.rs/webp-animation/badge.svg\n[docs]: https://docs.rs/webp-animation\n\nA high-level Rust wrapper for decoding and encoding\n[WebP](https://en.wikipedia.org/wiki/WebP) animations\n\n![Example](data/example.gif)\n\n_See `examples/encode_animation.rs` for source code of encoding the above image - example converted to gif for all-browser support, see the [example.webp file](data/example.webp)_\n\nUnderlying WebP format processing is handled by C-based\n[libwebp](https://developers.google.com/speed/webp/docs/container-api) library,\nwhich is interfaced through Rust [libwebp-sys2](https://crates.io/crates/libwebp-sys2)\ncrate.\n\nFunctional Goals:\n\n- Easy-to-use API that looks like Rust\n- Enable decoding and encoding of WebP streams\n- All configuration flags provided by `libwebp` should be usable\n\nNon-functional Goals:\n\n- High performance (approach `libwebp` performance without large overhead)\n- Write compherensive test cases, and test by automation\n- Ensure safety (no memory leaks or UB). Fuzz the API's. Safe to use for end users\n\nNon-goals\n\n- Provide other WebP/libwebp -related functionality (such as image en/decoding or muxing). For this functionality, see e.g. [libwebp-image](https://crates.io/crates/libwebp-image) or [webp](https://crates.io/crates/webp)\n\n## Examples\n\n### Decoding\n\nWill take a webp buffer, and try to decode it to frame(s)\n\n```rust\nuse webp_animation::prelude::*;\n\nlet buffer = std::fs::read(\"./data/animated.webp\").unwrap();\nlet decoder = Decoder::new(\u0026buffer).unwrap();\n\nfor frame in decoder.into_iter() {\n  assert_eq!(frame.dimensions(), (400, 400));\n\n  // w * h * rgba\n  assert_eq!(frame.data().len(), 400 * 400 * 4);\n\n  // if feature `image` is enabled (not by default),\n  // one can convert data to [`Image::ImageBuffer`]\n  assert_eq!(\n    frame.into_image().unwrap().dimensions(),\n    (400, 400)\n  );\n}\n```\n\nIt is also possible to supply more decoding options through `Decoder::new_with_options`.\n\n### Encoding\n\nWill take `n` frames as an input. WebP binary data is output at the end\n(wrapped into `WebPData` which acts as a `\u0026[u8]`)\n\n```rust\nuse webp_animation::prelude::*;\n\n// setup\nlet dimensions = (64, 32);\nlet bright_frame = [255, 255, 255, 255].repeat(64 * 32);\nlet dark_frame = [0, 0, 0, 255].repeat(64 * 32);\n\n// init encoder. uses by default lossless encoding,\n// for other alternatives see documentation about\n// `new_with_options`\nlet mut encoder = Encoder::new(dimensions).unwrap();\n\n// insert frames to specific (increasing) timestamps\nfor frame_idx in 0..5 {\n  let rgba_data = if frame_idx % 2 == 0 {\n    \u0026bright_frame\n  } else {\n    \u0026dark_frame\n  };\n\n  // (presentation) timestamp of the frame, should be in increasing order. represented in milliseconds\n  let frame_timestamp_ms = frame_idx * 170;\n\n  encoder.add_frame(rgba_data, frame_timestamp_ms).unwrap();\n}\n\n// final timestamp in milliseconds, until to the last frame is shown\nlet final_timestamp_ms = 1_000;\n\n// get encoded webp data\nlet webp_data = encoder.finalize(final_timestamp_ms).unwrap();\nstd::fs::write(\"my_animation.webp\", webp_data).unwrap();\n```\n\nSee the [documentation](https://docs.rs/webp-animation/latest/webp_animation) for other encoding options, e.g.\nfor lossy encoding. For tuning the options, use the [`Encoder::new_with_options`](https://docs.rs/webp-animation/latest/webp_animation/struct.Encoder.html#method.new_with_options) method.\n\n## Future plans\n\nKeep up with upstream `libwebp` changes.\n\nPossibly provide a compherensive CLI for working with WebP animations in future (conversions, optimizations, etc.)\n\n## License\n\nLicensed under either of\n\n- \u003ca href=\"LICENSE-APACHE\"\u003eApache License, Version 2.0\u003c/a\u003e or\n- \u003ca href=\"LICENSE-MIT\"\u003eMIT license\u003c/a\u003e\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the software by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaind%2Fwebp-animation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblaind%2Fwebp-animation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblaind%2Fwebp-animation/lists"}