El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Resizing Images

Updated on 2024-08-09 GMT+08:00

You can use the GUI or code mode on OBS Console or make an API call to resize images. Images can be resized based on a specific rule or a fixed width, height, or percentage.

NOTE:
  • A long side refers to the side with a larger ratio of its original size to its target size, and a short side refers to the side with a smaller ratio. Assume that the original size of an image is 400 × 200 pixels and it is resized to 100 × 100 pixels. The ratio of 400 pixels to 100 pixels is 4 and that of 200 pixels to 100 pixels is 2, so the long side is 400 pixels and the short side is 200 pixels.
  • For a target image after resizing, its long side cannot exceed 9,999 pixels, and the product of its width and height cannot exceed 24,999,999 pixels.
  • If you only specify the height or width for resizing, the target image keeps the same aspect ratio and format as the original image.
  • By default, resizing is not allowed to scale up an image. If you want an image to become larger after resizing, you need to set limit to 0 to obtain the enlarged image, or the original image will be returned. To do this, use the following format:

    https://hw-image-demo.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,w_500,limit_0

Table 1 describes the parameters.

This operation is represented by resize.

Table 1 Resizing parameters

Parameter

Value Description

Code Example

m

Type of resizing. The value can be lfit (the default value), mfit, fill, pad, or fixed.

  • lfit: Specify a rectangle with a given width (indicated by w) and height (indicated by h), lock the aspect ratio, and obtain the largest image in the rectangle.
  • mfit: Specify a rectangle with a given width (indicated by w) and height (indicated by h), lock the aspect ratio, and obtain the smallest image in the rectangle's extended area.
  • fill: Specify a rectangle with a given width (indicated by w) and height (indicated by h) and lock the aspect ratio. Obtain the smallest image in the rectangle's extended area, and center and crop the image. fill-based resizing actually centers and crops a target image resized with mfit.
  • pad: Specify a rectangle with a given width (indicated by w) and height (indicated by h) and lock the aspect ratio. Obtain the largest image in the rectangle and fill the blank area with color. pad-based resizing actually fills the blank area of a target image resized with lfit.
  • fixed: Resize an image based on a fixed width and height.
  • ratio: Specify an aspect ratio (a ratio of w to h), in the range of 1 to 1000, and obtain the largest image that meets the specified ratio.

image/resize,m_lfit,h_100,w_100

p

Percentage of the aspect ratio, in the range of 1 to 1000. If the value is:

  • < 100: The image is scaled down.
  • = 100: The image is kept unchanged in size.
  • > 100: The image is scaled up.

image/resize,p_50

h

Height of the target image, in the range of 1 to 9999. The product of the target image's width and height cannot exceed 24,999,999.

image/resize,m_lfit,h_100

w

Width of the target image, in the range of 1 to 9999. The product of the target image's width and height cannot exceed 24,999,999.

image/resize,m_fixed,h_100,w_100

l

The long side of the target image, in the range of 1 to 4096. The product of the target image's width and height cannot exceed 24,999,999.

The long side has a specified value, and the short side is scaled based on the ratio.

image/resize,l_100

s

The short side of the target image, in the range of 1 to 4096. The product of the target image's width and height cannot exceed 24,999,999.

The short side has a specified value, and the long side is scaled based on the ratio.

image/resize,s_100

color

Color for filling the blank area after resizing. This parameter can be used when you set m to pad.

The value is a hexadecimal code, from 000000 to FFFFFF (default value, representing white).

image/resize,m_pad,h_100,w_100,color_FF0000

limit

Whether to limit the size of the target image when the target image is larger than the original one. The value can be 0 or 1 (default value).

  • 0: The size is not limited.
  • 1: The size is limited.

image/resize,p_150,limit_0

CAUTION:

If a resized image is aliased, you can add /marker,u_plus to the end of the image processing URL for optimization.

For example, by adding /marker,u_plus, the processing URL https://hw-image-demo.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,m_fixed,w_2668,h_1999,limit_0 becomes https://hw-image-demo.obs.ap-southeast-1.myhuaweicloud.com/example.jpg?x-image-process=image/resize,m_fixed,w_2668,h_1999,limit_0/marker,u_plus. The latter displays an image with better quality.

Examples

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback