Image Operations - Filtering

Image Operations / Filtering

The Optidash Image API equips you with an extensive collection of high-quality filters you can apply to your images. From various modes of image blurring to sepia, duotone, monochrome, halftone, and color replacement, you have the flexibility to stack as many different filters together as you wish.

All filtering parameters must be passed within a filter hash, and every filter, at minimum, accepts a value which takes a positive float within the range 0 - 100. For example, to apply a pixelate filter:

{
    "filter": {
        "pixellate": {
            "value": 10
        }
    }
}

An example cURL request using the Image Fetch method to apply a pixelate filter will look like the following:

curl https://api.optidash.ai/1.0/fetch
     --user your-api-key: \
     --header "Content-Type: application/json" \
     --data '{
         "url": "https://www.website.com/image.jpg",
         "filter": {
             "pixellate": {
                 "value": 10
             }
         }
     }'

Using Multiple Filters

You can stack different filters together by adding additional filters within the filter hash. For example, to apply a Sepia Tone filter together with Gaussian Blur:

{
    "filter": {
        "sepia": {
            "value": 10
        },
        "blur": {
            "mode": "gaussian",
            "value": 10
        }
    }
}

Duotone

This highly artistic filter maps two input colors onto the dark and light areas of an image. The resulting image is then represented only with shades of the two input colors.

The Duotone filter requires two parameters: light and dark, which are color values mapped onto the grayscaled input image. Both parameters accept a color value as a hex-encoded string in RGB or RRGGBB format.

{
    "filter": {
        "duotone": {
            "light": "6AFF7F",
            "dark": "00007E"
        }
    }
}

Gaussian Blur

One of the most popular blurring algorithms, Gaussian Blur, mixes a fraction of the color of neighboring pixels by applying a convolution kernel. This effect makes sharp color transitions appear more gradual, resulting in a softened or blurred image.

To utilize the Gaussian Blur filter, you must set the blur filter mode to gaussian and specify a value that describes the amount of blur applied to the input image, within a range of 0 - 100.

{
    "filter": {
        "blur": {
            "mode": "gaussian",
            "value": 10
        }
    }
}

Sepia Tone

This filter adjusts the color of each pixel so they adopt reddish-brown tones, evoking a vintage atmosphere.

To apply the Sepia Tone filter, set a value within the sepia hash that describes the amount of brown shading applied to the image, with a float range of 0 - 100.

{
    "filter": {
        "sepia": {
            "value": 10
        }
    }
}

Pixelate

The Pixelate filter transforms the image into colored squares, the color of which is defined by the average color of the pixels being replaced.

To employ the Pixelate filter, set a value within the pixelate hash that indicates the size of the image pixelation, with a float range of 0 - 100.

{
    "filter": {
        "pixellate": {
            "value": 10
        }
    }
}

Monochrome

This filter remaps the color of each pixel so that it aligns with shades of a single color, effectively applying a monochromatic hue over the image.

To use the Monochrome filter, set a value within the monochrome hash that specifies the intensity of the monochromatic hue, along with a color parameter that accepts a hex-encoded string in RGB, RRGGBB, or AARRGGBB format. For example, to apply a semi-transparent blue hue (750015FF):

{
    "filter": {
        "monochrome": {
            "value": 10,
            "color": "750015FF"
        }
    }
}