[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/js/htmlarea/plugins/UploadImage/popups/ImageEditor/ -> load_image.php (source)

   1  <?
   2  /***********************************************************************
   3  ** Title.........:  Online Manipulation of Images
   4  ** Version.......:  1.0
   5  ** Author........:  Xiang Wei ZHUO <wei@zhuo.org>
   6  ** Filename......:  load_image.php
   7  ** Last changed..:  30 Aug 2003 
   8  ** Notes.........:  Configuration in config.inc.php 
   9  
  10                     Uses the GD, ImageMagic or NetPBM to manipulate
  11                     images online. ImageMagic is preferred as it provides
  12                     the best rotation algorithm. Below is a brief comparsion
  13                     of the image manipulation packages. Personal preference
  14                     is ImageMagick.
  15  
  16                                |     GD     | NetPBM | ImageMagick
  17                     ------------------------------------------------
  18                     GIF             NO(1)     YES        YES
  19                     JPEG            YES(2)    YES        YES
  20                     PNG             YES       YES        YES
  21                     Cropping        Good      Good       Good
  22                     Scaling         Fair      Good       Very Good
  23                     Rotation        Poor      Fair       Very Good
  24                     Flip            Good      Poor       Good
  25                     
  26  
  27                     (1) GIF is support in old GD say version 1.61 and below
  28                     (2) Full colour JPEG is not supported in GD versions
  29                         less than 2.01 with PHP.
  30  
  31  ***********************************************************************/
  32  
  33  //***************************************************************************
  34  
  35  include '../ImageManager/config.inc.php';
  36  
  37  // set this to whatever subdir you make
  38  $path = $BASE_ROOT.'/';
  39  //$path = $BASE_DIR.'/';
  40  
  41  //***************************************************************************
  42  
  43  //echo $path;
  44  
  45  require_once  'Transform.php';
  46  
  47  $action = '';
  48  
  49  //get the image file
  50  $img_file = $_GET['img'];
  51  
  52  if($img_file != '') {
  53      $path_info = pathinfo(urldecode($img_file));
  54      $path = $path_info['dirname']."/";
  55      $img_file = $path_info['basename'];
  56  }
  57  //var_dump($path);
  58  //var_dump($path_info);
  59  
  60  //get the parameters
  61  if (isset($_GET['action']))
  62      $action = $_GET['action'];
  63  if (isset($_GET['params']))
  64      $params = $_GET['params'];
  65  if(isset($_GET['file'])) {
  66      $save_file = urldecode($_GET['file']);
  67  }
  68  
  69  //manipulate the image if the parameters are valid
  70  if(isset($params)) {
  71      $values =  explode(',',$params,4);
  72      if(count($values)>0) {
  73          $file = manipulate($img_file, $action, $values);
  74      }
  75  }
  76  
  77  //manipulate the images
  78  function manipulate($img_file, $action, $values)
  79  {
  80      global $path, $save_file, $BASE_DIR,$BASE_ROOT;
  81  
  82      $img_location=$BASE_DIR.$BASE_ROOT.'/';
  83      //Load the Image Manipulation Driver
  84      $img = Image_Transform::factory(IMAGE_CLASS);
  85  
  86      
  87      $img->load($img_location.$img_file);
  88      switch ($action) {
  89          case 'crop':
  90              $img->crop(intval($values[0]),intval($values[1]),intval($values[2]),intval($values[3]));
  91          break;
  92      case 'scale':
  93              $img->resize(intval($values[0]),intval($values[1]));
  94          break;
  95      case 'rotate':
  96              $img->rotate(floatval($values[0]));
  97          break;
  98      case 'flip':
  99          if ($values[0] == 'hoz')
 100              $img->flip(true);
 101          else if($values[0] == 'ver') 
 102              $img->flip(false);
 103          break;
 104      case 'save':
 105  
 106          if (isset($save_file))
 107          {
 108              $quality = intval($values[1]);
 109              if($quality <0)
 110                  $quality = 85;
 111              $img->save($img_location.$save_file, $values[0], $quality);
 112          }
 113          break;
 114      }
 115  
 116      //get the unique file name
 117      $filename = $img->createUnique($img_location);
 118      //save the manipulated image 
 119      $img->save($img_location.$filename);
 120      $img->free();
 121  
 122      $imagesize = @getimagesize($filename);
 123      return array($filename, $imagesize[3]);
 124  }
 125  
 126  
 127  //well, let say the image was not manipulated, or no action parameter was given
 128  //we will get the image dimension anyway.
 129  $image = $img_file;
 130  $size = @getimagesize($image);
 131  $dimensions = $size[3];
 132  
 133  if (isset($file) && is_array($file))
 134  {
 135      $image = $file[0];
 136      $dimensions = $file[1];
 137  }
 138  
 139  //now display the image with 
 140  include 'man_image.html';
 141  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7