You are here

function ToolkitGdTest::getPixelColor in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Image/ToolkitGdTest.php \Drupal\system\Tests\Image\ToolkitGdTest::getPixelColor()

Function for finding a pixel's RGBa values.

1 call to ToolkitGdTest::getPixelColor()
ToolkitGdTest::testManipulations in core/modules/system/src/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

core/modules/system/src/Tests/Image/ToolkitGdTest.php, line 92
Contains \Drupal\system\Tests\Image\ToolkitGdTest.

Class

ToolkitGdTest
Tests that core image manipulations work properly: scale, resize, rotate, crop, scale and crop, and desaturate.

Namespace

Drupal\system\Tests\Image

Code

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