Conditions | 3 |
Paths | 2 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public function execute(string $uuid, ?int $dim) |
||
12 | { |
||
13 | $pathPicture = storage_path('app/public/characteristics/'.$uuid.'.png'); |
||
14 | |||
15 | $img = Image::make($pathPicture); |
||
16 | $h = $img->height(); |
||
17 | $w = $img->width(); |
||
18 | |||
19 | if($dim == null){ |
||
|
|||
20 | return $img->response(); |
||
21 | } |
||
22 | |||
23 | $img = Image::cache(function($image) use($pathPicture, $dim, $w, $h){ |
||
24 | if($w <= $h) { |
||
25 | $image->make($pathPicture)->widen($dim, function ($constraint) { |
||
26 | $constraint->upsize(); |
||
27 | }); |
||
28 | }else{ |
||
29 | $image->make($pathPicture)->heighten($dim, function ($constraint) { |
||
30 | $constraint->upsize(); |
||
31 | }); |
||
32 | } |
||
33 | }, 86400, true); |
||
34 | return $img->response(); |
||
35 | } |
||
38 |