tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Image Processing

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2024-02-02 15:51:37

Overview

This document provides an overview of APIs and SDK code samples for basic image processing.
API
Description
Scales up/down an image.
Crops an image, including regular cropping, scaling and cropping, cropping to circle, rounded corner cropping, and smart face cropping.
Rotates an image, including regular rotation and adaptive rotation.
Converts the format of an image, optimizes the GIF format, and performs progressive display.
Adjusts the quality of an image.
Blurs an image by a Gaussian function.
Sharpens an image.
Adds a watermark to an image.
Adds a real-time text watermark to an image.
Queries the basic information of an image, such as format, width, and height.
Queries the EXIF data of an image.
Queries the average hue of an image.
Removes the image metadata, including the EXIF data.
Generates a thumbnail through an image processing template.
Performs multiple operations on an image in sequence.

Scaling

Feature description

CI uses the imageMogr2 API to scale images.

Method prototype

func (s *CIService) Get(ctx context.Context, key string, operation string, opt *ObjectGetOptions, id ...string) (*Response, error)

func (s *CIService) GetToFile(ctx context.Context, key, localpath, operation string, opt *ObjectGetOptions, id ...string) (*Response, error)

Sample request

name := "test.jpg"
// Sample 1. Get an object from the response body
resp, err := c.CI.Get(context.Background(), name, "imageMogr2/thumbnail/!50px", nil)
if err != nil {
//ERROR
}
defer resp.Body.Close()
ioutil.ReadAll(resp.Body)

// Sample 2. Download an object
filepath := "test.jpg"
_, err = c.CI.GetToFile(context.Background(), name, filepath, "imageMogr2/thumbnail/!50px", nil)

Parameter description

Parameter
Description
Type
Required
key
Unique identifier of the object in the bucket. For example, if an object's access endpoint is examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/doc/pic.jpg, its key is doc/pic.jpg.
string
Yes
operation
Image processing operation, such as scaling, cropping, rotation, format conversion, and quality change.
string
Yes
ObjectGetOptions
Object download parameters. For more information, see Object Operations.
string
No
id
Object VersionId
string
No

Cropping

Feature description

CI uses the imageMogr2 API to crop images, including regular cropping, scaling and cropping, cropping to circle, rounded corner cropping, and smart face cropping.

Sample request

name := "test.jpg"
filepath := "test.jpg"
_, err = c.CI.GetToFile(context.Background(), name, filepath, "imageMogr2/cut/600x600x100x10", nil)

Other Basic Image Processing Operations

Feature description

You can perform other basic processing operations on images by changing the value of the operation parameter. For example, you can rotate the image clockwise by 90 degrees as follows:
name := "test.jpg"
filepath := "test.jpg"
_, err = c.CI.GetToFile(context.Background(), name, filepath, "imageMogr2/rotate/90", nil)


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan