Camera and Lens Parameters for Realistic Photography with GPT-Image2
Specify exact camera models like "Sony A7R IV" paired with "50mm lens" and aperture values such as "f/1.4" in structured JSON prompts to force GPT-Image2 to render realistic depth-of-field, bokeh, and sensor-appropriate perspective characteristics.
The awesome-gpt-image-2 repository implements a full-stack "Prompt-as-Code" architecture that transforms freeform photography descriptions into machine-readable camera specifications. By encoding precise gear parameters into JSON schemas at docs/templates.md, the system constrains GPT-Image2 to generate images that respect real-world optical physics, eliminating generic outputs through explicit sensor size, focal length, and film stock declarations.
Photography Template Structure
The repository defines realistic photography standards in docs/templates.md at line 749, where a JSON schema encapsulates every optical parameter the AI requires to simulate physical cameras. This template separates technical specifications from artistic direction, allowing developers to programmatically adjust gear without rewriting descriptive text.
The schema includes nested objects for camera_specs and film_aesthetic, ensuring the model receives explicit instructions about hardware rather than inferring from vague adjectives. Each parameter maps directly to optical characteristics: sensor dimensions affect perspective distortion, focal length determines field compression, and aperture values control depth-of-field calculations.
Specifying Camera and Lens Parameters
Full-Frame Sensor Simulation
The template mandates declaring specific camera bodies to establish sensor size baselines. The reference implementation uses "Shot on Sony A7R IV" in the gear field, signaling a full-frame 35mm sensor format to the model. This specification triggers GPT-Image2 to render true-to-life depth-of-field falloff and bokeh circles consistent with 35mm optical physics, rather than the deeper focus characteristics of smaller sensors.
Prime Lens Selection
Focal length declarations follow the camera body in the same gear string, formatted as "50mm lens". The 50mm focal length on a full-frame body produces a natural perspective with minimal distortion, matching human visual perception. By locking this parameter, developers ensure consistent framing across multiple generations, preventing the AI from drifting between wide-angle distortion and telephoto compression.
Aperture and Depth of Field Control
The aperture field accepts f-stop notation such as "f/1.4" to drive the shallow depth-of-field effect. When combined with the 50mm specification, this setting instructs GPT-Image2 to completely blur backgrounds while maintaining tack-sharp focus on subjects, replicating the selective focus capabilities of fast prime lenses. The template explicitly notes this creates "shallow depth of field, background completely blurred."
Film Emulation and Grain Settings
Beyond digital capture parameters, the film_aesthetic field injects analog characteristics using stock designations like "Kodak Portra 400". This triggers specific color science emulation—warm skin tones, muted greens, and high latitude in highlights—while adding texture through "subtle film grain" declarations. These analog constraints prevent the hyper-clean, sterile appearance common to unguided AI image generation.
Implementing Camera Specs in API Calls
Direct JSON Payload
To utilize these parameters programmatically, structure payloads matching the templates.md schema when calling the generation endpoint. The repository exposes this functionality through api/generate-image.js, which proxies validated JSON to the GPT-Image2 service.
const payload = {
type: "Hyper-realistic Photography",
subject: {
description: "A senior photographer holding a vintage camera",
details: "Wrinkled hands, silver hair, focused expression"
},
setting: "Outdoor rooftop at golden hour, city skyline behind",
camera_specs: {
gear: "Shot on Sony A7R IV, 50mm lens",
aperture: "f/1.4",
lighting: "Warm golden hour light with soft rim"
},
film_aesthetic: "Kodak Portra 400"
};
fetch("https://gpt-image2.canghe.ai/api/generate-image", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
})
.then(r => r.json())
.then(console.log);
CLI Skill Invocation
For command-line workflows, the repository provides a wrapper skill that accepts camera parameters as flags, accessing the same templates defined in data/style-library.json.
npm install -g gpt-image-2-style-library
gpt-image-2-style-library generate \
--type "Hyper-realistic Photography" \
--gear "Shot on Sony A7R IV, 50mm lens" \
--aperture "f/1.4" \
--lighting "Cinematic lighting, neon sign reflection" \
--film "Kodak Portra 400"
Both methods feed identical camera and lens specifications into the model, ensuring the resulting images respect the optical characteristics of the Sony A7R IV and 50mm prime combination.
Backend Integration Points
The frontend React application (src/main.jsx) renders these templates through a gallery interface, but the critical validation occurs in api/generate-image.js. This Vercel function reads environment variables including VITE_SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY, authenticates the request against Supabase, and forwards the camera-specific payload to the external GPT-Image2 service. The agents/skills/gpt-image-2-style-library/SKILL.md file documents how these components orchestrate the translation between human-readable gear descriptions and API-compatible JSON.
Summary
- Lock sensor size by declaring specific camera bodies like "Sony A7R IV" in the
gearfield to ensure proper perspective and depth-of-field physics. - Control focus using explicit aperture values such as "f/1.4" to generate shallow depth-of-field and background separation.
- Fix focal length at specific millimeters (e.g., "50mm lens") to prevent distortion drift and maintain consistent framing across generations.
- Emulate analog stocks via the
film_aestheticparameter to inject grain and color science that masks digital AI artifacts. - Reference line 749 of
docs/templates.mdfor the canonical Hyper-realistic Photography schema used by the repository's frontend and CLI tools.
Frequently Asked Questions
What camera formats does GPT-Image2 support through this repository?
The awesome-gpt-image-2 templates support any camera format specified in the gear string, including full-frame (Sony A7R IV), APS-C, or medium format bodies. The system passes these specifications directly to GPT-Image2 as plain text within the JSON payload, allowing the model to simulate sensor-specific characteristics like crop factor equivalents and depth-of-field behavior.
How does the f/1.4 aperture setting affect generated images?
Setting "aperture": "f/1.4" in the camera_specs object instructs GPT-Image2 to render extremely shallow depth of field, where only a narrow slice of the image remains in sharp focus while backgrounds dissolve into smooth bokeh. When combined with the 50mm lens specification on a full-frame body, this replicates the selective focus capabilities of professional portrait lenses.
Can I simulate vintage lenses or specific optical defects?
Yes, by modifying the gear field in docs/templates.md or your API payload to include vintage lens designations (e.g., "Helios 44-2 58mm") and adding descriptors like "swirly bokeh" or "chromatic aberration" in the subject details. The repository's JSON schema accepts arbitrary strings in these fields, allowing specification of lens characteristics beyond modern pristine optics.
Where does the backend process these camera parameters?
The Vercel function at api/generate-image.js receives the camera_specs JSON and forwards it to the GPT-Image2 API after authentication via Supabase. This endpoint validates the presence of required fields including the gear and aperture parameters before proxying the request, ensuring optical specifications reach the image generation model intact.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →