{"id":13530895,"url":"https://github.com/randy408/libspng","last_synced_at":"2025-05-16T05:06:02.907Z","repository":{"id":40744927,"uuid":"127125127","full_name":"randy408/libspng","owner":"randy408","description":"Simple, modern libpng alternative","archived":false,"fork":false,"pushed_at":"2024-06-15T13:27:26.000Z","size":965,"stargazers_count":780,"open_issues_count":77,"forks_count":81,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-08T20:55:37.494Z","etag":null,"topics":["c","c99","cmake","codec","decoding","encoder","libpng","meson","optimized","oss-fuzz","png","png-decoder","png-encoder","spng"],"latest_commit_sha":null,"homepage":"https://libspng.org","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/randy408.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"libspng"}},"created_at":"2018-03-28T10:39:20.000Z","updated_at":"2025-05-05T14:13:50.000Z","dependencies_parsed_at":"2024-11-08T04:21:32.136Z","dependency_job_id":null,"html_url":"https://github.com/randy408/libspng","commit_stats":{"total_commits":939,"total_committers":22,"mean_commits":42.68181818181818,"dds":"0.029818956336528202","last_synced_commit":"adc94393dbeddf9e027d1b2dfff7c1bab975224e"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randy408%2Flibspng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randy408%2Flibspng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randy408%2Flibspng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randy408%2Flibspng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/randy408","download_url":"https://codeload.github.com/randy408/libspng/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140885,"owners_count":22021239,"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":["c","c99","cmake","codec","decoding","encoder","libpng","meson","optimized","oss-fuzz","png","png-decoder","png-encoder","spng"],"created_at":"2024-08-01T07:00:57.241Z","updated_at":"2025-05-16T05:05:57.888Z","avatar_url":"https://github.com/randy408.png","language":"C","readme":"[![Gitter](https://badges.gitter.im/libspng/community.svg)](https://gitter.im/libspng/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n[![Financial Contributors on Open Collective](https://opencollective.com/libspng/all/badge.svg?label=financial+contributors)](https://opencollective.com/libspng)\n[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/libspng.svg)](https://oss-fuzz-build-logs.storage.googleapis.com/index.html#libspng)\n[![Coverity](https://scan.coverity.com/projects/15336/badge.svg)](https://scan.coverity.com/projects/randy408-libspng)\n[![tag](https://img.shields.io/github/tag-date/randy408/libspng.svg)](https://libspng.org/download)\n\n# libspng\n\nlib**spng** (**s**imple **png**) is a C library for reading and writing Portable Network Graphics (PNG)\nformat files with a focus on security and ease of use.\n\nlibspng is an alternative to libpng, the projects are separate and the APIs are\nnot compatible.\n\n## Motivation\n\nThe goal is to provide a fast PNG library with a simpler API than [libpng](https://github.com/glennrp/libpng/blob/libpng16/png.h),\nit outperforms the reference implementation in common use cases.\n\n## Performance\n\n![](https://libspng.org/perfx86.png)\n\n## Features\n\n| Feature                              |  spng   | libpng             | stb_image | lodepng |\n|--------------------------------------|---------|--------------------|-----------|---------|\n| Decode from stream                   | ✅      |  ✅               | ✅       | ❌      |\n| Gamma correction                     | ✅      |  ✅               | ❌       | ❌      |\n| No known security bugs\u003csup\u003e[1]\u003c/sup\u003e | ✅      |  ✅               | ❌       | ✅      |\n| Progressive image read               | ✅      |  ✅               | ❌       | ❌      |\n| Parses all standard chunks           | ✅      |  ✅               | ❌       | ❌      |\n| Doesn't require zlib\u003csup\u003e[2]\u003c/sup\u003e   | ✅      |  ❌               | ✅       | ✅      |\n| Encoding                             | ✅      |  ✅               | ✅       | ✅      |\n| Animated PNG                         | Planned  |  ✅\u003csup\u003e[3]\u003c/sup\u003e | ❌       | ❌      |\n\n\u003csup\u003e[1]\u003c/sup\u003e The project is fuzz tested on [OSS-Fuzz](https://github.com/google/oss-fuzz) and vulnerabilities are fixed before they become public.\n\n\u003csup\u003e[2]\u003c/sup\u003e Building with miniz is [supported](docs/build.md#miniz).\n\n\u003csup\u003e[3]\u003c/sup\u003e With a 3rd party patch\n\n## Getting spng\n\nDownload the [latest release](https://libspng.org/download) and include `spng.c/spng.h` in your project,\nyou can also build with CMake or Meson, refer to the [documentation](docs/build.md) for details.\n\n## Usage\n\n```c\n#include \u003cspng.h\u003e\n\n/* Create a decoder context */\nspng_ctx *ctx = spng_ctx_new(0);\n\n/* Set an input buffer */\nspng_set_png_buffer(ctx, buf, buf_size);\n\n/* Determine output image size */\nspng_decoded_image_size(ctx, SPNG_FMT_RGBA8, \u0026out_size);\n\n/* Decode to 8-bit RGBA */\nspng_decode_image(ctx, out, out_size, SPNG_FMT_RGBA8, 0);\n\n/* Free context memory */\nspng_ctx_free(ctx);\n\n\n/* Creating an encoder context requires a flag */\nspng_ctx *enc = spng_ctx_new(SPNG_CTX_ENCODER);\n\n/* Encode to internal buffer managed by the library */\nspng_set_option(enc, SPNG_ENCODE_TO_BUFFER, 1);\n\n/* Specify image dimensions, PNG format */\nstruct spng_ihdr ihdr =\n{\n    .width = width,\n    .height = height,\n    .bit_depth = 8,\n    .color_type = SPNG_COLOR_TYPE_TRUECOLOR_ALPHA\n};\n\n/* Image will be encoded according to ihdr.color_type, .bit_depth */\nspng_set_ihdr(enc, \u0026ihdr);\n\n/* SPNG_FMT_PNG is a special value that matches the format in ihdr,\n   SPNG_ENCODE_FINALIZE will finalize the PNG with the end-of-file marker */\nspng_encode_image(enc, image, image_size, SPNG_FMT_PNG, SPNG_ENCODE_FINALIZE);\n\n/* PNG is written to an internal buffer by default */\nvoid *png = spng_get_png_buffer(enc, \u0026png_size, \u0026error);\n\n/* User owns the buffer after a successful call */\nfree(png);\n\n/* Free context memory */\nspng_ctx_free(enc);\n```\n\nSee [example.c](examples/example.c).\n\n## License\n\nCode is licensed under the BSD 2-clause \"Simplified\" License.\n\nThe project contains optimizations and test images from libpng, these are licensed under the\n[PNG Reference Library License version 2](http://www.libpng.org/pub/png/src/libpng-LICENSE.txt).\n\n## Security \u0026 Testing\n\nCode is written according to the rules of the\n[CERT C Coding Standard](https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard).\nAll integer arithmetic is checked for overflow and all error conditions are handled gracefully.\n\nThe library is continuously fuzzed by [OSS-Fuzz](https://github.com/google/oss-fuzz),\ncode is also scanned with Clang Static Analyzer, Coverity Scan and PVS-Studio.\n\nThe test suite consists of over 1000 test cases,\n175 [test images](http://www.schaik.com/pngsuite/) are decoded with all possible\noutput format and flag combinations and compared against libpng for [correctness](tests/README.md#Correctness).\n\n## Versioning\n\nReleases follow the [semantic versioning](https://semver.org/) scheme with additional guarantees:\n\n* Releases from 0.4.0 to 0.8.x are stable\n* If 1.0.0 will introduce breaking changes then 0.8.x will be maintained as a separate stable branch\n\nCurrently 1.0.0 is planned to be [compatible](https://github.com/randy408/libspng/issues/3).\n\n## Documentation\n\nOnline documentation is available at [libspng.org/docs](https://libspng.org/docs).\n\n## Known Issues\n\n* Decoding to `SPNG_FMT_G8`, `SPNG_FMT_GA8` and `SPNG_FMT_GA16` output formats is not supported\n for all PNG color type and bit depth combinations, see documentation for details.\n* Gamma correction is not implemented for `SPNG_FMT_PNG`, `SPNG_FMT_G8`, `SPNG_FMT_GA8`\n and `SPNG_FMT_GA16` output formats.\n\n## Supporting spng\n\nYou can sponsor development through [OpenCollective](https://opencollective.com/libspng/), funds will be used for maintenance and further development according to the [roadmap](https://github.com/randy408/libspng/milestones).\n\n### OpenCollective backers\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/libspng\"\u003e\u003cimg src=\"https://opencollective.com/libspng/backers.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/libspng/contribute)]\n\n\u003ca href=\"https://opencollective.com/libspng/sponsor/0/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/1/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/2/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/3/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/4/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/5/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/6/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/7/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/8/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/libspng/sponsor/9/website\"\u003e\u003cimg src=\"https://opencollective.com/libspng/sponsor/9/avatar.svg\"\u003e\u003c/a\u003e\n","funding_links":["https://opencollective.com/libspng","https://opencollective.com/libspng/","https://opencollective.com/libspng/contribute"],"categories":["Image Processing","Libraries","C","compression"],"sub_categories":["C","PNG"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandy408%2Flibspng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandy408%2Flibspng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandy408%2Flibspng/lists"}