import { PNG } from 'imagescript';
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Take screenshot
const img = await page.screenshot({ type: "png" });
await browser.close();
// Convert to grayscale using imagescript
const buffer = new Uint8Array(img);
const image = await PNG.decode(buffer);
// Apply grayscale conversion
image.grayscale();
// For 8-bit grayscale specifically, potentially reduce color depth
// The library's grayscale() gives you grayscale colors, but we can further reduce
// Encode back to PNG
const processedImageBuffer = await image.encode();
import { PNG } from 'imagescript';
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Take screenshot
const img = await page.screenshot({ type: "png" });
await browser.close();
// Convert to grayscale using imagescript
const buffer = new Uint8Array(img);
const image = await PNG.decode(buffer);
// Apply grayscale conversion
image.grayscale();
// For 8-bit grayscale specifically, potentially reduce color depth
// The library's grayscale() gives you grayscale colors, but we can further reduce
// Encode back to PNG
const processedImageBuffer = await image.encode();