1--TEST--
2Test Tutorial, levelizeImage
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6require_once(dirname(__FILE__) . '/skipif.inc');
7?>
8--FILE--
9<?php
10
11$blackPoint = 50;
12$whitePoint = 100;
13$gamma = 2.2;
14
15function levelizeImage($blackPoint, $gamma,  $whitePoint) {
16    $imagick = new \Imagick();
17    $imagick->newPseudoimage(300, 300, 'gradient:black-white');
18    $maxQuantum = $imagick->getQuantum();
19    $imagick->evaluateimage(\Imagick::EVALUATE_POW, 1 / $gamma);
20
21    //Adjust the scale from black to white to the new 'distance' between black and white
22    $imagick->evaluateimage(\Imagick::EVALUATE_MULTIPLY, ($whitePoint - $blackPoint) / 100 );
23
24    //Add move the black point to it's new value
25    $imagick->evaluateimage(\Imagick::EVALUATE_ADD, ($blackPoint / 100) * $maxQuantum);
26    $imagick->setFormat("png");
27
28    $bytes = $imagick->getImageBlob();
29    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
30}
31
32levelizeImage($blackPoint, $gamma,  $whitePoint) ;
33echo "Ok";
34?>
35--EXPECTF--
36Ok