scale image - get image type
authorAlan <alan@roojs.com>
Thu, 14 Apr 2022 05:21:20 +0000 (13:21 +0800)
committerAlan <alan@roojs.com>
Thu, 14 Apr 2022 05:21:20 +0000 (13:21 +0800)
File/Convert/Solution/scaleimage.php

index f171b8e..37c42b5 100644 (file)
@@ -192,7 +192,18 @@ class File_Convert_Solution_scaleimage extends File_Convert_Solution
             $white = imagecolorallocate ( $thumb , 255, 255, 255);
 
             imagefill($thumb, 0,0,  $white);
-            $source = imagecreatefromjpeg($fn);
+            
+            switch(exif_imagetype($fn)) {
+                case IMAGETYPE_PNG:
+                    $source = imagecreatefrompng($fn);
+                    break;
+                case IMAGETYPE_JPEG:
+                    $source = imagecreatefromjpeg($fn);
+                    break;
+                default:
+                    die("invalid image type");
+                    
+            }
             // Resize
             //resource $dst_image , resource $src_image , 
                 // int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h