Image_Tools
[ class tree: Image_Tools ] [ index: Image_Tools ] [ all elements ]

Source for file thumbnail.php

Documentation is available at thumbnail.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */
  3. // $Id: thumbnail.php,v 1.1 2008/05/26 03:03:26 firman Exp $
  4.  
  5. /**
  6.  * Image_Tools
  7.  */
  8. require_once 'Image/Tools.php';
  9.  
  10. // creates an instance of Thumbnail tool object
  11. $thumb Image_Tools::factory('thumbnail');
  12. if (PEAR::isError($thumb)) {
  13.     echo $thumb->toString();
  14.     exit;
  15. }
  16.  
  17. // sets the image
  18. $thumb->set('image'dirname(__FILE__'/images/3dgirl.jpg');
  19.  
  20. // set the dimension
  21. if (isset($_GET['percent'])) {
  22.     $thumb->set('percent'50);
  23. else {
  24.     $thumb->set('width'100);
  25.     $thumb->set('height'80);
  26. }
  27.  
  28. // sets the method
  29. if (isset($_GET['method'])) {
  30.     switch ($_GET['method']{
  31.         case 'scale_min':
  32.             $thumb->set('method'IMAGE_TOOLS_THUMBNAIL_METHOD_SCALE_MIN);
  33.             break;
  34.         case 'crop':
  35.             $thumb->set('method'IMAGE_TOOLS_THUMBNAIL_METHOD_CROP);
  36.             break;
  37.     }
  38. }
  39.  
  40. // sets the horizontal alignment
  41. if (isset($_GET['halign'])) {
  42.     switch($_GET['halign']{
  43.         case 'left':
  44.             $thumb->set('halign'IMAGE_TOOLS_THUMBNAIL_ALIGN_LEFT);
  45.             break;
  46.         case 'right':
  47.             $thumb->set('halign'IMAGE_TOOLS_THUMBNAIL_ALIGN_RIGHT);
  48.             break;
  49.     }
  50. }
  51.  
  52. // sets the vertical alignment
  53. if (isset($_GET['valign'])) {
  54.     switch($_GET['valign']{
  55.         case 'top':
  56.             $thumb->set('valign'IMAGE_TOOLS_THUMBNAIL_ALIGN_TOP);
  57.             break;
  58.         case 'bottom':
  59.             $thumb->set('valign'IMAGE_TOOLS_THUMBNAIL_ALIGN_BOTTOM);
  60.             break;
  61.     }
  62. }
  63.  
  64. // display the image result
  65. $err $thumb->display(IMAGETYPE_JPEG);
  66. if (PEAR::isError($err)) {
  67.     echo $err->toString();
  68.     exit;
  69. }

Documentation generated on Mon, 11 Mar 2019 15:22:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.