📂 Add new directory for image-scale-cli tool

This commit is contained in:
2026-04-11 11:10:53 +08:00
parent 82e293f4c2
commit 9454512b7b
60 changed files with 3186 additions and 0 deletions
@@ -0,0 +1,53 @@
// Script to generate test images for each supported format
import sharp from "sharp";
const TEST_DIR = "./test-images";
// Ensure test directory exists
await Deno.mkdir(TEST_DIR, { recursive: true });
// Create a simple test image (100x100 red square)
const testBuffer = await sharp({
create: {
width: 100,
height: 100,
channels: 3,
background: { r: 255, g: 0, b: 0 },
},
})
.png()
.toBuffer();
// Save in different formats
await sharp(testBuffer).toFile(`${TEST_DIR}/test-100x100.png`);
console.log("Created: test-100x100.png");
await sharp(testBuffer).jpeg({ quality: 85 }).toFile(`${TEST_DIR}/test-100x100.jpg`);
console.log("Created: test-100x100.jpg");
await sharp(testBuffer).webp({ quality: 85 }).toFile(`${TEST_DIR}/test-100x100.webp`);
console.log("Created: test-100x100.webp");
// Create a larger test image (200x150 blue rectangle)
const largeBuffer = await sharp({
create: {
width: 200,
height: 150,
channels: 3,
background: { r: 0, g: 0, b: 255 },
},
})
.png()
.toBuffer();
await sharp(largeBuffer).toFile(`${TEST_DIR}/test-200x150.png`);
console.log("Created: test-200x150.png");
await sharp(largeBuffer).jpeg({ quality: 85 }).toFile(`${TEST_DIR}/test-200x150.jpg`);
console.log("Created: test-200x150.jpg");
// Create a GIF test image
await sharp(largeBuffer).gif().toFile(`${TEST_DIR}/test-200x150.gif`);
console.log("Created: test-200x150.gif");
console.log("\nTest images created successfully!");