function SmartcropTestCase::assertImageEqual in Smart Crop 7
Same name and namespace in other branches
- 6 tests/smartcrop.test \SmartcropTestCase::assertImageEqual()
Assert that two images are the same, with some difference allowed to account for e.g. compression artifacts.
Parameters
$image1 A GD image resource.:
$image2 A GD image resource.:
$max_diff (optional) The maximum allowed difference, range from 0 to 255, defaults to 1.:
$message (optional) The message to display along with the assertion.:
3 calls to SmartcropTestCase::assertImageEqual()
- SmartcropTestCase::testCrop in tests/
smartcrop.test - SmartcropTestCase::testImageEqual in tests/
smartcrop.test - Test the ImageEqual assertions.
- SmartcropTestCase::testScaleAndCrop in tests/
smartcrop.test - Test cropping of images with known properties.
File
- tests/
smartcrop.test, line 177 - Tests for the smartcrop module.
Class
- SmartcropTestCase
- @file Tests for the smartcrop module.
Code
function assertImageEqual($image1, $image2, $max_diff = 1, $message = NULL) {
if (empty($message)) {
$message = t('Images are equal.');
}
$difference = $this
->difference($image1, $image2);
$mean = $this
->mean($difference);
$this
->assertTrue($mean < $max_diff, $message);
imagedestroy($difference);
}