File size: 1,913 Bytes
0362b52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from typing import Dict, Any, Optional
from services import (
    lifestyle_shot_by_text,
    add_shadow,
    create_packshot,
    generate_hd_image
)

def generate_ad_set(
    api_key: str,
    image: Optional[bytes] = None,
    prompt: Optional[str] = None,
    config: Dict[str, Any] = None
) -> Dict[str, Any]:
    """
    Generate a set of product ads based on configuration.
    """
    if not config:
        config = {}
    
    result = {}
    
    # Generate HD image if prompt provided
    if prompt and not image:
        hd_response = generate_hd_image(
            api_key=api_key,
            prompt=prompt,
            num_results=config.get("num_results", 1),
            aspect_ratio=config.get("aspect_ratio", "1:1"),
            sync=config.get("sync", True)
        )
        result["hd_image"] = hd_response
        image = hd_response.get("result_url")
    
    # Create packshot if requested
    if config.get("create_packshot", False) and image:
        packshot_response = create_packshot(
            api_key=api_key,
            image_data=image,
            background_color=config.get("background_color", "#FFFFFF")
        )
        result["packshot"] = packshot_response
    
    # Add shadow if requested
    if config.get("add_shadow", False) and image:
        shadow_response = add_shadow(
            api_key=api_key,
            image_data=image,
            shadow_type=config.get("shadow_type", "natural")
        )
        result["shadow"] = shadow_response
    
    # Create lifestyle shot if requested
    if config.get("lifestyle_shot", False) and image:
        lifestyle_response = lifestyle_shot_by_text(
            api_key=api_key,
            image_data=image,
            scene_description=config.get("scene_description", ""),
            num_results=config.get("num_results", 1)
        )
        result["lifestyle"] = lifestyle_response
    
    return result