Generate Stunning Image Thumbnails with justmalhar/flux-thumbnails-v2 Cognitive Actions

21 Apr 2025
Generate Stunning Image Thumbnails with justmalhar/flux-thumbnails-v2 Cognitive Actions

In the fast-paced world of digital content, creating eye-catching thumbnails is essential for attracting viewers. The justmalhar/flux-thumbnails-v2 API offers powerful Cognitive Actions that enable developers to generate high-quality image thumbnails efficiently. By utilizing image-to-image transformation and inpainting techniques, this API supports custom dimensions, various output formats, and optimization features that significantly enhance processing speed.

In this blog post, we will explore the Generate Image Thumbnails action, its capabilities, and how you can easily integrate it into your applications to elevate your visual content.

Prerequisites

Before you start using the Cognitive Actions, ensure you have:

  • An API key for the Cognitive Actions platform.
  • The ability to make HTTP requests to interact with the API.

For authentication, you will typically pass your API key in the request headers.

Cognitive Actions Overview

Generate Image Thumbnails

The Generate Image Thumbnails action allows you to create thumbnails from images by applying various transformation techniques. It is designed for image processing and offers numerous parameters to tailor the output according to your needs.

Purpose: Generate image thumbnails using image-to-image transformation or inpainting techniques.

Category: image-processing

Input

The input to this action is defined by the following schema:

{
  "prompt": "string",
  "mask": "string (optional)",
  "seed": "integer (optional)",
  "image": "string (optional)",
  "width": "integer (optional)",
  "height": "integer (optional)",
  "imageFormat": "string (optional)",
  "outputCount": "integer (optional)",
  "denoiseSteps": "integer (optional)",
  "imageQuality": "integer (optional)",
  "modelWeights": "string (optional)",
  "fastInference": "boolean (optional)",
  "loraIntensity": "number (optional)",
  "inferenceModel": "string (optional)",
  "imageMegapixels": "string (optional)",
  "promptIntensity": "number (optional)",
  "imageAspectRatio": "string (optional)",
  "diffusionGuidance": "number (optional)",
  "additionalLoraWeights": "string (optional)",
  "safetyCheckerDisabled": "boolean (optional)",
  "additionalLoraIntensity": "number (optional)"
}

Example Input:

{
  "prompt": "a youtube thumbnail in the style of YTTHUMBNAIL, with text “$5M vs $500M”, a man standing in front of a white ship and a golden cruise",
  "imageFormat": "png",
  "outputCount": 4,
  "denoiseSteps": 50,
  "imageQuality": 100,
  "loraIntensity": 1,
  "inferenceModel": "dev",
  "promptIntensity": 0.8,
  "imageAspectRatio": "16:9",
  "diffusionGuidance": 3.5,
  "additionalLoraIntensity": 1
}

Output

The output of this action consists of an array of image URLs that link to the generated thumbnails.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/c6ebee90-12b4-4c33-b4a8-3a017862a98e/5f88c2d0-1a35-4c1a-8d2d-88caf091582c.png",
  "https://assets.cognitiveactions.com/invocations/c6ebee90-12b4-4c33-b4a8-3a017862a98e/443648b9-fc3f-4534-bd6a-37abf1489b11.png",
  "https://assets.cognitiveactions.com/invocations/c6ebee90-12b4-4c33-b4a8-3a017862a98e/8e8aaf96-6b3b-4b5d-923a-02c99af5ce95.png",
  "https://assets.cognitiveactions.com/invocations/c6ebee90-12b4-4c33-b4a8-3a017862a98e/108fa93a-d56a-4b00-982f-d44983ec205e.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how you can invoke the Generate Image Thumbnails action using Python:

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 = "b5878532-fb9f-4081-8b19-8f805920c623" # Action ID for Generate Image Thumbnails

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "a youtube thumbnail in the style of YTTHUMBNAIL, with text “$5M vs $500M”, a man standing in front of a white ship and a golden cruise",
    "imageFormat": "png",
    "outputCount": 4,
    "denoiseSteps": 50,
    "imageQuality": 100,
    "loraIntensity": 1,
    "inferenceModel": "dev",
    "promptIntensity": 0.8,
    "imageAspectRatio": "16:9",
    "diffusionGuidance": 3.5,
    "additionalLoraIntensity": 1
}

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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and use the action ID provided for Generate Image Thumbnails. The input payload is structured according to the action's requirements, ensuring you include all necessary parameters.

Conclusion

The Generate Image Thumbnails action from the justmalhar/flux-thumbnails-v2 API simplifies the process of creating visually appealing thumbnails for various applications. With a range of customizable options, you can produce high-quality images tailored to your specific needs.

Feel free to experiment with different parameters and explore the possibilities of this powerful tool in your projects! Happy coding!