Skip to content

Commit

Permalink
tests: deprecated GD changed to PNG
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 12, 2022
1 parent 5288181 commit 845d977
Show file tree
Hide file tree
Showing 37 changed files with 18 additions and 51 deletions.
4 changes: 1 addition & 3 deletions tests/Utils/Image.alpha1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ Assert::same($image->toString(), (string) $image);
$image = Image::fromBlank(200, 100, Image::rgb(255, 128, 0, 60));
$image->crop(0, 0, '60%', '60%');

ob_start();
imagegd2($image->getImageResource());
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha1.gd2'), ob_get_clean());
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha1.png'), $image->toString($image::PNG));
22 changes: 7 additions & 15 deletions tests/Utils/Image.alpha2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,36 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


function toGd2($image)
{
ob_start();
imagegd2($image->getImageResource());
return ob_get_clean();
}


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 100);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100.png'), $image->toString($image::PNG));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 99);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.99.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.99.png'), $image->toString($image::PNG));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 50);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50.png'), $image->toString($image::PNG));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 1);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.1.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.1.png'), $image->toString($image::PNG));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha2.png'), 0, 0, 0);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.0.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.0.png'), $image->toString($image::PNG));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 100);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100b.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.100b.png'), $image->toString($image::PNG));


$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->place(Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif'), 0, 0, 50);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50b.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha2.50b.png'), $image->toString($image::PNG));
18 changes: 5 additions & 13 deletions tests/Utils/Image.drawing.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


function toGd2($image)
{
ob_start();
imagegd2($image->getImageResource());
return ob_get_clean();
}


$size = 300;
$image = Image::fromBlank($size, $size);

Expand All @@ -36,14 +28,14 @@ $image->filledEllipse(187, 125, $radius, $radius, Image::rgb(0, 0, 255, 75));

$image->copyResampled($image, 200, 200, 0, 0, 80, 80, $size, $size);

$file = defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID >= 70424
? '/expected/Image.drawing.1b.gd2'
: '/expected/Image.drawing.1.gd2';
Assert::same(file_get_contents(__DIR__ . $file), toGd2($image));
$file = !defined('PHP_WINDOWS_VERSION_BUILD') || PHP_VERSION_ID >= 70424
? '/expected/Image.drawing.1b.png'
: '/expected/Image.drawing.1.png';
Assert::same(file_get_contents(__DIR__ . $file), $image->toString($image::PNG));


// palette-based image
$image = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');
$image->filledEllipse(100, 50, 50, 50, Image::rgb(255, 255, 0, 75));
$image->filledEllipse(100, 150, 50, 50, Image::rgb(255, 255, 0, 75));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.drawing.2.png'), $image->toString($image::PNG));
4 changes: 1 addition & 3 deletions tests/Utils/Image.place.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@ $rectangle = Image::fromBlank(50, 50, Image::rgb(255, 255, 255));
$image = Image::fromBlank(100, 100, Image::rgb(0, 0, 0));
$image->place($rectangle, '37.5%', '50%');

ob_start();
imagegd2($image->getImageResource());
Assert::same(file_get_contents(__DIR__ . '/expected/Image.place.gd2'), ob_get_clean());
Assert::same(file_get_contents(__DIR__ . '/expected/Image.place.png'), $image->toString($image::PNG));
21 changes: 4 additions & 17 deletions tests/Utils/Image.resize.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ require __DIR__ . '/../bootstrap.php';
$main = Image::fromFile(__DIR__ . '/fixtures.images/logo.gif');


function toGd2($image)
{
ob_start();
imagegd2($image->getImageResource());
return ob_get_clean();
}


test('cropping...', function () use ($main) {
$image = clone $main;
Assert::same(176, $image->width);
Expand Down Expand Up @@ -143,31 +135,26 @@ test('rotate', function () use ($main) {
test('alpha crop', function () use ($main) {
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->crop(1, 1, 8, 8);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.crop.gd2'), toGd2($image));
if (PHP_VERSION_ID < 70200 && gd_info()['GD Version'] === 'bundled (2.1.0 compatible)') {
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.crop-71.png'), $image->toString($image::PNG));
} else {
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.crop.png'), $image->toString($image::PNG));
}
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.crop.png'), $image->toString($image::PNG));
});


test('alpha resize', function () use ($main) {
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->resize(20, 20);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize1.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize1.png'), $image->toString($image::PNG));
});


test('alpha flip', function () use ($main) {
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha1.png');
$image->resize(-10, -10);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.flip1.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.flip1.png'), $image->toString($image::PNG));
});


test('palette alpha resize', function () use ($main) {
$image = Image::fromFile(__DIR__ . '/fixtures.images/alpha3.gif');
$image->resize(20, 20);
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize2.gd2'), toGd2($image));
Assert::same(file_get_contents(__DIR__ . '/expected/Image.alpha.resize2.png'), $image->toString($image::PNG));
});
Binary file removed tests/Utils/expected/Image.alpha.crop-71.png
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha.crop.gd2
Binary file not shown.
Binary file removed tests/Utils/expected/Image.alpha.flip1.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha.flip1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha.resize1.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha.resize1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha.resize2.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha.resize2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha1.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.0.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.1.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.100.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.100b.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.100b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.50.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.50b.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.50b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.alpha2.99.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.alpha2.99.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.drawing.1.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.drawing.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.drawing.1b.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.drawing.1b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.drawing.2.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.drawing.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed tests/Utils/expected/Image.place.gd2
Binary file not shown.
Binary file added tests/Utils/expected/Image.place.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 845d977

Please sign in to comment.