Implement creator studio and upload updates
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Upload;
|
||||
|
||||
use App\Services\Images\SquareThumbnailService;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Intervention\Image\ImageManager;
|
||||
use RuntimeException;
|
||||
@@ -12,7 +13,7 @@ final class PreviewService
|
||||
{
|
||||
private ?ImageManager $manager = null;
|
||||
|
||||
public function __construct()
|
||||
public function __construct(private readonly SquareThumbnailService $squareThumbnails)
|
||||
{
|
||||
try {
|
||||
$this->manager = extension_loaded('gd') ? ImageManager::gd() : ImageManager::imagick();
|
||||
@@ -37,13 +38,15 @@ final class PreviewService
|
||||
$thumbPath = "tmp/drafts/{$uploadId}/thumb.webp";
|
||||
|
||||
$preview = $this->manager->read($absolute)->scaleDown(1280, 1280);
|
||||
$thumb = $this->manager->read($absolute)->cover(320, 320);
|
||||
|
||||
$previewEncoded = (string) $preview->encode(new \Intervention\Image\Encoders\WebpEncoder(85));
|
||||
$thumbEncoded = (string) $thumb->encode(new \Intervention\Image\Encoders\WebpEncoder(82));
|
||||
|
||||
$disk->put($previewPath, $previewEncoded);
|
||||
$disk->put($thumbPath, $thumbEncoded);
|
||||
$this->squareThumbnails->generateFromPath($absolute, $disk->path($thumbPath), [
|
||||
'target_size' => (int) config('uploads.square_thumbnails.preview_size', 320),
|
||||
'quality' => (int) config('uploads.square_thumbnails.quality', 82),
|
||||
'allow_upscale' => false,
|
||||
]);
|
||||
|
||||
return [
|
||||
'preview_path' => $previewPath,
|
||||
|
||||
Reference in New Issue
Block a user