Automated Computed Embroidery

ACEParaOptimize

POST

The optional ACEParaOptimize object controls the server-side image optimization applied before punching: color reduction (K-means in Lab space), optional thread-color mapping (CIEDE2000), background removal to transparency, noise filtering and DPI-only scaling. It is used by the standalone OptimizePng request and also runs automatically before every Create request. Omit the object, or any single field, to use the defaults below. All numeric values are clamped server-side to the listed ranges.

FieldTypeDefaultRangeDescription
TargetColorCountint81-24Target number of colors K for the K-means reduction.
NoiseStrengthint20-10 (0 = off)Majority/mode filter passes on the label map after clustering (removes speckle without new colors).
PreSmoothStrengthint00-10 (0 = off)Edge-preserving bilateral pre-smoothing of the source before clustering.
MergeSimilarColorsboolfalsetrue / falseMerge perceptually near-identical palette colors after reduction.
MergeSimilarDeltaEint01-20 (if merge on)CIEDE2000 threshold for the merge; ignored when MergeSimilarColors is false.
ThreadTablestringnulltable name / nullYarn-table file name without extension (e.g. "Amann-Isacord 40"). Enables CIEDE2000 thread mapping; null = free Lab palette. Unknown name returns an error.
EnableResampleboolfalsetrue / falseEnable scaling. Scaling is DPI-only: pixels stay unchanged, physical size set via the PNG resolution (pHYs).
ScalePercentdouble100> 0Scale as a percent of the original size. Ignored when a target mm value is set.
TargetWidthMmdouble0> 0 to applyTarget physical width in mm; a missing side is filled proportionally.
TargetHeightMmdouble0> 0 to applyTarget physical height in mm. For SVG/AI a larger target re-rasterizes at ~300 DPI (long side capped at 8192 px).
EnableBackgroundReplacementboolfalsetrue / falseDetect and remove the background to transparency (before clustering).
BackgroundDetectionModestring"Auto"Auto / ManualAuto = infer the background color by border sampling; Manual = use SourceR/G/B.
SourceRbyte2550-255Manual background color - red channel (Manual mode only).
SourceGbyte2550-255Manual background color - green channel.
SourceBbyte2550-255Manual background color - blue channel.
BackgroundToleranceint300-150Euclidean RGB tolerance for matching background pixels.
RemoveBackgroundEverywhereboolfalsetrue / falseRemove the background color everywhere within tolerance, not only the region flood-filled from the border.
AutoRemoveVectorBackgroundboolfalsetrue / falseFor fully-opaque SVG/AI imports: make the border background transparent at raster time.

Example

{
  "RequestType": "OptimizePng",
  "ACEParaOptimize": {
    "TargetColorCount": 24,
    "NoiseStrength": 5,
    "PreSmoothStrength": 0,
    "ThreadTable": "Amann-Isacord 40",
    "EnableResample": true,
    "TargetWidthMm": 120.0,
    "TargetHeightMm": 120.0,
    "EnableBackgroundReplacement": true,
    "BackgroundDetectionMode": "Manual",
    "SourceR": 244, "SourceG": 209, "SourceB": 157,
    "BackgroundTolerance": 30,
    "RemoveBackgroundEverywhere": false
  }
}