作者 lyh

gx

... ... @@ -325,15 +325,14 @@ class CosService
$cos = config('filesystems.disks.cos');
$url = 'https://' . $cos['bucket'] . '.cos.' . $cos['region'] . '.myqcloud.com/' . ltrim($pathUrl, '/') . '?image/info';
try {
$xml = @file_get_contents($url);
if (!$xml) {
return '';
$imageInfo = @getimagesize($url);
if ($imageInfo) {
$width = $imageInfo[0];
$height = $imageInfo[1];
return "图片尺寸:宽度 {$width}px,高度 {$height}px";
} else {
return "错误:无法读取图片或链接无效";
}
$info = simplexml_load_string($xml);
if ($info === false || !isset($info->ImageHeight)) {
return '';
}
return (int) $info->ImageHeight;
} catch (\Exception $e) {
@file_put_contents(storage_path('logs/crop_image_error.log'), '获取图片高度失败: ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
return '';
... ...