{"id":13822495,"url":"https://github.com/AldaronLau/png_pong","last_synced_at":"2025-05-16T17:31:19.190Z","repository":{"id":44420793,"uuid":"200397314","full_name":"AldaronLau/png_pong","owner":"AldaronLau","description":"A pure Rust PNG image decoder and encoder based on lodepng.","archived":false,"fork":false,"pushed_at":"2024-11-06T04:24:13.000Z","size":64440,"stargazers_count":26,"open_issues_count":6,"forks_count":3,"subscribers_count":3,"default_branch":"v0","last_synced_at":"2024-11-06T05:16:45.595Z","etag":null,"topics":["crate","decoder","encoder","forbid-unsafe","lodepng","pix","png","png-decoder","png-encoder","png-pong","pngs","rust-png"],"latest_commit_sha":null,"homepage":"https://docs.rs/png_pong","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/AldaronLau.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-08-03T16:29:26.000Z","updated_at":"2024-11-06T04:24:15.000Z","dependencies_parsed_at":"2024-11-06T05:26:50.316Z","dependency_job_id":null,"html_url":"https://github.com/AldaronLau/png_pong","commit_stats":{"total_commits":34,"total_committers":7,"mean_commits":4.857142857142857,"dds":"0.38235294117647056","last_synced_commit":"112e11c28cbe8fdaa3bc28351ad4691a8ca913d1"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AldaronLau%2Fpng_pong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AldaronLau%2Fpng_pong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AldaronLau%2Fpng_pong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AldaronLau%2Fpng_pong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AldaronLau","download_url":"https://codeload.github.com/AldaronLau/png_pong/tar.gz/refs/heads/v0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225028961,"owners_count":17409615,"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":["crate","decoder","encoder","forbid-unsafe","lodepng","pix","png","png-decoder","png-encoder","png-pong","pngs","rust-png"],"created_at":"2024-08-04T08:02:02.705Z","updated_at":"2024-11-19T23:30:41.180Z","avatar_url":"https://github.com/AldaronLau.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# ![PNG Pong]\n\n#### A pure Rust PNG/APNG encoder \u0026 decoder\n\n[![tests](https://github.com/AldaronLau/png_pong/actions/workflows/ci.yml/badge.svg)](https://github.com/AldaronLau/png_pong/actions/workflows/ci.yml)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/AldaronLau/png_pong)](https://github.com/AldaronLau/png_pong/)\n[![GitHub contributors](https://img.shields.io/github/contributors/AldaronLau/png_pong)](https://github.com/AldaronLau/png_pong/graphs/contributors)  \n[![Crates.io](https://img.shields.io/crates/v/png_pong)](https://crates.io/crates/png_pong)\n[![Crates.io](https://img.shields.io/crates/d/png_pong)](https://crates.io/crates/png_pong)\n[![Crates.io (recent)](https://img.shields.io/crates/dr/png_pong)](https://crates.io/crates/png_pong)  \n[![Crates.io](https://img.shields.io/crates/l/png_pong)](https://github.com/AldaronLau/png_pong/search?l=Text\u0026q=license)\n[![Docs.rs](https://docs.rs/png_pong/badge.svg)](https://docs.rs/png_pong/)\n\nThis is a pure Rust PNG image decoder and encoder taking inspiration from\nlodepng.  This crate allows easy reading and writing of PNG files without any\nsystem dependencies.\n\n### Why another PNG crate?\n\nThese are the 4 Rust PNG encoder/decoder crates I know of:\n- [png] - The one everyone uses (used to be able to load less pngs than\n  png\\_pong and slower, but has caught up).\n- [lodepng] - Loads all the PNGs, code is ported from C, therefore code is hard\n  read \u0026 maintain, also uses slow implementation of deflate/inflate algorithm.\n- [imagefmt] - Abandoned, and limited in what files it can open, but with a lot\n  less lines of code.\n- [imagine] - PNG decoding only.\n\nOriginally I made the [aci\\_png] based on imagefmt, and intended to add more\nfeatures.  At the time, I didn't want to write a PNG encoder/decoder from\nscratch so I decided to take `lodepng` which has more features (and more low\nlevel features) and clean up the code, upgrade to 2018 edition of Rust, depend\non the miniz\\_oxide crate (because it can decompress faster than lodepng's\nINFLATE implementation) and get rid of the libc dependency so it *actually*\nbecomes pure Rust (lodepng claimed to be, but called C's malloc and free).\nThen, I rewrote the entire library, based on [gift] and [pix].\n\n### Goals\n\n - Forbid unsafe.\n - APNG support as iterator.\n - Fast.\n - Compatible with pix / gift-style API.\n - Load all PNG files crushed with pngcrush.\n - Save crushed PNG files.\n - Clean, well-documented, concise code.\n - Implement all completed, non-deprecated chunks in the\n   [PNG 1.2 Specification], including the [PNG 1.2 Extensions] and the\n   [APNG Specification]\n\n### TODO\n\n - Implement APNG reading.\n - Implement Chunk reading (with all the different chunk structs).\n - StepDecoder should wrap StepDecoder, RasterEncoder should wrap ChunkEncoder\n - More test cases to test against.\n\n### Benchmarks And Comparisons\n\nTODO: Update, ran on older png\\_pong and Rust 1.52.1\n\nUsing Rust 1.52.1, criterion and 4 different PNG sizes with PNGs from\n\"./tests/png/\" (units are: us / microseconds).  I stopped anything that was\npredicted to take longer than a half hour with criterion with the message\n\"TIMEOUT\".\n\n- sRGB 1x1: Uses `tests/png/profile.png`\n- sRGBA 1x1: Uses `tests/png/test.png`\n- sRGB 64x64: Uses `test/png/4.png`\n- sRGBA 64x64: Uses `tests/png/res.png`\n- sRGB 256x256: `tests/png/PngSuite.png`\n- sRGBA 256x256: Uses `tests/png/icon.png`\n- sRGB 4096x4096: `tests/png/plopgrizzly.png`\n- sRGBA 4096x4096: Uses `tests/png/noise.png`\n\n#### Encoder\n\n| Library    | sRGB 1x1 | sRGBA 1x1 | sRGB 64x64 | sRGBA 64x64 | sRGB 256x256 | sRGBA 256x256 | sRGB 4096x4096 | sRGBA 4096x4096 |\n|------------|----------|-----------|------------|-------------|--------------|---------------|----------------|-----------------|\n| png_pong   | 41.956   | 8.2661    | 1\\_025.7   | 700.80      | 2\\_646.1     | 5\\_061.5      | 587\\_320       | 3\\_587\\_100     |\n| png        | 29.538   | 9.4122    | 213.49     | 203.02      | 944.99       | 1\\_534.3      | 201\\_680       | 1\\_535\\_300     |\n| lodepng    | 59.989   | 10.700    | 1\\_399.3   | 982.63      | 3\\_391.3     | 6\\_664.7      | 831\\_190       | 3\\_394\\_900     |\n| imagefmt   | 8.7942   | 8.7399    | 211.01     | 177.82      | 901.22       | 1\\_569.4      | 218\\_550       | 1\\_285\\_700     |\n| imagine    | ---      | ---       | ---        | ---         | ---          | ---           | ---            | ---             |\n| aci_png    | FAILS    | 30.987    | FAILS      | 289.24      | FAILS        | 2\\_298.1      | FAILS          | 2\\_135\\_400     |\n| libpng-sys | 6.8443   | 2.9461    | 1\\_613.5   | 769.70      | 2\\_261.1     | 4\\_745.2      | 520\\_770       | 2\\_926\\_900     |\n\n#### Decoder\n\n| Library    | sRGB 1x1 | sRGBA 1x1 | sRGB 64x64 | sRGBA 64x64 | sRGB 256x256 | sRGBA 256x256 | sRGB 4096x4096 | sRGBA 4096x4096 |\n|------------|----------|-----------|------------|-------------|--------------|---------------|----------------|-----------------|\n| png_pong   | 7.7520   | 3.9459    | 77.981     | 99.384      | 752.95       | 901.98        | 178\\_880       | 570\\_200        |\n| png        | 8.1195   | 6.6107    | 54.834     | 71.873      | 643.09       | 686.29        | 128\\_000       | 355\\_080        |\n| lodepng    | 5.8958   | 5.4527    | 77.050     | 97.762      | 882.83       | 982.76        | 230\\_570       | 563\\_210        |\n| imagefmt   | 4.2864   | 4.8706    | 74.715     | 82.026      | 566.86       | 758.27        | 69\\_465        | 545\\_060        |\n| imagine    | 2.8809   | 0.44822   | 3\\_202.3   | 2\\_266.4    | 2\\_056.1     | 10\\_753       | 442\\_750       | 27\\_944\\_000    |\n| aci_png    | 5.0243   | 4.3516    | 201.29     | 174.30      | 1\\_500.6     | 1\\_689.8      | 398\\_340       | 1\\_323\\_600     |\n| libpng-sys | 3.6011   | 0.48747   | 1.8175     | 0.67344     | 25.809       | 4.4175        | 19\\_400        | 18\\_262         |\n\n## Table of Contents\n\n - [API]\n - [Features]\n - [Upgrade]\n - [License]\n   - [Contribution]\n\n## API\n\nAPI documentation can be found on [docs.rs].\n\n## Features\n\nThere are no optional features.\n\n## Upgrade\n\nYou can use the [changelog] to facilitate upgrading this crate as a dependency.\n\n## MSRV\n\nThe current MSRV is Rust 1.70.\n\nMSRV is updated according to the [Ardaku MSRV guidelines].\n\n## License\n\nCopyright © 2019-2024 The PNG Pong Crate Contributor(s)\n\nLicensed under either of\n - Apache License, Version 2.0, ([LICENSE-APACHE] or\n   \u003chttps://www.apache.org/licenses/LICENSE-2.0\u003e)\n - Zlib License, ([LICENSE-ZLIB] or \u003chttps://opensource.org/licenses/Zlib\u003e)\n\nat your option.\n\n### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\nBefore contributing, check out the [contribution guidelines], and, as always,\nmake sure to always follow the [code of conduct].\n\n[Ardaku MSRV guidelines]: https://github.com/ardaku/.github/blob/v1/profile/MSRV.md\n[PNG Pong]: https://raw.githubusercontent.com/AldaronLau/png_pong/v0/res/icon.png\n[code of conduct]: https://github.com/AldaronLau/png_pong/blob/v0/CODE_OF_CONDUCT.md\n[contribution guidelines]: https://github.com/AldaronLau/png_pong/blob/v0/CONTRIBUTING.md\n[LICENSE-APACHE]: https://github.com/AldaronLau/png_pong/blob/v0/LICENSE-APACHE\n[LICENSE-ZLIB]: https://github.com/AldaronLau/png_pong/blob/v0/LICENSE-ZLIB\n[changelog]: https://github.com/AldaronLau/png_pong/blob/v0/CHANGELOG.md\n[docs.rs]: https://docs.rs/png_pong\n[API]: #api\n[Features]: #features\n[Upgrade]: #upgrade\n[License]: #license\n[Contribution]: #contribution\n[PNG 1.2 Specification]: http://www.libpng.org/pub/png/spec/1.2/PNG-Contents.html\n[PNG 1.2 Extensions]: https://pmt.sourceforge.io/specs/pngext-1.2.0-pdg-h20.html\n[APNG Specification]: https://wiki.mozilla.org/APNG_Specification\n[gift]: https://crates.io/crates/gift\n[pix]: https://crates.io/crates/pix\n[aci\\_png]: https://crates.io/crates/aci_png\n[png]: https://crates.io/crates/png\n[lodepng]: https://crates.io/crates/lodepng\n[imagefmt]: https://crates.io/crates/imagefmt\n[imagine]: https://crates.io/crates/imagine\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAldaronLau%2Fpng_pong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAldaronLau%2Fpng_pong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAldaronLau%2Fpng_pong/lists"}