Description
Find transparent raster borders using a supplied alpha threshold.
Print and screen geometry depends on coordinate scale, placed image size, bleed/inset definitions and pixel transparency. Placed pixels per inch differs from printer dots per inch, and a caller-chosen margin differs from a verified production tolerance. Empty-image conventions and threshold equality affect bounding results.
Find transparent raster borders using a supplied alpha threshold.
When to use this tool
Use Bitmap Trim Transparent Border Count when checking the stated artwork geometry, placement, screen angle or alpha-bound convention.
How to use the tool and how it works
- Enter alphaRows, transparentThreshold. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read leftTrim, rightTrim, topTrim, bottomTrim, contentWidth, contentHeight, empty. Inspect empty before interpreting the associated values.
Require rectangular alphaRows with every value and transparentThreshold in [0,1]. A pixel is content only when alpha>threshold; find its bounding rectangle and report trim counts. For no content, return zero content dimensions, left/top zero, right=width and bottom=height with empty=true.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| alphaRows | Alpha Rows | Required. Array of array of finite number; maximum items 128; maximum items 128. |
| transparentThreshold | Alpha<=threshold is transparent; only strictly greater alpha contributes content. | Required. Finite number; minimum 0; maximum 1. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| leftTrim | Left Trim | Required. Safe integer. |
| rightTrim | On empty content, the full supplied width; leftTrim is then zero by convention. | Required. Safe integer. |
| topTrim | Top Trim | Required. Safe integer. |
| bottomTrim | Bottom Trim | Required. Safe integer. |
| contentWidth | Content Width | Required. Safe integer. |
| contentHeight | Content Height | Required. Safe integer. |
| empty | True when no pixel exceeds threshold, including zero-sized arrays. | Required. Boolean. |
{
"input": {
"alphaRows": [
[
0,
0,
0,
0
],
[
0,
1,
1,
0
],
[
0,
0,
0,
0
]
],
"transparentThreshold": 0
},
"output": {
"leftTrim": 1,
"rightTrim": 1,
"topTrim": 1,
"bottomTrim": 1,
"contentWidth": 2,
"contentHeight": 1,
"empty": false
}
} Limitations and assumptions
- Threshold equality counts as transparent; only supplied alpha values are scanned, without reading an image, changing pixels or treating zero placeholders as a unique crop.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.
Alternative or Complementary methods
Inspect rendered artwork and verified production/device specifications for actual print quality, cropping, fit and manufacturing requirements.
References
Similar or alternative tools
- Image Effective DPI Placement
Calculate placed image pixels per inch independently along each axis.
- Glyph Overhang Optical Margin Term Tool
Calculate explicit glyph ink overhang beyond a zero-origin advance box without prescribing optical margin alignment.