-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcreate-jpeg-placeholders.js
More file actions
56 lines (45 loc) · 1.97 KB
/
Copy pathcreate-jpeg-placeholders.js
File metadata and controls
56 lines (45 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Create actual JPEG placeholder images using Sharp
import sharp from 'sharp';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
async function createJPEGPlaceholder(width, height, filename, color = { r: 128, g: 128, b: 128 }) {
try {
// Create a solid color image
const image = sharp({
create: {
width,
height,
channels: 3,
background: color
}
})
.jpeg({ quality: 80 })
const outputPath = path.join(__dirname, 'images', filename);
await image.toFile(outputPath);
const stats = fs.statSync(outputPath);
console.log(`Created: ${filename} (${width}x${height}, ${stats.size} bytes)`);
} catch (error) {
console.error(`Failed to create ${filename}:`, error.message);
}
}
// Create placeholder images with different colors and sizes
async function main() {
const imageDir = path.join(__dirname, 'images');
// Ensure directory exists
if (!fs.existsSync(imageDir)) {
fs.mkdirSync(imageDir, { recursive: true });
}
console.log('Creating JPEG placeholder images...\n');
// Create different colored placeholders to distinguish them
await createJPEGPlaceholder(1200, 1200, 'harness-main.jpg', { r: 100, g: 150, b: 200 }); // Blue-ish main image
await createJPEGPlaceholder(1000, 1000, 'harness-detail.jpg', { r: 150, g: 100, b: 100 }); // Red-ish detail
await createJPEGPlaceholder(1000, 800, 'harness-dimensions.jpg', { r: 100, g: 150, b: 100 }); // Green-ish dimensions
await createJPEGPlaceholder(1100, 1100, 'harness-application.jpg', { r: 150, g: 150, b: 100 }); // Yellow-ish application
console.log('\n✅ All placeholder images created successfully!');
console.log('These are solid color JPEG images that meet Amazon requirements.');
console.log('Replace with actual product photos before creating real listings.');
}
main().catch(console.error);