Image Processing

Last updated: 2020-09-17 15:48:40

    Overview

    COS has integrated Cloud Infinite (CI), a one-stop professional multimedia solution that offers the image processing features outlined below. For more information, see Image Processing Overview.

    Service Feature Description
    Basic image processing service Scaling Proportional scaling, scaling image to target width and height, and more
    Cropping Cut (regular cropping), crop (scaling and cropping), iradius (inscribed circle cropping), and scrop (smart cropping)
    Rotation Adaptive rotation and common rotation
    Format conversion Format conversion, GIF optimization, and progressive display
    Quality conversion Changes the quality of images in JPG and WEBP formats
    Gaussian blur Blurs images
    Sharpening Sharpens images
    Watermarking Image watermarks, text watermarks
    Obtaining image information Basic information, EXIF data, average hue
    Removing metadata Includes EXIF data
    Quick thumbnail template Performs quick format conversion, scaling, and cropping to generate thumbnails
    Setting style Sets image styles to easily manage images for different purposes

    SDK API Reference

    For the parameters and method descriptions of all the APIs in the SDK, see Api Documentation.

    Using Image Processing when Uploading

    The following example shows how COS automatically processes an image when you upload it.

    Upon successful upload, COS will save both the original and processed images. You can obtain the processing result using a common download request.

    Sample code

    PutObjectRequest request = new PutObjectRequest(bucket, key, srcPath);
    
    JObject o = new JObject();
    // Do not return the original image
    o["is_pic_info"] = 0;
    JArray rules = new JArray();
    JObject rule = new JObject();
    rule["bucket"] = bucket;
    rule["fileid"] = key;
    // Processing parameters. For the rules, see https://intl.cloud.tencent.com/document/product/460/6924?from_cn_redirect=1.
    // This example proportionally scales the image to within 400 × 400 pixels
    rule["rule"] = "imageView2/thumbnail/400x400";
    rules.Add(rule);
    o["rules"] = rules;
    
    request.SetRequestHeader("Pic-Operation", o.ToString());
    // Execute the request
    PutObjectResult result = cosXml.PutObject(request);

    Note:

    For the complete sample, go to GitHub.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help