Example #1
0
 /**
  * Main class constructor.
  *
  * @param  string   $source  Path to the source image to load for manipulation.
  * @param  boolean  $cache   Path to wherever you would like the image cache to appear
  */
 public function __construct($source, $cache = false)
 {
     @ini_set('memory_limit', '256M');
     # Try to load GD image resource
     $this->img = $this->GD_create($source);
     # Make sure a resource exists
     if ($this->img) {
         foreach ($this->settings as $setting => $val) {
             $this->{$setting} = $val;
         }
         # Dump settings to variables
         $this->limit();
         # Limit max size
         $this->copytrans();
         # Preserve transparency
         $this->_img = $this->clone_resource();
         # Make a backup in case of reset
         $this->docroot = File::docroot();
         # Get document root for urls
         $this->protocol = empty($_SERVER["HTTPS"]) ? 'http://' : 'https://';
         # Get server protocol
         $this->img_cache = $cache ? realpath($cache) . '/' : $this->docroot . '/img/cache/';
         # Make sure we have valid cache string
         # Extra safety to avoid root folder deletion by accident
         if ($this->img_cache == File::docroot()) {
             $this->img_cache . '/img/cache/';
         }
     }
 }