Transform Your Images into Stunning Ghibli Art with Mirage Ghibli

25 Apr 2025
Transform Your Images into Stunning Ghibli Art with Mirage Ghibli

In the world of digital art, the ability to transform images into unique styles can greatly enhance creativity and engagement. Mirage Ghibli offers an innovative solution with its Cognitive Action, "Ghiblify Image." This action allows developers to convert any image into a captivating Ghibli anime style, all while being significantly faster and more cost-effective than traditional methods. By leveraging this action, you can streamline your creative projects, enhance visual storytelling, and captivate your audience with beautifully stylized images.

Imagine using this technology for various applications such as creating personalized gifts, enhancing social media content, or even generating unique artwork for games and animations. The possibilities are endless, making it a valuable tool for artists, marketers, and developers alike.

Prerequisites

Before diving into the implementation, ensure you have a Cognitive Actions API key and a basic understanding of how to make API calls. This will facilitate a smooth integration of the Ghiblify Image action into your projects.

Ghiblify Image

The "Ghiblify Image" action is designed to transform your standard images into enchanting Ghibli-style artwork. It addresses the challenge of creating visually appealing and stylistically coherent images without the need for extensive manual editing or artistic skills.

Input Requirements

To utilize this action, you'll need to provide the following inputs:

  • image (string): The URI of the input image you wish to transform.
  • prompt (string): A text description of the desired features, enhancing the activation of specific styles.
  • goFast (boolean): An optional flag to enable faster image generation.
  • aspectRatio (string): The desired aspect ratio for the output image.
  • numOutputs (integer): The number of images you want to generate.
  • outputFormat (string): The desired format for the output image (e.g., webp, jpg, png).
  • Additional parameters like guidanceScale, outputQuality, and numInferenceSteps can further refine the output.

Expected Output

The output will be a URI linking to the generated Ghibli-style image. For example:

  • https://assets.cognitiveactions.com/invocations/4ec8fbc5-9e6f-47cf-b66a-80a54ad91aaf/a75affdc-cf86-4444-bbca-a2d894b7a229.webp

Use Cases for this Specific Action

  • Personalized Gifts: Create unique artwork for friends or family by transforming their photos into Ghibli-style illustrations.
  • Social Media Engagement: Enhance your social media posts with eye-catching visuals that stand out in a crowded feed.
  • Game Development: Generate character designs or backgrounds that embody the whimsical and adventurous spirit of Ghibli films.

By employing the Ghiblify Image action, developers can significantly enhance their visual content creation processes, making it easier to produce high-quality, stylized images without extensive resources.

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 = "4e3ebe99-00e4-44a1-9a49-4b55144c7e62" # Action ID for: Ghiblify Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "image": "https://replicate.delivery/pbxt/Mjo5VWBA0fm8oq3BefpbdtXeJitBJc6AobPnnMdFxxCKzT3P/linkedin.jpeg",
  "goFast": true,
  "prompt": "GHBLI anime style photo",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 10,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.75,
  "imageResolution": "1",
  "numInferenceSteps": 28
}

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 Mirage Ghibli Cognitive Action provides a powerful tool for developers looking to infuse their projects with artistic flair. By leveraging the Ghiblify Image action, you can easily transform standard images into stunning Ghibli-style art, making it a perfect solution for a variety of applications. Whether you're creating personalized gifts, enhancing digital content, or developing engaging visuals for games, this action simplifies the process and delivers impressive results.

Ready to get started? Integrate the Ghiblify Image action into your workflow and watch your creative possibilities unfold!