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