moonsflyer před 4 měsíci
rodič
revize
981fa2aac4
1 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. 7 5
      app/common/service/ImageCompressService.php

+ 7 - 5
app/common/service/ImageCompressService.php

@@ -38,16 +38,17 @@ class ImageCompressService
             $newSize = self::calculateNewSize($width, $height, $maxWidth, $maxHeight);
             $newWidth = $newSize['width'];
             $newHeight = $newSize['height'];
-
+            outFileLog($newWidth,'upload_img','$newWidth');
+            outFileLog($newHeight,'upload_img','$newHeight');
             // 创建源图片资源
             $sourceImage = self::createImageFromType($sourcePath, $type);
             if (!$sourceImage) {
                 throw new Exception('不支持的图片格式');
             }
-
+            outFileLog($sourceImage,'upload_img','$sourceImage');
             // 创建新图片资源
             $newImage = imagecreatetruecolor($newWidth, $newHeight);
-            
+            outFileLog($newImage,'upload_img','$newImage');
             // 处理透明背景(PNG/GIF)
             if ($type == IMAGETYPE_PNG || $type == IMAGETYPE_GIF) {
                 imagealphablending($newImage, false);
@@ -61,10 +62,11 @@ class ImageCompressService
 
             // 生成压缩后的文件路径
             $compressedPath = self::generateCompressedPath($sourcePath);
-
+            outFileLog($compressedPath,'upload_img','$compressedPath');
             // 保存压缩后的图片
             $result = self::saveImageByType($newImage, $compressedPath, $type, $quality);
-
+            utFileLog($result,'upload_img','$result');
+//            $imageInfo = getimagesize($result);
             // 释放内存
             imagedestroy($sourceImage);
             imagedestroy($newImage);