Skip to content

Commit

Permalink
Declare that GD supports resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Dec 3, 2024
1 parent aec243b commit ef5c8a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/Gd/DriverInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ protected function checkFeature($feature)
case static::FEATURE_MULTIPLELAYERS:
throw new NotSupportedException('GD does not support layer sets');
case static::FEATURE_CUSTOMRESOLUTION:
throw new NotSupportedException('GD does not support setting custom resolutions');
if (!function_exists('imageresolution')) {
throw new NotSupportedException('GD driver for PHP older than 7.2 does not support setting custom resolutions');
}
break;
case static::FEATURE_EXPORTWITHCUSTOMRESOLUTION:
throw new NotSupportedException('GD driver does not support exporting images with custom resolutions');
if (!function_exists('imageresolution')) {
throw new NotSupportedException('GD driver for PHP older than 7.2 does not support exporting images with custom resolutions');
}
break;
case static::FEATURE_DRAWFILLEDCHORDSCORRECTLY:
throw new NotSupportedException('The GD Drawer can NOT draw correctly filled chords');
case static::FEATURE_DRAWUNFILLEDCIRCLESWITHTICHKESSCORRECTLY:
Expand Down
6 changes: 6 additions & 0 deletions tests/tests/Gd/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ protected function getImagine()
*/
protected function getImageResolution(ImageInterface $image)
{
$resolutions = imageresolution($image->getGdResource());

return array(
'x' => $resolutions[0],
'y' => $resolutions[1],
);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions tests/tests/Image/AbstractImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,10 +952,14 @@ public function testResolutionOnSave($source)

public function provideVariousSources()
{
return array(
array(IMAGINE_TEST_FIXTURESFOLDER . '/example.svg'),
$result = array(
array(IMAGINE_TEST_FIXTURESFOLDER . '/100-percent-black.png'),
);
if ($this->getImagine() instanceof \Imagine\Imagick\Imagine) {
$result[] = array(IMAGINE_TEST_FIXTURESFOLDER . '/example.svg');
}

return $result;
}

public function testFillAlphaPrecision()
Expand Down

0 comments on commit ef5c8a6

Please sign in to comment.