forked from leftypol/leftypol
LibMagickMediaHandler.php: update
This commit is contained in:
parent
4dfdbd0818
commit
2f23213ac5
1 changed files with 13 additions and 20 deletions
|
@ -87,8 +87,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
private function generateThumbImpl(
|
private function generateThumbImpl(
|
||||||
\Imagick $imagick,
|
\Imagick $imagick,
|
||||||
string $source_file_mime,
|
string $source_file_mime,
|
||||||
string $preferred_out_file_dir,
|
string $preferred_out_file_basepath,
|
||||||
string $preferred_out_file_name,
|
|
||||||
string $preferred_out_mime,
|
string $preferred_out_mime,
|
||||||
int $width,
|
int $width,
|
||||||
int $height,
|
int $height,
|
||||||
|
@ -101,7 +100,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
&& $this->frames_for_gif_thumbs !== self::THUMB_KEEP_FRAMES_NO
|
&& $this->frames_for_gif_thumbs !== self::THUMB_KEEP_FRAMES_NO
|
||||||
&& $imagick->getNumberImages() > 1
|
&& $imagick->getNumberImages() > 1
|
||||||
) {
|
) {
|
||||||
$out_path = $preferred_out_file_dir . \DIRECTORY_SEPARATOR . $preferred_out_file_name . '.gif';
|
$out_path = $preferred_out_file_basepath . '.gif';
|
||||||
|
|
||||||
if ($width > $max_width || $height > $max_height) {
|
if ($width > $max_width || $height > $max_height) {
|
||||||
$thumb_width = $max_width;
|
$thumb_width = $max_width;
|
||||||
|
@ -167,7 +166,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
$out_ext = Metadata\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;
|
$out_path = $preferred_out_file_basepath . '.' . $out_ext;
|
||||||
|
|
||||||
$imagick->stripImage();
|
$imagick->stripImage();
|
||||||
$imagick->setImageCompressionQuality(70);
|
$imagick->setImageCompressionQuality(70);
|
||||||
|
@ -237,8 +236,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
|
|
||||||
public function generateThumb(
|
public function generateThumb(
|
||||||
mixed $handle,
|
mixed $handle,
|
||||||
string $preferred_out_file_dir,
|
string $preferred_out_file_basepath,
|
||||||
string $preferred_out_file_name,
|
|
||||||
string $preferred_out_mime,
|
string $preferred_out_mime,
|
||||||
int $max_width,
|
int $max_width,
|
||||||
int $max_height
|
int $max_height
|
||||||
|
@ -249,7 +247,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
$height = $imagick->getImageHeight();
|
$height = $imagick->getImageHeight();
|
||||||
|
|
||||||
if (!$this->strip_metadata && $width <= $max_width && $height <= $max_height) {
|
if (!$this->strip_metadata && $width <= $max_width && $height <= $max_height) {
|
||||||
$out_path = $preferred_out_file_dir . \DIRECTORY_SEPARATOR . $preferred_out_file_name . '.' . Metadata\mime_to_ext($source_file_mime);
|
$out_path = $preferred_out_file_basepath . '.' . Metadata\mime_to_ext($source_file_mime);
|
||||||
|
|
||||||
$this->move_or_link_or_copy($source_file_kind, $source_file_path, $out_path);
|
$this->move_or_link_or_copy($source_file_kind, $source_file_path, $out_path);
|
||||||
|
|
||||||
|
@ -270,8 +268,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
return self::generateThumbImpl(
|
return self::generateThumbImpl(
|
||||||
$imagick,
|
$imagick,
|
||||||
$source_file_mime,
|
$source_file_mime,
|
||||||
$preferred_out_file_dir,
|
$preferred_out_file_basepath,
|
||||||
$preferred_out_file_name,
|
|
||||||
$preferred_out_mime,
|
$preferred_out_mime,
|
||||||
$width,
|
$width,
|
||||||
$height,
|
$height,
|
||||||
|
@ -283,10 +280,8 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
|
|
||||||
public function installMediaAndGenerateThumb(
|
public function installMediaAndGenerateThumb(
|
||||||
mixed $handle,
|
mixed $handle,
|
||||||
string $media_preferred_out_file_dir,
|
string $media_preferred_out_file_basepath,
|
||||||
string $media_preferred_out_file_name,
|
string $thumb_preferred_out_file_basepath,
|
||||||
string $thumb_preferred_out_file_dir,
|
|
||||||
string $thumb_preferred_out_file_name,
|
|
||||||
string $thumb_preferred_out_mime,
|
string $thumb_preferred_out_mime,
|
||||||
int $thumb_max_width,
|
int $thumb_max_width,
|
||||||
int $thumb_max_height
|
int $thumb_max_height
|
||||||
|
@ -297,12 +292,12 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
$height = $imagick->getImageHeight();
|
$height = $imagick->getImageHeight();
|
||||||
|
|
||||||
if (!$this->strip_metadata) {
|
if (!$this->strip_metadata) {
|
||||||
$media_out_path = $media_preferred_out_file_dir . \DIRECTORY_SEPARATOR . $media_preferred_out_file_name . '.' . Metadata\mime_to_ext($media_file_mime);
|
$media_out_path = $media_preferred_out_file_basepath . '.' . Metadata\mime_to_ext($media_file_mime);
|
||||||
|
|
||||||
$this->move_or_link_or_copy($media_file_kind, $media_file_path, $media_out_path);
|
$this->move_or_link_or_copy($media_file_kind, $media_file_path, $media_out_path);
|
||||||
|
|
||||||
if ($width <= $thumb_max_width && $height >= $thumb_max_height) {
|
if ($width <= $thumb_max_width && $height >= $thumb_max_height) {
|
||||||
$thumb_out_path = $thumb_preferred_out_file_dir . \DIRECTORY_SEPARATOR . '.' . Metadata\mime_to_ext($media_file_mime);
|
$thumb_out_path = $thumb_preferred_out_file_basepath . '.' . Metadata\mime_to_ext($media_file_mime);
|
||||||
if (!Fs\link_or_copy($media_out_path, $thumb_out_path)) {
|
if (!Fs\link_or_copy($media_out_path, $thumb_out_path)) {
|
||||||
throw new MediaException("Could not link or copy '$media_out_path' to '$thumb_out_path'", MediaException::ERR_IO_ERR);
|
throw new MediaException("Could not link or copy '$media_out_path' to '$thumb_out_path'", MediaException::ERR_IO_ERR);
|
||||||
}
|
}
|
||||||
|
@ -319,8 +314,7 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
$thumb = self::generateThumbImpl(
|
$thumb = self::generateThumbImpl(
|
||||||
$imagick,
|
$imagick,
|
||||||
$media_file_mime,
|
$media_file_mime,
|
||||||
$thumb_preferred_out_file_dir,
|
$thumb_preferred_out_file_basepath,
|
||||||
$thumb_preferred_out_file_name,
|
|
||||||
$thumb_preferred_out_mime,
|
$thumb_preferred_out_mime,
|
||||||
$width,
|
$width,
|
||||||
$height,
|
$height,
|
||||||
|
@ -345,14 +339,13 @@ class LibMagickMediaHandler implements MediaHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
$out_ext = Metadata\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;
|
$out_path = $media_preferred_out_file_basepath . '.' . $out_ext;
|
||||||
$imagick->writeImage("$out_ext:$out_path");
|
$imagick->writeImage("$out_ext:$out_path");
|
||||||
|
|
||||||
$thumb = self::generateThumbImpl(
|
$thumb = self::generateThumbImpl(
|
||||||
$imagick,
|
$imagick,
|
||||||
$media_file_mime,
|
$media_file_mime,
|
||||||
$thumb_preferred_out_file_dir,
|
$thumb_preferred_out_file_basepath,
|
||||||
$thumb_preferred_out_file_name,
|
|
||||||
$thumb_preferred_out_mime,
|
$thumb_preferred_out_mime,
|
||||||
$width,
|
$width,
|
||||||
$height,
|
$height,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue