Skip to content

Commit 8516214

Browse files
committed
Refactor image handling to use Laravel facade and update composer dependencies
1 parent 45090ba commit 8516214

File tree

4 files changed

+53
-7
lines changed

4 files changed

+53
-7
lines changed

app/Models/DokumentasiKegiatan.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Support\Facades\Auth;
77
use Illuminate\Support\Facades\Storage;
8-
use Intervention\Image\Facades\Image;
8+
use Intervention\Image\Laravel\Facades\Image;
99

1010
class DokumentasiKegiatan extends Model
1111
{
@@ -28,8 +28,8 @@ protected static function booted(): void
2828
if ($dokumentasi->isDirty('file') && ! empty($dokumentasi->file) && ! $dokumentasi->uncompress) {
2929
$files = array_diff($dokumentasi->file, $dokumentasi->getOriginal('file') ?? []);
3030
foreach ($files as $file) {
31-
$image = Image::make(Storage::disk('dokumentasi')->path($file))
32-
->encode('webp', 50);
31+
$image = Image::read(Storage::disk('dokumentasi')->path($file))
32+
->toWebp(50);
3333
Storage::disk('dokumentasi')->put($file, (string) $image);
3434
}
3535
}

app/Models/IzinKeluar.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Illuminate\Database\Eloquent\Relations\BelongsTo;
77
use Illuminate\Support\Facades\Auth;
88
use Illuminate\Support\Facades\Storage;
9-
use Intervention\Image\Facades\Image;
9+
use Intervention\Image\Laravel\Facades\Image;
1010

1111
class IzinKeluar extends Model
1212
{
@@ -35,8 +35,8 @@ protected static function booted(): void
3535
if ($izin->isDirty('bukti') && $izin->bukti) {
3636
$files = array_diff($izin->bukti, $izin->getOriginal('bukti') ?? []);
3737
foreach ($files as $file) {
38-
$image = Image::make(Storage::disk('izin_keluar')->path($file))
39-
->encode('webp', 50);
38+
$image = Image::read(Storage::disk('izin_keluar')->path($file))
39+
->toWebp(50);
4040
Storage::disk('izin_keluar')->put($file, (string) $image);
4141
}
4242
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": "^8.2",
15-
"intervention/image": "^2.0",
15+
"intervention/image-laravel": "*",
1616
"laravel/framework": "^11.9",
1717
"laravel/nova": "^5.0",
1818
"laravel/tinker": "^2.9",

config/image.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Image Driver
8+
|--------------------------------------------------------------------------
9+
|
10+
| Intervention Image supports “GD Library” and “Imagick” to process images
11+
| internally. Depending on your PHP setup, you can choose one of them.
12+
|
13+
| Included options:
14+
| - \Intervention\Image\Drivers\Gd\Driver::class
15+
| - \Intervention\Image\Drivers\Imagick\Driver::class
16+
|
17+
*/
18+
19+
'driver' => \Intervention\Image\Drivers\Imagick\Driver::class,
20+
21+
/*
22+
|--------------------------------------------------------------------------
23+
| Configuration Options
24+
|--------------------------------------------------------------------------
25+
|
26+
| These options control the behavior of Intervention Image.
27+
|
28+
| - "autoOrientation" controls whether an imported image should be
29+
| automatically rotated according to any existing Exif data.
30+
|
31+
| - "decodeAnimation" decides whether a possibly animated image is
32+
| decoded as such or whether the animation is discarded.
33+
|
34+
| - "blendingColor" Defines the default blending color.
35+
|
36+
| - "strip" controls if meta data like exif tags should be removed when
37+
| encoding images.
38+
*/
39+
40+
'options' => [
41+
'autoOrientation' => true,
42+
'decodeAnimation' => true,
43+
'blendingColor' => 'ffffff',
44+
'strip' => false,
45+
]
46+
];

0 commit comments

Comments
 (0)