Documentation Index Fetch the complete documentation index at: https://documentation.bannerify.co/llms.txt
Use this file to discover all available pages before exploring further.
create_image
Generate an image from a template with optional modifications.
client.create_image(
template_id: str ,
modifications: Optional[List[Dict[ str , Any]]] = None ,
format : str = "png" ,
thumbnail: bool = False
) -> Dict[ str , Any]
Parameters
The template ID (e.g., ‘tpl_xxxxxxxxx’)
Array of modifications to apply to the template Toggle element visibility
Output format: ‘png’, ‘jpeg’, or ‘webp’
Generate thumbnail version
Returns
Returns a dict with either result or error:
# Success
{
"result" : bytes # Image data
}
# Error
{
"error" : {
"code" : str ,
"message" : str ,
"docs" : str
}
}
Examples
Basic Image Generation
from bannerify import BannerifyClient
client = BannerifyClient( "your-api-key" )
result = client.create_image( "tpl_xxxxxxxxx" )
if "result" in result:
with open ( "output.png" , "wb" ) as f:
f.write(result[ "result" ])
print ( "Image created successfully!" )
With Modifications
result = client.create_image(
"tpl_xxxxxxxxx" ,
modifications = [
{ "name" : "title" , "text" : "Welcome to Bannerify" },
{ "name" : "subtitle" , "text" : "Generate images at scale" },
{ "name" : "logo" , "src" : "https://example.com/logo.png" }
]
)
Generate WebP
result = client.create_image(
"tpl_xxxxxxxxx" ,
format = "webp" ,
modifications = [
{ "name" : "title" , "text" : "WebP Output" }
]
)
if "result" in result:
with open ( "output.webp" , "wb" ) as f:
f.write(result[ "result" ])
Generate Thumbnail
result = client.create_image(
"tpl_xxxxxxxxx" ,
thumbnail = True
)
Error Handling
result = client.create_image(
"tpl_xxxxxxxxx" ,
modifications = [
{ "name" : "title" , "text" : "Test" }
]
)
if "error" in result:
print ( f "Error Code: { result[ 'error' ][ 'code' ] } " )
print ( f "Message: { result[ 'error' ][ 'message' ] } " )
print ( f "Documentation: { result[ 'error' ][ 'docs' ] } " )
else :
with open ( "output.png" , "wb" ) as f:
f.write(result[ "result" ])
Use Cases
Dynamic Marketing Banners
products = [
{ "name" : "Product A" , "price" : "$29.99" , "image" : "https://example.com/a.jpg" },
{ "name" : "Product B" , "price" : "$39.99" , "image" : "https://example.com/b.jpg" },
]
for i, product in enumerate (products):
result = client.create_image(
"tpl_product_banner" ,
modifications = [
{ "name" : "product_name" , "text" : product[ "name" ]},
{ "name" : "price" , "text" : product[ "price" ]},
{ "name" : "product_image" , "src" : product[ "image" ]}
]
)
if "result" in result:
with open ( f "banner_ { i } .png" , "wb" ) as f:
f.write(result[ "result" ])
Social Media Posts
from datetime import datetime
result = client.create_image(
"tpl_social_post" ,
modifications = [
{ "name" : "headline" , "text" : "New Blog Post!" },
{ "name" : "author" , "text" : "John Doe" },
{ "name" : "date" , "text" : datetime.now().strftime( "%B %d , %Y" )}
]
)
Toggle Visibility
result = client.create_image(
"tpl_xxxxxxxxx" ,
modifications = [
{ "name" : "watermark" , "visible" : False },
{ "name" : "badge" , "visible" : True }
]
)