Transform Your Images with Photomaker's Custom Styling Actions

25 Apr 2025
Transform Your Images with Photomaker's Custom Styling Actions

In today's digital landscape, creating visually captivating content is more important than ever. Photomaker offers a powerful suite of Cognitive Actions designed to help developers generate customized images tailored to their specific needs. By leveraging advanced image-to-image models, Photomaker allows for the seamless creation of photos, paintings, and avatars in various artistic styles. Whether you're looking to enhance marketing materials, create unique social media content, or develop personalized avatars for applications, Photomaker simplifies the process, saving you time and effort while delivering stunning results.

Prerequisites

To get started with Photomaker, you'll need an API key for the Cognitive Actions service and a basic understanding of how to make API calls.

Generate Styled Images

Purpose

The "Generate Styled Images" action allows you to create customized visual content by transforming an input image into a new style. This capability is perfect for developers looking to produce unique artwork or personalized images based on existing photos. With adjustable fidelity and a variety of style options, you can achieve the desired aesthetic for your project.

Input Requirements

To utilize this action, you must provide the following inputs:

  • Input Image: A URI of the initial image you want to modify (required).
  • Prompt: A descriptive phrase that guides the image generation (default: "A photo of a person img").
  • Style Template Name: Select from predefined styles like "Cinematic," "Digital Art," or "Fantasy art" (default: "Photographic (Default)").
  • Guidance Scale: A value from 1 to 10 that influences how closely the generated image adheres to the prompt (default: 5).
  • Number of Steps: The number of sampling steps for image generation, ranging from 1 to 100 (default: 20).
  • Negative Prompt: Elements to avoid in the generated image (default includes various undesirable qualities).
  • Number of Outputs: Specify how many variations you want (default: 1).
  • Style Strength Percentage: A percentage that defines the strength of the style applied (default: 20%).

Expected Output

The output will be a URI linking to the generated image(s) based on your parameters. For example, a successful request may return a link to a beautifully styled image that aligns with the provided prompt and style template.

Use Cases for this Action

  1. Marketing Materials: Create eye-catching visuals for promotional campaigns that stand out from the competition.
  2. Social Media Content: Generate unique images that capture attention and engage followers on platforms like Instagram and Facebook.
  3. Personalized Avatars: Develop custom avatars for user profiles in applications or gaming platforms, allowing for greater user engagement.
  4. Artistic Projects: Transform ordinary photos into stunning pieces of art for exhibitions or personal collections.
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 = "fd5976a7-c92e-40e9-afa2-bba1b1149425" # Action ID for: Generate Styled Images

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "A photo of a scientist img receiving the Nobel Prize",
  "inputImage": "https://replicate.delivery/pbxt/KFkSv1oX0v3e7GnOrmzULGqCA8222pC6FI2EKcfuCZWxvHN3/newton_0.jpg",
  "guidanceScale": 5,
  "numberOfSteps": 50,
  "negativePrompt": "nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry",
  "numberOfOutputs": 1,
  "styleTemplateName": "Photographic (Default)",
  "styleStrengthPercentage": 20
}

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

Photomaker's "Generate Styled Images" action empowers developers to create customized and visually appealing content with ease. By providing a flexible set of parameters and style options, this action can be applied across various industries, from marketing to gaming. Embrace the power of AI-driven image generation and explore how Photomaker can enhance your projects today. As you dive into the capabilities of this action, consider experimenting with different styles and prompts to see how they can elevate your visual content.