{"id":13732037,"url":"https://github.com/catid/Zpng","last_synced_at":"2025-05-08T06:31:07.126Z","repository":{"id":137388726,"uuid":"131947838","full_name":"catid/Zpng","owner":"catid","description":"Better lossless compression than PNG with a simpler algorithm","archived":false,"fork":false,"pushed_at":"2018-06-17T16:10:58.000Z","size":698,"stargazers_count":266,"open_issues_count":2,"forks_count":17,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-08-04T02:10:44.061Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catid.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}},"created_at":"2018-05-03T05:52:14.000Z","updated_at":"2024-07-31T06:32:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"0b3747a9-67cc-4c71-b7a4-cd0a488ed5c4","html_url":"https://github.com/catid/Zpng","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catid%2FZpng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catid%2FZpng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catid%2FZpng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catid%2FZpng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catid","download_url":"https://codeload.github.com/catid/Zpng/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224707602,"owners_count":17356362,"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":[],"created_at":"2024-08-03T02:01:44.465Z","updated_at":"2024-11-14T23:30:49.598Z","avatar_url":"https://github.com/catid.png","language":"C","funding_links":[],"categories":["Graphics"],"sub_categories":[],"readme":"# Zpng\nSmall experimental lossless photographic image compression library with a C API and command-line interface.\n\nIt's much faster than PNG and compresses better for photographic images.\nThis compressor often takes less than 6% of the time of a PNG compressor and produces a file that is 66% of the size.\nIt was written in just 500 lines of C code thanks to Facebook's Zstd library.\n\nThe goal was to see if I could create a better lossless compressor than PNG in just one evening (a few hours) using Zstd and some past experience writing my GCIF library.  Zstd is magical.\n\nI'm not expecting anyone else to use this, but feel free if you need some fast compression in just a few hundred lines of C code.\n\n\n#### Example results\n\n```\n$ ./ZpngApp.exe -c IMG_0008.jpg IMG_0008.zpng\nCompressing IMG_0008.jpg to IMG_0008.zpng\nLoaded IMG_0008.jpg in 338.712 msec\nCompressed ZPNG in 248.737 msec\nZPNG compression size: 27731886 bytes\n\n$ ./ZpngApp.exe -d IMG_0008.zpng IMG_0008.png\nDecompressing IMG_0008.zpng to IMG_0008.png (output will be PNG format)\nDecompressed ZPNG in 123.028 msec\nCompressed PNG in 4339.82 msec\nWrote decompressed PNG file: IMG_0008.png\n\n$ ll IMG_0008.*\n-rw-r--r-- 1 leon 197121 13991058 Jun 25  2017 IMG_0008.jpg\n-rw-r--r-- 1 leon 197121 41897485 May  2 22:29 IMG_0008.png\n-rw-r--r-- 1 leon 197121 27731886 May  2 22:29 IMG_0008.zpng\n```\n\nFLIF and other formats get better compression ratios but you will wait like 20 seconds for them to finish.\n\nThis compressor runs faster than some JPEG decoders!\nThis compressor takes less than 6% of the time of the PNG compressor and produces a file that is 66% of the size.\n\n\n#### How it works\n\nThis library is similar to PNG in that the image is first filtered, and then submitted to a data compressor.\nThe filtering step is a bit simpler and faster but somehow more effective than the one used in PNG.\nThe data compressor used is Zstd, which makes it significantly faster than PNG to compress and decompress.\n\nFiltering:\n\n(1) Reversible color channel transformation.\n(2) Split each color channel into a separate color plane.\n(3) Subtract each color value from the one to its left.\n\nThis kind of filtering works great for large photographic images and is very fast.\n\n\n#### Experimental results\n\nI ran a few experiments to arrive at this simple codec:\n\nInterleaving is a 1% compression win, and a 0.3% performance win: Not used.\n\nSplitting the data into blocks of 4 at a time actually reduces compression.\n\n```\nNo filtering:\nTotal size = 2629842851\nTotal compress time = 12942621 usec\n\nSubtract only:\nTotal size = 1570514796\nTotal compress time = 16961469 usec\n\nColor filter, followed by subtract:\nTotal size = 1514724952\nTotal compress time = 16554638 usec\n\nSubtract, followed by color filter:\nTotal size = 1514724952\nTotal compress time = 16376380 usec\nTotal de-compress time = 6511436 usec\nNotes: Order of applying filter does not matter but this way is faster.\n\nSubtract, followed by color filter YUVr from JPEG2000:\nTotal size = 1506802640\nTotal compress time = 17169743 usec\nTotal de-compress time = 7107897 usec\nNote: Only 0.5% better compression ratio in trade for performance impact.\n\nSubtract, followed by color filter, splitting into YUV color planes:\nTotal size = 1486938616\nTotal compress time = 14514563 usec\nTotal de-compress time = 6596546 usec\nNote: Huge improvement!  Let's call this Zpng!\n```\n\n#### Credits\n\nSoftware by Christopher A. Taylor mrcatid@gmail.com\n\nPlease reach out if you need support or would like to collaborate on a project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatid%2FZpng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatid%2FZpng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatid%2FZpng/lists"}