Image Operations - Automatic Enhancements

Image Operations / Automatic Enhancements

On this page:

With Automatic Enhancements you can automatically adjust the image's shadow details, contrast, saturation and color of a face to give pleasing skin tones. Automatic Enhancements are also used to repair red eye artifacts due to camera flash.

All automatic enhancements must be passed within the auto hash:

{
    "auto": {
        "enhance": true,
        "redeye": true
    }
}

Enhancements

To enable Automatic Enhancements you have to set enhanace to true within the auto hash. Lets have a look at the example output produced by the auto enhancement feature.

{
    "auto": {
        "enhance": true
    }
}
Given the input image 750px × 400px
Automatic Enhancements Input
Automatically enhance it by adjusting shadow details, contrast, saturation and skin color
Automatic Enhancements Output

Red Eye Removal

In order to automatically repair red eye artifacts due to camera flash, simply set redeye to true within the auto hash.

{
    "auto": {
        "redeye": true
    }
}
Given the input image 750px × 400px
Red Eye Removal Input
Automatically repair red eye artifact
Red Eye Removal Output

Code Examples for Automatic Enahncements

Below, you'll find examples of how to use Automatic Enahncements from the Optidash API:

  • PHP
  • Node
  • Ruby
  • Go
  • Python
  • Java
<?php

/**
* Instantiate new `$opti` by calling a constructor
*/

$opti = new Optidash\Optidash('your-api-key');

/**
* Provide a publicly available image URL with fetch(string) method
* and automatically enhance the image by setting enhance: true
*/

$opti
    ->fetch('https://www.website.com/image.jpg')
    ->auto(array(
        'enhance' => true
    ))
    ->toJSON(function ($error, $meta) {
        if (!empty($error)) {
            throw new Exception($error);
        }

        /**
        * You'll find the full JSON metadata array within the `$meta` variable.
        * Remember to always check if the `success` property is set to `true`.
        */

        if ($meta['success'] == true) {
            print ($meta['output']['url']);
        } else {
            print ($meta['message']);
        }
    });
/**
* Module dependencies
*/

const Optidash = require("optidash");

/**
* Instantiate new `opti` by calling a constructor
*/

const opti = new Optidash("your-api-key");

/**
* Provide a publicly available image URL with fetch(string) method
* and automatically enhance the image by setting enhance: true
*/

opti
    .fetch("https://www.website.com/image.jpg")
    .auto({
        enhance: true
    })
    .toJSON((err, meta) => {
        if (err) {
            return console.log(err);
        }

        /**
        * You'll find the full JSON metadata hash within the `meta` variable.
        * Remember to always check if the `success` property is set to `true`.
        */

        if (meta.success) {
            console.log(meta.output.url);
        } else {
            console.log(meta.message);
        }
    });
##
# Require dependencies

require "optidash"

##
# Instantiate new `opti` by calling a constructor

opti = Optidash.new("your-api-key")

##
# Provide a publicly available image URL with fetch(string) method
# and automatically enhance the image by setting enhance: true

err, meta = opti
    .fetch("https://www.website.com/image.jpg")
    .auto(
        enhance: true
    )
    .to_json

abort(err) if err

##
# You'll find the full JSON metadata hash within the `meta` variable.
# Remember to always check if the `success` property is set to `true`.

if meta["success"]
    puts meta["output"]["url"]
else
    puts meta["message"]
end
package main

/**
* Import dependencies
*/

import (
    "fmt"
    "github.com/optidash/optidash-go"
)

func main() {

    /**
    * Instantiate new `opti` by calling a constructor
    */

    opti, err := optidash.NewClient("your-api-key")

    if err != nil {
        panic(err)
    }

    /**
    * Provide a publicly available image URL with Fetch(string) method
    * and automatically enhance the image by setting enhance: true
    */

    meta, err := opti.
        Fetch("https://www.website.com/image.jpg").
        Auto(optidash.P{
            "enhance": true
        }).
        ToJSON()

    if err != nil {
        panic(err)
    }

    /**
    * You'll find the full JSON metadata hash within the `meta` variable.
    * Remember to always check if the `success` property is set to `true`.
    */

    if meta["success"].(map[string]interface{})["success"].(bool) {
        fmt.Println(meta["output"].(map[string]interface{})["url"])
    } else {
        fmt.Println(meta["message"])
    }
}
##
# Import dependencies

from optidash import optidash

##
# Instantiate new `opti` by calling a constructor

opti = optidash('your-api-key')

##
# Provide a publicly available image URL with fetch(string) method
# and automatically enhance the image by setting enhance: true

err, meta = (
    opti
        .fetch('https://www.website.com/image.jpg')
        .auto({
            'enhance': True
        })
        .toJSON()
)

if err is not None:
    raise StandardError(err)

##
# You'll find the full JSON metadata hash within the `meta` variable.
# Remember to always check if the `success` property is set to `true`.

if meta['success'] is True:
    print (meta['output']['url'])
else:
    print (meta['message'])
package com.optidash.examples;

/**
* Import dependencies
*/

import static com.optidash.OperationConfiguration.settings;
import com.optidash.Optidash;
import com.optidash.Fetch;
import com.optidash.Response;

public class Enhancements {
    public static void main(String[] args) {

        /**
        * Instantiate new `opti` by calling a constructor
        */

        Optidash opti = new Optidash("your-api-key");

        /**
        * Provide a publicly available image URL with fetch(string) method
        * and automaticaly enhance the image by setting enhance: true
        */

        final Fetch fetch = opti.fetch("https://www.website.com/image.jpg");

        fetch.auto(
            settings()
                .set("enhance", true)
        );

        final Response response = fetch.toJson();

        /**
        * You'll find the full JSON metadata hash within the `Response#getMetadata()` variable.
        * Remember to always check if the `Response#successful` property is set to `true`.
        */

        if (response.isSuccessful()) {
            System.out.println(response.getMetadata().getOutput().get("url"));
        } else {
            System.out.println(response.getMessage());
        }
    }
}
Grace Przemek Magda Damian
Have questions? Let's talk!We usually respond in just under an hour

Thanks for reaching out!

We've received your message
and will get to it as quickly as possible.

Whoops, looks like something went wrong.

We encountered an unexpected error and cannot complete your request. Please try reloading the page.