Qwen Image Edit
Advanced text-based image editing using the Qwen Image Edit model through the ImagineoAI API. This model enables powerful AI-driven image transformations using natural language prompts.
Overview
The Qwen Image Edit model is a ComfyDeploy-powered AI model that specializes in text-based image editing. It allows you to describe changes to images using natural language, with support for both positive and negative prompts for precise control over the output.
Method
The Qwen Image Edit model is accessed through the standard generate method with model_type: "qwen-image-edit":
Signature:
client.images.generate(input: GenerateImageInput): Promise<GenerateImageOutput | null>
Parameters
Required Parameters
prompt(string): The text prompt describing the desired edit or transformationmodel_type(string): Must be set to"qwen-image-edit"width(number): Output image width in pixels (64-2048)height(number): Output image height in pixels (64-2048)
Optional Parameters
lora_1(string): Optional LoRA model name for style enhancementstrength_model(number): LoRA model strength (0-2, default: 1)negative_prompt(string): Text describing what to avoid in the generationwebhook_url(string): URL for receiving completion notificationswebhook_secret(string): Secret for webhook authentication
Examples
Basic Image Edit
Transform an image with a simple text prompt:
const client = new ImagineoAIClient(apiUrl, { apiKey: 'sk-...' });
const result = await client.images.generate({
prompt: 'Make the scene more vibrant and colorful with a sunset atmosphere',
model_type: 'qwen-image-edit',
width: 1024,
height: 1024,
});
if (result) {
console.log('Edited image URL:', result.image_url);
console.log('Run ID:', result.run_id);
}
Advanced Edit with Negative Prompt
Use negative prompts to avoid specific elements:
const result = await client.images.generate({
prompt: 'Transform into a fantasy landscape with magical floating islands',
negative_prompt: 'modern buildings, cars, technology, people',
model_type: 'qwen-image-edit',
width: 1920,
height: 1080,
});
Style Enhancement with LoRA
Apply a specific style using a LoRA model:
const result = await client.images.generate({
prompt: 'Apply an artistic watercolor painting style to the image',
model_type: 'qwen-image-edit',
lora_1: 'watercolor-style-v2',
strength_model: 1.5, // Increase LoRA influence
width: 1024,
height: 1024,
});
Complex Scene Transformation
Perform complex transformations with detailed prompts:
const result = await client.images.generate({
prompt: 'Transform the urban street into a cyberpunk scene with neon lights, holographic advertisements, flying vehicles, and rain-slicked streets reflecting the lights',
negative_prompt: 'daylight, traditional signs, clear sky',
model_type: 'qwen-image-edit',
lora_1: 'cyberpunk-aesthetic-v3',
strength_model: 1.2,
width: 1920,
height: 1080,
});
Webhook Integration
Set up webhooks for asynchronous processing:
const result = await client.images.generate({
prompt: 'Convert the photograph into a detailed pencil sketch',
model_type: 'qwen-image-edit',
width: 1024,
height: 1024,
webhook_url: 'https://your-server.com/webhook/qwen-complete',
webhook_secret: 'your-webhook-secret'
});
// The webhook will receive updates when the edit is complete
Use Cases
1. Style Transfer
Transform images into different artistic styles:
- Convert photos to paintings, sketches, or digital art
- Apply specific art movement styles (impressionist, cubist, etc.)
- Create themed variations (fantasy, sci-fi, vintage)
2. Scene Modification
Change environmental aspects of images:
- Time of day transformations (day to night)
- Season changes (summer to winter)
- Weather effects (add rain, snow, fog)
3. Object Manipulation
Modify or enhance specific elements:
- Change colors or textures
- Add or remove objects (using negative prompts)
- Transform objects into different materials
4. Mood and Atmosphere
Adjust the emotional tone of images:
- Make scenes more dramatic or peaceful
- Add cinematic effects
- Enhance lighting and shadows
Best Practices
Prompt Engineering
-
Be Specific: Provide detailed descriptions of desired changes
// Good
prompt: 'Transform the modern office into a Victorian-era library with wooden bookshelves, leather-bound books, and warm gas lamp lighting'
// Less effective
prompt: 'Make it old-fashioned' -
Use Negative Prompts: Explicitly exclude unwanted elements
negative_prompt: 'modern technology, plastic, neon lights, contemporary furniture' -
Layer Your Instructions: Break complex edits into clear components
prompt: 'First, change the time to golden hour sunset. Second, add warm orange and pink tones to the sky. Finally, create long shadows and warm lighting on all surfaces'
LoRA Models
- Use LoRA models for consistent style application
- Adjust
strength_modelbased on desired intensity (0.5-1.5 typically works best) - Lower values (0.5-0.8) for subtle enhancements
- Higher values (1.2-2.0) for dramatic transformations
Performance Tips
- Resolution: Start with lower resolutions for testing (512x512), then increase for final outputs
- Batch Processing: Use webhooks for multiple edits to avoid blocking
- Caching: Store successful prompts and settings for reuse
Error Handling
try {
const result = await client.images.generate({
prompt: 'Transform into watercolor painting',
model_type: 'qwen-image-edit',
width: 1024,
height: 1024,
});
if (result) {
console.log('Success:', result.image_url);
} else {
console.log('No content returned (204)');
}
} catch (error) {
if (error.code === 'VALIDATION_ERROR') {
console.error('Invalid parameters:', error.message);
} else if (error.code === 'INSUFFICIENT_CREDITS') {
console.error('Not enough credits for this operation');
} else {
console.error('Unexpected error:', error);
}
}
Integration with Other Features
Combining with Other Models
You can chain Qwen Image Edit with other models for complex workflows:
// Step 1: Edit with Qwen
const editResult = await client.images.generate({
prompt: 'Transform into fantasy landscape',
model_type: 'qwen-image-edit',
width: 1024,
height: 1024,
});
// Step 2: Upscale the result
if (editResult) {
const upscaleResult = await client.images.upscale({
original_run_id: editResult.run_id,
scale_factor: 2
});
}
Working with Run IDs
The returned run_id can be used to:
- Track the generation status
- Reference the image in other operations
- Retrieve the image later
- Use as input for other transformations
Limitations
- Maximum resolution: 2048x2048 pixels
- LoRA strength range: 0-2
- Processing time varies based on complexity and resolution
- Credits are consumed based on image dimensions
See Also
- Generate Method - Main generation method documentation
- API Reference - Complete type definitions
- Usage Guide - General SDK usage patterns