Create Stunning Custom Images with Hdmi Wireless Actions

27 Apr 2025
Create Stunning Custom Images with Hdmi Wireless Actions

The "Hdmi Wireless" service offers powerful Cognitive Actions that enable developers to create custom images tailored to their specific needs. With the "Generate Custom Image" action, you can transform text prompts into visually captivating images while selecting various parameters such as aspect ratio, image quality, and format. This capability streamlines the creative process, allowing developers to produce high-quality visuals quickly and efficiently.

Imagine a scenario where you're developing an e-commerce application and need eye-catching product images. Instead of relying on stock images or lengthy design processes, you can simply input a descriptive prompt and receive a custom image that perfectly aligns with your vision. This action not only saves time but also enhances the user experience by providing unique visuals that stand out.

Prerequisites

To get started, you'll need an API key for the Cognitive Actions service and a basic understanding of making API calls.

Generate Custom Image

The "Generate Custom Image" action allows you to create a custom image based on an input prompt, offering flexibility in image inpainting, aspect ratio, quality, and format. This action is particularly useful for developers looking to automate the image creation process for applications like marketing, e-commerce, or content generation.

Input Requirements

The input for this action requires a structured JSON object, which includes:

  • prompt: A text description of the desired image, essential for guiding the generation process.
  • mask (optional): A URI for an image mask used in inpainting mode.
  • image (optional): A URI for an input image for image-to-image translation.
  • model: Choose between "dev" for detailed output or "schnell" for faster processing.
  • aspectRatio: Specify the desired aspect ratio, with options for custom dimensions.
  • Additional parameters such as width, height, output count, image quality, and more can be specified to further customize the output.

Expected Output

The action will return a URL to the generated image, which can be used directly in applications or displayed on websites. The output will adhere to the specified format and quality settings.

Use Cases for this specific action

  1. E-commerce Product Images: Generate unique product visuals that capture customer attention.
  2. Marketing Materials: Create tailored images for advertisements, social media posts, or promotional content.
  3. Content Creation: Automate the production of visuals for blogs, articles, and other digital content, enhancing engagement.
  4. Personalized User Experiences: Develop applications that allow users to create custom images based on their preferences.
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 = "e8ab0e42-6a93-4693-b19d-25c3f487c889" # Action ID for: Generate Custom Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "prompt": "Crea una imagen de producto capaz de captar a los clientes de manera visual del TOK en color blanco sostenido en el aire con un fondo blanco  y nítido con un enfoque especial en el TOK , se muestran perfectamente las dos salidas del TOK,una HDMI y USB ,\n",
  "megapixels": "1",
  "aspectRatio": "1:1",
  "outputCount": 1,
  "imageQuality": 80,
  "outputFormat": "webp",
  "guidanceScale": 3,
  "loraIntensity": 1,
  "enableFastMode": false,
  "inferenceSteps": 28,
  "promptStrength": 0.8,
  "additionalLoraIntensity": 1
}

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

The "Generate Custom Image" action within the Hdmi Wireless service offers a robust solution for developers seeking to enhance their applications with custom visuals. By leveraging this action, you can streamline your image creation process, improve user engagement, and deliver tailored content that meets your audience's needs.

As you explore the possibilities, consider integrating this functionality into your projects to see the transformative impact of personalized imagery.