MCPcopy
hub / github.com/Leonxlnx/taste-skill / processOne

Function processOne

scripts/process-readme-buttons.mjs:81–102  ·  view source on GitHub ↗
(srcPath, outPath)

Source from the content-addressed store, hash-verified

79}
80
81async function processOne(srcPath, outPath) {
82 const { data, info } = await sharp(srcPath)
83 .ensureAlpha()
84 .raw()
85 .toBuffer({ resolveWithObject: true });
86
87 const rgba = Buffer.from(data);
88 removeOuterBackground(rgba, info.width, info.height);
89 const bounds = getBounds(rgba, info.width, info.height);
90
91 await sharp(rgba, {
92 raw: { width: info.width, height: info.height, channels: 4 },
93 })
94 .extract(bounds)
95 .png({ compressionLevel: 9, adaptiveFiltering: true })
96 .toFile(outPath);
97
98 const meta = await sharp(outPath).metadata();
99 console.log(
100 `${path.basename(outPath)} -> ${meta.width}x${meta.height}, ${fs.statSync(outPath).size} bytes`
101 );
102}
103
104fs.mkdirSync(outDir, { recursive: true });
105

Callers 1

Calls 2

removeOuterBackgroundFunction · 0.70
getBoundsFunction · 0.70

Tested by

no test coverage detected