Skip to main content

Data Processing

Data processing provides rich file processing capabilities, allowing cloud-based processing without downloading files.

Image Processing

Perform operations such as cropping, scaling, watermarking, and format conversion on images to optimize user experience and save bandwidth costs.

After activation:

  • Basic Image Processing: Enabled by default, can be used directly
  • ⚙️ Smart Image Compression: Requires manual activation
  • ⚙️ Advanced Image Compression: Requires manual activation
FeatureDescription
Basic Image ProcessingSupports cropping, scaling, rotation, format conversion, quality adjustment, Gaussian blur, sharpening, and other operations
Smart Image CompressionSupports automatic compression when accessing images without parameters, or active compression through processing parameter imageSlim. Supports JPG, static PNG, GIF formats. Compression does not change image format
Advanced Image CompressionConverts images to AVIF, HEIF, TPG, ASTC compression formats through processing parameter imageMogr2/format. Also supports SVG image compression

Document Processing

Convert documents to HTML or images to enable online preview functionality.

📌 Feature Support

CloudBase Cloud Storage currently supports the following document processing features:

  • Document to HTML: Supports converting Word, Excel, PPT, PDF, and other formats to HTML for online preview
  • Document to Image: Supports converting documents to image formats (PNG, JPG)

Not currently supported: Video and audio multimedia processing features.

FeatureDescriptionSupported Formats
Document to HTMLConvert documents to HTML for online previewWord, Excel, PPT, PDF, etc.
Document to ImageConvert documents to image formatWord, Excel, PPT, PDF, etc.

Use Cases:

  • Online Document Viewing: Preview documents in browser without downloading
  • Document Content Display: Display document content as images or HTML in applications
  • Knowledge Base Systems: Document content search and display

Operation Steps

Basic Image Processing

📌 Feature Description

Basic image processing supports real-time image processing through URL parameters without pre-configuration. Enabled by default.

You can access CloudDev Platform - Cloud Storage page, click "Go to COS Bucket", and find "Basic Image Processing" module in the left menu "Data Processing" → "Image Processing".

1. Process Using URL Parameters

Simply add processing parameters after the image access URL:

https://your-bucket.cos.ap-region.myqcloud.com/image.jpg?imageMogr2/thumbnail/!50p
💡 Get Image URL

To get temporary access links for images in cloud storage, please refer to Get Temporary Link.

2. Common Processing Parameters

OperationParameter ExampleDescription
Proportional ScalingimageMogr2/thumbnail/500xSpecify width as 500px, height scales proportionally
Force ScalingimageMogr2/thumbnail/!300x200Force scale to 300x200 pixels (ignore aspect ratio)
Scale by PercentageimageMogr2/thumbnail/!50pScale to 50% of original
Regular CroppingimageMogr2/crop/300x300x10x10Crop 300x300 pixel area starting from coordinates (10,10)
Smart CroppingimageMogr2/crop/300x300/gravity/faceSmart crop 300x300 pixels based on face position
RotationimageMogr2/rotate/90Rotate 90 degrees clockwise
Format ConversionimageMogr2/format/webpConvert to WebP format
Quality AdjustmentimageMogr2/quality/85Adjust image quality to 85 (range 1-100)
Gaussian BlurimageMogr2/blur/3x5Gaussian blur with radius 3 and standard deviation 5
SharpeningimageMogr2/sharpen/3Sharpen with radius 3

3. Create Image Style (Optional)

If you need to reuse the same processing rules, you can create image styles:

  1. Access CloudDev Platform - Cloud Storage page and click "Go to COS Bucket"
  2. In the left menu "Data Processing" → "Image Processing", click "Style Management" → "Add Style"
  3. Configure processing parameters and name the style (e.g., thumbnail)
  4. Use style: image.jpg?imageView2/style/thumbnail

4. Advanced Processing Examples

# Scale + Format Conversion + Quality Adjustment (combined use)
https://example.com/image.jpg?imageMogr2/thumbnail/!50p/format/webp/quality/80

# Crop + Rotate
https://example.com/image.jpg?imageMogr2/crop/300x300/rotate/90

# Add Text Watermark
https://example.com/image.jpg?watermark/2/text/Q2xvdWRCYXNl/font/SGVsdmV0aWNh/fontsize/30/fill/IzAwMDAwMA==/dissolve/80/gravity/southeast/dx/10/dy/10

Smart Image Compression

Smart image compression can significantly reduce image size while maintaining visual quality. Supports JPG, static PNG, GIF formats. Compression does not change image format.

1. Activate Smart Compression

  1. Access CloudDev Platform - Cloud Storage page and click "Go to COS Bucket"
  2. Find "Smart Image Compression" module in the left menu "Data Processing" → "Image Processing"
  3. Click "Activate Service" and confirm activation (billed by number of calls)

2. Use Smart Compression

Two methods available:

Method 1: Auto Compression (Recommended)

No additional parameters needed. Images in JPG, PNG, GIF formats will be automatically compressed when accessed normally:

# Direct access to image, auto compression
https://your-bucket.cos.ap-region.myqcloud.com/image.jpg

Method 2: API Compression

When accessing an image, add the smart compression parameter imageSlim after the image link to access the compressed image:

# Use imageSlim parameter for active compression
https://your-bucket.cos.ap-region.myqcloud.com/image.jpg?imageSlim
📖 Reference Documentation

For more detailed parameter descriptions, please refer to Smart Image Compression Interface Description.

3. Compression Effect Comparison

Smart compression can significantly reduce file size without changing image format:

FormatBefore CompressionAfter CompressionCompression RateVisual Quality
JPG500 KB250 KB50%No noticeable difference
PNG800 KB400 KB50%No noticeable difference
GIF1 MB500 KB50%No noticeable difference

Advanced Image Compression

Advanced image compression converts images to high compression rate formats like AVIF, HEIF, TPG, ASTC through the imageMogr2/format parameter. Also supports SVG image compression.

1. Enable Advanced Compression

  1. Access CloudDev Platform - Cloud Storage page and click "Go to COS Bucket"
  2. Find "Advanced Image Compression" option in the left menu "Data Processing" → "Image Processing"
  3. Click "Activate Service" and confirm activation (billed by number of calls)

2. Supported Compression Formats

FormatParameterCompression RateCompatibility
HEIFimageMogr2/format/heifMore than 80% smaller than JPGiOS 11+, Android P+ native support
AVIFimageMogr2/format/avifNext-generation format, highest compression rateChrome 85+, Firefox 93+
TPGimageMogr2/format/tpgTencent's proprietary format, extremely high compression rateRequires client SDK support
ASTCimageMogr2/format/astcSuitable for texture compressionOpenGL ES 3.0+

3. Usage Methods

Method 1: Process on Download (Not Saved)

Add processing parameters after image access URL:

# Convert to HEIF format
https://your-bucket.cos.ap-region.myqcloud.com/image.jpg?imageMogr2/format/heif

# Convert to AVIF format
https://your-bucket.cos.ap-region.myqcloud.com/image.jpg?imageMogr2/format/avif

# Convert to TPG format
https://your-bucket.cos.ap-region.myqcloud.com/image.jpg?imageMogr2/format/tpg

Method 2: Process on Upload (Save Result)

Process and save during image upload:

// Add Pic-Operations in request header
{
"is_pic_info": 1,
"rules": [{
"fileid": "compressed-image.heif",
"rule": "imageMogr2/format/heif"
}]
}

Method 3: Cloud Data Processing (Process Existing Images)

Process and save existing stored images:

POST /<ObjectKey>?image_process HTTP/1.1
# Request body same as upload processing

4. Compression Effect Comparison

FormatFile SizeCompression RateUse Case
Original (PNG)1335.2 KB-Original image
HEIF52.87 KB96.0%iOS/Android mobile
AVIF~50 KB96.3%Modern browsers
TPG~55 KB95.9%Tencent ecosystem apps

Document to HTML

Convert documents to HTML format for online preview functionality.

1. Activate Document Preview Service

  1. Access CloudDev Platform - Cloud Storage page and click "Go to COS Bucket"
  2. Click "Activate Service" in the left menu "Data Processing" → "Document Processing"
  3. Confirm activation of document preview feature

2. Use Document to HTML

Preview documents directly through URL parameters:

https://your-bucket.cos.ap-region.myqcloud.com/document.pdf?ci-process=doc-preview&dstType=html

Core Parameters:

ParameterRequiredDescriptionValue
ci-processYesSpecify Cloud Infinite processing capabilityFixed as doc-preview
dstTypeYesOutput target file typeFixed as html (lowercase)
srcTypeNoInput source file typeIf not filled, auto-detect based on file extension (e.g., pptx, pdf, docx)
signNoObject download signatureRequired for private read files, needs URLencode
copyableNoWhether to allow content copying1=copyable (default), 0=not copyable
htmlParamsNoCustom configuration parameters (JSON)Requires URL-safe Base64 encoding
htmlwaterwordNoWatermark text contentRequires URL-safe Base64 encoding
htmlfillstyleNoWatermark color and transparencyRGBA format (e.g., rgba(192,192,192,0.6)), requires Base64 encoding
htmlfrontNoWatermark text stylee.g., bold 20px Serif, requires Base64 encoding
htmlrotateNoWatermark rotation angle0-360, default 315
htmlhorizontalNoWatermark horizontal spacingUnit px, default 50
htmlverticalNoWatermark vertical spacingUnit px, default 100

Usage Examples:

# Basic preview
https://your-bucket.cos.ap-region.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html

# Disable copying + Add watermark (Base64 encoding of "test" is dGVzdAog)
https://your-bucket.cos.ap-region.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html&copyable=0&htmlwaterword=dGVzdAog

# Switch to English interface (htmlParams requires Base64 encoding)
https://your-bucket.cos.ap-region.myqcloud.com/test.pptx?ci-process=doc-preview&dstType=html&htmlParams=eyJjb21tb25PcHRpb25zIjp7Imxhbmd1YWdlIjoiZW4ifX0

htmlParams Configuration Example:

// Hide header, switch language to English
{
"mode": "normal",
"commonOptions": {
"isShowHeader": false,
"language": "en"
}
}
// Use as htmlParams parameter value after encoding
📖 Reference Documentation

For detailed usage instructions, please refer to Document to HTML Usage Guide.

3. Supported Document Formats

  • Presentation Files: pptx, ppt, pot, potx, pps, ppsx, dps, dpt, pptm, potm, ppsm
  • Text Files: doc, dot, wps, wpt, docx, dotx, docm, dotm
  • Spreadsheet Files: xls, xlt, et, ett, xlsx, xltx, xlsb, xlsm, xltm, ets
  • Other Formats: pdf, txt, log, xml, htm, html, code files, etc.

4. Notes

  • File Size Limit: Input file size must be within 200MB
  • Page Limit: Input file page count limited to 5000 pages
  • Encoding Requirement: String parameters like htmlParams, htmlwaterword must be URL-safe Base64 encoded
  • Permission Requirement: Private read files must pass sign parameter for authentication

Document to Image

Convert each page of a document to image format.

1. Convert Using URL Parameters

Convert documents to images in real-time through URL parameters:

https://your-bucket.cos.ap-region.myqcloud.com/document.pdf?ci-process=doc-preview&page=1&dstType=png

Core Parameters:

ParameterDescriptionValue
ci-processRequired, specify Cloud Infinite processing capabilityFixed as doc-preview
pageOptional, document page number to convertInteger, starts from 1, default converts page 1
dstTypeOptional, output image formatpng or jpg, default is jpg
srcTypeOptional, source file extension typeSpecify when file has no extension (e.g., pptx, pdf, docx)
scaleOptional, preview image scale ratio10-200, default 100 (i.e., 100%)
qualityOptional, generated image quality1-100, default 100
imageDpiOptional, render image at specified DPI96-600, default 96 (Note: high DPI increases processing time)

Usage Examples:

# Basic conversion: convert page 1 to PNG
https://your-bucket.cos.ap-region.myqcloud.com/document.pdf?ci-process=doc-preview&page=1&dstType=png

# Specify quality and scale: convert to JPG, quality 85, scale 50%
https://your-bucket.cos.ap-region.myqcloud.com/document.pdf?ci-process=doc-preview&page=1&dstType=jpg&quality=85&scale=50

# Combine with image processing: add watermark after conversion (requires URL encoding)
https://your-bucket.cos.ap-region.myqcloud.com/test.pptx?ci-process=doc-preview&page=1&ImageParams=imageMogr2/thumbnail/!50p|watermark/2/text/dGVzdA/fontsize/30
📖 Reference Documentation

2. Supported Document Formats

  • Microsoft Office: Word (.doc/.docx), Excel (.xls/.xlsx), PowerPoint (.ppt/.pptx)
  • PDF Documents (.pdf)

3. Notes

  • Timeout Limit: Synchronous interface defaults to 10-second conversion timeout, suitable for documents within a hundred pages or previewing a few pages
  • File Limit: Input file size limited to 200MB, page count limited to 5000 pages
  • Private Read Buckets: URL needs to carry COS authorization signature

FAQ

Q: Will image processing modify the original image?

A: No. Image processing is real-time and does not modify the original file. Processed images are dynamically generated on access.

Q: How to save processed images?

A: Two methods:

  1. Persistent Processing: Add |saveas parameter in processing parameters to save processing result as new file
  2. Download and Upload: Download processed image locally, then upload to bucket

Q: Will processed images be cached?

A: Yes. Processed images will be cached at CDN nodes. Subsequent access to the same URL returns cached results without repeated processing.

Q: Does document preview support encrypted documents?

A: Currently does not support encrypted document preview. Documents need to be decrypted before uploading to bucket for preview.

Q: How to batch process images?

A: Can use the following methods:

  1. Workflow: Create workflow in console to automatically process newly uploaded files
  2. Batch Processing Task: Create batch processing task in console to process existing files
  3. SDK: Traverse file list through code and call processing API