Edit existing images using Flux Kontext Max model, supports precise mask control and multiple aspect ratio outputs
Flux image editing is based on the advanced Flux Kontext Max model, intelligently editing existing images according to text descriptions. Supports precise mask control, local file and online image input, and flexible aspect ratio output settings.
🎯 Precise Editing
Using masks allows precise control of editing areas - white regions will be edited, black regions remain unchanged. Without mask, AI automatically determines editing regions.
From ultra-narrow portrait to ultra-wide landscape
API Method
OpenAI Compatible
Standard Images Edit API
Result URL
10-minute validity
Download promptly
💡 Cost Savings: Calling Flux image editing through APIYI, combined with exchange rate advantage and top-up bonuses, saves over 12.5% compared to official pricing!
🔄 Result Reproducibility: Using the same seed value and identical other parameters yields consistent editing results. This is helpful for debugging and client satisfaction testing.
# Add text to imageadd_text = edit_local_image( image_path="poster.jpg", prompt='Add the text "SALE 50% OFF" in bold red letters at the top center', aspect_ratio="3:2")# Modify existing textmodify_text = edit_local_image( image_path="sign.jpg", prompt='Change the text from "Open" to "Closed"', aspect_ratio="1:1")# Use quotes for text accuracyprecise_text = edit_local_image( image_path="banner.jpg", prompt='Replace the existing text with exactly "Welcome to Our Store"', aspect_ratio="7:3")
# Maintain lighting consistencylighting_edit = edit_local_image( image_path="interior.jpg", prompt="Add a lamp in the corner, matching the existing warm lighting", aspect_ratio="16:9")# Maintain perspective and proportionsperspective_edit = edit_local_image( image_path="street.jpg", prompt="Add a bicycle parked next to the building, matching the street perspective", aspect_ratio="3:2")
# Maintain character featurescharacter_edit = edit_local_image( image_path="person.jpg", prompt="Change the person's shirt to blue while keeping all facial features identical", aspect_ratio="2:3", seed=42 # Use fixed seed for consistency)
# Change backgroundbackground_edit = edit_local_image( image_path="portrait.jpg", prompt="Replace the background with a modern office environment", aspect_ratio="2:3")# Remove backgroundremove_bg = edit_local_image( image_path="product.jpg", prompt="Remove the background, make it transparent", aspect_ratio="1:1")
# Add elementsadd_element = edit_local_image( image_path="room.jpg", prompt="Add a beautiful plant in the corner of the room", aspect_ratio="16:9")# Remove objectsremove_object = edit_local_image( image_path="street.jpg", prompt="Remove the car from the street, replace with empty road", aspect_ratio="3:2")# Replace objectsreplace_object = edit_local_image( image_path="table.jpg", prompt="Replace the apple on the table with an orange", aspect_ratio="1:1")
# Artistic styleartistic_style = edit_local_image( image_path="landscape.jpg", prompt="Transform into an impressionist painting style", aspect_ratio="3:2")# Season changeseason_change = edit_local_image( image_path="park.jpg", prompt="Change from summer to autumn, add colorful fall leaves", aspect_ratio="16:9")
# Use mask for precise area editingmasked_edit = edit_local_image( image_path="group_photo.jpg", prompt="Blur the faces of the people in the masked area", aspect_ratio="3:2", mask_path="face_mask.png" # White areas will be edited)
Based on official documentation professional recommendations:
Copy
# ❌ Vague descriptionprompt = "make it better"# ✅ Specific and detailed instructionsprompt = """Remove the person standing in the background on the left side,fill the area with matching landscape elements,maintain the original lighting and perspective"""# ✅ Text editing with quotestext_prompt = 'Change the store sign text to "OPEN 24/7" in red letters'# ✅ Consistency instructionsconsistency_prompt = """Add a red sports car parked in the driveway,matching the existing lighting conditions and perspective,ensure it fits naturally with the house architecture"""# ✅ Precise local editingprecise_prompt = """Change only the woman's dress color from blue to emerald green,keep all other elements including lighting, background, and pose unchanged"""
A: Flux’s official security design - all result URLs automatically expire 10 minutes after generation. This protects user privacy and reduces server storage pressure.
A: Use tools like Photoshop, GIMP, or generate via code. Key point: white areas (255) will be edited, black areas (0) remain unchanged, gray areas partially edited.
A: Based on official recommendations: use quotes around specific text in prompts, like 'Change the sign to "OPEN 24/7"' for more accurate text results.
A: Can be achieved through multiple API calls, using each edit’s result as next input. Remember to download intermediate results within 10 minutes each time.
Although Flux API natively only supports single image editing, we provide a dual image composition editing solution, particularly suitable for pattern transfer and style fusion scenarios.
Transfer pattern designs to clothing models, auto-adjusts size and position for natural wearing effect
Copy
BATCH_PROMPT="Transfer the pattern/design from the left image to the clothes of the model in the right image, with the size being 2/3 of the width of the chest, located in the middle. Make it look natural and well-integrated."
Artistic Creation
Combine images with different artistic styles to create unique mixed effects
Copy
BATCH_PROMPT="Combine the artistic style from the left image with the subject matter from the right image, creating a harmonious artistic fusion."
Architectural Design
Apply decorative elements to architectural images, preview renovation effects
Copy
BATCH_PROMPT="Apply the decorative elements from the left image to the building in the right image, maintaining architectural harmony."
Batch Processing Tip: Script supports processing multiple image pairs at once, suitable for batch design work. All results and intermediate files are automatically saved for future use.
Dependency Requirements: Script requires jq (JSON processing), Python3 + PIL (image processing), and optional ImageMagick. See built-in script help for detailed installation instructions.
🎨 Professional Advice: For complex editing tasks, recommend testing effects with lower-cost models first, then use Flux Kontext Max for final editing once satisfied.