{"_id":"@data2image/core","_rev":"6-58cce13f9cfc415a6f55dbe4e726a9b1","name":"@data2image/core","dist-tags":{"latest":"1.2.1"},"versions":{"1.0.0":{"name":"@data2image/core","version":"1.0.0","keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"license":"GPL-3.0-only","_id":"@data2image/core@1.0.0","maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"homepage":"https://github.com/Benji377/data2image","bugs":{"url":"https://github.com/Benji377/data2image/issues"},"dist":{"shasum":"4e8568f9cdbc1c6c784a05e2c5c6c4f0b3a46426","tarball":"https://registry.npmjs.org/@data2image/core/-/core-1.0.0.tgz","fileCount":7,"integrity":"sha512-lEzWK8VEDGR64XFuhL3oYSnim+3VrHGyFUexl/8+ipz6oprWwEEaB0OmcSUDOpCXXsd/Y9gGxUQoYjOI02+17g==","signatures":[{"sig":"MEQCIC7YbuVdP+JGhZ0lJbNF3IK+qxF+i+G+x6l0axiCPhflAiApPlVmKELpuXYpQfgIYVFAPl+CiHPZPGAlqqQ9v2KaEw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34237},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"595492a8844a3479e4b10701036e3b9fb44b69b1","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"benji377","email":"demetzbenjamin23@gmail.com"},"repository":{"url":"git+https://github.com/Benji377/data2image.git","type":"git","directory":"packages/core"},"_npmVersion":"11.11.0","description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","directories":{},"_nodeVersion":"25.7.0","dependencies":{"pako":"^2.1.0","upng-js":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","@types/pako":"^2.0.3"},"_npmOperationalInternal":{"tmp":"tmp/core_1.0.0_1773143380466_0.5800828714333377","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@data2image/core","version":"1.0.1","keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"license":"MIT","_id":"@data2image/core@1.0.1","maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"homepage":"https://benji377.github.io/data2image/","bugs":{"url":"https://github.com/Benji377/data2image/issues"},"dist":{"shasum":"baf518855c8b5ef807c95d87b53c2a6e055eea78","tarball":"https://registry.npmjs.org/@data2image/core/-/core-1.0.1.tgz","fileCount":9,"integrity":"sha512-yy/2TsFFls1DP3hPbeuDCP0CCWuEmg1WENX5mqbIBNbqG6/H8nsaHdHUcELF+81Em490Gtzn77jUm9AOuGxcrw==","signatures":[{"sig":"MEUCIEojuzKlnMlSl1ceRAqB7HsHtTqeUeCHp+wOBXF4wTmqAiEAlOO8QbiPQ3hl/Z+zvsRCclevKgggvMwahCs6JIHrLmE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@data2image%2fcore@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":38413},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"ac8186e7ddb266337aa26cefd2744ae8fbaa0d48","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c5e66f15-70c4-409b-8f8f-03d12c006108"}},"repository":{"url":"git+https://github.com/Benji377/data2image.git","type":"git","directory":"packages/core"},"_npmVersion":"11.9.0","description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","directories":{},"_nodeVersion":"24.14.0","dependencies":{"pako":"^2.1.0","upng-js":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","@types/pako":"^2.0.3"},"_npmOperationalInternal":{"tmp":"tmp/core_1.0.1_1773146749769_0.1601565394633242","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@data2image/core","version":"1.0.2","keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"license":"MIT","_id":"@data2image/core@1.0.2","maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"homepage":"https://benji377.github.io/data2image/","bugs":{"url":"https://github.com/Benji377/data2image/issues"},"dist":{"shasum":"9c0e78b4eaebd3f84f6a1ff5f6960415e968a318","tarball":"https://registry.npmjs.org/@data2image/core/-/core-1.0.2.tgz","fileCount":9,"integrity":"sha512-Y7aLmSXcrIf+Bs/Bk30QQ1M4J042jj9gL688m1IEt9fiP8+er+ZnRjbNrBbns03lUIJvFM2eV2eb1mYnCLgsrQ==","signatures":[{"sig":"MEYCIQDVIWlK2pH9f+PSbP7qbWIj6T/aePTtOQdlBRU+HHqGvAIhALHWpzming6sLv5ie2SPMrf8qhHzYWjT8Eg1PwJxOeS7","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@data2image%2fcore@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":38295},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"2ed3cb99db05980f18f9163fb20d5cf7ab3f3514","scripts":{"test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c5e66f15-70c4-409b-8f8f-03d12c006108"}},"repository":{"url":"git+https://github.com/Benji377/data2image.git","type":"git","directory":"packages/core"},"_npmVersion":"11.9.0","description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","directories":{},"_nodeVersion":"24.14.0","dependencies":{"pako":"^2.1.0","upng-js":"^2.1.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^3.0.0","@types/pako":"^2.0.3"},"_npmOperationalInternal":{"tmp":"tmp/core_1.0.2_1773147008890_0.5290856054839821","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@data2image/core","version":"1.1.0","keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"license":"MIT","_id":"@data2image/core@1.1.0","maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"homepage":"https://benji377.github.io/data2image/","bugs":{"url":"https://github.com/Benji377/data2image/issues"},"dist":{"shasum":"672433deb4c7b83e184d4c08bf0ca3d874847d59","tarball":"https://registry.npmjs.org/@data2image/core/-/core-1.1.0.tgz","fileCount":9,"integrity":"sha512-YpobkK+MDLDzEUo9UFM9iUitmtdLTx3QJWoDH+piJJPxxy728fBI2G2qwBux4tmNbOv4/sK8D/YO+84xQrWpMw==","signatures":[{"sig":"MEQCIBnWOYEhjIASKKritshFStHTsbOr/qpmKqSlZJLtec1dAiA7lPt0UXt+/hb4rS6PVP4nrp3c51kRtkX4n8GdDcLnAw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@data2image%2fcore@1.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":35967},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"186a47c042be29fe696ad775af2fbdd79a544569","scripts":{"test":"vitest run","build":"tsup","benchmark":"tsx benchmark.ts","test:watch":"vitest"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c5e66f15-70c4-409b-8f8f-03d12c006108"}},"repository":{"url":"git+https://github.com/Benji377/data2image.git","type":"git","directory":"packages/core"},"_npmVersion":"11.9.0","description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","directories":{},"_nodeVersion":"24.14.0","dependencies":{"fflate":"^0.8.2","fast-png":"^8.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","tsup":"^8.0.0","vitest":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_1.1.0_1774444844659_0.75157970216413","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@data2image/core","version":"1.2.0","keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"license":"MIT","_id":"@data2image/core@1.2.0","maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"homepage":"https://benji377.github.io/data2image/","bugs":{"url":"https://github.com/Benji377/data2image/issues"},"dist":{"shasum":"85b863dc03d41111d48fa390d5e1072b2bb8666a","tarball":"https://registry.npmjs.org/@data2image/core/-/core-1.2.0.tgz","fileCount":11,"integrity":"sha512-dKo/cGowytGAfZzuKVbdWurwonobnFSWIeNXCOBLCK0D3Dt3leN/1rjF15Sq50DXlrOthgCF44nrftEXP0Aliw==","signatures":[{"sig":"MEQCIEChLId+JkZgiAo1/sNilKlyPxwnA7RMo53VVn/QryvIAiB/fzIOHwJXykri+QwA9eNc0KmNL6Q6cXUj710XGBhr1w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@data2image%2fcore@1.2.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":35317},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"gitHead":"bdb4d41f382475e93b3769bb0768ce8c4e76e56d","scripts":{"test":"vitest run","build":"tsdown","benchmark":"tsx benchmark.ts","test:watch":"vitest"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c5e66f15-70c4-409b-8f8f-03d12c006108"}},"repository":{"url":"git+https://github.com/Benji377/data2image.git","type":"git","directory":"packages/core"},"_npmVersion":"11.11.0","description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","directories":{},"_nodeVersion":"24.14.1","dependencies":{"fflate":"^0.8.2","fast-png":"^8.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","tsdown":"^0.21.8","vitest":"^4.0.0"},"_npmOperationalInternal":{"tmp":"tmp/core_1.2.0_1776420443037_0.8469610666283016","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@data2image/core","version":"1.2.1","description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","type":"module","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.mts","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"scripts":{"build":"tsdown","test":"vitest run","test:watch":"vitest","benchmark":"tsx benchmark.ts"},"keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Benji377/data2image.git","directory":"packages/core"},"homepage":"https://benji377.github.io/data2image/","dependencies":{"fast-png":"^8.0.0","fflate":"^0.8.2"},"devDependencies":{"tsdown":"^0.22.0","tsx":"^4.19.2","vitest":"^4.0.0"},"gitHead":"547e491d56e63b683588796eb52a49cd0c9e8929","_id":"@data2image/core@1.2.1","bugs":{"url":"https://github.com/Benji377/data2image/issues"},"_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-2ztE3iYlFCbNH2P4pvFGyaQmHcNawQH6cPbk9g8gs4DuQNql9TvvQzPz5YX0dQbs0OuPh+E6OP3VIXbtPItFnA==","shasum":"90194ea8b3751033a7c0055f68ee6f31f1ba9f2f","tarball":"https://registry.npmjs.org/@data2image/core/-/core-1.2.1.tgz","fileCount":11,"unpackedSize":35319,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@data2image%2fcore@1.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC1RuTLqruXr49c85ysjPd1j0gN6ZfhhTRaqxgtI+WCUAIgdJuTIe8FHGrDMnpii0Hkt1NR2eTvtDuj4CeZRObUyEk="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c5e66f15-70c4-409b-8f8f-03d12c006108"}},"directories":{},"maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/core_1.2.1_1778346921827_0.9941981156016801"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-10T11:49:40.302Z","modified":"2026-05-09T17:15:22.245Z","1.0.0":"2026-03-10T11:49:40.610Z","1.0.1":"2026-03-10T12:45:49.917Z","1.0.2":"2026-03-10T12:50:09.028Z","1.1.0":"2026-03-25T13:20:44.781Z","1.2.0":"2026-04-17T10:07:23.641Z","1.2.1":"2026-05-09T17:15:21.960Z"},"bugs":{"url":"https://github.com/Benji377/data2image/issues"},"license":"MIT","homepage":"https://benji377.github.io/data2image/","keywords":["data2image","file-to-image","encoder","decoder","png","steganography"],"repository":{"type":"git","url":"git+https://github.com/Benji377/data2image.git","directory":"packages/core"},"description":"Convert any file to a PNG image and back. Isomorphic encoder/decoder library.","maintainers":[{"name":"benji377","email":"demetzbenjamin23@gmail.com"}],"readme":"# @data2image/core\n\nConvert any file to a PNG image and back, with perfect lossless round-trip integrity.\n\nThis is the core encoder/decoder library for Data2Image. Works in Node.js, Deno, Bun, and browsers.\n\n## Installation\n\n```bash\nnpm install @data2image/core\n```\n\n## Usage\n\n### Encode\n\n```typescript\nimport { encode } from \"@data2image/core\";\nimport { readFileSync, writeFileSync } from \"fs\";\n\nconst fileData = readFileSync(\"document.pdf\");\nconst pngBytes = encode(fileData, \"document.pdf\");\nwriteFileSync(\"document.pdf.d2i.png\", pngBytes);\n```\n\n### Decode\n\n```typescript\nimport { decode } from \"@data2image/core\";\nimport { readFileSync, writeFileSync } from \"fs\";\n\nconst pngData = readFileSync(\"document.pdf.d2i.png\");\nconst { filename, data } = decode(pngData);\n\nconsole.log(filename); // \"document.pdf\"\nwriteFileSync(filename, data);\n```\n\n### Browser Usage\n\n```typescript\nimport { encode, decode } from \"@data2image/core\";\n\n// Encode\nconst fileBytes = new Uint8Array(await file.arrayBuffer());\nconst pngBytes = encode(fileBytes, file.name);\n\n// Create downloadable blob\nconst blob = new Blob([pngBytes], { type: \"image/png\" });\nconst url = URL.createObjectURL(blob);\n\n// Decode\nconst { filename, data } = decode(pngBytes);\n```\n\n## API\n\n### `encode(data, filename)`\n\nEncodes file data into a PNG image.\n\n**Parameters:**\n- `data: Uint8Array`: Raw file bytes\n- `filename: string`: Original filename (will be embedded in the image)\n\n**Returns:** `Uint8Array`: PNG image bytes\n\n**Throws:** Error if filename exceeds 65535 bytes when UTF-8 encoded\n\n### `decode(png)`\n\nDecodes a Data2Image PNG back to the original file.\n\n**Parameters:**\n- `png: Uint8Array`: PNG file bytes (`.d2i.png`)\n\n**Returns:** `{ filename: string, data: Uint8Array }`\n\n**Throws:**\n- Error if magic bytes don't match (not a valid Data2Image file)\n- Error if CRC-32 checksum fails (corrupted data)\n- Error if payload is incomplete\n\n## How It Works\n\n1. **Compress**: file data is deflate-compressed (via fflate)\n2. **Frame**: binary format with magic bytes, CRC-32, filename, compressed data\n3. **Rasterize**: frame is laid out as RGBA pixels in a square PNG\n4. **Decode**: reverse the process, verify integrity with CRC-32\n\n## Binary Format (v1)\n\n```\n[4B magic \"D2I\\x01\"]\n[4B payload length (uint32 BE)]\n[4B CRC-32 checksum]\n[2B filename length (uint16 BE)]\n[N filename (UTF-8)]\n[... deflate-compressed data]\n[... zero padding to fill square]\n```\n\n## Features\n\n- Lossless round-trip, decode always returns exact original bytes\n- CRC-32 integrity verification \n- Filename preservation (including Unicode)\n- Compression via deflate\n- Isomorphic: works in Node.js, Deno, Bun, browsers\n- TypeScript with full type definitions\n- ESM + CJS dual build\n\n## Related Packages\n\n- **[data2image](https://www.npmjs.com/package/data2image)** CLI tool\n- **[Website](https://benji377.github.io/data2image/)** Web app with drag-and-drop\n\n## License\n\n[MIT](https://github.com/Benji377/data2image/blob/main/packages/core/LICENSE)\n","readmeFilename":"README.md"}