- Media API
- Transformations
- Adjust
- blackAndWhite
blackAndWhite
The blackAndWhite transformation converts an image to pure black and white (binary) with an adjustable threshold. This creates a high-contrast posterized effect where pixels are either completely black or completely white. Useful for creating sketches, documents, or artistic effects.
Serving Content via CDN
The Media API is a CDN-based service that serves transformed images via GET requests. When you request a transformed image URL, the transformation is applied dynamically on the first request and then cached for subsequent requests.
URL Pattern
https://media.vyso.io/black-and-white:threshold=50/ASSET_ID.jpgExamples
Standard Black and White (Balanced Threshold)
curl -i GET https://media.vyso.io/black-and-white:threshold=50/ASSET_ID.jpgLow Threshold (More Black)
curl -i GET https://media.vyso.io/black-and-white:threshold=20/ASSET_ID.jpgHigh Threshold (More White)
curl -i GET https://media.vyso.io/black-and-white:threshold=80/ASSET_ID.jpgNo Threshold (Pure Binary)
curl -i GET https://media.vyso.io/black-and-white:threshold=0/ASSET_ID.jpgMaximum Threshold
curl -i GET https://media.vyso.io/black-and-white:threshold=100/ASSET_ID.jpgOn the first request, you'll receive a X-Cache: MISS header while the transformation is applied and cached. Subsequent requests will return X-Cache: HIT.
Parameters
thresholdREQUIREDThreshold value for determining black vs white. Accepted values:
0- Mostly black image (low threshold, preserves only brightest details)50- Balanced black and white (medium threshold, default)100- Mostly white image (high threshold, preserves only darkest details)- Range: 0-100 (representing percentage)
- Decimal values are supported (e.g.,
35.5)
Response
The API returns a binary black and white version of the image with pixels converted to either pure black or pure white based on the threshold value. The response format depends on the format of the asset stored in the Vyso asset cloud.
Content-Type: Determined by the stored asset format (e.g., image/jpeg, image/png)