Transform Eye Colors Effortlessly with hazxone/eye-color Cognitive Actions

25 Apr 2025
Transform Eye Colors Effortlessly with hazxone/eye-color Cognitive Actions

Integrating visual enhancements into your applications has never been easier, thanks to the hazxone/eye-color Cognitive Actions. This set of actions is tailored for image processing, enabling developers to manipulate eye colors in images seamlessly. Whether you’re building a photo editing app, a fun filter feature, or just want to experiment with eye colors, these pre-built actions simplify the process and enhance user engagement.

Prerequisites

Before diving into the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, allowing you to authenticate your requests.
  • Basic knowledge of making HTTP requests from your development environment.

Authentication generally involves passing your API key in the request headers, ensuring secure access to the Cognitive Actions.

Cognitive Actions Overview

Change Iris Color

The Change Iris Color action allows you to adjust the eye color in images. You can choose from a variety of colors like Green, Red, Blue, SaddleBrown, Orange, and Purple. It also features a transparency slider to customize the color's opacity, ensuring that the changes blend well with the original image. This action works best with images where the eyes are wide open.

Input

The input for this action requires the following fields:

  • image (string, required): A valid URI pointing to the input image.
  • eyeColor (string, optional): The desired eye color from the options: 'Green', 'Red', 'Blue', 'SaddleBrown', 'Orange', 'Purple'. Defaults to 'Blue'.
  • alpha (number, optional): Specifies the transparency of the chosen color. Must be a value between 0.1 and 0.4, with a default of 0.15.
Example Input
{
  "alpha": 0.13,
  "image": "https://replicate.delivery/pbxt/KkfwbYVaoHXUexqWn85qP40IX5wd1FBasMfHrChwESvyjtTq/Jurica%20Koletic%20Unsplash.jpg",
  "eyeColor": "Red"
}

Output

Upon successful execution, the action returns a URL pointing to the modified image with the adjusted eye color.

Example Output
https://assets.cognitiveactions.com/invocations/b4440a3f-5963-4601-aa12-dfa42fd11b61/2527e903-bdd0-4b3a-9188-fa5f81c2165c.png

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call the Change Iris Color action:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "592dbe03-6ddb-41dd-92de-24c62839b7e5" # Action ID for Change Iris Color

# Construct the input payload based on the action's requirements
payload = {
    "alpha": 0.13,
    "image": "https://replicate.delivery/pbxt/KkfwbYVaoHXUexqWn85qP40IX5wd1FBasMfHrChwESvyjtTq/Jurica%20Koletic%20Unsplash.jpg",
    "eyeColor": "Red"
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this snippet, replace the COGNITIVE_ACTIONS_API_KEY with your actual API key and specify the endpoint URL as needed. The action_id corresponds to the Change Iris Color action, while the payload is structured according to the required input schema.

Conclusion

The hazxone/eye-color Cognitive Actions, particularly the Change Iris Color, provide an efficient way to enhance images by changing eye colors dynamically. With just a few lines of code, developers can seamlessly integrate fun and engaging features into their applications. Explore this action further, experiment with different parameters, and see how you can innovate your image-processing solutions!