All Products
Search
Document Center

Object Storage Service:style

Last Updated:Mar 20, 2026

Use the style command to create, retrieve, delete, and list image styles on an OSS bucket.

An image style is a named preset that stores an Image Processing parameter string. Once defined, apply it to any object URL instead of repeating the full parameter string each time.

Prerequisites

Before you begin, make sure you have:

  • ossutil 1.7.16 or later (the style command is not available in earlier versions)

  • The required RAM permissions for the operations you plan to run: For details on granting these permissions, see Attach a custom policy to a RAM user.

    OperationRequired permission
    Create an image styleoss:PutStyle
    Retrieve an image styleoss:GetStyle
    Delete an image styleoss:DeleteStyle
ossutil 1.6.16 and later let you invoke the tool as ossutil on any operating system. Earlier versions require the binary name to match the operating system. For details, see ossutil command reference.

Create an image style

Synopsis

ossutil style --method put oss://<bucketname>/ <stylename> <local_xml_file>

Parameters

ParameterRequiredDescription
bucketnameYesName of the bucket
stylenameYesName to assign to the image style
local_xml_fileYesPath to the local XML file that defines the style content (for example, config.xml)

The XML file must follow this structure:

<?xml version="1.0" encoding="UTF-8"?>
<Style>
  <Content>image/resize,p_50</Content>
</Style>

The <Content> element holds an Image Processing parameter string. For the full list of supported operations and values, see Image Processing parameters.

Example

Create config.xml with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<Style>
  <Content>image/resize,p_50</Content>
</Style>

Then run:

ossutil style --method put oss://examplebucket/ examplestyle config.xml

The following output confirms the style was created:

0.299514(s) elapsed

Retrieve an image style

Synopsis

ossutil style --method get oss://<bucketname>/ <stylename> [local_xml_file]

Parameters

ParameterRequiredDescription
bucketnameYesName of the bucket
stylenameYesName of the image style to retrieve
local_xml_fileNoPath to a local file where the result is saved. If omitted, the result prints to stdout.

Examples

Print the style definition to stdout:

ossutil style --method get oss://examplebucket/ examplestyle

Output:

<?xml version="1.0" encoding="UTF-8"?>
<Style>
  <Name>examplestyle</Name>
  <Content>image/resize,p_100</Content>
  <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
  <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
</Style>

0.150473(s) elapsed

Save the style definition to a local file:

ossutil style --method get oss://examplebucket/ examplestyle local.xml

The following output confirms the file was saved:

0.214483(s) elapsed

local.xml contains:

<?xml version="1.0" encoding="UTF-8"?>
<Style>
  <Name>examplestyle</Name>
  <Content>image/resize,p_100</Content>
  <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
  <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
</Style>

Delete an image style

Synopsis

ossutil style --method delete oss://<bucketname>/ <stylename>

Parameters

ParameterRequiredDescription
bucketnameYesName of the bucket
stylenameYesName of the image style to delete

Example

ossutil style --method delete oss://examplebucket examplestyle

The following output confirms the style was deleted:

0.184183(s) elapsed

List image styles

Synopsis

ossutil style --method list oss://<bucketname>/ [local_xml_file]

Parameters

ParameterRequiredDescription
bucketnameYesName of the bucket
local_xml_fileNoPath to a local file where the results are saved. If omitted, results print to stdout.

Examples

Print all styles to stdout:

ossutil style --method list oss://examplebucket/

Output:

<?xml version="1.0" encoding="UTF-8"?>
<StyleList>
  <Style>
    <Name>examplestyle1</Name>
    <Content>image/resize,p_100</Content>
    <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
    <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
  </Style>
  <Style>
    <Name>examplestyle2</Name>
    <Content>image/resize,p_100</Content>
    <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
    <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
  </Style>
</StyleList>

0.155333(s) elapsed

Save all styles to a local file:

ossutil style --method list oss://examplebucket/ local.xml

The following output confirms the file was saved:

2.655387(s) elapsed

local.xml contains:

<?xml version="1.0" encoding="UTF-8"?>
<StyleList>
  <Style>
    <Name>examplestyle1</Name>
    <Content>image/resize,p_100</Content>
    <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
    <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
  </Style>
  <Style>
    <Name>examplestyle2</Name>
    <Content>image/resize,p_100</Content>
    <CreateTime>Thu, 22 Dec 2022 13:59:06 GMT</CreateTime>
    <LastModifyTime>Thu, 22 Dec 2022 13:59:06 GMT</LastModifyTime>
  </Style>
</StyleList>