diff --git a/inc/Service/Media/GdThumbGenerator.php b/inc/Service/Media/GdThumbGenerator.php index 1c5f446a..7132b867 100644 --- a/inc/Service/Media/GdThumbGenerator.php +++ b/inc/Service/Media/GdThumbGenerator.php @@ -2,11 +2,11 @@ namespace Vichan\Service\Media; use Vichan\Data\ThumbGenerationResult; +use Vichan\Functions\Fs; -use function Vichan\Functions\Fs\link_or_copy; class GdThumbGenerator implements ThumbGenerator { - private const PHP81 = PHP_MAJOR_VERSION >= 8 && PHP_MINOR_VERSION >= 1; + private const PHP81 = \PHP_MAJOR_VERSION >= 8 && \PHP_MINOR_VERSION >= 1; private const MIME_TO_EXT = [ 'image/jpeg' => 'jpg', @@ -21,17 +21,17 @@ class GdThumbGenerator implements ThumbGenerator { private static function imageCreateFrom(string $file, string $mime): mixed { switch ($mime) { case 'image/jpeg': - return imagecreatefromjpeg($file); + return \imagecreatefromjpeg($file); case 'image/png': - return imagecreatefrompng($file); + return \imagecreatefrompng($file); case 'image/gif': - return imagecreatefromgif($file); + return \imagecreatefromgif($file); case 'image/webp': - return imagecreatefromwbmp($file); + return \imagecreatefromwbmp($file); case 'image/bmp': - return imagecreatefrombmp($file); + return \imagecreatefrombmp($file); case 'image/avif': - return self::PHP81 ? imagecreatefromavif($file) : false; + return self::PHP81 ? \imagecreatefromavif($file) : false; } return false; } @@ -40,17 +40,17 @@ class GdThumbGenerator implements ThumbGenerator { // Somebody should tune the quality and speed values... switch ($mime) { case 'image/jpeg': - return imagejpeg($gd, $file, 50); + return \imagejpeg($gd, $file, 50); case 'image/png': - return imagepng($gd, $file, 7); + return \imagepng($gd, $file, 7); case 'image/gif': - return imagegif($gd, $file); + return \imagegif($gd, $file); case 'image/webp': - return imagewbmp($gd, $file, 50); + return \imagewbmp($gd, $file, 50); case 'image/bmp': - return imagebmp($gd, $file, true); + return \imagebmp($gd, $file, true); case 'image/avif': - return self::PHP81 ? imageavif($gd, $file, 30, 6) : false; + return self::PHP81 ? \imageavif($gd, $file, 30, 6) : false; } return false; } @@ -59,9 +59,9 @@ class GdThumbGenerator implements ThumbGenerator { $gd = \imagecreatetruecolor($width, $height); switch ($mime) { case 'image/png': - imagecolortransparent($gd, imagecolorallocatealpha($gd, 0, 0, 0, 0)); - imagesavealpha($gd, true); - imagealphablending($gd, false); + \imagecolortransparent($gd, \imagecolorallocatealpha($gd, 0, 0, 0, 0)); + \imagesavealpha($gd, true); + \imagealphablending($gd, false); break; case 'image/gif': \imagecolortransparent($gd, \imagecolorallocatealpha($gd, 0, 0, 0, 0)); @@ -100,7 +100,7 @@ class GdThumbGenerator implements ThumbGenerator { if ($width <= $max_width && $height <= $max_height) { $out_path = $preferred_out_file_path . '.' . self::MIME_TO_EXT[$source_file_mime]; - if (!link_or_copy($source_file_path, $out_path)) { + if (!Fs\link_or_copy($source_file_path, $out_path)) { throw new \RuntimeException("Could not link or copy '$source_file_path' to '$out_path'"); }