Exemplo n.º 1
0
/**
 * Require The tuliIP class
 */
require_once '../../tulipIP/tulipIP.class.php';
/**
 * Load The Image From Source File
 */
$path = "../../src.jpg";
$image = tulipIP::loadImage($path);
//x coordinate to start cropping from
// Note you can get the width of $path instead of $image (it's the same)
$x = floor(tulipIP::getWidth($image) / 2);
//y coordinate to start cropping from
$y = 0;
//  x coordinate where to end the cropping
$width = tulipIP::getWidth($path);
//  y coordinate where to end the cropping
$height = tulipIP::getHeight($path);
/**
 * Note: crop method return new gd resource and has no effects in the given gd gd resource($image)
 * =====
 * crop the second half of the image
 */
$croped_image = tulipIP::crop($image, $x, $y, $x, $height);
/**
 * Save The result
 */
$dest = "./";
header('Content-type:' . TIP_PNG);
tulipIP::saveImage(null, $croped_image);
tulipIP::saveImage($dest, $croped_image, TIP_JPG, "croped-image");
Exemplo n.º 2
0
 *  4- $width -> end x coordinate
 *  5- $height -> end y coordinate
 * 
 */
/**
 * Load The Image From Source File
 */
$path = "../../src.jpg";
$image = tulipIP::loadImage($path);
/**
 * Appley gray filter for the second half of the gd resource ($image) only
 */
$dest = "./";
$x = floor(tulipIP::getWidth($image) / 2);
$y = 0;
$width = tulipIP::getWidth($image);
$height = tulipIP::getHeight($image);
$copy = tulipIP::gdClone($image);
tulipIP::gray_part($copy, $x, $y, $width, $height);
tulipIP::saveImage($dest, $copy, TIP_PNG, 'gray_part');
imagedestroy($copy);
/**
 * apply gray filter for the given gd resource except the selected area
 * where selected area is Square (100*100) in the top left corner of the image
 */
$copy = tulipIP::gdClone($image);
tulipIP::gray_invert($copy, 0, 0, 100, 100);
tulipIP::saveImage($dest, $copy, TIP_PNG, 'gray_invertr');
imagedestroy($copy);
// destroy the source
imagedestroy($image);