""" Lahr Carpet Cleaning — Gemini Imagen hero image generator. Generates: hero living room, cleaning in progress, clean result. Saves to: assets/images/hero/ Run: python3 tools/gen-images.py """ import os import sys try: from google import genai from google.genai import types except ImportError: print("Installing google-genai...") os.system(f"{sys.executable} -m pip install google-genai --quiet") from google import genai from google.genai import types API_KEY = os.environ.get("GEMINI_API_KEY", "AIzaSyB_1p8KvaT_rdNJGPs8HKk8bKsvUlcL6Kg") OUT_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "assets", "images", "hero") os.makedirs(OUT_DIR, exist_ok=True) client = genai.Client(api_key=API_KEY) IMAGES = [ { "name": "hero-living-room", "prompt": ( "Luxurious modern living room with spotlessly clean cream carpet, " "natural light streaming through large windows, contemporary furniture, " "professional interior photography, warm inviting atmosphere, no people, " "ultra-realistic, 8K quality" ), "aspect": "16:9", }, { "name": "hero-clean-result", "prompt": ( "Pristine white plush carpet in a beautiful upscale residential home, " "dramatic before-after transformation, deeply cleaned carpet with " "vacuum lines visible, natural light, professional photography, no people" ), "aspect": "16:9", }, { "name": "hero-technician", "prompt": ( "Professional carpet cleaning technician pushing a large upright hot water " "extraction machine across residential carpet in a bright modern home interior. " "Machine resembles an oversized upright vacuum cleaner with a cylindrical body. " "No steam visible anywhere, no water spraying, no hoses visible, completely dry. " "Technician shown from behind or side, no face, plain black shirt, no logo. " "High-end professional photography." ), "aspect": "16:9", }, { "name": "hero-before-after", "prompt": ( "Side-by-side residential living room carpet: left half heavily soiled with mud " "and dark stains, right half same carpet after professional hot water extraction " "cleaning, bright and pristine. No steam, no water, no machines visible anywhere. " "Dramatic before-after contrast. Professional photography, no people." ), "aspect": "16:9", }, { "name": "hero-stairs", "prompt": ( "Beautiful staircase with freshly cleaned plush carpet on stairs, " "modern home interior, natural light from above, professional result, " "no people, architectural photography, high-end residential" ), "aspect": "3:4", }, ] def generate(): for item in IMAGES: out_path = os.path.join(OUT_DIR, f"{item['name']}.jpg") print(f"Generating {item['name']}...") try: resp = client.models.generate_images( model="imagen-4.0-generate-001", prompt=item["prompt"], config=types.GenerateImagesConfig( number_of_images=1, aspect_ratio=item["aspect"], output_mime_type="image/jpeg", safety_filter_level="block_low_and_above", ), ) if resp.generated_images: image_bytes = resp.generated_images[0].image.image_bytes with open(out_path, "wb") as f: f.write(image_bytes) size_kb = len(image_bytes) // 1024 print(f" Saved {out_path} ({size_kb}KB)") else: print(f" No image returned for {item['name']}") except Exception as e: print(f" Error on {item['name']}: {e}") if __name__ == "__main__": generate() print("\nDone. Images in assets/images/hero/")