Skip to content
Image Resolution Checker logo

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

PresetDimensionsAspect RatioUse Case
avatar100×1001:1User avatars
thumbnail300×3001:1Thumbnails
hd1920×108016:9HD wallpapers
4k3840×216016:94K wallpapers
8k7680×432016:98K wallpapers
8k-cinema8192×43201.89:1DCI 8K
8k-4-38192×61444:38K 4:3 professional
mobile-wallpaper1080×19209:16Mobile wallpapers
tablet2048×15364:3Tablet images
app-icon1024×10241:1App Store icons
instagram-square1080×10801:1Instagram square
instagram-portrait1080×13504:5Instagram portrait
twitter-post1200×67516:9Twitter posts
facebook-cover820×3122.6:1Facebook covers
ultrawide3440×14402.39:1Ultrawide wallpapers
customuser-defined-Custom dimensions

Error Codes

CodeTypeDescriptionSuggestion
E001FILE_NOT_FOUNDFile does not existCheck path
E002UNSUPPORTED_FORMATUnsupported image formatConvert to JPG/​PNG/​WebP
E003DIMENSION_TOO_SMALLImage is too smallUse higher resolution image
E004DIMENSION_TOO_LARGEImage is too largeCompress or resize
E005ASPECT_RATIO_MISMATCHAspect ratio doesn't matchUse crop/​pad repair
E006INVALID_CONFIGConfiguration errorCheck config file
E007REPAIR_FAILEDRepair operation failedManual intervention needed
E008CORRUPT_IMAGEImage file is corruptedRe-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 validation
  • ValidationResult: Result of single image validation
  • BatchReport: Detailed report for batch processing
  • RepairOptions: Configuration for repair operations
  • ImageRulesConfig: Configuration file structure

See references/​types.ts for complete type definitions.