function ToolkitGdTest::getPixelColor

Function for finding a pixel's RGBa values.

1 call to ToolkitGdTest::getPixelColor()
ToolkitGdTest::testManipulations in drupal/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php
Since PHP can't visually check that our images have been manipulated properly, build a list of expected color values for each of the corners and the expected height and widths for the final images.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitGdTest.php, line 82
Definition of Drupal\system\Tests\Image\ToolkitGdTest.

Class

ToolkitGdTest
Test the core GD image manipulation functions.

Namespace

Drupal\system\Tests\Image

Code

function getPixelColor($image, $x, $y) {
  $color_index = imagecolorat($image->resource, $x, $y);
  $transparent_index = imagecolortransparent($image->resource);
  if ($color_index == $transparent_index) {
    return array(
      0,
      0,
      0,
      127,
    );
  }
  return array_values(imagecolorsforindex($image->resource, $color_index));
}