PHP Classes
elePHPant
Icontem

File: examples/basic/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/basic/index.php  >  Download  
File: examples/basic/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: 2,203 bytes
 

Contents

Class file image Download
<?php

/**
 * First we require the tulipIP class
 */
require_once '../../tulipIP/tulipIP.class.php';

/**
 * this option will handle errors behavior
 *
 * Important : Using This Method Is Optional
 * =========
 *
 * Note : tulipIP Class does not throw any kinds of errors
 * ====== or exceptions instead tuliIP log file will be created
 * contains all errors or exception raised throw progress
 * PLUS: errors or exception raised throw progress will
 * be also writen to Apache log file
 *
 * First argument will allow tulipIP to write the log file - change it to false
 * to prevent tuliIP to write errors to the log file
 * second argumengt if true: exist log file will be removed then new one will be created
 * if false : tulipIP will write errors to exist log file
 *
 */
tulipIP::log(true, true);

/**
 * Load Image from source File
 * return gd resource in success false otherwise
 */
$path = "../../src.jpg";
$img = tulipIP::loadImage($path);

/**
 * Here We use tuliIP gray filter on loaded img
 * return true on success false otherwise
 */
if ($img) {
   
$result = tulipIP::gray($img);
} else {
    echo
"Unable To Load The Image";
}

/**
 * finally we save imag to directory and show the result in the browser
 *
 * Note : pass (null) as dest argument to output the image directly in the browser
 * ======
 * Note : you can change the outputted image format using one of
 * ====== supported tuliIP formats -> TIP_JPG , TIP_JPEG , TIP_PNG , TIP_GIF
 *
 * Important : Do Not Use TIP_JPG as content type when you send Header this
 * =========== will cause problems in (Safari) and (IE) browsers
 * use TIP_JPEG instead
 *
 * Note : we can change the quality of the outputted image by passing integer in range (0,100)
 * ====== to saveImage Method where better quality means bigger file(s) size
 */
$dest = "./";
if (
$result) {
   
// output the image directly to the browser
   
header("Content-type:".TIP_JPEG);
   
tulipIP::saveImage(null, $img);
   
// output the image to the dest directory
   
tulipIP::saveImage($dest, $img, TIP_JPG, "negate-filter", 100);
}

/**
 * Destroy the resource
 */
imagedestroy($img);
?>