作者 lyh

gx

... ... @@ -35,15 +35,10 @@ class CropImage extends Command
public function handle(){
echo '测试裁剪->cs-crop:'.PHP_EOL;
$images ='https://ecdn6.globalso.com/upload/p/1/image_other/2025-05/1746675561075.jpg';
$image = str_replace_url($images);
$cosService = new CosService();
$new_url = $cosService->cropAndUploadFromCos($image);
return $new_url;
// $project_id = $this->argument('project_id');
// ProjectServer::useProject($project_id);
// $this->_action();
// DB::disconnect('custom_mysql');
$project_id = $this->argument('project_id');
ProjectServer::useProject($project_id);
$this->_action($project_id);
DB::disconnect('custom_mysql');
}
/**
... ... @@ -60,8 +55,9 @@ class CropImage extends Command
foreach ($data as $val){
//处理图片为相对路径
$image = str_replace_url($val);
$new_url = $cosService->cropAndUploadFromCos($image);
echo '返回的图片路径:'.$new_url.PHP_EOL;
$height = $cosService->getImageHeight($image);
echo '返回的图片高度:'.$height.PHP_EOL;
$cosService->cropCosImage($image);
}
}
return true;
... ...
... ... @@ -315,13 +315,13 @@ class CosService
/**
* @remark :获取cos图片高度
* @name :cropAndUploadFromCos
* @name :getImageHeight
* @author :lyh
* @method :post
* @time :2025/5/8 10:58
* @param :pathUrl->存储桶路径
* @param :pathUrl->存储桶相对路径
*/
public function getImageHeight($pathUrl,$maxHeight = 300){
public function getImageHeight($pathUrl){
$cos = config('filesystems.disks.cos');
$url = 'https://' . $cos['bucket'] . '.cos.' . $cos['region'] . '.myqcloud.com/' . ltrim($pathUrl, '/') . '?image/info';
$imageInfo = @getimagesize($url);
... ... @@ -340,10 +340,9 @@ class CosService
* @method :post
* @time :2025/5/8 11:06
*/
public function cropCosImage($cosUrl,$height = 200)
public function cropCosImage($cosUrl,$height = 220)
{
$cos = config('filesystems.disks.cos');
// 初始化 COS 客户端
$cosClient = new Client([
'region' => $cos['region'],
'credentials' => [
... ...