LibMagickMediaHandler.php: update

This commit is contained in:
Zankaria 2025-03-28 12:52:03 +01:00
parent 2c55c4fa23
commit 37fbb35f8b

View file

@ -20,6 +20,7 @@ class LibMagickMediaHandler implements MediaHandler {
private bool $frames_for_gif_thumbs; private bool $frames_for_gif_thumbs;
private int $image_max_width; private int $image_max_width;
private int $image_max_height; private int $image_max_height;
private string $static_thumb_mime;
private static function degreesFromOrientation(int $orientation): int { private static function degreesFromOrientation(int $orientation): int {
@ -86,7 +87,6 @@ class LibMagickMediaHandler implements MediaHandler {
\Imagick $imagick, \Imagick $imagick,
string $source_file_mime, string $source_file_mime,
string $preferred_out_file_basepath, string $preferred_out_file_basepath,
string $preferred_out_mime,
int $width, int $width,
int $height, int $height,
int $max_width, int $max_width,
@ -163,7 +163,7 @@ class LibMagickMediaHandler implements MediaHandler {
$thumb_height = $height; $thumb_height = $height;
} }
$out_ext = Metadata\mime_to_ext($preferred_out_mime); $out_ext = Metadata\mime_to_ext($this->static_thumb_mime);
$out_path = $preferred_out_file_basepath . '.' . $out_ext; $out_path = $preferred_out_file_basepath . '.' . $out_ext;
$imagick->stripImage(); $imagick->stripImage();
@ -172,7 +172,7 @@ class LibMagickMediaHandler implements MediaHandler {
return new ThumbGenerationResult( return new ThumbGenerationResult(
$out_path, $out_path,
$preferred_out_mime, $this->static_thumb_mime,
$thumb_width, $thumb_width,
$thumb_height $thumb_height
); );
@ -194,11 +194,12 @@ class LibMagickMediaHandler implements MediaHandler {
return false; return false;
} }
public function __construct(bool $strip_metadata, int $frames_for_gif_thumbs, int $max_width, int $max_height) { public function __construct(bool $strip_metadata, int $frames_for_gif_thumbs, int $max_width, int $max_height, string $static_thumb_mime) {
$this->strip_metadata = $strip_metadata; $this->strip_metadata = $strip_metadata;
$this->frames_for_gif_thumbs = $frames_for_gif_thumbs; $this->frames_for_gif_thumbs = $frames_for_gif_thumbs;
$this->image_max_width = $max_width; $this->image_max_width = $max_width;
$this->image_max_height = $max_height; $this->image_max_height = $max_height;
$this->static_thumb_mime = $static_thumb_mime;
} }
public function supportsMime(string $mime): bool { public function supportsMime(string $mime): bool {
@ -246,7 +247,6 @@ class LibMagickMediaHandler implements MediaHandler {
public function generateThumb( public function generateThumb(
mixed $handle, mixed $handle,
string $preferred_out_file_basepath, string $preferred_out_file_basepath,
string $preferred_out_mime,
int $max_width, int $max_width,
int $max_height int $max_height
): ThumbGenerationResult { ): ThumbGenerationResult {
@ -270,7 +270,6 @@ class LibMagickMediaHandler implements MediaHandler {
$imagick, $imagick,
$source_file_mime, $source_file_mime,
$preferred_out_file_basepath, $preferred_out_file_basepath,
$preferred_out_mime,
$width, $width,
$height, $height,
$max_width, $max_width,
@ -283,7 +282,6 @@ class LibMagickMediaHandler implements MediaHandler {
mixed $handle, mixed $handle,
string $media_preferred_out_file_basepath, string $media_preferred_out_file_basepath,
string $thumb_preferred_out_file_basepath, string $thumb_preferred_out_file_basepath,
string $thumb_preferred_out_mime,
int $thumb_max_width, int $thumb_max_width,
int $thumb_max_height int $thumb_max_height
): MediaInstallResult { ): MediaInstallResult {
@ -308,7 +306,6 @@ class LibMagickMediaHandler implements MediaHandler {
$imagick, $imagick,
$media_file_mime, $media_file_mime,
$thumb_preferred_out_file_basepath, $thumb_preferred_out_file_basepath,
$thumb_preferred_out_mime,
$width, $width,
$height, $height,
$thumb_max_width, $thumb_max_width,
@ -334,7 +331,6 @@ class LibMagickMediaHandler implements MediaHandler {
$imagick, $imagick,
$media_file_mime, $media_file_mime,
$thumb_preferred_out_file_basepath, $thumb_preferred_out_file_basepath,
$thumb_preferred_out_mime,
$width, $width,
$height, $height,
$thumb_max_width, $thumb_max_width,