src/Manipulators/Encode.php
public function run(Image $image)
    {
        $format = $this->getFormat($image);
        $quality = $this->getQuality();

        if (in_array($format, ['jpg', 'pjpg'], true)) {
            $image = $image->getDriver()
                           ->newImage($image->width(), $image->height(), '#fff')
                           ->insert($image, 'top-left', 0, 0);
        }

        if ($format === 'pjpg') {
            $image->interlace();
            $format = 'jpg';
        }

        return $image->encode($format, $quality);
    }
public function run(Image $image)
    {
        $format = $this->getFormat($image);
        $quality = $this->getQuality();

        if (in_array($format, ['jpg', 'pjpg'], true)) {
            $image = $image->getDriver()
                           ->newImage($image->width(), $image->height(), '#fff')
                           ->insert($image, 'top-left', 0, 0);
        }

        if ($format === 'pjpg') {
            $image->interlace();
            $format = 'jpg';
        }

        return $image->encode($format, $quality);
    }
public function run ( Image $ image ) { $ format = $ this -> getFormat ( $ image ) ; $ quality = $ this -> getQuality ( ) ; if ( in_array ( $ format , [ 'jpg' , 'pjpg' ] , true ) ) { $ image = $ image -> getDriver ( ) -> newImage ( $ image -> width ( ) , $ image -> height ( ) , '#fff' ) -> insert ( $ image , 'top-left' , 0 , 0 ) ; } if ( $ format === 'pjpg' ) { $ image -> interlace ( ) ; $ format = 'jpg' ; } return $ image -> encode ( $ format , $ quality ) ; }
Perform output image manipulation.
@param  Image $image The source image.
@return Image The manipulated image.
Perform output image manipulation .