tencent cloud

masukan

Basic Image Processing

Terakhir diperbarui:2023-02-23 16:33:22

    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 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 blurring 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

    When performing basic image processing, you need to specify the image processing rule. For more information, see Image Processing Overview.
    For all the code samples, visit GitHub.
    Below are some examples:

    Scaling

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

    Cropping

    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Crop the radius of an inscribed circle to an integer greater than 0 and less than half of the shorter side of the original image. The center of the inscribed circle is the center of the image.
    String rule = "imageMogr2/iradius/150";
    getObj.putCustomQueryParameter(rule, null);
    cosClient.getObject(getObj, new File("qrcode-cropping.png"));
    

    Rotation

    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Rotate 90 degrees clockwise
    String rule = "imageMogr2/rotate/90";
    getObj.putCustomQueryParameter(rule, null);
    cosClient.getObject(getObj, new File("qrcode-rotate.png"));
    

    Obtaining average hue

    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Obtaining image's average hue
    String rule = "imageAve";
    COSObject object = cosClient.getObject(getObj);
    COSObjectInputStream objectContent = object.getObjectContent();
    

    Obtaining basic image information

    String bucketName = "examplebucket-1250000000";
    String key = "qrcode.png";
    GetObjectRequest getObj = new GetObjectRequest(bucketName, key);
    // Basic image information
    String rule = "imageInfo";
    getObj.putCustomQueryParameter(rule, null);
    COSObject object = cosClient.getObject(getObj);
    COSObjectInputStream objectContent = object.getObjectContent();
    
    Hubungi Kami

    Hubungi tim penjualan atau penasihat bisnis kami untuk membantu bisnis Anda.

    Dukungan Teknis

    Buka tiket jika Anda mencari bantuan lebih lanjut. Tiket kami tersedia 7x24.

    Dukungan Telepon 7x24