<?php
    // get the class
    include_once ('../inc/transform.class.php');
    
    if (!$_GET['thumb']) {
    	exit('error');
    }

    $thumb = $_GET['thumb'];
    $thumb_array = explode(',',$thumb);
    $mode = array_shift($thumb_array);
    $upload_path = '../upload/';
    
    $imageTransform = new imageTransform; 
    
    switch ($mode){ 
		case 'gray':
            $file = $thumb_array[0];
            $path = $upload_path.$file; 
            //make the new image name eg: gray,google.jpg       
            $save = implode(",",array($mode,$file));   
                $imageTransform->view('gray', $path, null, $save);
		break;
            
		case 'rotate':
            //degrees allowed, add any degree you want
            $degrees = array('90','180');
        
            $degree = $thumb_array[0];
            $file = $thumb_array[1];
            $path = $upload_path.$file; 
            $save = implode(",",array($mode,$degree,$file));   
            
            if (in_array($degree,$degrees)) {        
                $imageTransform->view('rotate', $path, $degree, $save);
            }    
		break;
            
		case 'resize':
		case 'crop':
            //sizes allowed, add any thing you want
            $sizes = array('50x50','100x100','200x200');
            
            $size = $thumb_array[0];
            $file = $thumb_array[1];
            $path = $upload_path.$file;        

            if (in_array($size,$sizes)) {
            	$imageTransform->view($mode, $path, $size,implode(",",array($mode,$size,$file)));
            }
		break;
        
		case 'flip':
		case 'flop':
            $file = $thumb_array[0];
            $path = $upload_path.$file;        
            $save = implode(",",array($mode,$file));   
                $imageTransform->view($mode, $path, null, $save);
		break;
    
    	default :
            exit('This is not valid mode');
    }

?>