This guide helps you resolve common issues with auto-image-diff.
- Installation Issues
- Runtime Errors
- Image Processing Problems
- Performance Issues
- Classification Issues
- Integration Problems
- Debug Mode
- Getting Help
Problem: Error message "ImageMagick not found" or "convert: command not found"
Solutions:
-
Verify ImageMagick installation:
# Check if installed convert -version # or on Windows magick -version
-
Install ImageMagick:
# macOS brew install imagemagick # Ubuntu/Debian sudo apt-get update && sudo apt-get install imagemagick # Windows - download from imagemagick.org
-
Add to PATH (Windows):
- Add ImageMagick bin directory to system PATH
- Restart terminal/command prompt
-
Check Node.js bindings:
# Reinstall gm module npm rebuild gm
Problem: "Unsupported Node.js version" or syntax errors
Solution:
# Check version (need 22.0.0+)
node --version
# Install correct version using nvm
nvm install 22
nvm use 22Problem: "EACCES: permission denied" during global install
Solutions:
-
Use npm prefix:
npm config set prefix ~/.npm-global export PATH=~/.npm-global/bin:$PATH npm install -g auto-image-diff
-
Fix npm permissions:
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
Problem: "JavaScript heap out of memory"
Solutions:
-
Increase Node.js memory:
# Set memory limit to 8GB export NODE_OPTIONS="--max-old-space-size=8192" aid batch ref/ target/ output/
-
Reduce batch concurrency:
aid batch ref/ target/ output/ --max-concurrency 2
-
Process smaller images:
# Resize images first convert large.png -resize 50% smaller.png
Problem: "ENOENT: no such file or directory"
Solutions:
-
Check file paths:
# Use absolute paths aid compare /full/path/to/image1.png /full/path/to/image2.png output/ -
Verify file exists:
ls -la image1.png image2.png
-
Check working directory:
pwd
Problem: "EACCES: permission denied" when writing output
Solutions:
-
Check directory permissions:
ls -la output/ chmod 755 output/
-
Create output directory:
mkdir -p output
Problem: "Failed to align images" or poor alignment results
Solutions:
-
Try different alignment methods:
# Default subimage method aid compare ref.png target.png out/ # OpenCV feature-based aid compare ref.png target.png out/ --alignment-method opencv # Phase correlation aid compare ref.png target.png out/ --alignment-method phase
-
Check image similarity:
- Images must have overlapping content
- Very different images cannot be aligned
-
Verify image formats:
file image1.png image2.png # Should show: PNG image data
Problem: False positives or missing differences
Solutions:
-
Adjust threshold:
# More sensitive (lower threshold) aid compare ref.png target.png out/ --threshold 0.01 # Less sensitive (higher threshold) aid compare ref.png target.png out/ --threshold 1.0
-
Use exclusion regions:
// exclusions.json { "regions": [ { "x": 0, "y": 0, "width": 200, "height": 50, "reason": "Dynamic timestamp" } ] }
aid compare ref.png target.png out/ --exclusions exclusions.json
-
Enable classification:
aid compare ref.png target.png out/ --classify
Problem: "OpenCV not loaded" or "Feature detection failed"
Solutions:
-
Install OpenCV dependencies:
npm run setup:opencv
-
Check WASM file:
ls node_modules/opencv-js/opencv.js
-
Use fallback method:
aid compare ref.png target.png out/ --alignment-method subimage
Problem: Image processing takes too long
Solutions:
-
Enable parallel processing:
aid batch ref/ target/ out/ --parallel --max-concurrency 8
-
Reduce image size:
# Preprocess large images for img in *.png; do convert "$img" -resize 2000x2000\> "resized_$img" done
-
Skip classification:
# Faster without classification aid compare ref.png target.png out/ -
Use SSD for temp files:
export TMPDIR=/path/to/ssd/temp
Problem: Excessive memory consumption
Solutions:
-
Process in batches:
# Process 10 images at a time find ref/ -name "*.png" | head -10 | while read f; do aid compare "$f" "target/$(basename $f)" output/ done
-
Clear Node.js cache:
node --expose-gc script.js # Call global.gc() in code
Problem: Changes classified incorrectly
Solutions:
-
Review classification rules:
- Content: Text/image changes
- Style: Color/visual changes
- Layout: Position changes
- Size: Dimension changes
-
Adjust confidence thresholds:
// Custom classifier class MyClassifier extends DifferenceClassifier { classify(region, context) { // Adjust confidence calculation } }
-
Check region size:
- Very small regions may be misclassified
- Merge adjacent regions for better accuracy
Problem: Tests fail in CI but pass locally
Solutions:
-
Check ImageMagick version:
# .github/workflows/ci.yml - name: Install ImageMagick run: | sudo apt-get update sudo apt-get install -y imagemagick convert -version
-
Set consistent environment:
# Use same Node version nvm use 22 # Set timezone export TZ=UTC
-
Debug CI output:
# Add debug flag aid compare ref.png target.png out/ --debug
Problem: Errors when using programmatically
Solutions:
-
Check async/await usage:
// Correct try { const result = await processor.compareImages(img1, img2); } catch (error) { console.error('Comparison failed:', error); }
-
Handle file paths correctly:
import * as path from 'path'; const absolutePath = path.resolve(relativePath);
# Set debug environment variable
export DEBUG=auto-image-diff:*
aid compare ref.png target.png out/
# Or inline
DEBUG=auto-image-diff:* aid compare ref.png target.png out/auto-image-diff:align- Alignment operationsauto-image-diff:compare- Comparison operationsauto-image-diff:classify- Classification processauto-image-diff:batch- Batch processing
# Enable verbose mode
aid compare ref.png target.png out/ --verbose
# Save debug output
aid compare ref.png target.png out/ --verbose 2> debug.log# Generate full debug report
aid debug-report > debug-report.txt
# Include system info
aid compare ref.png target.png out/ --debug --system-info# Check installation
aid doctor
# Version information
aid --version
# Help for specific command
aid compare --help| Code | Meaning | Solution |
|---|---|---|
| 1 | General error | Check error message |
| 2 | File not found | Verify file paths |
| 3 | ImageMagick error | Check IM installation |
| 4 | Memory error | Increase heap size |
| 5 | Permission denied | Check file permissions |
When reporting issues, include:
- Error message: Full error output
- Environment: OS, Node.js version, ImageMagick version
- Command: Exact command that failed
- Files: Sample images if possible
- Debug output: Run with
--debugflag
If nothing else works:
-
Clean install:
npm uninstall -g auto-image-diff npm cache clean --force npm install -g auto-image-diff
-
Use Docker (if available):
docker run -v $(pwd):/work auto-image-diff compare /work/ref.png /work/target.png /work/out/ -
Manual ImageMagick:
# Direct ImageMagick commands compare -metric RMSE ref.png target.png diff.png