serverfireteam / panel

An easily configurable admin panel for Laravel applications.
MIT License
427 stars 144 forks source link

Resize issue #320

Open Fragger5000 opened 7 years ago

Fragger5000 commented 7 years ago

According to this article http://image.intervention.io/api/resize , the proportional resize of an image is very simple

// resize the image to a width of 300 and constrain aspect ratio (auto height) , moreover I prevent possible upsizing $img->resize(300, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); });

so I tried to do the same in LaravelPanel

$this->edit->add('immagine', 'Immagine', 'image')->rule('mimes:jpg,jpeg')->move('art_img/')->resize(240, null, function ($constraint) { $constraint->aspectRatio(); $constraint->upsize(); });

Unfortunately I get this error:

[2017-01-20 12:15:49] local.ERROR: exception 'ErrorException' with message 'pathinfo() expects parameter 1 to be string, object given' in C:\xampp\htdocs\my_project\vendor\intervention\image\src\Intervention\Image\Image.php:139

Am I doing something wrong?

In this moment I'm using a temporary (yet barbaric) workaround:

$y = round(240/1.33, 0, PHP_ROUND_HALF_DOWN); $this->edit->add('immagine', 'Immagine', 'image')->rule('mimes:jpg,jpeg')->move('art_img/')->resize(240,$y);

Clearly I prefer to use the full potential of Intervention image.