Aspect Ratio
This rule checks that an image maintains the specified aspect ratio (w/h).
Parameter table
param | unit | required | description |
---|---|---|---|
aspectRatio | ratio | yes | The desired aspect ratio of the image. |
margin | ratio | no | Margin for the aspect ratio difference acceptance. |
divideRatio | ratio | no | The denominator for aspect ratio when it cannot be expressed directly like repeating decimals (e.g., 16/9, set aspectRatio to 16 and divideRatio to 9). |
Correction
The correction process proposes a maximum of three alternatives:
- First Proposal (Adjusting Width):
- The first proposal adjusts the width while preserving the original height, aiming to achieve the specified aspect ratio.
- Second Proposal (Adjusting Height):
- The second proposal adjusts the height while preserving the original width, aiming to achieve the specified aspect ratio.
- Third Proposal (Cropping Center):
- The third proposal involves cropping the image while keeping the center, ensuring the specified aspect ratio.
The correction process ensures that at most three proposals are generated,considering the specified aspect ratio constraint.The image is resized or cropped to meet the desired aspect ratio, providing alternative proposals.
How to setup
This rule evaluates whether an image's aspect ratio adheres to the specified constraints. Key parameters include:
aspectRatio
: The desired aspect ratio of the image (w/h).margin
: Margin for the acceptance of the aspect ratio difference.If provided, images with a difference between the actual ratio and the target ratio within this margin are accepted.divideRatio
: The denominator for aspect ratio when it cannot be expressed directly like repeating decimals(e.g., 16/9, set aspectRatio to 16 and divideRatio to 9).
The aspect ratio is a dimensionless quantity, representing the ratio of the image's width to its height.The correction process ensures that at most three proposals are generated,considering the specified aspect ratio constraint.The image is resized or cropped to meet the desired aspect ratio, providing alternative proposals.
Creator tips
- You can investigate the image size and aspect ratio by checking its properties.
- Editing tools like paint can be used to adjust the aspect ratio of images.
Examples
value | valid | aspectRatio | divideRatio | margin | description |
---|---|---|---|---|---|
✅ | 1 | The image shoud be a square image. | |||
❌ | 1 | The image shoud be a square image. | |||
✅ | 2 | 0.01 | Image width should be twice (or nearly) its height. | ||
✅ | 16 | 9 | Image ratio should be 16/9. |