Transparent Background
This rule ensures that the image has a transparent background
Parameter table
param | unit | required | description |
---|---|---|---|
threshold | % | no | Maximum percentage of image edges to be opaque |
Detailed description
The image validation algorithm of this rule examines the alpha channel of the image to determine if the background is transparent. The alpha channel is a component of an image that represents the transparency of each pixel.
The algorithm counts the number of non-transparent pixels on the top, bottom, left, and right borders of the image. If the proportion of non-transparent pixels on the image border is at least the specified threshold percentage, the image is considered valid. Otherwise, an error is raised, indicating that the background is not transparent.
Correction
The correction process of this rule aims to make the background of the image transparent. It does so by identifying the most present color on the border of the image. If at least 85% of the border is covered by a dominant color, that color is made transparent. The format of the corrected image will be PNG. However, it's important to note that correction is not always possible.
If there is no dominant color covering at least 85% of the border, a warning is issued, and no correction is applied.
Creator tips
- Ensure your image has a transparent background when it is intended to have one.
- If your image has a non-transparent background, be prepared to address potential corrections, especially if the correction process detects a lack of a dominant color covering at least 85% of the image border.
Examples
value | valid | threshold | description |
---|---|---|---|
✅ | The image background shoud be transparent. | ||
❌ | The image background shoud be transparent. | ||
✅ | 25 | The image background shoud be transparent. |