Skip to main content

Aspect Ratio

This rule checks that an image maintains the specified aspect ratio (w/h).

Parameter table

paramunitrequireddescription
aspectRatioratioyesThe desired aspect ratio of the image.
marginrationoMargin for the aspect ratio difference acceptance.
divideRatiorationoThe 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:

  1. First Proposal (Adjusting Width):
  • The first proposal adjusts the width while preserving the original height, aiming to achieve the specified aspect ratio.
  1. Second Proposal (Adjusting Height):
  • The second proposal adjusts the height while preserving the original width, aiming to achieve the specified aspect ratio.
  1. 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

valuevalidaspectRatiodivideRatiomargindescription
Diamond1The image shoud be a square image.
Minecraft Player1The image shoud be a square image.
Minecraft Tools20.01Image width should be twice (or nearly) its height.
16:9 Grid169Image ratio should be 16/9.