Class ImageCropStyle Stay organized with collections Save and categorize content based on your preferences.
Page Summary
ImageCropStyle is a class used to apply crop styles to image components in Apps Script, as images cannot be sized or resized directly.
The class provides methods to set the aspect ratio and the crop type of an image.
The
setAspectRatio(ratio)method sets the aspect ratio when using theRECTANGLE_CUSTOMcrop type, requiring a positive numerical value.The
setImageCropType(type)method sets the crop type for the image, defaulting toSQUARE.
A class that represents a crop style that can be applied to image components. You can't set thesize of an image or resize it, but you can crop the image.
Methods
| Method | Return type | Brief description |
|---|---|---|
set | Image | Sets the aspect ratio to use if the crop type isRECTANGLE_CUSTOM. |
set | Image | Sets the crop type for the image. |
Detailed documentation
setAspectRatio(ratio)
Sets the aspect ratio to use if the crop type isRECTANGLE_CUSTOM. The ratio mustbe a positive value.
Parameters
| Name | Type | Description |
|---|---|---|
ratio | Number | The ratio to apply. |
Return
Image — This object, for chaining.
Throws
Error — if the input is negative or zero.
setImageCropType(type)
Sets the crop type for the image. Default is SQUARE.
Parameters
| Name | Type | Description |
|---|---|---|
type | Image | The crop type. |
Return
Image — This object, for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-03 UTC.