package com.backendsys.modules.sdk.tencentcloud.cos.utils;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.model.GetObjectRequest;

public class TencentBasicImageUtil {

    public static void imageProcessing(COSClient cosClient, String bucket_name, String object_key, String rule) {
        //图片在bucket中的相对位置，比如根目录下file文件夹中的demo.png路径为file/demo.png
        GetObjectRequest getObj = new GetObjectRequest(bucket_name, object_key);
        getObj.putCustomQueryParameter(rule, null);
        cosClient.getObject(getObj); // , new File("demo.png")
    }

    /**
     * 选用样式1，并限定缩略图的宽高最小值为400 × 600 绝对质量为85
     * https://cloud.tencent.com/document/product/460/6929
     */
    public static void quickThumbnailTemplate(COSClient cosClient, String bucket_name, String object_key) {
        String rule = "imageView2/1/w/400/h/600/q/85";
        imageProcessing(cosClient, bucket_name, object_key, rule);
    }

}
