mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
Compare commits
4 commits
93406b83a5
...
677320d45d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
677320d45d | ||
|
|
cea5de8b1b | ||
|
|
3fecfe14bd | ||
|
|
f7d9618f56 |
4 changed files with 51 additions and 32 deletions
2
.github/workflows/docker-build.yml
vendored
2
.github/workflows/docker-build.yml
vendored
|
|
@ -43,7 +43,7 @@ jobs:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=tag
|
type=ref,event=tag
|
||||||
latest
|
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,10 @@ final class DeviceModel extends Model
|
||||||
|
|
||||||
public function getColorDepthAttribute(): ?string
|
public function getColorDepthAttribute(): ?string
|
||||||
{
|
{
|
||||||
if (! $this->bit_depth){
|
if (! $this->bit_depth) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->bit_depth . 'bit';
|
return $this->bit_depth.'bit';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ use App\Models\Device;
|
||||||
use App\Models\DeviceModel;
|
use App\Models\DeviceModel;
|
||||||
use App\Models\Plugin;
|
use App\Models\Plugin;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Imagick;
|
use Imagick;
|
||||||
use ImagickException;
|
use ImagickException;
|
||||||
use ImagickPixel;
|
use ImagickPixel;
|
||||||
use Log;
|
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Spatie\Browsershot\Browsershot;
|
use Spatie\Browsershot\Browsershot;
|
||||||
|
|
@ -63,6 +63,15 @@ class ImageGenerationService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate that the PNG file was created and is valid
|
||||||
|
if (! file_exists($pngPath)) {
|
||||||
|
throw new RuntimeException('PNG file was not created: '.$pngPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filesize($pngPath) === 0) {
|
||||||
|
throw new RuntimeException('PNG file is empty: '.$pngPath);
|
||||||
|
}
|
||||||
|
|
||||||
// Convert image based on DeviceModel settings or fallback to device settings
|
// Convert image based on DeviceModel settings or fallback to device settings
|
||||||
self::convertImage($pngPath, $bmpPath, $imageSettings);
|
self::convertImage($pngPath, $bmpPath, $imageSettings);
|
||||||
|
|
||||||
|
|
@ -293,6 +302,7 @@ class ImageGenerationService
|
||||||
*/
|
*/
|
||||||
private static function convertToBmpImageMagick(string $pngPath, string $bmpPath): void
|
private static function convertToBmpImageMagick(string $pngPath, string $bmpPath): void
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$imagick = new Imagick($pngPath);
|
$imagick = new Imagick($pngPath);
|
||||||
$imagick->setImageType(Imagick::IMGTYPE_GRAYSCALE);
|
$imagick->setImageType(Imagick::IMGTYPE_GRAYSCALE);
|
||||||
$imagick->quantizeImage(2, Imagick::COLORSPACE_GRAY, 0, true, false);
|
$imagick->quantizeImage(2, Imagick::COLORSPACE_GRAY, 0, true, false);
|
||||||
|
|
@ -301,6 +311,10 @@ class ImageGenerationService
|
||||||
$imagick->setFormat('BMP3');
|
$imagick->setFormat('BMP3');
|
||||||
$imagick->writeImage($bmpPath);
|
$imagick->writeImage($bmpPath);
|
||||||
$imagick->clear();
|
$imagick->clear();
|
||||||
|
} catch (ImagickException $e) {
|
||||||
|
Log::error('ImageMagick conversion failed for PNG: '.$pngPath.' - '.$e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -308,6 +322,7 @@ class ImageGenerationService
|
||||||
*/
|
*/
|
||||||
private static function convertToPngImageMagick(string $pngPath, ?int $width, ?int $height, ?int $rotate, $quantize = true): void
|
private static function convertToPngImageMagick(string $pngPath, ?int $width, ?int $height, ?int $rotate, $quantize = true): void
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$imagick = new Imagick($pngPath);
|
$imagick = new Imagick($pngPath);
|
||||||
if ($width !== 800 || $height !== 480) {
|
if ($width !== 800 || $height !== 480) {
|
||||||
$imagick->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1, true);
|
$imagick->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1, true);
|
||||||
|
|
@ -328,6 +343,10 @@ class ImageGenerationService
|
||||||
$imagick->setFormat('png');
|
$imagick->setFormat('png');
|
||||||
$imagick->writeImage($pngPath);
|
$imagick->writeImage($pngPath);
|
||||||
$imagick->clear();
|
$imagick->clear();
|
||||||
|
} catch (ImagickException $e) {
|
||||||
|
Log::error('ImageMagick conversion failed for PNG: '.$pngPath.' - '.$e->getMessage());
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function cleanupFolder(): void
|
public static function cleanupFolder(): void
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ it('loads plugins from catalog URL', function () {
|
||||||
'byos' => [
|
'byos' => [
|
||||||
'byos_laravel' => [
|
'byos_laravel' => [
|
||||||
'compatibility' => true,
|
'compatibility' => true,
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
'logo_url' => 'https://example.com/logo.png',
|
'logo_url' => 'https://example.com/logo.png',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue