샘플
pngjs 6.0.0: PNG.sync.read
검증된 샘플 — npm pngjs 6.0.0: PNG.sync.read. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: PNG.sync.read synchronously parses a valid PNG buffer…
sha256:36bf5ff87b5f72739114863f4ed40e2139412f2c3d46448e478369eec3dc8f9d
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify PNG.sync.read in pkg:npm/pngjs@6.0.0
- 패키지
- 심벌
-
- PNG.sync.read
- 생성일
- 2026-09-01T10:56:50Z
컨트랙트
- PNG.sync.read synchronously parses a valid PNG buffer into a PNG instance with width, height, and RGBA data buffer matching the source image dimensions
- PNG.sync.read parses image pixel data accurately, preserving individual RGBA channel values
- PNG.sync.read accepts optional configuration options such as skipRescale
- PNG.sync.read throws an error when provided with an invalid or corrupted PNG buffer
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
소스
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.read 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.read
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:f72599b51e1ee1957f5532e8229ce1550b5845876b659ae62dd9a0bacf3802fe","contract":["PNG.sync.read synchronously parses a valid PNG buffer into a PNG instance with width, height, and RGBA data buffer matching the source image dimensions","PNG.sync.read parses image pixel data accurately, preserving individual RGBA channel values","PNG.sync.read accepts optional configuration options such as skipRescale","PNG.sync.read throws an error when provided with an invalid or corrupted PNG buffer"],"goal":"verify PNG.sync.read in pkg:npm/pngjs@6.0.0","kind":"HOW","packages":["pkg:npm/pngjs@6.0.0"],"schemaVersion":1,"symbols":["PNG.sync.read"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/pngjs@6.0.0"],"schemaVersion":1,"subject":"pkg:npm/pngjs@6.0.0","symbols":["PNG.sync.read"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-pngjs-sync-read",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pngjs-sync-read",
"version": "1.0.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-read",
"version": "1.0.0",
"private": true,
"type": "module",
"description": "Clean-room verification for PNG.sync.read in pkg:npm/pngjs@6.0.0",
"dependencies": {
"pngjs": "6.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify PNG.sync.read in pkg:npm/pngjs@6.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/pngjs@6.0.0"
],
"symbols": [
"PNG.sync.read"
]
}
import { PNG } from 'pngjs';
/**
* Synchronously parses a PNG buffer into a PNG instance.
*
* @param {Buffer} buffer - Raw PNG file buffer.
* @param {object} [options] - Parsing options passed to PNG.sync.read.
* @returns {PNG} Decoded PNG instance containing width, height, data (RGBA buffer), etc.
*/
export function parsePng(buffer, options) {
return PNG.sync.read(buffer, options);
}
/**
* Synchronously creates a PNG buffer from raw RGBA pixel data.
*
* @param {number} width - Image width.
* @param {number} height - Image height.
* @param {Buffer|Uint8Array} [rgbaData] - Optional RGBA pixel buffer of length width * height * 4.
* @returns {Buffer} Encoded PNG buffer.
*/
export function createPngBuffer(width, height, rgbaData) {
const png = new PNG({ width, height });
if (rgbaData) {
Buffer.from(rgbaData).copy(png.data);
}
return PNG.sync.write(png);
}
export { PNG };
import assert from 'node:assert/strict';
import { Buffer } from 'node:buffer';
import { PNG, parsePng, createPngBuffer } from '../src/index.mjs';
// Contract 1: PNG.sync.read exists as a synchronous parsing function on PNG.sync
{
assert.equal(typeof PNG.sync, 'object', 'PNG.sync must be an object');
assert.equal(typeof PNG.sync.read, 'function', 'PNG.sync.read must be a function');
assert.equal(typeof parsePng, 'function', 'parsePng wrapper must be a function');
}
// Contract 2: PNG.sync.read synchronously parses a valid PNG buffer and extracts dimensions and RGBA pixel buffer
{
const width = 2;
const height = 2;
const rawRgba = Buffer.from([
255, 0, 0, 255, // Pixel (0, 0): Red
0, 255, 0, 255, // Pixel (1, 0): Green
0, 0, 255, 255, // Pixel (0, 1): Blue
255, 255, 0, 128, // Pixel (1, 1): Semi-transparent Yellow
]);
const pngBuffer = createPngBuffer(width, height, rawRgba);
assert.ok(Buffer.isBuffer(pngBuffer), 'createPngBuffer must return a Buffer');
assert.ok(pngBuffer.length > 0, 'PNG buffer must not be empty');
// Parse using PNG.sync.read directly
const decoded = PNG.sync.read(pngBuffer);
assert.equal(decoded.width, width, 'Decoded width must match original width');
assert.equal(decoded.height, height, 'Decoded height must match original height');
assert.ok(Buffer.isBuffer(decoded.data), 'Decoded data must be a Buffer');
assert.equal(decoded.data.length, width * height * 4, 'Decoded data length must equal width * height * 4');
// Verify pixel byte values
assert.deepEqual(Array.from(decoded.data), Array.from(rawRgba), 'Decoded pixel data must match input RGBA bytes');
}
// Contract 3: PNG.sync.read accepts optional configuration options such as skipRescale
{
const width = 1;
const height = 1;
const rawRgba = Buffer.from([120, 150, 200, 255]);
const pngBuffer = createPngBuffer(width, height, rawRgba);
const decodedWithOptions = PNG.sync.read(pngBuffer, { skipRescale: true });
assert.equal(decodedWithOptions.width, 1);
assert.equal(decodedWithOptions.height, 1);
assert.deepEqual(Array.from(decodedWithOptions.data), [120, 150, 200, 255]);
}
// Contract 4: PNG.sync.read throws an error when provided with an invalid or corrupted PNG buffer
{
const invalidBuffer = Buffer.from('invalid non-png data payload');
assert.throws(
() => {
PNG.sync.read(invalidBuffer);
},
/unrecognised|unrecognized|signature|invalid|corrupted|chunk|stream/i,
'PNG.sync.read must throw when buffer does not have valid PNG data'
);
const truncatedBuffer = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]); // Header only, missing chunks
assert.throws(
() => {
PNG.sync.read(truncatedBuffer);
},
/error|invalid|truncated|eof|stream|end|chunk|unrecognised|unrecognized/i,
'PNG.sync.read must throw on truncated PNG buffer'
);
}
console.log('Contract passed: PNG.sync.read behavior in pkg:npm/pngjs@6.0.0 successfully verified.');
오리진 시더
익명