Annotation of embedaddon/php/ext/gd/tests/imagecopyresampled_basic.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: imagecopyresampled()
        !             3: --SKIPIF--
        !             4: <?php 
        !             5:        if (!function_exists('imagecopyresampled')) die('skip imagecopyresampled() not available'); 
        !             6:        if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled');
        !             7: ?>
        !             8: --FILE--
        !             9: <?php
        !            10: 
        !            11: /* Prototype  : bool imagecopyresampled  ( resource $dst_image  , resource $src_image  , int $dst_x  , int $dst_y  , int $src_x  , int $src_y  , int $dst_w  , int $dst_h  , int $src_w  , int $src_h  )
        !            12:  * Description: Copy and resize part of an image with resampling.
        !            13:  * Source code: ext/standard/image.c
        !            14:  * Alias to functions: 
        !            15:  */
        !            16: 
        !            17: echo "Simple test of imagecopyresampled() function\n";
        !            18: 
        !            19: $dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png';
        !            20: $dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png';
        !            21: 
        !            22: // create a blank image
        !            23: $image_lge = imagecreatetruecolor(400, 300);
        !            24: 
        !            25: // set the background color to black 
        !            26: $bg = imagecolorallocate($image_lge, 0, 0, 0);
        !            27: 
        !            28: // fill polygon with blue
        !            29: $col_ellipse = imagecolorallocate($image_lge, 0, 255, 0);
        !            30: 
        !            31: // draw the eclipse
        !            32: imagefilledellipse($image_lge, 200, 150, 300, 200, $col_ellipse);
        !            33: 
        !            34: // output the picture to a file
        !            35: imagepng($image_lge, $dest_lge);
        !            36: 
        !            37: // Get new dimensions
        !            38: $percent = 0.5; // new image 50% of orginal
        !            39: list($width, $height) = getimagesize($dest_lge);
        !            40: echo "Size of orginal: width=". $width . " height=" . $height . "\n";
        !            41: 
        !            42: $new_width = $width * $percent;
        !            43: $new_height = $height * $percent;
        !            44: 
        !            45: // Resample
        !            46: $image_sml = imagecreatetruecolor($new_width, $new_height);
        !            47: imagecopyresampled($image_sml, $image_lge, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        !            48: 
        !            49: imagepng($image_sml, $dest_sml);
        !            50: 
        !            51: list($width, $height) = getimagesize($dest_sml);
        !            52: echo "Size of copy: width=". $width . " height=" . $height . "\n";
        !            53: 
        !            54: imagedestroy($image_lge); 
        !            55: imagedestroy($image_sml);
        !            56:  
        !            57: 
        !            58: echo "Done\n"; 
        !            59: ?>
        !            60: --CLEAN--
        !            61: <?php 
        !            62:        $dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png';
        !            63:        $dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png';
        !            64:        @unlink($dest_lge);
        !            65:        @unlink($dest_sml);
        !            66: ?>
        !            67: --EXPECT--
        !            68: Simple test of imagecopyresampled() function
        !            69: Size of orginal: width=400 height=300
        !            70: Size of copy: width=200 height=150
        !            71: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>