forked from leftypol/leftypol
MediaHandler: update
This commit is contained in:
parent
dd788acaf0
commit
573c8e2fb6
4 changed files with 16 additions and 16 deletions
|
@ -2,7 +2,7 @@
|
|||
namespace Vichan\Service\Media;
|
||||
|
||||
use Vichan\Data\ThumbGenerationResult;
|
||||
use Vichan\Functions\{Fs, Mime};
|
||||
use Vichan\Functions\{Fs, Metadata};
|
||||
|
||||
|
||||
class LibMagickMediaHandler implements MediaHandler {
|
||||
|
@ -163,7 +163,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
$thumb_height = $height;
|
||||
}
|
||||
|
||||
$out_ext = Mime\mime_to_ext($preferred_out_mime);
|
||||
$out_ext = Metadata\mime_to_ext($preferred_out_mime);
|
||||
$out_path = $preferred_out_file_dir . \DIRECTORY_SEPARATOR . $preferred_out_file_name . '.' . $out_ext;
|
||||
|
||||
$imagick->stripImage();
|
||||
|
@ -201,7 +201,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
}
|
||||
|
||||
public function supportsMime(string $mime): bool {
|
||||
$ext = Mime\mime_to_ext($mime);
|
||||
$ext = Metadata\mime_to_ext($mime);
|
||||
if ($ext === null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
}
|
||||
|
||||
public function openHandle(string $file_path, string $file_mime, int $file_kind): mixed {
|
||||
$ext = Mime\mime_to_ext($file_mime);
|
||||
$ext = Metadata\mime_to_ext($file_mime);
|
||||
$path = \realpath($file_path);
|
||||
// Open it as the supplied mime type.
|
||||
$imagick = new \Imagick("$ext:$path");
|
||||
|
@ -237,7 +237,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
$height = $imagick->getImageHeight();
|
||||
|
||||
if (!$this->strip_metadata && $width <= $max_width && $height <= $max_height) {
|
||||
$out_path = $preferred_out_file_dir . \DIRECTORY_SEPARATOR . $preferred_out_file_name . '.' . Mime\mime_to_ext($source_file_mime);
|
||||
$out_path = $preferred_out_file_dir . \DIRECTORY_SEPARATOR . $preferred_out_file_name . '.' . Metadata\mime_to_ext($source_file_mime);
|
||||
|
||||
if ($source_file_kind === self::FILE_KIND_UPLOADED) {
|
||||
if (!Fs\move_or_copy_uploaded($source_file_path, $out_path)) {
|
||||
|
@ -294,7 +294,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
$height = $imagick->getImageHeight();
|
||||
|
||||
if (!$this->strip_metadata) {
|
||||
$media_out_path = $media_preferred_out_file_dir . \DIRECTORY_SEPARATOR . $media_preferred_out_file_name . '.' . Mime\mime_to_ext($media_file_mime);
|
||||
$media_out_path = $media_preferred_out_file_dir . \DIRECTORY_SEPARATOR . $media_preferred_out_file_name . '.' . Metadata\mime_to_ext($media_file_mime);
|
||||
|
||||
if ($media_file_kind === self::FILE_KIND_UPLOADED) {
|
||||
if (!Fs\move_or_copy_uploaded($media_file_path, $media_out_path)) {
|
||||
|
@ -307,7 +307,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
}
|
||||
|
||||
if ($width <= $thumb_max_width && $height >= $thumb_max_height) {
|
||||
$thumb_out_path = $thumb_preferred_out_file_dir . \DIRECTORY_SEPARATOR . '.' . Mime\mime_to_ext($media_file_mime);
|
||||
$thumb_out_path = $thumb_preferred_out_file_dir . \DIRECTORY_SEPARATOR . '.' . Metadata\mime_to_ext($media_file_mime);
|
||||
if (!Fs\link_or_copy($media_out_path, $thumb_out_path)) {
|
||||
throw new \RuntimeException("Could not link or copy '$media_out_path' to '$thumb_out_path'");
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
|||
$imagick->profileImage('icc', $profiles['icc']);
|
||||
}
|
||||
|
||||
$out_ext = Mime\mime_to_ext($media_file_mime);
|
||||
$out_ext = Metadata\mime_to_ext($media_file_mime);
|
||||
$out_path = $media_preferred_out_file_dir . \DIRECTORY_SEPARATOR . $media_preferred_out_file_name . '.' . $out_ext;
|
||||
$imagick->writeImage("$out_ext:$out_path");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue