File: 239_Tutorial_gradientReflection_basic.phpt

package info (click to toggle)
php-imagick 3.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,288 kB
  • sloc: ansic: 17,876; php: 1,440; xml: 444; pascal: 80; sh: 19; makefile: 2
file content (50 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--TEST--
Test Tutorial, gradientReflection
--SKIPIF--
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?>
--FILE--
<?php


function gradientReflection() {
    $im = new \Imagick();
    $im->newPseudoImage(640, 480, "magick:logo");
    
    $reflection = clone $im;

    $reflection->flipImage();

    $reflection->cropImage($im->getImageWidth(), $im->getImageHeight() * 0.75, 0, 0);

    $gradient = new \Imagick();
    $gradient->newPseudoImage(
         $reflection->getImageWidth(),
         $reflection->getImageHeight(),
         //Putting spaces in the rgba string is bad
         'gradient:rgba(255,0,255,0.6)-rgba(255,255,0,0.99)'
    );

    $reflection->compositeimage(
       $gradient,
       \Imagick::COMPOSITE_DSTOUT,
       0, 0
    );

    $canvas = new \Imagick();
    $canvas->newImage($im->getImageWidth(), $im->getImageHeight() * 1.75, new \ImagickPixel('rgba(255, 255, 255, 0)'));
    $canvas->compositeImage($im, \Imagick::COMPOSITE_BLEND, 0, 0);
    $canvas->setImageFormat('png');
    $canvas->compositeImage($reflection, \Imagick::COMPOSITE_BLEND, 0, $im->getImageHeight());

    $canvas->stripImage();
    $canvas->setImageFormat('png');
    header('Content-Type: image/png');
    $bytes = $canvas;
    if (strlen($bytes) <= 0) { echo "Failed to generate image.";} 
}

gradientReflection() ;
echo "Ok";
?>
--EXPECTF--
Ok