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

Source for file test.php

Documentation is available at test.php

  1. <?php
  2. #ini_set('include_path', '.');
  3. /**
  4.  * Usage: test.php?driver=XX
  5.  * 
  6.  */
  7. // as we're testing we want high error reporting
  8.  
  9. // Where we'll put resulting image and HTML files...
  10. define('TEST_DIR'dirname(__FILE__. DIRECTORY_SEPARATOR);
  11. define('TEST_IMAGE_DIR'TEST_DIR . 'images' . DIRECTORY_SEPARATOR);
  12. define('TEST_OUTPUT_DIR'TEST_DIR . 'tmp' . DIRECTORY_SEPARATOR);
  13.  
  14. define('FONTS''/usr/share/fonts/');
  15. define('FONTS_TTF'FONTS . DIRECTORY_SEPARATOR . 'corefonts' . DIRECTORY_SEPARATOR);
  16.  
  17. #$lib_path = array('IM' =>)
  18.  
  19.  
  20. $driver $_GET['driver'];
  21. $image $_GET['image'];
  22. if (!defined('IMAGE_TRANSFORM_LIB_PATH')) {
  23.     define('IMAGE_TRANSFORM_LIB_PATH''/usr/bin/');
  24. }
  25.  
  26. if ($driver == 'IM' || $driver == 'NetPBM'{
  27.     // Assume binaries are in your path
  28.     #define('IMAGE_TRANSFORM_LIB_PATH', '');
  29. }
  30.  
  31. require_once 'Image/Transform.php';
  32. $im Image_Transform::factory($driver);
  33. #var_dump($im);
  34. if (PEAR::isError($im)) {
  35.     die($im->message);
  36. }
  37. // Load the image
  38. $im->load(TEST_IMAGE_DIR . $image);
  39.  
  40. /*
  41.  * Initialise variables
  42.  */
  43. $cmd = isset($_GET['cmd']$_GET['cmd''';
  44. $angle = isset($_GET['angle']intval($_GET['angle']: 0;
  45. $width = isset($_GET['width']intval($_GET['width']$im->getImageWidth();
  46. $height = isset($_GET['height']intval($_GET['height']$im->getImageHeight();
  47. // Text to be added
  48. $text = isset($_GET['text']$_GET['text''Sample Text';
  49.  
  50. /*
  51.  * Now start.  Switch cmd to find which test to run
  52.  */
  53. $cmds explode('|'$cmd);
  54. foreach($cmds as $cmd){
  55.     switch($cmd){
  56.         case 'addText':
  57.             $im->addText(array('text' => $text'font' => FONTS_TTF . '/arial.ttf'));
  58.             break;
  59.         case 'resize'
  60.             $im->resize($width/2$height/2);
  61.             break;
  62.         case 'rotate'
  63.             $im->rotate($angle);
  64.             break;
  65.         case 'scaleByX':
  66.             $im->scaleByX($width/2);
  67.             break;
  68.         case 'scaleByY':
  69.             $im->scaleByY($width/2);
  70.             break;
  71.         case 'scaleByFactor':
  72.             $im->scaleByFactor(0.5);
  73.             break;
  74.         case 'scaleByPercentage':
  75.             $im->scaleByPercentage(50);
  76.             break;
  77.         default:
  78.             trigger_error('No command specified... aborting');
  79.     // switch
  80. }
  81.  
  82. $im->display(null100);
  83. #$im->save($image_file . '-' . $driver);
  84. $im->free();
  85. /*
  86.  * Now load the image, and:
  87.  *  a) add text and then resize
  88.  *  a) resize and then add text
  89.  * Check the font size is different
  90.  */
  91.  
  92. /*
  93.  * Rotate the image
  94.  */
  95.  
  96. ?>

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