{"id":19501726,"url":"https://github.com/imageoptim/mozjpeg-rust","last_synced_at":"2025-04-06T03:07:54.893Z","repository":{"id":44736590,"uuid":"121208635","full_name":"ImageOptim/mozjpeg-rust","owner":"ImageOptim","description":"Safe Rust wrapper for the MozJPEG library","archived":false,"fork":false,"pushed_at":"2024-03-25T23:07:41.000Z","size":769,"stargazers_count":71,"open_issues_count":1,"forks_count":18,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-04-14T13:51:51.555Z","etag":null,"topics":["libjpeg-turbo","rust-bindings"],"latest_commit_sha":null,"homepage":"https://lib.rs/mozjpeg","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ImageOptim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-02-12T06:24:58.000Z","updated_at":"2024-06-20T00:07:43.940Z","dependencies_parsed_at":"2024-02-03T23:19:40.464Z","dependency_job_id":"ad68c8c6-804a-418a-851a-b58782a63f00","html_url":"https://github.com/ImageOptim/mozjpeg-rust","commit_stats":{"total_commits":69,"total_committers":9,"mean_commits":7.666666666666667,"dds":"0.21739130434782605","last_synced_commit":"1a786819990bb393acb0416777e2584f73aa8369"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImageOptim%2Fmozjpeg-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImageOptim%2Fmozjpeg-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImageOptim%2Fmozjpeg-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ImageOptim%2Fmozjpeg-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ImageOptim","download_url":"https://codeload.github.com/ImageOptim/mozjpeg-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":["libjpeg-turbo","rust-bindings"],"created_at":"2024-11-10T22:13:46.911Z","updated_at":"2025-04-06T03:07:54.877Z","avatar_url":"https://github.com/ImageOptim.png","language":"Rust","readme":"# Rust wrapper for MozJPEG library\n\nThis library adds a safe(r) interface on top of libjpeg-turbo and MozJPEG for reading and writing well-compressed JPEG images.\n\nThe interface is still being developed, so it has rough edges and may change.\n\nIn particular, error handling is weird due to libjpeg's peculiar design. Error handling can't use `Result`, but needs to depend on Rust's `resume_unwind` (a panic, basically) to signal any errors in libjpeg. It's necessary to wrap all uses of this library in `catch_unwind`.\n\nIn crates compiled with `panic=abort` setting, any JPEG error will abort the process.\n\n## Decoding example\n\n```rust\nstd::panic::catch_unwind(|| -\u003e std::io::Result\u003cVec\u003crgb::Rgb::\u003cu8\u003e\u003e\u003e {\n    let d = mozjpeg::Decompress::with_markers(mozjpeg::ALL_MARKERS)\n        .from_path(\"tests/test.jpg\")?;\n\n    d.width(); // FYI\n    d.height();\n    d.color_space() == mozjpeg::ColorSpace::JCS_YCbCr;\n    for marker in d.markers() { /* read metadata or color profiles */ }\n\n    // rgb() enables conversion\n    let mut image = d.rgb()?;\n    image.width();\n    image.height();\n    image.color_space() == mozjpeg::ColorSpace::JCS_RGB;\n\n    let pixels = image.read_scanlines()?;\n    image.finish()?;\n    Ok(pixels)\n});\n```\n\n## Encoding example\n\n```rust\n# let width = 8; let height = 8;\nstd::panic::catch_unwind(|| -\u003e std::io::Result\u003cVec\u003cu8\u003e\u003e {\n    let mut comp = mozjpeg::Compress::new(mozjpeg::ColorSpace::JCS_RGB);\n\n    comp.set_size(width, height);\n    let mut comp = comp.start_compress(Vec::new())?; // any io::Write will work\n\n    // replace with your image data\n    let pixels = vec![0u8; width * height * 3];\n    comp.write_scanlines(\u0026pixels[..])?;\n\n    let writer = comp.finish()?;\n    Ok(writer)\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimageoptim%2Fmozjpeg-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimageoptim%2Fmozjpeg-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimageoptim%2Fmozjpeg-rust/lists"}