{"id":20687611,"url":"https://github.com/susumuota/fast-png-parser","last_synced_at":"2026-04-12T03:05:12.760Z","repository":{"id":65147943,"uuid":"583831901","full_name":"susumuota/fast-png-parser","owner":"susumuota","description":"Fast, lightweight and memory efficient PNG chunk parser.","archived":false,"fork":false,"pushed_at":"2022-12-31T19:57:07.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T00:30:27.189Z","etag":null,"topics":["javascript","node","nodejs","npm","npm-module","parser","png","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/susumuota.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}},"created_at":"2022-12-31T04:43:36.000Z","updated_at":"2023-01-02T08:40:12.000Z","dependencies_parsed_at":"2023-01-05T04:25:20.047Z","dependency_job_id":null,"html_url":"https://github.com/susumuota/fast-png-parser","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/susumuota%2Ffast-png-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susumuota%2Ffast-png-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susumuota%2Ffast-png-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/susumuota%2Ffast-png-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/susumuota","download_url":"https://codeload.github.com/susumuota/fast-png-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242945840,"owners_count":20210762,"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":["javascript","node","nodejs","npm","npm-module","parser","png","typescript"],"created_at":"2024-11-16T22:57:47.046Z","updated_at":"2025-12-25T03:35:44.327Z","avatar_url":"https://github.com/susumuota.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fast-png-parser\n\n[![npm](https://img.shields.io/npm/v/fast-png-parser?color=blue)](https://www.npmjs.com/package/fast-png-parser)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/fast-png-parser)](https://github.com/susumuota/fast-png-parser)\n[![GitHub](https://img.shields.io/github/license/susumuota/fast-png-parser)](https://github.com/susumuota/fast-png-parser/blob/main/LICENSE)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/susumuota/fast-png-parser/build.yaml)](https://github.com/susumuota/fast-png-parser/actions/workflows/build.yaml)\n[![GitHub last commit](https://img.shields.io/github/last-commit/susumuota/fast-png-parser)](https://github.com/susumuota/fast-png-parser/commits)\n\nFast, lightweight and memory efficient PNG chunk parser.\n\n## Install\n\n```sh\nnpm install --save fast-png-parser\n```\n\n## Usage\n\n- Extract the image `width` and `height`.\n\nIt should be fast and memory efficient because `extractPNG` returns immediately just after the `IHDR` chunk. It must be the first chunk of PNG file so that you can skip all of the rest of chunks.\n\n```javascript\nimport { open } from 'node:fs/promises';\nimport { extractPNG, parsePNG } from 'fast-png-parser';\n\nconst fh = await open('test.png', 'r');\nconst chunks = await extractPNG(fh, { filter: type =\u003e type === 'IHDR', maxChunks: 1 });\nfh.close();\n\nif (chunks[0]) {\n  const ihdr = parsePNG(chunks[0]);\n  console.log(ihdr.width, ihdr.height);\n}\n```\n\n- Extract the first `tEXt` chunk.\n\nIt should be fast and memory efficient because `extractPNG` returns immediately just after the first `tEXt` chunk. In most cases, `tEXt` chunks appear before `IDAT` chunks so that you can skip to read large `IDAT` chunks.\n\n```javascript\nimport { open } from 'node:fs/promises';\nimport { extractPNG, parsePNG } from 'fast-png-parser';\n\nconst fh = await open('test.png', 'r');\nconst chunks = await extractPNG(fh, { filter: type =\u003e type === 'tEXt', maxChunks: 1 });\nfh.close();\n\nif (chunks[0]) {\n  const text = parsePNG(chunks[0]);\n  console.log(text.keyword, text.text);\n}\n```\n\n- CRC check\n\nIf you need to check CRC, install `crc-32` module and create `calcCRC32` function to check CRC.\n\n```javascript\nimport { open } from 'node:fs/promises';\nimport { extractPNG, parsePNG } from 'fast-png-parser';\nimport CRC32 from 'crc-32';\n\nconst calcCRC32 = chunk =\u003e CRC32.buf(Buffer.concat([Buffer.from(chunk.type), chunk.data]));\n\nconst fh = await open('test.png', 'r');\nconst chunks = await extractPNG(fh);\nfh.close();\n\nconsole.log(chunks.map(chunk =\u003e chunk.crc === calcCRC32(chunk)));\n```\n\n## Source code\n\n- https://github.com/susumuota/fast-png-parser\n\n## License\n\nMIT License. See LICENSE file.\n\n## Author\n\nSusumu OTA\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusumuota%2Ffast-png-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsusumuota%2Ffast-png-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsusumuota%2Ffast-png-parser/lists"}