1--TEST--
2Test Imagick, forwardFourierTransformImage
3--SKIPIF--
4<?php
5$imageMagickRequiredVersion=0x675;
6
7require_once(dirname(__FILE__) . '/skipif.inc');
8require_once(dirname(__FILE__) . '/skipprobefourier.inc');
9
10?>
11--FILE--
12<?php
13
14
15//Utility function for forwardTransformImage
16function createMask() {
17    $draw = new \ImagickDraw();
18
19    $draw->setStrokeOpacity(0);
20    $draw->setStrokeColor('rgb(255, 255, 255)');
21    $draw->setFillColor('rgb(255, 255, 255)');
22
23    //Draw a circle on the y-axis, with it's centre
24    //at x, y that touches the origin
25    $draw->circle(250, 250, 220, 250);
26
27    $imagick = new \Imagick();
28    $imagick->newImage(512, 512, "black");
29    $imagick->drawImage($draw);
30    $imagick->gaussianBlurImage(20, 20);
31    $imagick->autoLevelImage();
32
33    return $imagick;
34}
35
36
37function forwardFourierTransformImage() {
38    $imagick = new \Imagick();
39    $imagick->newPseudoImage(640, 480, "magick:logo");
40    $imagick->resizeimage(512, 512, \Imagick::FILTER_LANCZOS, 1);
41
42    $mask = createMask();
43    $imagick->forwardFourierTransformImage(true);
44
45    $imagick->setIteratorIndex(0);
46    $magnitude = $imagick->getimage();
47
48    $imagick->setIteratorIndex(1);
49    $imagickPhase = $imagick->getimage();
50
51    if (true) {
52        $imagickPhase->compositeImage($mask, \Imagick::COMPOSITE_MULTIPLY, 0, 0);
53    }
54
55    if (false) {
56        $output = clone $imagickPhase;
57        $output->setimageformat('png');
58    $bytes = $output->getImageBlob();
59    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
60    }
61
62    $magnitude->inverseFourierTransformImage($imagickPhase, true);
63
64    $magnitude->setimageformat('png');
65    $bytes = $magnitude->getImageBlob();
66    if (strlen($bytes) <= 0) { echo "Failed to generate image.";}
67}
68
69forwardFourierTransformImage() ;
70echo "Ok";
71?>
72--EXPECTF--
73Ok