Advertisement
plas71k

Image_lib.php ioncube7 => decoded

Mar 24th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.89 KB | None | 0 0
  1. <?php
  2. class MagentoGarden_Image
  3. {
  4.     private $_adapter = null;
  5.     private $_fileName = null;
  6.    
  7.     /**
  8.      * Constructor
  9.      *
  10.      * @param Varien_Image_Adapter $adapter. Default value is GD2
  11.      * @param string $fileName
  12.      * @return void
  13.      */
  14.     function __construct($fileName = null, $adapter = MagentoGarden_Image_Adapter::ADAPTER_GD2)
  15.     {
  16.         $this->_getAdapter($adapter);
  17.         $this->_fileName = $fileName;
  18.        
  19.         if (isset($fileName)) {
  20.             $this->open();
  21.         }
  22.        
  23.     }
  24.    
  25.     /**
  26.      * Opens an image and creates image handle
  27.      *
  28.      * @access public
  29.      * @return void
  30.      */
  31.     function open()
  32.     {
  33.         $this->_getAdapter()->checkDependencies();
  34.        
  35.         if (!file_exists($this->_fileName)) {
  36.             throw new Exception('' . 'File \'' . $this->_fileName . '\' does not exists.');
  37.         }
  38.        
  39.         $this->_getAdapter()->open($this->_fileName);
  40.     }
  41.    
  42.     /**
  43.      * Display handled image in your browser
  44.      *
  45.      * @access public
  46.      * @return void
  47.      */
  48.     function display()
  49.     {
  50.         $this->_getAdapter()->display();
  51.     }
  52.    
  53.     /**
  54.      * Save handled image into file
  55.      *
  56.      * @param string $destination. Default value is NULL
  57.      * @param string $newFileName. Default value is NULL
  58.      * @access public
  59.      * @return void
  60.      */
  61.     function save($destination = null, $newFileName = null)
  62.     {
  63.         $this->_getAdapter()->save($destination, $newFileName);
  64.     }
  65.    
  66.     /**
  67.      * Rotate an image.
  68.      *
  69.      * @param int $angle
  70.      * @access public
  71.      * @return void
  72.      */
  73.     function rotate($angle)
  74.     {
  75.         $this->_getAdapter()->rotate($angle);
  76.     }
  77.    
  78.     /**
  79.      * Crop an image.
  80.      *
  81.      * @param int $top. Default value is 0
  82.      * @param int $left. Default value is 0
  83.      * @param int $right. Default value is 0
  84.      * @param int $bottom. Default value is 0
  85.      * @access public
  86.      * @return void
  87.      */
  88.     function crop($top = 0, $left = 0, $right = 0, $bottom = 0)
  89.     {
  90.         $this->_getAdapter()->crop($top, $left, $right, $bottom);
  91.     }
  92.    
  93.     /**
  94.      * Resize an image
  95.      *
  96.      * @param int $width
  97.      * @param int $height
  98.      * @access public
  99.      * @return void
  100.      */
  101.     function resize($width, $height = null)
  102.     {
  103.         $this->_getAdapter()->resize($width, $height);
  104.     }
  105.    
  106.     function keepAspectRatio($value)
  107.     {
  108.         return $this->_getAdapter()->keepAspectRatio($value);
  109.     }
  110.    
  111.     function keepFrame($value)
  112.     {
  113.         return $this->_getAdapter()->keepFrame($value);
  114.     }
  115.    
  116.     function keepTransparency($value)
  117.     {
  118.         return $this->_getAdapter()->keepTransparency($value);
  119.     }
  120.    
  121.     function constrainOnly($value)
  122.     {
  123.         return $this->_getAdapter()->constrainOnly($value);
  124.     }
  125.    
  126.     function backgroundColor($value)
  127.     {
  128.         return $this->_getAdapter()->backgroundColor($value);
  129.     }
  130.    
  131.     /**
  132.      * Get/set quality, values in percentage from 0 to 100
  133.      *
  134.      * @param int $value
  135.      * @return int
  136.      */
  137.     function quality($value)
  138.     {
  139.         return $this->_getAdapter()->quality($value);
  140.     }
  141.    
  142.     /**
  143.      * Adds watermark to our image.
  144.      *
  145.      * @param string $watermarkImage. Absolute path to watermark image.
  146.      * @param int $positionX. Watermark X position.
  147.      * @param int $positionY. Watermark Y position.
  148.      * @param int $watermarkImageOpacity. Watermark image opacity.
  149.      * @param bool $repeat. Enable or disable watermark brick.
  150.      * @access public
  151.      * @return void
  152.      */
  153.     function watermark($watermarkImage, $positionX = 0, $positionY = 0, $watermarkImageOpacity = 30, $repeat = false)
  154.     {
  155.         if (!file_exists($watermarkImage)) {
  156.             throw new Exception('' . 'Required file \'' . $watermarkImage . '\' does not exists.');
  157.         }
  158.        
  159.         $this->_getAdapter()->watermark($watermarkImage, $positionX, $positionY, $watermarkImageOpacity, $repeat);
  160.     }
  161.    
  162.     /**
  163.      * Get mime type of handled image
  164.      *
  165.      * @access public
  166.      * @return string
  167.      */
  168.     function getMimeType()
  169.     {
  170.         return $this->_getAdapter()->getMimeType();
  171.     }
  172.    
  173.     /**
  174.      * process
  175.      *
  176.      * @access public
  177.      * @return void
  178.      */
  179.     function process()
  180.     {
  181.     }
  182.    
  183.     /**
  184.      * instruction
  185.      *
  186.      * @access public
  187.      * @return void
  188.      */
  189.     function instruction()
  190.     {
  191.     }
  192.    
  193.     /**
  194.      * Set image background color
  195.      *
  196.      * @param int $color
  197.      * @access public
  198.      * @return void
  199.      */
  200.     function setImageBackgroundColor($color)
  201.     {
  202.         $this->_getAdapter()->imageBackgroundColor = intval($color);
  203.     }
  204.    
  205.     function setIsCategoryWatermark($_value)
  206.     {
  207.         $this->_getAdapter()->setIsCategoryWatermark($_value);
  208.         return $this;
  209.     }
  210.    
  211.     function setPositionType($_position_type)
  212.     {
  213.         $this->_getAdapter()->setPositionType($_position_type);
  214.         return $this;
  215.     }
  216.    
  217.     /**
  218.      * Set watermark position
  219.      *
  220.      * @param string $position
  221.      * @return Varien_Image
  222.      */
  223.     function setWatermarkPosition($position)
  224.     {
  225.         $this->_getAdapter()->setWatermarkPosition($position);
  226.         return $this;
  227.     }
  228.    
  229.     /**
  230.      * Set watermark image opacity
  231.      *
  232.      * @param int $imageOpacity
  233.      * @return Varien_Image
  234.      */
  235.     function setWatermarkImageOpacity($imageOpacity)
  236.     {
  237.         $this->_getAdapter()->setWatermarkImageOpacity($imageOpacity);
  238.         return $this;
  239.     }
  240.    
  241.     /**
  242.      * Set watermark width
  243.      *
  244.      * @param int $width
  245.      * @return Varien_Image
  246.      */
  247.     function setWatermarkWidth($width)
  248.     {
  249.         $this->_getAdapter()->setWatermarkWidth($width);
  250.         return $this;
  251.     }
  252.    
  253.     /**
  254.      * Set watermark heigth
  255.      *
  256.      * @param int $heigth
  257.      * @return Varien_Image
  258.      */
  259.     function setWatermarkHeigth($heigth)
  260.     {
  261.         $this->_getAdapter()->setWatermarkHeigth($heigth);
  262.         return $this;
  263.     }
  264.    
  265.     /**
  266.      * Retrieve image adapter object
  267.      *
  268.      * @param string $adapter
  269.      * @return Varien_Image_Adapter_Abstract
  270.      */
  271.     function _getAdapter($adapter = null)
  272.     {
  273.         if (!isset($this->_adapter)) {
  274.             $this->_adapter = MagentoGarden_Image_Adapter::factory($adapter);
  275.         }
  276.        
  277.         return $this->_adapter;
  278.     }
  279.    
  280.     /**
  281.      * Retrieve original image width
  282.      *
  283.      * @return int|null
  284.      */
  285.     function getOriginalWidth()
  286.     {
  287.         return $this->_getAdapter()->getOriginalWidth();
  288.     }
  289.    
  290.     /**
  291.      * Retrieve original image height
  292.      *
  293.      * @return int|null
  294.      */
  295.     function getOriginalHeight()
  296.     {
  297.         return $this->_getAdapter()->getOriginalHeight();
  298.     }
  299. }
  300.  
  301. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement