UniSharp / laravel-filemanager

Media gallery with CKEditor, TinyMCE and Summernote support. Built on Laravel file system.
https://unisharp.github.io/laravel-filemanager/
MIT License
2.08k stars 720 forks source link

Image Cropping throws an error : "Width and height of cutout needs to be defined" #963

Open galih56 opened 4 years ago

galih56 commented 4 years ago

I want to crop an image inside the file manager folder. But somehow the file manager threw this error message. I don't know what is happening

use Intervention\Image\Point;
use Intervention\Image\Size;

class CropCommand extends ResizeCommand
{
    /**
     * Crop an image instance
     *
     * @param  \Intervention\Image\Image $image
     * @return boolean
     */
    public function execute($image)
    {
        $width = $this->argument(0)->type('digit')->required()->value();
        $height = $this->argument(1)->type('digit')->required()->value();
        $x = $this->argument(2)->type('digit')->value();
        $y = $this->argument(3)->type('digit')->value();

        if (is_null($width) || is_null($height)) {
            throw new \Intervention\Image\Exception\InvalidArgumentException(
                "Width and height of cutout needs to be defined." //given error
            );
        }

There is only resolution options. I can't find something like crop button that allow me to control the size. image

I don't know if it's related to event listener that i make. But Here's my event listener code. EventServiceProvider.php

protected $listen = [
        'App\Events\Auth\UserActivationEmail' => [
            'App\Listeners\Auth\SendActivationEmail',
        ],
        ImageWasUploaded::class => [
           OptimizeImageLFM::class ,
        ],
        ImageIsDeleting::class=>[
            DeleteImageLFM::class
        ],
        ImageWasResized::class=>[
            UpdateImageLFM::class
        ]
        // Registered::class => [
        //     SendEmailVerificationNotification::class,
        // ],
    ];
<?php

namespace App\Listeners;

use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\LFMImage;
use Log;
use Image;
class UpdateImageLFM
{
    public function __construct() {  }

    public function handle($event)
    {
        $event_path=$event->path();

        Log::info($event_path);
        $img=Image::make($event_path);
        $event_path=explode(public_path(''),$event_path);
        $event_path=str_replace('\\','/',$event_path[1]);
        $event_path=str_replace('/image','image',$event_path);
        $image=LFMImage::where('path','like',"%$event_path")->first();

        $file_name=$img->basename;
        $file_size=LFMImage::convert_bytes_to_specified($img->filesize(),'K',2);
        $width=$img->width();
        $height=$img->height();

        $data= [ 
            'file_name'=>$file_name,
            'file_size'=>$file_size,
            'width'=>$width,
            'height'=>$height,
            'path'=>$event_path,
        ]; 
        ;
        $image->file_name=$file_name;
        $image->file_size=$file_size;
        $image->width=$width;
        $image->height=$height;
        $image->path=$event_path;
        $image->save()
    }
}
mduzoylum commented 2 years ago

I ve same issue. Did you find any solution ? @galih56