diff --git a/app/Helpers/Lpj.php b/app/Helpers/Lpj.php index 4cd0887..6448738 100644 --- a/app/Helpers/Lpj.php +++ b/app/Helpers/Lpj.php @@ -20,6 +20,7 @@ use Modules\Usermanagement\Models\User; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Storage; + use Modules\Lpj\Services\ImageResizeService; /** * Format tanggal ke dalam format Bahasa Indonesia @@ -775,3 +776,20 @@ Log::error('Tidak dapat memparsing timestamp dengan format apapun: "' . $timestamp . '"'); return null; } + + if (!function_exists('resize_image')) { + /** + * Merubah ukuran gambar secara on-the-fly dan mengembalikan path-nya. + * + * @param string $path Path asli gambar. + * @param int|null $width Lebar yang diinginkan. + * @param int|null $height Tinggi yang diinginkan (opsional, akan menjaga rasio aspek jika null). + * @param int $quality Kualitas gambar (1-100). + * @return string Path gambar yang sudah di-resize. + */ + function resize_image(string $path, ?int $width, ?int $height = null, int $quality = 80): string + { + + return app(ImageResizeService::class)->resize($path, $width, $height, $quality); + } + }