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

Torch Object Storage

Copy page
Download PDF
Image processing
Resize
Copy page
Download PDF
Resize
The resize feature allows you to adjust the dimensions of images stored in TOS. This topic introduces the parameters and provides examples of the resize feature.​
Supported parameters​
Resizing to a specific width and height​
​
Parameter​
Description​
Value​
Required​
m​
Resize mode.​
  • lfit (Default): Resizes the image proportionally to fit entirely within a bounding box defined by width (w) and height (h). The result is the largest version of the image that completely fits inside the box.​
  • mfit: Resizes the image proportionally to fit within a bounding box defined by w and h, producing the smallest version of the image that completely covers the box.​
  • fill: First, TOS performs resizing, as in the mfit mode, to find the smallest image that covers the box. Then, it centers and crops the result to the exact dimensions (w x h).​
  • pad: TOS first performs resizing, as in the lfit mode, to find the largest image that fits inside the box (w x h). Then, it centers the image and fills any remaining space with the background color specified by the color parameter.​
  • fixed: Resizes the image to an exact width and height, regardless of the original aspect ratio.​
No​
w​
The width of the resized image.​
[1,16384]​
Yes​
h​
The height of the resized image.​
[1,16384]​
Yes​
l​
The length of the long side of the resized image.​
[1,16384]​
Yes​
s​
The length of the short side of the resized image.​
[1,16384]​
Yes​
limit​
Specifies whether to resize the image when the target dimensions are larger than those of the original.​
  • 1 (Default): No. TOS returns the original image.​
  • 0: Yes.​
No​
color​
The color that will be used to fill the resized image in pad mode.​
A hexadecimal color code ranging from 000000 to FFFFFF. The default is FFFFFF (white).​
No​
​
tip​
  • Required: In order to use the resize feature, you must specify at least one of the required parameters. Failure to do so will result in a MissingArgument error.​
  • Long side: The side of the image with a larger ratio of original to target dimensions.​
  • Short side: The side of the image with a smaller ratio of original to target dimensions.​
Resizing by a percentage​
​
Parameter​
Description​
Value​
Required​
p​
The percentage by which the image will be resized.​
[1,1000]​
A value less than 100 scales down the image, while a value greater than 100 scales it up.​
Yes​
​
Determining parameter priority and the bounding box​
  1. When both w and h are specified, the bounding box is constructed using the provided w and h values directly.​
  1. When only one of w or h is specified:​
  1. In lfit, mfit, and fixed modes, the unspecified dimension is calculated based on the aspect ratio of the original image to form the bounding box.​
  1. For the fill and pad modes, a square bounding box is constructed using the specified dimension.​
  1. When neither w nor h is specified:​
  1. If both l and s are specified, the bounding box is constructed with the long side set to l and the short side set to s.​
  1. If only one of l or s is specified:​
  1. In lfit, mfit, and fixed modes, the unspecified dimension is calculated based on the aspect ratio of the original image to form the bounding box.​
  1. For the fill and pad modes, a square bounding box is constructed using the specified dimension.​
  1. If neither l nor s is specified, proportional resizing is performed using the p parameter.​
Resizing an image based on the given parameters​
In this section, we will show you how images are resized based on the parameters you provide. The original image size is 400 by 200 pixels.​
  1. A bounding box of 100x100 is created when both w and h are set to 100, based on the parameter priorities. The resized images produced under various modes are as follows:​
  • ​
    lfit mode
    mfit mode
    fixed mode
    fill mode
    pad mode
    ​
    The image is proportionally scaled down. The result is an image that fits entirely within the 100x50 bounding box.​
    ​​​
    ​
  1. Based on the parameter priorities and the aspect ratio of the original image (2:1), if w is set to 200, h is calculated as 100. This results in a bounding box of 200x100, and the resizing operation proceeds as described above.​
  1. Setting l to 200 and s to 100 results in a bounding box with a long side of 200 and a short side of 100. Since the width of the original image corresponds to the long side and the height corresponds to the short side, the resulting bounding box is sized 200x100. The resizing operation then proceeds as described above.​
  1. Setting l to 200, with the width of the original image as the long side and an aspect ratio of 2:1, results in a bounding box of 200x100. The resizing operation then proceeds as described above.​
Examples​
tip​
This guide uses the same static image for all examples. ​
​Image​​
  • Set the width to 100 for proportional resizing.​
  • ​Image​​
  • Set the height to 100 for proportional resizing.​
  • ​Image​​
  • Set the long side to 100 for proportional resizing.​
  • ​Image​​
  • Set the short side to 100 for proportional resizing.​
  • ​Image​​
  • Set the height and width to 200 and the mode to lfit.​
  • ​Image​​
  • Set the height and width to 200 and the mode to mfit.​
  • ​Image​​
  • Set the height and width to 200 and the mode to fixed.​
  • ​Image​​
  • Set the height and width to 200 and the mode to fill.​
  • ​Image​​
  • Set the height and width to 200, the mode to pad, and the color to FF0000 (red).​
  • ​Image​​
  • Resize the image proportionally to 30%.​
  • ​Image​​
​
Last updated: 2026.02.03 17:51:49