AI-generated Key Takeaways
-
ImageCropStyle
allows cropping images within Google Apps Script, but not resizing them directly. -
Two main methods,
setAspectRatio
andsetImageCropType
, provide control over the cropping process. -
setAspectRatio
is applicable only when using theRECTANGLE_CUSTOM
crop type and requires a positive ratio value. -
setImageCropType
lets you choose the shape of the crop, withSQUARE
being the default option. -
Both methods return the
ImageCropStyle
object, enabling method chaining for streamlined code.
A class that represents a crop style that can be applied to image components. You can't set the size 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 is RECTANGLE_CUSTOM . |
set | Image | Sets the crop type for the image. |
Detailed documentation
setAspectRatio(ratio)
Sets the aspect ratio to use if the crop type is RECTANGLE_CUSTOM
. The ratio must
be 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.