Class ImageCropStyle
ImageCropStyle
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.
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
ImageCropStyle
— 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
Return
ImageCropStyle
— This object, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[null,null,["Last updated 2024-12-02 UTC."],[[["`ImageCropStyle` allows cropping images within Google Apps Script, but not resizing them directly."],["Two main methods, `setAspectRatio` and `setImageCropType`, provide control over the cropping process."],["`setAspectRatio` is applicable only when using the `RECTANGLE_CUSTOM` crop type and requires a positive ratio value."],["`setImageCropType` lets you choose the shape of the crop, with `SQUARE` being the default option."],["Both methods return the `ImageCropStyle` object, enabling method chaining for streamlined code."]]],["The `ImageCropStyle` class allows users to crop images without resizing them. Key actions include setting the image crop type using `setImageCropType`, which defaults to SQUARE. For a `RECTANGLE_CUSTOM` crop type, you can set the aspect ratio via `setAspectRatio`, which requires a positive numeric value. Both methods return the `ImageCropStyle` object, enabling method chaining. `setAspectRatio` throws an error if the ratio is zero or negative.\n"]]