You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Image processing
Creating image styles
Copy page
Download PDF
Creating image styles
An image style is a template that contains multiple image processing parameters such as format conversion and progressive display. You can use an image style to process multiple images uniformly, thereby simplifying operations. This topic describes how to create an image style using the graphical user interface (GUI) or API code.​
Creating a style using the GUI​
  1. Log in to the TOS console.​
  1. In the left navigation pane, click Buckets. In the Buckets list, click the bucket you want to manage.​
  1. In the left navigation pane, select Data processing > Image processing.​
  1. On the Image processing page, click the style tab, and then click Create style.​
  1. On the Create style page, click Basic Edit. Set the following parameters and click Create.​
tip​
When setting style parameters, you can see what the processed image will look like and the code that will go with it in the right area of the Create style page.​
  • ​
    Parameter​
    Description​
    Constraints and limitations​
    Rule name​
    Enter the name of the style. The style name must:​
    • Start with uppercase and lowercase letters, numbers, or underscores (_).​
    • Contain only numbers, uppercase and lowercase letters, underscores (_), hyphens (-), and periods (.).​
    • Be between 1 and 256 characters long.​
    • You can create a maximum of 100 styles.​
    • Style names can be duplicated. To apply the same style to objects with different prefixes, create multiple styles with the same name and assign a different prefix to each one.​
    Rule effective prefix​
    Enter the prefix of the object(s) to which the style will apply. If this field is left blank, the style will apply to all objects in the bucket by default. Follow these guidelines when specifying a prefix:​
    • Prefixes can contain Chinese characters, letters, numbers, and common symbols.​
    • Prefixes cannot start with a forward slash (/) or backslash (\). Consecutive forward slashes (/) are not allowed.​
    • .. cannot be used as a directory name.​
    • You can configure a maximum of 10 different prefixes for one style. Prefixes cannot contain each other. For example, if prefix 1 is set to "event", prefix 2 cannot be "event/test" for the same style.​
    • To apply the same style to objects with different prefixes while achieving different effects, create multiple styles with the same name and assign a different prefix to each one.​
    Format conversion​
    Set the output format for image conversion. The options are Original image format, jpg, jpeg, png, bmp, gif, webp, and tiff. Original image format is selected by default.​
    -​
    Progressive display​
    Specify whether to enable progressive display, which makes the image appear blurry at first and then sharpens it as more data loads. Progressive display is disabled by default.​
    This feature only applies to JPG images.​
    Adaptive direction​
    Select whether to rotate the image based on the EXIF rotation value in the original image. Adaptive direction is enabled by default.​
    If the original image does not contain rotation parameters, the adaptive direction feature will not be applied to the image.​
    Image quality​
    Select whether to compress the original image and adjust its quality. The default setting is Relative mass, with a compression percentage of 90. The options are:​
    • Relative mass: Compresses the image to q% of the original image's quality.​
    • Absolute mass: Directly compresses the image to Q%. The quality of the compressed image is independent of that of the original image.​
    • No compression: No compression is applied to the original image.​
    • The image quality feature only applies to JPG and WEBP images.​
    • For WebP images, relative quality is equivalent to absolute quality. In other words, both methods produce the same result.​
    Resizing method​
    Select whether to resize the image.​
    • No resizing (Default)​
    • Scale down​
    • Scale up​
    • Specify width and height resizing mode​
    • Fixed Width + Adaptive Height: Scales the image proportionally based on a fixed width.​
    • Fixed Height + Adaptive Width: Scales the image proportionally based on a fixed height.​
    • Fixed Width & Height + Resize by Longer Side: Creates a bounding box with fixed dimensions and scales the image proportionally to the largest size that fully fits within the box.​
    • Fixed Width & Height + Resize by Shorter Side: Creates a bounding box with fixed dimensions and scales the image proportionally to the smallest size that fully covers the box.​
    • Fixed Width & Height + Thumbnail Fill: Creates a bounding box with fixed dimensions. Proportionally scales the image to the largest size that fully fits within the box. Centers the image within the box, and fills any remaining space with a specified color.​
    • Fixed Width & Height + Center Crop: Creates a bounding box with fixed dimensions. Proportionally scales the image to the smallest size that fully covers the box. Performs a center crop based on the box dimensions.​
    • Fixed Width & Height: Scales the image to an exact width and height without preserving the proportions.​
    -​
    Image brightness​
    Adjust the brightness of the image. The value range is from -100 to 100, and the default value is 0. The values indicate the following:​
    • Value < 0: Reduces image brightness.​
    • Value = 0: No adjustment to image brightness.​
    • Value > 0: Increases image brightness.​
    -​
    Image contrast​
    Adjust the contrast of the image. The value range is from -100 to 100, and the default value is 0. The values indicate the following:​
    • Value < 0: Decreases image contrast.​
    • Value = 0: No adjustment to image contrast.​
    • Value > 0: Increases image contrast.​
    -​
    Image sharpening​
    Adjust the sharpness of the image. The value range is from 50 to 399. Image sharpening is disabled by default.​
    Higher values increase image clarity, but excessively high values may cause distortion. For optimal results, a value of 100 is recommended.​
    -​
    Image blur​
    Select whether to apply a blur effect to the image. Image blur is disabled by default. If it is enabled, you need to set the following parameters:​
    • Blur Radius: The value range is from 1 to 50. The larger the value is, the blurrier the image.​
    • Standard Deviation in Gaussian Blur: The value range is from 1 to 50. The larger the value is, the blurrier the image.​
    -​
    Image rotation​
    Set the angle of the clockwise rotation for the image. The value can range from 0 to 360, and the default value is 0.​
    If the rotation angle is not a multiple of 90°, the size of the processed image will increase.​
    The width or height of the image must not exceed 4096 pixels.​
    Watermark​
    Select whether to add an image or text watermark to the image. Note that image and text watermarks cannot be applied simultaneously. No watermark is selected by default. Other options are:​
    • Image watermark​
    • Select Image watermark, and configure the parameters, such as Path of the Watermark Image, Watermark Image Preprocessing, and Transparency. Here are some of the parameters:​
    • Path of the Watermark Image: Specify the path to the watermark image. For example, if the watermark image is named "abc.jpg" and placed in the "test" folder of the bucket, the path should be test/abc.jpg.​
    • Proportion: Specify the proportion of the watermark image to the original image. This parameter only becomes available when the Watermark Image Preprocessing option is enabled.​
    • Vertical Margin: Specify the distance between the watermark and the bottom edge of the image. This parameter only applies when the watermark position is set to top left, top center, top right, bottom left, bottom center or bottom right.​
    • Horizontal Margin: Specify the distance between the watermark and the right edge of the image. This parameter only applies when the watermark is set to top left, center left, bottom left, top right, center right, or bottom right.​
    • Text watermark​
    • Select Text watermark, and configure the parameters, such as Text Content, Text Font, and Text Rotation. Here are some of the parameters:​
    • Text Content: It can contain up to 16 characters.​
    • Text Font: The options are Default Front (WenQuanYi Zen Hei), WenQuanYi Zen Hei, WenQuanYi Micro Hei, Fāng Zhèng Shū Sòng, Fāng Zhèng Kǎi Tǐ, Fāng Zhèng Hēi Tǐ, Fāng Zhèng Fǎng Sòng, and DroidSans Fallback.​
    • Vertical Margin: Specify the distance between the text and the bottom edge of the image. This parameter only applies when the watermark position is set to top left, top center, top right, bottom left, bottom center or bottom right.​
    • Horizontal Margin: Specify the distance between the text and the right edge of the image. This parameter only applies when the watermark is set to top left, center left, bottom left, top right, center right, or bottom right.​
    Image watermark​
    • To preview the watermark effect, you must set the access permission of the watermark image to public read.​
    • The watermark image and the original image must reside in the same bucket. Otherwise, the watermarking process will fail.​
    Remove meta information​
    Select whether to remove image metadata.​
    • The following types of metadata can be removed: bKGD, cHRM, EXIF, gAMA, iCCP, iTXt, tEXt, zCCP and zTXt.​
    • Removing image metadata will delete all of these types. It is not possible to retain certain metadata.​
    ​
Creating a style using API code​
  1. Log in to the TOS console.​
  1. In the left navigation pane, click Buckets. In the Buckets list, click the bucket you want to manage.​
  1. In the left navigation pane, select Data processing > Image processing.​
  1. On the Image processing page, click the style tab, and then click Create style.​
  1. On the Create style page, click Advanced Edit. Set the following parameters and click Create.​
  • ​
    Parameter​
    Description​
    Constraints and limitations​
    Rule name​
    Enter the name of the style. The style name must:​
    • Start with uppercase and lowercase letters, numbers, or underscores (_).​
    • Contain only numbers, uppercase and lowercase letters, underscores (_), hyphens (-), and periods (.).​
    • Be between 1 and 256 characters long.​
    • You can create a maximum of 100 styles.​
    • Style names can be duplicated. To apply the same style to objects with different prefixes, create multiple styles with the same name and assign a different prefix to each one.​
    Rule effective prefix​
    Enter the prefix of the object(s) to which the style will apply. If this field is left blank, the style will apply to all objects in the bucket by default. Follow these guidelines when specifying a prefix:​
    • Prefixes can contain Chinese characters, letters, numbers, and common symbols.​
    • Prefixes cannot start with a forward slash (/) or backslash (\). Consecutive forward slashes (/) are not allowed.​
    • .. cannot be used as a directory name.​
    • You can configure a maximum of 10 different prefixes for one style. Prefixes cannot contain each other. For example, if prefix 1 is set to "event", prefix 2 cannot be "event/test" for the same style.​
    • To apply the same style to objects with different prefixes while achieving different effects, create multiple styles with the same name and assign a different prefix to each one.​
    Code​
    Enter the code in the following format: image/action1,parame_value1/action2,parame_value2/.... For example, to set the width to 200, enter image/resize,w_200.​
    For a list of supported parameters, see Image processing parameters.​
    -​
    ​
Next steps​
Once you have successfully created an image style, you can use it to process images. For instructions, see Using image styles.​
Related operations​
  • Export a style​
  • On the Image processing page, select the desired style and click Export style to save the style file locally.​
  • Import a style​
  • On the Image processing page, click Import style. Select the style file from your local device, and click Open to import it.​
tip​
The imported style file must be in txt format and must not exceed 256 KB in size. It must also comply with the style specifications.​
​
Last updated: 2026.08.14 16:23:29