샘플
@img/sharp-wasm32 0.35.5: stats
검증된 샘플 — npm @img/sharp-wasm32 0.35.5: stats. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: require('@img/sharp-wasm32/sharp.node').stats is a…
sha256:adadd60630665c01ad082a9c20141b80b11d5795be55ce88826f428d3986a058
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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-11-28 |
케이스
HOW- 목표
- verify @img/sharp-wasm32.stats in pkg:npm/%40img/sharp-wasm32@0.35.5
- 심벌
-
- @img/sharp-wasm32.stats
- 환경
- node 22.23.2
- 생성일
- 2026-11-28T01:24:17Z
컨트랙트
- require('@img/sharp-wasm32/sharp.node').stats is a function accepting ({ input, debuglog }, callback)
- stats() on a 2x2 opaque 3-channel raw uchar RGB buffer returns 3 channels with exact min/max/sum/squaresSum/mean/minX/minY/maxX/maxY, positive stdev, finite entropy and sharpness, RGB dominant object, and isOpaque === true
- stats() on a 2x2 4-channel raw RGBA buffer with alpha < 255 returns 4 channels with alpha min 128 and max 255 and isOpaque === false
- stats() on a uniform 4x4 3-channel created image returns zero stdev, zero entropy, zero sharpness, isOpaque === true, and quantized dominant { r: 200, g: 40, b: 24 }
- stats() on an invalid non-image buffer invokes the callback with a non-empty Error
- calling stats() directly without required numeric input fields (limitInputPixels, limitInputChannels) throws TypeError synchronously
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.cjs
- test/contract.cjs
소스
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 @img/sharp-wasm32.stats in pkg:npm/%40img/sharp-wasm32@0.35.5
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40img/sharp-wasm32@0.35.5
Demonstrate these symbols/APIs:
- @img/sharp-wasm32.stats
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:688790e577c2cdc36d2993e9962a316c17533723e0f5a7a1d2dee6f19a5dde96","constraints":{"executionContext":"node"},"contract":["require('@img/sharp-wasm32/sharp.node').stats is a function accepting ({ input, debuglog }, callback)","stats() on a 2x2 opaque 3-channel raw uchar RGB buffer returns 3 channels with exact min/max/sum/squaresSum/mean/minX/minY/maxX/maxY, positive stdev, finite entropy and sharpness, RGB dominant object, and isOpaque === true","stats() on a 2x2 4-channel raw RGBA buffer with alpha \u003c 255 returns 4 channels with alpha min 128 and max 255 and isOpaque === false","stats() on a uniform 4x4 3-channel created image returns zero stdev, zero entropy, zero sharpness, isOpaque === true, and quantized dominant { r: 200, g: 40, b: 24 }","stats() on an invalid non-image buffer invokes the callback with a non-empty Error","calling stats() directly without required numeric input fields (limitInputPixels, limitInputChannels) throws TypeError synchronously"],"goal":"verify @img/sharp-wasm32.stats in pkg:npm/%40img/sharp-wasm32@0.35.5","kind":"HOW","packages":["pkg:npm/%40img/sharp-wasm32@0.35.5"],"schemaVersion":1,"symbols":["@img/sharp-wasm32.stats"]},"contractCommand":["node","test/contract.cjs"],"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/%40img/sharp-wasm32@0.35.5"],"schemaVersion":1,"subject":"pkg:npm/%40img/sharp-wasm32@0.35.5","symbols":["@img/sharp-wasm32.stats"],"verifierAdapter":"node-typescript@1"}
{
"name": "sharp-wasm32-stats-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sharp-wasm32-stats-sample",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"@img/sharp-wasm32": "0.35.5"
}
},
"node_modules/@emnapi/runtime": {
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
"license": "MIT",
"dependencies": {
"tslib": "^2.4.0"
}
},
"node_modules/@img/sharp-wasm32": {
"version": "0.35.5",
"resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz",
"integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==",
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
"dependencies": {
"@emnapi/runtime": "^1.11.3"
},
"engines": {
"node": ">=20.9.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/tslib": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz",
"integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==",
"license": "0BSD"
}
}
}
{
"name": "sharp-wasm32-stats-sample",
"version": "1.0.0",
"private": true,
"type": "commonjs",
"license": "MIT-0",
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"@img/sharp-wasm32": "0.35.5"
}
}
{
"schemaVersion": 1,
"goal": "verify @img/sharp-wasm32.stats in pkg:npm/%40img/sharp-wasm32@0.35.5",
"kind": "HOW",
"packages": [
"pkg:npm/%40img/sharp-wasm32@0.35.5"
],
"symbols": [
"@img/sharp-wasm32.stats"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
'use strict';
const sharpWasm = require('@img/sharp-wasm32/sharp.node');
const DEFAULT_INPUT = {
failOn: 'warning',
limitInputPixels: 268402689,
limitInputChannels: 16,
unlimited: false,
autoOrient: false
};
function computeStats(input, debuglog = () => {}) {
const fullInput = { ...DEFAULT_INPUT, ...input };
return new Promise((resolve, reject) => {
sharpWasm.stats({ input: fullInput, debuglog }, (err, result) => {
if (err) {
reject(err);
return;
}
resolve(result);
});
});
}
module.exports = {
sharpWasm,
computeStats
};
'use strict';
const assert = require('node:assert/strict');
const { sharpWasm, computeStats } = require('../src/index.cjs');
async function main() {
assert.equal(typeof sharpWasm.stats, 'function', 'sharp.node exports stats()');
// 1. 2x2 opaque 3-channel raw RGB pixel buffer
const rgbBuffer = Buffer.from([
10, 100, 200,
30, 120, 220,
50, 140, 240,
70, 160, 240
]);
const rgbStats = await computeStats({
buffer: rgbBuffer,
failOn: 'warning',
rawDepth: 'uchar',
rawChannels: 3,
rawWidth: 2,
rawHeight: 2,
rawPremultiplied: false,
rawPageHeight: 0
});
assert.equal(rgbStats.channels.length, 3);
assert.equal(rgbStats.isOpaque, true);
assert.equal(rgbStats.channels[0].min, 10);
assert.equal(rgbStats.channels[0].max, 70);
assert.equal(rgbStats.channels[0].sum, 160);
assert.equal(rgbStats.channels[0].squaresSum, 8400);
assert.equal(rgbStats.channels[0].mean, 40);
assert.equal(rgbStats.channels[0].minX, 0);
assert.equal(rgbStats.channels[0].minY, 0);
assert.equal(rgbStats.channels[0].maxX, 1);
assert.equal(rgbStats.channels[0].maxY, 1);
assert.ok(rgbStats.channels[0].stdev > 0);
assert.equal(rgbStats.channels[1].min, 100);
assert.equal(rgbStats.channels[1].max, 160);
assert.equal(rgbStats.channels[1].sum, 520);
assert.equal(rgbStats.channels[1].mean, 130);
assert.equal(rgbStats.channels[2].min, 200);
assert.equal(rgbStats.channels[2].max, 240);
assert.equal(rgbStats.channels[2].sum, 900);
assert.equal(rgbStats.channels[2].mean, 225);
assert.equal(typeof rgbStats.entropy, 'number');
assert.ok(Number.isFinite(rgbStats.entropy) && rgbStats.entropy >= 0);
assert.equal(typeof rgbStats.sharpness, 'number');
assert.ok(Number.isFinite(rgbStats.sharpness) && rgbStats.sharpness >= 0);
assert.equal(typeof rgbStats.dominant.r, 'number');
assert.equal(typeof rgbStats.dominant.g, 'number');
assert.equal(typeof rgbStats.dominant.b, 'number');
// 2. 2x2 4-channel RGBA raw buffer with a semi-transparent pixel
const rgbaBuffer = Buffer.from([
255, 0, 0, 255,
0, 255, 0, 128,
0, 0, 255, 255,
255, 255, 255, 255
]);
const rgbaStats = await computeStats({
buffer: rgbaBuffer,
failOn: 'warning',
rawDepth: 'uchar',
rawChannels: 4,
rawWidth: 2,
rawHeight: 2,
rawPremultiplied: false,
rawPageHeight: 0
});
assert.equal(rgbaStats.channels.length, 4);
assert.equal(rgbaStats.channels[3].min, 128);
assert.equal(rgbaStats.channels[3].max, 255);
assert.equal(rgbaStats.isOpaque, false);
// 3. Uniform solid created image
const solidStats = await computeStats({
failOn: 'warning',
createChannels: 3,
createWidth: 4,
createHeight: 4,
createPageHeight: 0,
createBackground: [200, 40, 20]
});
assert.equal(solidStats.channels.length, 3);
assert.equal(solidStats.channels[0].min, 200);
assert.equal(solidStats.channels[0].max, 200);
assert.equal(solidStats.channels[0].mean, 200);
assert.equal(solidStats.channels[0].stdev, 0);
assert.equal(solidStats.channels[1].mean, 40);
assert.equal(solidStats.channels[2].mean, 20);
assert.equal(solidStats.isOpaque, true);
assert.equal(solidStats.entropy, 0);
assert.equal(solidStats.sharpness, 0);
assert.deepEqual(solidStats.dominant, { r: 200, g: 40, b: 24 });
// 4. Invalid non-image buffer reports an Error via callback
await assert.rejects(
() => computeStats({
buffer: Buffer.from('not-an-image'),
failOn: 'warning'
}),
(err) => err instanceof Error && err.message.length > 0
);
// 5. Omitting required numeric input fields throws TypeError synchronously
assert.throws(
() => {
sharpWasm.stats(
{
input: {
buffer: rgbBuffer,
failOn: 'warning',
rawDepth: 'uchar',
rawChannels: 3,
rawWidth: 2,
rawHeight: 2,
rawPremultiplied: false,
rawPageHeight: 0
},
debuglog: () => {}
},
() => {}
);
},
TypeError
);
console.log('PASS: @img/sharp-wasm32.stats contract verified');
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
오리진 시더
익명