Download the PHP package meyfa/phpunit-assert-gd without Composer

On this page you can find all versions of the php package meyfa/phpunit-assert-gd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpunit-assert-gd

AssertGD for PHPUnit

CI

Trying to assert images with PHPUnit? This project provides a constraint and the required assertions that allow you do to so.

It supports comparing files on disk as well as image resources in memory.

Installation

Add this package to your Composer dev-dependencies:

Compatibility table

AssertGD version Supported PHP version Supported PHPUnit version
4.* >= 8.1 10.1
3.* >= 7.3 9
2.* >= 7.2 8
1.* 5.3.3 - 8.0 4.8.36 - 6.5.0

Examples

The assertions are available as a trait, so you can easily use them in your test case class:

Plain comparisons

Use assertSimilarGD if you expect 2 images to be exactly equal. Use assertNotSimilarGD if you expect there to be differences.

Threshold values

Provide a number between 0 and 1 to set the error threshold. For example, a value of 0.2 would allow for at most 20% difference.

Parameter types

Instead of file paths, you can pass in GD image resources. This eliminates having to write something to disk prior to the comparison.

Manual constraint

If you need to configure mock objects or do other, more complex matching calls, use isSimilarGD to obtain a constraint object (similar to what would be returned by equalTo, isTrue, etc.).

Difference calculation

By default, this library calculates the difference between two images by comparing the RGBA color channel information at each pixel coordinate of the source image and the test image, and averaging the difference between each pixel to calculate the difference score.

This will work for the majority of cases, but may give incorrect scoring in certain circumstances, such as images that contain a lot of transparency.

An alternative calculation method, which scales the RGB color channels based on their alpha transparency - meaning more transparent pixels will affect the difficulty score less to offset their less observable difference on the image itself - can be enabled by adding a new ScaledRgbChannels instance to the 5th parameter of the assertSimilarGD or assertNotSimilarGD methods.

Custom difference calculators

If you wish to completely customise how calculations are done in this library, you may also create your own calculation algorithm by creating a class that implements the AssertGd\DiffCalculator interface.

A class implementing this interface must provide a calculate method that is provided two GdImage instances, and the X and Y co-ordinate (as ints) of the pixel being compared in both images.

The method should return a float between 0 and 1, where 0 is an exact match and 1 is the complete opposite.

You may then provide an instance of the class as the 5th parameter of the assertSimilarGD or assertNotSimilarGD method to use this calculation method for determining the image difference.


All versions of phpunit-assert-gd with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
phpunit/phpunit Version ^10.1
ext-gd Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package meyfa/phpunit-assert-gd contains the following files

Loading the files please wait ....