Introduction to Photography Modifiers

Welcome to the next step in your journey of creating stunning AI-generated images! In the previous lesson, you explored how artistic styles and quality modifiers can enhance visual output. Now, we will build on that foundation by introducing photography modifiers.

Photography modifiers help you guide the model toward images that resemble real-world photography. These modifiers can describe camera proximity, camera position, lighting, lens type, camera settings, and film style.

Types of Photography Modifiers
  • Camera Proximity: Controls how close or far the camera appears from the subject. Examples include "close-up" and "wide shot".

  • Camera Position: Describes the angle or perspective. Examples include "bird's-eye view" and "low-angle perspective".

  • Lighting: Shapes the mood of the image. Examples include "natural lighting", "dramatic backlight", and "soft diffused lighting".

  • Camera Settings: Adds effects such as "motion blur", "soft focus", "bokeh effect", or "f/1.8 aperture".

  • Lens Types: Simulates lenses such as "fisheye lens", "macro lens", or "wide-angle lens".

  • Film Types: Adds visual moods such as "black and white film", "vintage film", or "polaroid style".

Implementing Photography Modifiers in Code
from google import genai
from google.genai import types
import os
import time

GEMINI_IMAGE_MODEL = "gemini-3.1-flash-image"

api_key = os.getenv("GEMINI_API_KEY")

if not api_key:
    raise ValueError("GEMINI_API_KEY not found in environment variables. Set it before running the script.")

base_url = os.getenv("GEMINI_BASE_URL")

if not base_url:
    raise ValueError("GEMINI_BASE_URL not found in environment variables. Set it before running the script.")

client = genai.Client(
    api_key=api_key,
    http_options=types.HttpOptions(
        base_url=base_url,
    ),
)

photo_modifiers = [
    "A dramatic portrait of an old man, shot with a Canon 5D, f/1.8 aperture, natural lighting",
    "A breathtaking mountain landscape, golden hour, taken with a Sony Alpha, HDR",
    "A cozy cafe scene, cinematic lighting, bokeh effect, DSLR-quality",
    "A street in New York City, taken with a fisheye lens, wide-angle perspective",
    "An aerial view of a lush rainforest, captured from a drone",
]

for index, photo_prompt in enumerate(photo_modifiers):
    response = client.models.generate_content(
        model=GEMINI_IMAGE_MODEL,
        contents=photo_prompt,
        config=types.GenerateContentConfig(
            response_modalities=["IMAGE"],
            image_config=types.ImageConfig(
                aspect_ratio="16:9",
            )
        ),
    )

    image_parts = [part for part in response.parts if part.inline_data]

    if not image_parts:
        print(f"No image generated for prompt: {photo_prompt}")
        continue

    image = image_parts[0].as_image()
    timestamp = int(time.time() * 1000)
    image_filename = f"image_{timestamp}_{index}.png"
    output_path = os.path.join("static", "images", image_filename)
    os.makedirs(os.path.dirname(output_path), exist_ok=True)
    image.save(output_path)
Summary and Next Steps

In this lesson, you learned how photography modifiers help guide AI-generated images toward specific photographic effects. By including details about lens type, lighting, camera position, and film style, you can create more realistic and expressive images.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal