From 2c55c4fa23f9b51c0a5fe2019a11edb16e697588 Mon Sep 17 00:00:00 2001 From: Zankaria Date: Fri, 28 Mar 2025 12:48:01 +0100 Subject: [PATCH] GdMediaHandler.php: update --- inc/Service/Media/GdMediaHandler.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/inc/Service/Media/GdMediaHandler.php b/inc/Service/Media/GdMediaHandler.php index 64c5785b..60bb1099 100644 --- a/inc/Service/Media/GdMediaHandler.php +++ b/inc/Service/Media/GdMediaHandler.php @@ -19,6 +19,7 @@ class GdMediaHandler implements MediaHandler { private array $exif_readers; private int $image_max_width; private int $image_max_height; + private string $thumb_mime; private static function imageCreateFrom(string $file, string $mime): mixed { @@ -93,7 +94,6 @@ class GdMediaHandler implements MediaHandler { string $source_file_mime, string $source_file_kind, string $preferred_out_file_basepath, - string $preferred_out_mime, int $max_width, int $max_height ) { @@ -112,12 +112,12 @@ class GdMediaHandler implements MediaHandler { $height ); } else { - $out_path = $preferred_out_file_basepath . '.' . Metadata\mime_to_ext($preferred_out_mime); + $out_path = $preferred_out_file_basepath . '.' . Metadata\mime_to_ext($this->thumb_mime); - $gd_other = self::createCanvas($preferred_out_mime, $max_width, $max_height); + $gd_other = self::createCanvas($this->thumb_mime, $max_width, $max_height); \imagecopyresampled($gd_other, $gd, 0, 0, 0, 0, $max_width, $max_height, $width, $height); - if (!self::imageSaveTo($gd_other, $out_path, $preferred_out_mime)) { + if (!self::imageSaveTo($gd_other, $out_path, $this->thumb_mime)) { \imagedestroy($gd_other); throw new MediaException("Could not create thumbnail file at '$out_path'", MediaException::ERR_IO_ERR); } @@ -126,7 +126,7 @@ class GdMediaHandler implements MediaHandler { return new ThumbGenerationResult( $out_path, - $preferred_out_mime, + $this->thumb_mime, $max_width, $max_height ); @@ -138,11 +138,12 @@ class GdMediaHandler implements MediaHandler { * May cause the loss of color profiles. Orientation is still handled in JPG and PNG. * @param array $exif_readers A map of mime types to {@link Vichan\Data\Driver\Metadata\ExifReader} instances. */ - public function __construct(bool $strip_redraw, array $exif_readers, int $max_width, int $max_height) { + public function __construct(bool $strip_redraw, array $exif_readers, int $max_width, int $max_height, string $thumb_mime) { $this->strip_redraw = $strip_redraw; $this->exif_readers = $exif_readers; $this->image_max_width = $max_width; $this->image_max_height = $max_height; + $this->thumb_mime = $thumb_mime; } public function supportsMime(string $mime): bool { @@ -228,7 +229,6 @@ class GdMediaHandler implements MediaHandler { mixed $handle, string $media_preferred_out_file_basepath, string $thumb_preferred_out_file_basepath, - string $thumb_preferred_out_mime, int $thumb_max_width, int $thumb_max_height ): MediaInstallResult { @@ -249,7 +249,6 @@ class GdMediaHandler implements MediaHandler { $source_file_mime, $source_file_kind, $thumb_preferred_out_file_basepath, - $thumb_preferred_out_mime, $thumb_max_width, $thumb_max_height ); @@ -259,7 +258,6 @@ class GdMediaHandler implements MediaHandler { public function generateThumb( mixed $handle, string $preferred_out_file_basepath, - string $preferred_out_mime, int $max_width, int $max_height ): ThumbGenerationResult { @@ -271,7 +269,6 @@ class GdMediaHandler implements MediaHandler { $source_file_mime, $source_file_kind, $preferred_out_file_basepath, - $preferred_out_mime, $max_width, $max_height );