protected function createImage(string $disk, $source, $destination, $width = 0, $height = 0, $fit = false): bool
    {
        if ($width == 0) {
            $width = null;
        }

        if ($height == 0) {
            $height = null;
        }

        if ($this->isLocalOrPublic($disk)) {
            $source = config('filesystems.disks.' . $disk . '.root') . DIRECTORY_SEPARATOR . $source;
            $destination = config('filesystems.disks.' . $disk . '.root') . DIRECTORY_SEPARATOR . $destination;
        } else {
            $source = Storage::disk($disk)->url($source);
        }

        /** @var \Intervention\Image\Image $image */
        $image = Image::make($source);

        if ($fit) {
            $image->fit($width, $height, function (Constraint $constraint) {
                $constraint->upsize();
            });
        } else {
            $image->resize($width, $height, function (Constraint $constraint) {
                $constraint->upsize();
                $constraint->aspectRatio();
            });
        }

        if ($this->isLocalOrPublic($disk)) {
            $image->save($destination);
            $image->destroy();
        } else {
            Storage::disk($disk)->put($destination, (string)$image->encode());
        }

        return true;
    }
protected function createImage(string $disk, $source, $destination, $width = 0, $height = 0, $fit = false): bool
    {
        if ($width == 0) {
            $width = null;
        }

        if ($height == 0) {
            $height = null;
        }

        if ($this->isLocalOrPublic($disk)) {
            $source = config('filesystems.disks.' . $disk . '.root') . DIRECTORY_SEPARATOR . $source;
            $destination = config('filesystems.disks.' . $disk . '.root') . DIRECTORY_SEPARATOR . $destination;
        } else {
            $source = Storage::disk($disk)->url($source);
        }

        /** @var \Intervention\Image\Image $image */
        $image = Image::make($source);

        if ($fit) {
            $image->fit($width, $height, function (Constraint $constraint) {
                $constraint->upsize();
            });
        } else {
            $image->resize($width, $height, function (Constraint $constraint) {
                $constraint->upsize();
                $constraint->aspectRatio();
            });
        }

        if ($this->isLocalOrPublic($disk)) {
            $image->save($destination);
            $image->destroy();
        } else {
            Storage::disk($disk)->put($destination, (string)$image->encode());
        }

        return true;
    }
protected function createImage ( string $ disk , $ source , $ destination , $ width = 0 , $ height = 0 , $ fit = false ) : bool { if ( $ width == 0 ) { $ width = null ; } if ( $ height == 0 ) { $ height = null ; } if ( $ this -> isLocalOrPublic ( $ disk ) ) { $ source = config ( 'filesystems.disks.' . $ disk . '.root' ) . DIRECTORY_SEPARATOR . $ source ; $ destination = config ( 'filesystems.disks.' . $ disk . '.root' ) . DIRECTORY_SEPARATOR . $ destination ; } else { $ source = Storage :: disk ( $ disk ) -> url ( $ source ) ; } /** @var \Intervention\Image\Image $image */ $ image = Image :: make ( $ source ) ; if ( $ fit ) { $ image -> fit ( $ width , $ height , function ( Constraint $ constraint ) { $ constraint -> upsize ( ) ; } ) ; } else { $ image -> resize ( $ width , $ height , function ( Constraint $ constraint ) { $ constraint -> upsize ( ) ; $ constraint -> aspectRatio ( ) ; } ) ; } if ( $ this -> isLocalOrPublic ( $ disk ) ) { $ image -> save ( $ destination ) ; $ image -> destroy ( ) ; } else { Storage :: disk ( $ disk ) -> put ( $ destination , ( string ) $ image -> encode ( ) ) ; } return true ; }
Creating image based on provided data

@param string $disk
@param $source
@param $destination
@param int $width
@param int $height
@param bool $fit
@return bool
Creating image based on provided data