Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/resize/index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of hyyan  >  Tulip Image Processor  >  examples/resize/index.php  >  Download  
File: examples/resize/index.php
Role: Example script
Content type: text/plain
Description: index
Class: Tulip Image Processor
Apply different types of effects to images
Author: By
Last change:
Date: 2 years ago
Size: 1,905 bytes
 

Contents

Class file image Download
<?php

/**
 * Require The tuliIP class
 */
require_once '../../tulipIP/tulipIP.class.php';

/**
 * Load The Image From Source File
 */
$path "../../src.jpg";
$image tulipIP::loadImage($path);

/**
 * Important: This method will return new gd resource and won't affect the given gd Resource
 * ==========
 */
$dest "./";

//resize image to (100*100)
$resized tulipIP::resize($image100100);
tulipIP::saveImage($dest$resizedTIP_PNG"100-100");
imagedestroy($resized);

// resize image with the given width(100) and let tulipIP handle the new height (aspect ratio)
$resized tulipIP::resize($image100TIP_FIXED);
tulipIP::saveImage($dest$resizedTIP_PNG"100-FIXED");
imagedestroy($resized);

// resize image with the given height(150) and let tulipIP handle the new width (aspect ratio)
$resized tulipIP::resize($imageTIP_FIXED150);
tulipIP::saveImage($dest$resizedTIP_PNG"FIXED-150");
imagedestroy($resized);

/**
 * resize image with the given width(100) and let tulipIP keep original height
 * You can also do the following
 * $resized = tulipIP::resize($image, 100,tulipIP::getHeight($image));
 */
$resized tulipIP::resize($image100TIP_CURRENT);
tulipIP::saveImage($dest$resizedTIP_PNG"100-original");
imagedestroy($resized);

/**
 * resize image with the given height(150) and let tulipIP keep original width
 * You can also do the following
 * $resized = tulipIP::resize($image, tulipIP::getWidth($image),150);
 */
$resized tulipIP::resize($imageTIP_CURRENT150);
tulipIP::saveImage($dest$resizedTIP_PNG"original-150");
imagedestroy($resized);


/**
 * Note: if the params ($new_width,$new_height) were one of this states :
 * TIP_FIXED TIP_FIXED
 * TIP_FIXED TIP_CURRENT
 * TIP_CURRENT TIP_FIXED
 * TIP_CURRENT TIP_CURRENT
 * a copy of given gd resource will be returned with no modifition
 */
// destroy the source
imagedestroy($image);
?>