Skip to content

Main content

Bitmap Trim Transparent Border Count Tool

Find explicit alpha-mask border trims for pixels above a supplied threshold; an empty image uses a zero-origin empty crop and removes full right/bottom extents.

Loading tool…

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

  1. Enter alphaRows, transparentThreshold. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. 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 fieldMeaning and unitsAccepted input
alphaRowsAlpha RowsRequired. Array of array of finite number; maximum items 128; maximum items 128.
transparentThresholdAlpha<=threshold is transparent; only strictly greater alpha contributes content.Required. Finite number; minimum 0; maximum 1.
Output fieldInterpretationReturned shape
leftTrimLeft TrimRequired. Safe integer.
rightTrimOn empty content, the full supplied width; leftTrim is then zero by convention.Required. Safe integer.
topTrimTop TrimRequired. Safe integer.
bottomTrimBottom TrimRequired. Safe integer.
contentWidthContent WidthRequired. Safe integer.
contentHeightContent HeightRequired. Safe integer.
emptyTrue when no pixel exceeds threshold, including zero-sized arrays.Required. Boolean.
json
{
  "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

  1. Calculation and input contract: graphic-design/bitmap-trim-transparent-border-count — tool.io

Similar or alternative tools