Sample
pngjs 6.0.0: PNG.sync.write
Verified sample for npm pngjs 6.0.0: PNG.sync.write. The contract ran on node 22 · linux debian/x64 · docker and passed: assert PNG.sync.write synchronously…
sha256:2a9fbf0340e9afbe710152e08a6ac7ca20b825292cecd18899a950118726be01
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-01 |
Case
HOW- Goal
- verify PNG.sync.write in pkg:npm/pngjs@6.0.0
- Packages
- Symbols
-
- PNG.sync.write
- Environment
- node 22.23.2
- Created
- 2026-09-01T10:59:02Z
Contract
- assert PNG.sync.write synchronously encodes a PNG instance to a binary Buffer with standard PNG magic header
- assert PNG.sync.write produces valid PNG data that preserves pixel RGBA values when read back with PNG.sync.read
- assert PNG.sync.write supports compression and filter options such as deflateLevel and filterType
- assert PNG.sync.write correctly encodes single-pixel 1x1 images
Files
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify PNG.sync.write in pkg:npm/pngjs@6.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pngjs@6.0.0
Demonstrate these symbols/APIs:
- PNG.sync.write
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:cb66cd45df16befaf441cc1d42c334c3f4f42d2f4a948317d27d2d55eba7920e","contract":["assert PNG.sync.write synchronously encodes a PNG instance to a binary Buffer with standard PNG magic header","assert PNG.sync.write produces valid PNG data that preserves pixel RGBA values when read back with PNG.sync.read","assert PNG.sync.write supports compression and filter options such as deflateLevel and filterType","assert PNG.sync.write correctly encodes single-pixel 1x1 images"],"goal":"verify PNG.sync.write in pkg:npm/pngjs@6.0.0","kind":"HOW","packages":["pkg:npm/pngjs@6.0.0"],"schemaVersion":1,"symbols":["PNG.sync.write"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/pngjs@6.0.0"],"schemaVersion":1,"subject":"pkg:npm/pngjs@6.0.0","symbols":["PNG.sync.write"],"verifierAdapter":"node-typescript@1"}
const { PNG } = require('pngjs');
/**
* Creates and synchronously encodes a PNG image with RGBA pixel data.
*
* @param {number} width - Image width in pixels
* @param {number} height - Image height in pixels
* @param {Buffer|Uint8Array} [rgbaData] - Raw RGBA pixel data
* @param {Object} [options] - Options passed to PNG.sync.write
* @returns {Buffer} Encoded PNG binary buffer
*/
function encodePngSync(width, height, rgbaData, options) {
const png = new PNG({ width, height });
if (rgbaData) {
if (rgbaData.length !== width * height * 4) {
throw new Error(`Invalid RGBA buffer length: expected ${width * height * 4}, got ${rgbaData.length}`);
}
rgbaData.copy(png.data);
}
return PNG.sync.write(png, options);
}
module.exports = {
encodePngSync,
PNG,
};
{
"name": "sample-pngjs-sync-write",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pngjs-sync-write",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"pngjs": "6.0.0"
}
},
"node_modules/pngjs": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-6.0.0.tgz",
"integrity": "sha512-TRzzuFRRmEoSW/p1KVAmiOgPco2Irlah+bGFCeNfJXxxYGwSw7YwAOAcd7X28K/m5bjBWKsC29KyoMfHbypayg==",
"license": "MIT",
"engines": {
"node": ">=12.13.0"
}
}
}
}
{
"name": "sample-pngjs-sync-write",
"version": "1.0.0",
"description": "Clean-room sample verifying PNG.sync.write in pkg:npm/pngjs@6.0.0",
"main": "index.js",
"license": "MIT-0",
"dependencies": {
"pngjs": "6.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify PNG.sync.write in pkg:npm/pngjs@6.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/pngjs@6.0.0"
],
"symbols": [
"PNG.sync.write"
]
}
import assert from 'node:assert';
import { PNG } from 'pngjs';
import { encodePngSync } from '../index.js';
// 1. assert PNG.sync.write synchronously encodes a PNG instance to a binary Buffer with standard PNG magic header
const png1 = new PNG({ width: 2, height: 2 });
png1.data[0] = 255; png1.data[1] = 0; png1.data[2] = 0; png1.data[3] = 255; // Red
png1.data[4] = 0; png1.data[5] = 255; png1.data[6] = 0; png1.data[7] = 255; // Green
png1.data[8] = 0; png1.data[9] = 0; png1.data[10] = 255; png1.data[11] = 255; // Blue
png1.data[12] = 255; png1.data[13] = 255; png1.data[14] = 0; png1.data[15] = 255; // Yellow
const outBuffer = PNG.sync.write(png1);
assert(Buffer.isBuffer(outBuffer), 'PNG.sync.write must return a Buffer instance');
assert(outBuffer.length > 8, 'PNG buffer must contain PNG header');
const pngSignature = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
assert.deepStrictEqual(
Array.from(outBuffer.subarray(0, 8)),
pngSignature,
'PNG.sync.write output must start with the standard PNG 8-byte header'
);
// 2. assert PNG.sync.write produces valid PNG data that preserves pixel RGBA values when read back with PNG.sync.read
const decoded = PNG.sync.read(outBuffer);
assert.strictEqual(decoded.width, 2, 'Decoded PNG width must match original');
assert.strictEqual(decoded.height, 2, 'Decoded PNG height must match original');
assert.deepStrictEqual(
Array.from(decoded.data),
Array.from(png1.data),
'Decoded pixel RGBA data must exactly match original image data'
);
// 3. assert PNG.sync.write supports compression and filter options such as deflateLevel and filterType
const png3 = new PNG({ width: 4, height: 4 });
for (let i = 0; i < png3.data.length; i += 4) {
png3.data[i] = (i * 17) % 256;
png3.data[i + 1] = (i * 31) % 256;
png3.data[i + 2] = (i * 47) % 256;
png3.data[i + 3] = 255;
}
const compressedBuf = PNG.sync.write(png3, {
deflateLevel: 9,
filterType: 4,
});
assert(Buffer.isBuffer(compressedBuf), 'PNG.sync.write with options must return a Buffer');
const decodedCompressed = PNG.sync.read(compressedBuf);
assert.strictEqual(decodedCompressed.width, 4);
assert.strictEqual(decodedCompressed.height, 4);
assert.deepStrictEqual(
Array.from(decodedCompressed.data),
Array.from(png3.data),
'Decoded pixel data with custom compression options must match original'
);
// 4. assert PNG.sync.write correctly encodes single-pixel 1x1 images
const png1x1 = new PNG({ width: 1, height: 1 });
png1x1.data[0] = 128;
png1x1.data[1] = 64;
png1x1.data[2] = 32;
png1x1.data[3] = 200;
const buf1x1 = PNG.sync.write(png1x1);
const decoded1x1 = PNG.sync.read(buf1x1);
assert.strictEqual(decoded1x1.width, 1);
assert.strictEqual(decoded1x1.height, 1);
assert.strictEqual(decoded1x1.data[0], 128);
assert.strictEqual(decoded1x1.data[1], 64);
assert.strictEqual(decoded1x1.data[2], 32);
assert.strictEqual(decoded1x1.data[3], 200);
console.log('All contract assertions passed.');
Origin Seeder
anonymous