{"id":15668292,"url":"https://github.com/devstopfix/chunk-png-elixir","last_synced_at":"2025-07-08T16:33:33.339Z","repository":{"id":64863023,"uuid":"578573836","full_name":"devstopfix/chunk-png-elixir","owner":"devstopfix","description":"Manipulate chunks and metadata of PNG files","archived":false,"fork":false,"pushed_at":"2022-12-16T16:12:23.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T06:49:12.978Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/devstopfix.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}},"created_at":"2022-12-15T11:31:22.000Z","updated_at":"2022-12-15T11:32:59.000Z","dependencies_parsed_at":"2022-12-17T00:52:02.139Z","dependency_job_id":null,"html_url":"https://github.com/devstopfix/chunk-png-elixir","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fchunk-png-elixir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fchunk-png-elixir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fchunk-png-elixir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devstopfix%2Fchunk-png-elixir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devstopfix","download_url":"https://codeload.github.com/devstopfix/chunk-png-elixir/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246277352,"owners_count":20751548,"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-10-03T14:07:58.441Z","updated_at":"2025-03-30T04:42:12.961Z","avatar_url":"https://github.com/devstopfix.png","language":"Elixir","readme":"# ChunkPNG\n\nLibrary for manipulating metadata in PNG files.\n\n## About\n\nPNG files consist of a magic number, a mandatory header chunk, then a list of\noptional chunks. This library splits the file into a list of chunks with a\ncursor and allows you to insert and remove chunks.\n\nA standard PNG may consist of:\n\n1. magic number (8 bytes)\n2. `IHDR` - mandatory first chunk of a PNG datastream\n3. `PLTE` - pallete for indexed PNG images\n4. `IDAT` - image data chunk(s)\n5. `IEND` - image trailer, the last in a PNG datastream\n\nConsider the use case of inserting copyright metadata. After parsing your image\nyou receive a list of chunks in the form of a list-zipper which is a tuple of\nthe list of chunks up until IDHR, then the focus (probably PLTE), then the\nremaining list of chunks after the focus. You may immediately insert your\nnew chunks to the left of the focus and after the IHDR, or navigate to the\nend and append new chunks there.\n\nThere are three forms of textual chunks:\n\n* `tEXt` - simple key-value using the Latin-1 character set\n* `iTXt` - simple key-value using UTF-8 encoding with optional value compression\n* `zTXt` - equivalent to `tEXt` but using deflate compression for large text blocks\n\nWhen finished the list of chunks can be written out to a file or a buffer.\n\n## Installation\n\nFrom hex:\n\n```elixir\n{:chunk_png, \"~\u003e 1.0\"}\n```\n\nThis library relies on [codepagex] for [Latin-1/ISO 8859-1 encoding][latin1] and for \nfaster compilation we recommend adding this configuration to your application:\n\n```elixir\nconfig :codepagex, :encodings, [:iso_8859_1]\n```\n\n## Example\n\nFetch an image:\n\n```bash\nwget https://elixir-lang.org/images/logo/logo.png -O /tmp/elixir.png\n```\n\nManipulate and write:\n\n```elixir\n{:ok, img} = ChunkPNG.parse_file!(\"/tmp/elixir.png\")\n\nimg\n|\u003e ChunkPNG.insert_left(ChunkPNG.TEXT.new!(\"Copyright\", \"José Valim\"))\n|\u003e ChunkPNG.write_file(\"/tmp/elixir-c.png\")\n```\n\nVerify:\n\n```bash\n% hexdump -C /tmp/elixir-c.png | grep -A 1 Copy\n00000020  40 00 00 00 14 74 45 58  74 43 6f 70 79 72 69 67  |@....tEXtCopyrig|\n00000030  68 74 00 4a 6f 73 e9 20  56 61 6c 69 6d d0 b2 dd  |ht.Jos. Valim...|\n```\n\n\n[codepagex]: https://github.com/tallakt/codepagex#encoding-selection\n[latin1]: https://en.wikipedia.org/wiki/ISO/IEC_8859-1","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstopfix%2Fchunk-png-elixir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevstopfix%2Fchunk-png-elixir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevstopfix%2Fchunk-png-elixir/lists"}