正在显示
1 个修改的文件
包含
7 行增加
和
8 行删除
| @@ -325,15 +325,14 @@ class CosService | @@ -325,15 +325,14 @@ class CosService | ||
| 325 | $cos = config('filesystems.disks.cos'); | 325 | $cos = config('filesystems.disks.cos'); |
| 326 | $url = 'https://' . $cos['bucket'] . '.cos.' . $cos['region'] . '.myqcloud.com/' . ltrim($pathUrl, '/') . '?image/info'; | 326 | $url = 'https://' . $cos['bucket'] . '.cos.' . $cos['region'] . '.myqcloud.com/' . ltrim($pathUrl, '/') . '?image/info'; |
| 327 | try { | 327 | try { |
| 328 | - $xml = @file_get_contents($url); | ||
| 329 | - if (!$xml) { | ||
| 330 | - return ''; | 328 | + $imageInfo = @getimagesize($url); |
| 329 | + if ($imageInfo) { | ||
| 330 | + $width = $imageInfo[0]; | ||
| 331 | + $height = $imageInfo[1]; | ||
| 332 | + return "图片尺寸:宽度 {$width}px,高度 {$height}px"; | ||
| 333 | + } else { | ||
| 334 | + return "错误:无法读取图片或链接无效"; | ||
| 331 | } | 335 | } |
| 332 | - $info = simplexml_load_string($xml); | ||
| 333 | - if ($info === false || !isset($info->ImageHeight)) { | ||
| 334 | - return ''; | ||
| 335 | - } | ||
| 336 | - return (int) $info->ImageHeight; | ||
| 337 | } catch (\Exception $e) { | 336 | } catch (\Exception $e) { |
| 338 | @file_put_contents(storage_path('logs/crop_image_error.log'), '获取图片高度失败: ' . $e->getMessage() . PHP_EOL, FILE_APPEND); | 337 | @file_put_contents(storage_path('logs/crop_image_error.log'), '获取图片高度失败: ' . $e->getMessage() . PHP_EOL, FILE_APPEND); |
| 339 | return ''; | 338 | return ''; |
-
请 注册 或 登录 后发表评论