GET
/
transform

How to use

The background_color transformation allows you to set a background color for transparent images.

Pass the following query param to the API endpoint:

background_color=color

Where:

  • color is either a color name or a hexadecimal RGB value without the ”#” character.

For example: background_color=red or background_color=FF0000

Parameter

color: The color to set as the background. This parameter accepts two formats:

  • Color name (e.g., “red”, “blue”, “green”)
  • Hexadecimal RGB value without the ”#” character (e.g., “FF0000” for red)

Effect of Background Color

  • Fills transparent areas of the image with the specified color.
  • Useful for converting transparent images to a solid background.
  • Can be used to create consistent backgrounds for images with varying levels of transparency.

This transformation is particularly useful when working with transparent PNG or WebP images and you need to set a solid background color.

Original Image

URL : https://www.thunderimage.com/sample/yosemite.png

Image with Red Background

URL: /transform?url=https://www.thunderimage.com/sample/yosemite.png&background_color=red

Image with Light Blue Background (using hex color)

URL: /transform?url=https://www.thunderimage.com/sample/yosemite.png&background_color=87CEEB

Best Practices

  • Use color names for common colors and hexadecimal values for more specific color choices.
  • Consider the contrast between the background color and the non-transparent parts of the image.
  • When using the image on a website, try to match the background color with the page background for seamless integration.
  • Remember that this transformation only affects transparent areas of the image; it will not change any opaque parts.
  • If you’re unsure about the exact color to use, consider using a color picker tool to get the hexadecimal value.
  • For images that will be printed, ensure you’re using the correct color values (e.g., CMYK equivalents) for accurate reproduction.

Note

The background_color transformation is most effective with images that have transparency. For fully opaque images, this transformation will have no visible effect. Also, note that some image formats (like JPEG) do not support transparency, so applying this transformation to such formats will not produce any change in the image.

Authorizations

x-api-key
string
headerrequired

API key required for authentication

Query Parameters

url
string
required

The URL of the image to be transformed.

background_color
string

Sets the background color of a transparent image. Accepts a color name or hexadecimal RGB expression without the '#' character.

Response

200 - image/jpeg

The transformed image in JPEG format.