作者 lyh

gx

@@ -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 '';  
331 - }  
332 - $info = simplexml_load_string($xml);  
333 - if ($info === false || !isset($info->ImageHeight)) {  
334 - 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 "错误:无法读取图片或链接无效";
335 } 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 '';