| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | 
							- <?php
 
- namespace file;
 
- use think\Image;
 
- class ImgHelper
 
- {
 
-     
 
-     public static function isImage($filepath)
 
-     {
 
-         
 
-         if (function_exists('exif_imagetype') && file_exists($filepath)) {
 
-             $mimetype = @exif_imagetype($filepath);
 
-             if ($mimetype == IMAGETYPE_GIF || $mimetype == IMAGETYPE_JPEG || $mimetype == IMAGETYPE_PNG || $mimetype == IMAGETYPE_BMP) {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         
 
-         $ext = strtolower(PathHelper::getExt($filepath));
 
-         if (in_array($ext, ['gif', 'jpg', 'jpeg', 'png', 'bmp'])) {
 
-             return true;
 
-         }
 
-         return false;
 
-     }
 
-     
 
-     function thumb($filePath, $width, $height, $savePath = '', $type = 2)
 
-     {
 
-         if (!$savePath) {
 
-             $savePath = $filePath;
 
-         }
 
-         $image = Image::open($filePath);
 
-         return $image->thumb($width, $height, $type)->save($savePath);
 
-     }
 
- }
 
 
  |