Skip to content

A little PHP function that can compare PDFs and images using the Imagick PHP extension.

License

Notifications You must be signed in to change notification settings

machinateur/imagickompare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

machinateur/imagickompare

A little PHP function that can compare PDFs and images using the Imagick PHP extension.

Requirements

  • At least PHP >=7.4 is required
    • Extension ext-imagick is required

Installation

composer require machinateur/imagickompare

Usage

<?php

require_once __DIR__ . '/vendor/autoload.php';

// simply compare two files (pdf, png, etc.)
$diffPercentage = \compare_with_imagick('/path/to/control-file', '/path/to/compare-file');
// or define a resolution
$diffPercentage = \compare_with_imagick('/path/to/control-file', '/path/to/compare-file', [100, 100]);
// and define a fuzziness for diff metrics
$diffPercentage = \compare_with_imagick('/path/to/control-file', '/path/to/compare-file', fuzziness: 5);
// the merged file can be saved as well, when passing an open file handle
$diffPercentage = \compare_with_imagick('/path/to/control-file', '/path/to/compare-file', fh: $fh = \fopen('php://temp'));

Tests

There are no tests for this library as of now.

I have used it in two of my projects (the-printe, php-qpdf-ffi) to assess PDF file differences in their tests.

License

It's MIT.

About

A little PHP function that can compare PDFs and images using the Imagick PHP extension.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages