src/Lib/ImageTransform.php
public function makeThumbnail($prefix, array $config)
    {
        $defaultConfig = [
            'jpeg_quality' => 100
        ];
        $config = array_merge($defaultConfig, $config);

        $width = !empty($config['w']) ? $config['w'] : null;
        $height = !empty($config['h']) ? $config['h'] : null;

        $image = $this->ImageManager->make($this->Path->fullPath());

        if (!empty($config['orientate'])) {
            $image = $this->orientate($image);
        }

        if (!empty($config['crop'])) {
            $image = $this->thumbnailCrop($image, $width, $height);
        } elseif (!empty($config['fit'])) {
            $image = $this->thumbnailFit($image, $width, $height);
        } elseif (!empty($config['custom'])) {
            $image = $this->thumbnailCustom($image, $config['custom'], $config['params']);
        } else {
            $image = $this->thumbnailResize($image, $width, $height);
        }

        unset($config['crop'], $config['w'], $config['h'], $config['custom'], $config['params'], $config['orientate']);

        $image->save($this->Path->fullPath($prefix), $config['jpeg_quality']);

        return $this->Path->fullPath($prefix);
    }
public function makeThumbnail($prefix, array $config)
    {
        $defaultConfig = [
            'jpeg_quality' => 100
        ];
        $config = array_merge($defaultConfig, $config);

        $width = !empty($config['w']) ? $config['w'] : null;
        $height = !empty($config['h']) ? $config['h'] : null;

        $image = $this->ImageManager->make($this->Path->fullPath());

        if (!empty($config['orientate'])) {
            $image = $this->orientate($image);
        }

        if (!empty($config['crop'])) {
            $image = $this->thumbnailCrop($image, $width, $height);
        } elseif (!empty($config['fit'])) {
            $image = $this->thumbnailFit($image, $width, $height);
        } elseif (!empty($config['custom'])) {
            $image = $this->thumbnailCustom($image, $config['custom'], $config['params']);
        } else {
            $image = $this->thumbnailResize($image, $width, $height);
        }

        unset($config['crop'], $config['w'], $config['h'], $config['custom'], $config['params'], $config['orientate']);

        $image->save($this->Path->fullPath($prefix), $config['jpeg_quality']);

        return $this->Path->fullPath($prefix);
    }
public function makeThumbnail ( $ prefix , array $ config ) { $ defaultConfig = [ 'jpeg_quality' => 100 ] ; $ config = array_merge ( $ defaultConfig , $ config ) ; $ width = ! empty ( $ config [ 'w' ] ) ? $ config [ 'w' ] : null ; $ height = ! empty ( $ config [ 'h' ] ) ? $ config [ 'h' ] : null ; $ image = $ this -> ImageManager -> make ( $ this -> Path -> fullPath ( ) ) ; if ( ! empty ( $ config [ 'orientate' ] ) ) { $ image = $ this -> orientate ( $ image ) ; } if ( ! empty ( $ config [ 'crop' ] ) ) { $ image = $ this -> thumbnailCrop ( $ image , $ width , $ height ) ; } elseif ( ! empty ( $ config [ 'fit' ] ) ) { $ image = $ this -> thumbnailFit ( $ image , $ width , $ height ) ; } elseif ( ! empty ( $ config [ 'custom' ] ) ) { $ image = $ this -> thumbnailCustom ( $ image , $ config [ 'custom' ] , $ config [ 'params' ] ) ; } else { $ image = $ this -> thumbnailResize ( $ image , $ width , $ height ) ; } unset ( $ config [ 'crop' ] , $ config [ 'w' ] , $ config [ 'h' ] , $ config [ 'custom' ] , $ config [ 'params' ] , $ config [ 'orientate' ] ) ; $ image -> save ( $ this -> Path -> fullPath ( $ prefix ) , $ config [ 'jpeg_quality' ] ) ; return $ this -> Path -> fullPath ( $ prefix ) ; }
Generate and save the thumbnail

@param string $prefix The thumbnail prefix
@param array $config Array of thumbnail config
@return string
Generate and save the thumbnail