{"id":20358419,"url":"https://github.com/noxf/libwebp-sys","last_synced_at":"2025-04-09T14:13:38.509Z","repository":{"id":30997225,"uuid":"109795973","full_name":"NoXF/libwebp-sys","owner":"NoXF","description":"bindgen'd FFI bindings to libwebp","archived":false,"fork":false,"pushed_at":"2023-11-10T07:03:48.000Z","size":3838,"stargazers_count":30,"open_issues_count":1,"forks_count":13,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-01-22T21:13:26.450Z","etag":null,"topics":["libwebp","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NoXF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2017-11-07T06:30:37.000Z","updated_at":"2024-02-19T04:33:40.329Z","dependencies_parsed_at":"2024-02-19T04:33:38.771Z","dependency_job_id":"2514a507-a194-494d-9c5e-cd56b86c9bc4","html_url":"https://github.com/NoXF/libwebp-sys","commit_stats":{"total_commits":49,"total_committers":7,"mean_commits":7.0,"dds":0.653061224489796,"last_synced_commit":"f218f8c9976c0db4dcc5dff8837cc5628b3544a3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoXF%2Flibwebp-sys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoXF%2Flibwebp-sys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoXF%2Flibwebp-sys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NoXF%2Flibwebp-sys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NoXF","download_url":"https://codeload.github.com/NoXF/libwebp-sys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054193,"owners_count":21039952,"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":["libwebp","rust"],"created_at":"2024-11-14T23:26:50.230Z","updated_at":"2025-04-09T14:13:38.483Z","avatar_url":"https://github.com/NoXF.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libwebp-sys\n\n[bindgen](https://github.com/servo/rust-bindgen)'d FFI bindings to [libwebp](https://developers.google.com/speed/webp/docs/api).\n\nlibwebp is built with the [`cc`](//lib.rs/cc) crate. It needs a C compiler, but `cmake` is not used.\n\nSet `RUSTFLAGS=\"-Ctarget-cpu=native\"` or your desired CPU architecture to optimize the C code for it.\n\n## Usage\n\nAdd the following to the `Cargo.toml` in your project:\n\n```toml\n[dependencies]\nlibwebp-sys = \"0.12\"\n```\n\nor to require `no_std` support:\n\n```toml\nlibwebp-sys = { version = \"0.12\", default-features = false, features = [\"parallel\"] }\n```\n\nThe `neon`, `sse41` and `avx2` feature flags can be set to force support for Neon, SSE 4.1 and AVX2\nrespectively, but this is usually unnecessary as it can be set through\n`-Ctarget-feature` (e.g. `RUSTFLAGS=\"-Ctarget-feature=avx2\"`) as well.\n\n## Examples\n\n### Encode\n\n```rust\npub fn encode_webp(input_image: \u0026[u8], width: u32, height: u32, quality: i32) -\u003e Result\u003cVec\u003cu8\u003e\u003e {\n    unsafe {\n\t    let mut out_buf = std::ptr::null_mut();\n\t    let stride = width as i32 * 4;\n\t    let len = WebPEncodeRGBA(input_image.as_ptr(), width as i32, height as i32, stride, quality as f32, \u0026mut out_buf);\n\t    Ok(std::slice::from_raw_parts(out_buf, len as usize).into())\n    }\n}\n```\n\n### Decode\n\n```rust\npub fn decode_webp(buf: \u0026[u8]) -\u003e Result\u003cVec\u003cu8\u003e\u003e {\n\tlet mut width = 0;\n\tlet mut height = 0;\n\tlet len = buf.len();\n\tunsafe {\n\t\tWebPGetInfo(buf.as_ptr(), len, \u0026mut width, \u0026mut height);\n\t\tlet out_buf = WebPDecodeRGBA(buf.as_ptr(), len, \u0026mut width, \u0026mut height);\n\t}\n\tOk(std::slice::::from_raw_parts(out_buf, width * height * 4).into())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoxf%2Flibwebp-sys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoxf%2Flibwebp-sys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoxf%2Flibwebp-sys/lists"}