Enhance Your Images with Ic Light's Advanced Relighting Actions

26 Apr 2025
Enhance Your Images with Ic Light's Advanced Relighting Actions

In the world of image processing, achieving the perfect look for your images can often be a challenging task. With "Ic Light," you have access to powerful Cognitive Actions that allow you to relight and enhance images effortlessly. This service brings advanced capabilities to the table, including the ability to generate images at any resolution with customizable lighting directions and quality settings. Whether you're a developer looking to create stunning graphics for a website, an artist wanting to enhance your portfolio, or a marketer needing eye-catching visuals for campaigns, Ic Light provides the tools to simplify and optimize your image enhancement process.

Prerequisites

Before diving into the functionalities of Ic Light, ensure you have your Cognitive Actions API key and a basic understanding of making API calls.

Relight and Enhance Image

Purpose

The "Relight and Enhance Image" action is a powerful tool designed to help you manipulate existing images by relighting them and generating new versions at any desired resolution. This action solves the common problem of static lighting in images, allowing you to create dynamic visuals by adjusting lighting, enhancing quality, and customizing output.

Input Requirements

To use this action, you'll need to provide a set of inputs, including:

  • prompt: A descriptive text guiding the relighting process (e.g., "Woman, detailed face, sci-fi RGB glowing, cyberpunk").
  • subjectImage: The URI of the main image you want to enhance.
  • Additional parameters include options for light source, image dimensions, quality, and various denoising and guidance settings.

Expected Output

The output will be a high-quality image based on your specifications, available in formats such as webp, jpg, or png. The generated images will reflect the adjustments made through your input parameters, delivering unique and visually compelling results.

Use Cases for this Specific Action

  • E-commerce: Enhance product images by adding dynamic lighting effects to make them more appealing to potential buyers.
  • Digital Art: Artists can relight their existing artworks to explore different visual styles and atmospheres.
  • Social Media: Marketers can create eye-catching visuals that stand out in feeds by customizing lighting and enhancing quality.
  • Game Development: Game developers can improve in-game graphics by modifying character or environment images for better realism.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "3a7c2a80-53ca-43a2-aa8f-7a4f4800dfc6" # Action ID for: Relight and Enhance Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "steps": 25,
  "width": 512,
  "height": 640,
  "prompt": "Woman, detailed face, sci-fi RGB glowing, cyberpunk",
  "lightSource": "None",
  "outputFormat": "webp",
  "subjectImage": "https://replicate.delivery/pbxt/LKArbc3pT7J4HBp4avXse2pa7bLbSBjweKjCPGx2CRc7KOZn/i3.png",
  "outputQuality": 100,
  "appendedPrompt": "best quality",
  "negativePrompt": "lowres, bad anatomy, bad hands, cropped, worst quality",
  "numberOfImages": 1,
  "highResolutionScale": 1.5,
  "lowResolutionDenoise": 0.9,
  "highResolutionDenoise": 0.5,
  "classifierFreeGuidanceScale": 2
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

Conclusion

Ic Light's "Relight and Enhance Image" action offers developers a robust solution for enhancing and customizing images with ease. By leveraging this powerful tool, you can transform your images to meet various needs, from marketing to artistic expression. As you explore the capabilities of Ic Light, consider how these enhancements can elevate your projects and engage your audience more effectively. Start integrating these actions today and take your image processing to the next level!