Basic Image Processing

Last updated: 2021-06-09 14:19:54

    Overview

    COS has integrated Cloud Infinite (CI), a one-stop professional multimedia solution that offers the image processing features outlined below. For more information, please 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

    Basic Image Processing

    Samples of basic image processing are as follows:

    Scaling

    java
    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Scale down the image’s width and height to 50%.
    String rule = "imageMogr2/thumbnail/!50p";
    getObj.putCustomQueryParameter(rule, null);
    cosClient.getObject(getObj, new File("qrcode-50p.png"));
    

    Cropping

    java
    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Scale down the image’s width and height to 50%.
    String rule = "imageMogr2/iradius/150";
    getObj.putCustomQueryParameter(rule, null);
    cosClient.getObject(getObj, new File("qrcode-cropping.png"));
    

    Rotation

    java
    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Scale down the image’s width and height to 50%.
    String rule = "imageMogr2/rotate/90";
    getObj.putCustomQueryParameter(rule, null);
    cosClient.getObject(getObj, new File("qrcode-rotate.png"));