Image Resolution Checker
**name**: image-resolution-checker
SKILL.md
Full skill instructions
Image Resolution Checker Skill
name: image-resolution-checker
description: Comprehensive image resolution validation with auto-repair capabilities. Use when you need to: (1) Validate image dimensions against presets or custom thresholds, (2) Batch process multiple images with detailed reports, (3) Auto-repair invalid images using scale/crop/pad strategies, (4) Generate validation reports with friendly error messages. Supports JPG, PNG, GIF, WebP, BMP, TIFF, SVG, HEIC, AVIF formats.
Quick Start
import { validateImage, validateBatch, validateAndRepair } from './scripts/index';
// Single image validation
const result = await validateImage('photo.jpg', { preset: 'thumbnail' });
// Batch validation with auto-repair
const report = await validateBatch(['a.jpg', 'b.png'], {
preset: 'hd',
repairStrategy: 'scale',
outputDir: './output'
});
// Auto-repair
const repaired = await validateAndRepair('photo.jpg', {
preset: 'hd',
repairStrategy: 'crop'
});
Core Features
1. Validation Rules
Preset-based validation:
const result = await validateImage('photo.jpg', {
preset: '4k',
strict: true
});
Custom threshold validation:
const result = await validateImage('photo.jpg', {
threshold: {
minWidth: 1920,
maxWidth: 3840,
minHeight: 1080,
maxHeight: 2160
}
});
2. Auto-Repair Strategies
- scale: Maintain aspect ratio, fit within target dimensions
- crop: Center crop to exact dimensions
- pad: Add background color padding to reach dimensions
const repaired = await validateAndRepair('photo.jpg', {
preset: 'hd',
repairStrategy: 'scale',
outputDir: './repaired'
});
3. Batch Processing
Process multiple images with detailed reports:
const report = await validateBatch(['a.jpg', 'b.png', 'c.webp'], {
configFile: './.image-rules.yaml',
repairStrategy: 'scale',
onProgress: (current, total) => {
console.log(`Progress: ${current}/${total}`);
}
});
4. Configuration Files
Create .image-rules.yaml or .image-rules.json:
version: "1.0"
defaults:
strict: true
repairStrategy: scale
outputDir: "./output"
presets:
custom-hd:
width: 1920
height: 1080
output:
validDir: "valid/"
repairedDir: "repaired/"
invalidDir: "invalid/"
Available Presets
| Preset | Dimensions | Aspect Ratio | Use Case |
|---|---|---|---|
| avatar | 100×100 | 1:1 | User avatars |
| thumbnail | 300×300 | 1:1 | Thumbnails |
| hd | 1920×1080 | 16:9 | HD wallpapers |
| 4k | 3840×2160 | 16:9 | 4K wallpapers |
| 8k | 7680×4320 | 16:9 | 8K wallpapers |
| 8k-cinema | 8192×4320 | 1.89:1 | DCI 8K |
| 8k-4-3 | 8192×6144 | 4:3 | 8K 4:3 professional |
| mobile-wallpaper | 1080×1920 | 9:16 | Mobile wallpapers |
| tablet | 2048×1536 | 4:3 | Tablet images |
| app-icon | 1024×1024 | 1:1 | App Store icons |
| instagram-square | 1080×1080 | 1:1 | Instagram square |
| instagram-portrait | 1080×1350 | 4:5 | Instagram portrait |
| twitter-post | 1200×675 | 16:9 | Twitter posts |
| facebook-cover | 820×312 | 2.6:1 | Facebook covers |
| ultrawide | 3440×1440 | 2.39:1 | Ultrawide wallpapers |
| custom | user-defined | - | Custom dimensions |
Error Codes
| Code | Type | Description | Suggestion |
|---|---|---|---|
| E001 | FILE_NOT_FOUND | File does not exist | Check path |
| E002 | UNSUPPORTED_FORMAT | Unsupported image format | Convert to JPG/PNG/WebP |
| E003 | DIMENSION_TOO_SMALL | Image is too small | Use higher resolution image |
| E004 | DIMENSION_TOO_LARGE | Image is too large | Compress or resize |
| E005 | ASPECT_RATIO_MISMATCH | Aspect ratio doesn't match | Use crop/pad repair |
| E006 | INVALID_CONFIG | Configuration error | Check config file |
| E007 | REPAIR_FAILED | Repair operation failed | Manual intervention needed |
| E008 | CORRUPT_IMAGE | Image file is corrupted | Re-download or replace |
CLI Usage
# Validate single image
npx ts-node scripts/cli.ts validate photo.jpg --preset=thumbnail
# Batch validate
npx ts-node scripts/cli.ts validate-batch *.jpg --preset=hd --repair=scale
# Auto-repair
npx ts-node scripts/cli.ts repair photo.jpg --preset=hd --strategy=crop
# Use config file
npx ts-node scripts/cli.ts validate-batch *.jpg --config=.image-rules.yaml
Advanced Options
Dry Run Mode
const report = await validateBatch(['a.jpg', 'b.png'], {
dryRun: true, // Don't actually repair, just report
repairStrategy: 'scale'
});
Detailed Error Mode
const result = await validateImage('photo.jpg', {
detailedErrors: true // Include stack traces and full context
});
Progress Callbacks
const report = await validateBatch(files, {
onProgress: (current, total, currentFile) => {
console.log(`[${current}/${total}] Processing ${currentFile}`);
},
onComplete: (file, result) => {
console.log(`✓ ${file}: ${result.valid ? 'VALID' : 'INVALID'}`);
}
});
TypeScript Types
All TypeScript types are defined in references/types.ts. Key types:
ValidationOptions: Configuration for validationValidationResult: Result of single image validationBatchReport: Detailed report for batch processingRepairOptions: Configuration for repair operationsImageRulesConfig: Configuration file structure
See references/types.ts for complete type definitions.
