-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-dimensions.js
More file actions
52 lines (43 loc) · 1.7 KB
/
check-dimensions.js
File metadata and controls
52 lines (43 loc) · 1.7 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
const sharp = require('sharp');
const fs = require('fs').promises;
const path = require('path');
const expectedDimensions = {
'5.5-inch': { width: 1242, height: 2208 },
'6.5-inch': { width: 1242, height: 2688 },
'ipad': { width: 2048, height: 2732 },
'android-phone': { width: 1242, height: 2688 },
'android-7-tablet': { width: 1800, height: 2880 },
'android-10-tablet': { width: 1800, height: 2880 }
};
async function checkDirectory(dirPath) {
try {
const files = await fs.readdir(dirPath);
const imageFiles = files.filter(file => /\.(png|jpg|jpeg)$/i.test(file));
for (const file of imageFiles) {
const filePath = path.join(dirPath, file);
const metadata = await sharp(filePath).metadata();
const dirName = path.basename(dirPath);
const expected = expectedDimensions[dirName];
console.log(`\nChecking ${file}:`);
console.log(`Actual dimensions: ${metadata.width} x ${metadata.height}`);
console.log(`Expected dimensions: ${expected.width} x ${expected.height}`);
if (metadata.width === expected.width && metadata.height === expected.height) {
console.log('✅ Dimensions are correct');
} else {
console.log('❌ Dimensions do not match requirements');
}
}
} catch (error) {
console.error(`Error processing directory ${dirPath}:`, error);
}
}
async function main() {
const baseDir = 'app-store-assets/screenshots';
const directories = Object.keys(expectedDimensions);
console.log('Checking screenshot dimensions...\n');
for (const dir of directories) {
console.log(`\n📁 Checking ${dir} directory:`);
await checkDirectory(path.join(baseDir, dir));
}
}
main().catch(console.error);