src/Ivliev/Imagefly/Imagefly.php
private function _set_params()
    {
        // Get values from request
        $params = \Request::route('params');
        $filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
        
        // echo $params; exit;
        
        // If enforcing params, ensure it's a match
        if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
            abort(404);
        }
        
        $image = new Image();
        $image->configure(config('image'));
        if (function_exists('exif_read_data')) {
            $this->image = $image->make($filepath)->orientate();
        } else {
            $this->image = $image->make($filepath);
        }
        
        // The parameters are separated by hyphens
        $raw_params = explode('-', $params);
        
        // Update param values from passed values
        foreach ($raw_params as $raw_param) {
            $name = $raw_param[0];
            $value = substr($raw_param, 1, strlen($raw_param) - 1);
            
            if ($name == 'c') {
                $this->url_params[$name] = TRUE;
                
                // When croping, we must have a width and height to pass to imagecreatetruecolor method
                // Make width the height or vice versa if either is not passed
                if (empty($this->url_params['w'])) {
                    $this->url_params['w'] = $this->url_params['h'];
                }
                if (empty($this->url_params['h'])) {
                    $this->url_params['h'] = $this->url_params['w'];
                }
            } elseif (key_exists($name, $this->url_params)) {
                // Remaining expected params (w, h, q)
                $this->url_params[$name] = $value;
            } else {
                // Watermarks or invalid params
                $this->url_params[$raw_param] = $raw_param;
            }
        }
        
        // Do not scale up images
        if (! $this->config['scale_up']) {
            if ($this->url_params['w'] > $this->image->width()) {
                $this->url_params['w'] = $this->image->width();
            }
            if ($this->url_params['h'] > $this->image->height()) {
                $this->url_params['h'] = $this->image->height();
            }
        }
        
        // Must have at least a width or height
        if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
            throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
                ':uri' => Request::$current->uri()
            ));
        }
        
        // Set the url filepath
        $this->source_file = $filepath;
    }
private function _set_params()
    {
        // Get values from request
        $params = \Request::route('params');
        $filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
        
        // echo $params; exit;
        
        // If enforcing params, ensure it's a match
        if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
            abort(404);
        }
        
        $image = new Image();
        $image->configure(config('image'));
        if (function_exists('exif_read_data')) {
            $this->image = $image->make($filepath)->orientate();
        } else {
            $this->image = $image->make($filepath);
        }
        
        // The parameters are separated by hyphens
        $raw_params = explode('-', $params);
        
        // Update param values from passed values
        foreach ($raw_params as $raw_param) {
            $name = $raw_param[0];
            $value = substr($raw_param, 1, strlen($raw_param) - 1);
            
            if ($name == 'c') {
                $this->url_params[$name] = TRUE;
                
                // When croping, we must have a width and height to pass to imagecreatetruecolor method
                // Make width the height or vice versa if either is not passed
                if (empty($this->url_params['w'])) {
                    $this->url_params['w'] = $this->url_params['h'];
                }
                if (empty($this->url_params['h'])) {
                    $this->url_params['h'] = $this->url_params['w'];
                }
            } elseif (key_exists($name, $this->url_params)) {
                // Remaining expected params (w, h, q)
                $this->url_params[$name] = $value;
            } else {
                // Watermarks or invalid params
                $this->url_params[$raw_param] = $raw_param;
            }
        }
        
        // Do not scale up images
        if (! $this->config['scale_up']) {
            if ($this->url_params['w'] > $this->image->width()) {
                $this->url_params['w'] = $this->image->width();
            }
            if ($this->url_params['h'] > $this->image->height()) {
                $this->url_params['h'] = $this->image->height();
            }
        }
        
        // Must have at least a width or height
        if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
            throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
                ':uri' => Request::$current->uri()
            ));
        }
        
        // Set the url filepath
        $this->source_file = $filepath;
    }
private function _set_params ( ) { // Get values from request $ params = \ Request :: route ( 'params' ) ; $ filepath = $ this -> config [ 'abs_path' ] . '/' . \ Request :: route ( 'imagepath' ) ; // echo $params; exit; // If enforcing params, ensure it's a match if ( $ this -> config [ 'enforce_presets' ] && ! in_array ( $ params , $ this -> config [ 'presets' ] ) ) { abort ( 404 ) ; } $ image = new Image ( ) ; $ image -> configure ( config ( 'image' ) ) ; if ( function_exists ( 'exif_read_data' ) ) { $ this -> image = $ image -> make ( $ filepath ) -> orientate ( ) ; } else { $ this -> image = $ image -> make ( $ filepath ) ; } // The parameters are separated by hyphens $ raw_params = explode ( '-' , $ params ) ; // Update param values from passed values foreach ( $ raw_params as $ raw_param ) { $ name = $ raw_param [ 0 ] ; $ value = substr ( $ raw_param , 1 , strlen ( $ raw_param ) - 1 ) ; if ( $ name == 'c' ) { $ this -> url_params [ $ name ] = TRUE ; // When croping, we must have a width and height to pass to imagecreatetruecolor method // Make width the height or vice versa if either is not passed if ( empty ( $ this -> url_params [ 'w' ] ) ) { $ this -> url_params [ 'w' ] = $ this -> url_params [ 'h' ] ; } if ( empty ( $ this -> url_params [ 'h' ] ) ) { $ this -> url_params [ 'h' ] = $ this -> url_params [ 'w' ] ; } } elseif ( key_exists ( $ name , $ this -> url_params ) ) { // Remaining expected params (w, h, q) $ this -> url_params [ $ name ] = $ value ; } else { // Watermarks or invalid params $ this -> url_params [ $ raw_param ] = $ raw_param ; } } // Do not scale up images if ( ! $ this -> config [ 'scale_up' ] ) { if ( $ this -> url_params [ 'w' ] > $ this -> image -> width ( ) ) { $ this -> url_params [ 'w' ] = $ this -> image -> width ( ) ; } if ( $ this -> url_params [ 'h' ] > $ this -> image -> height ( ) ) { $ this -> url_params [ 'h' ] = $ this -> image -> height ( ) ; } } // Must have at least a width or height if ( empty ( $ this -> url_params [ 'w' ] ) and empty ( $ this -> url_params [ 'h' ] ) ) { throw new HTTP_Exception_404 ( 'The requested URL :uri was not found on this server.' , array ( ':uri' => Request :: $ current -> uri ( ) ) ) ; } // Set the url filepath $ this -> source_file = $ filepath ; }
Sets the operations params from the url
Sets the operations params from the url