content-true / image-unblur-pixel-compare
Measure pixel changes between aligned original and restored RGB images
Package info
github.com/Content-true/image-unblur-pixel-compare
pkg:composer/content-true/image-unblur-pixel-compare
Requires
- php: ^8.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A dependency-free PHP library for measuring differences between aligned, decoded RGB images. It returns normalized mean absolute change, PSNR in decibels, and a per-channel difference array that a caller can render as a visual map. Pixel changes cannot establish that newly visible detail is real.
composer require content-true/image-unblur-pixel-compare
use ContentTrue\ImageUnblur\PixelCompare; $original = [0, 0, 0, 100, 100, 100]; $edited = [0, 0, 0, 120, 120, 120]; $report = PixelCompare::compare($original, $edited); // pixels: 2; identical: false; difference: [0,0,0,20,20,20]
Decode PNG/JPEG and align dimensions in your own application before passing the flat row-major RGB arrays. This library does not open files or upload images. When reviewing an unblur image online result, keep the original and inspect text, faces and edges side by side: a high PSNR means smaller pixel differences, not greater truthfulness. The psnrDb value is null for identical images because the mathematical value is infinite.
Requires PHP 8.1+. Run php -d zend.assertions=1 -d assert.exception=1 tests/smoke.php. MIT license.