Last active
February 4, 2026 17:43
-
-
Save jmanhype/bf8df85cc28055be9c14b2915f5d9c6c to your computer and use it in GitHub Desktop.
NANO BANANA PROTOCOL: Raw Bash Script for Consistent AI Character Generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # π NANO BANANA PRO: RAW ASSET GENERATION PROTOCOL | |
| # Session: Feb 4, 2026 | |
| # Model: gemini-3-pro-image-preview | |
| # Logic: Base64 Reference Injection + Prompt Engineering for Consistency | |
| # 1. PRE-FLIGHT: ENCODE DNA | |
| # Ensure 'riley.jpg' exists in the current directory. | |
| if [ ! -f "riley.jpg" ]; then | |
| echo "β Error: riley.jpg not found!" | |
| exit 1 | |
| fi | |
| echo "𧬠Encoding Character DNA..." | |
| base64 -i riley.jpg > riley_base64.txt | |
| # 2. DEFINING THE SHOT LIST (The "V2" Series) | |
| # Format: "filename:Prompt Description" | |
| # Note: The script automatically appends the Consistency/Critical prompt blocks. | |
| shots=( | |
| "riley_escalade_v2:Riley opening back passenger door of a black Cadillac Escalade SUV at night in NYC. iPhone 17 quality photorealistic. She is wearing a white varsity jacket with black leather sleeves. She is looking back before getting in." | |
| "knicks_cheers_v2:POV shot of two hands holding stadium cups at a Knicks basketball game. Left arm has a white varsity jacket sleeve. Right hand masculine. They are clinking toasts. Basketball court background." | |
| "riley_hibachi_pov_v2:iPhone 17 flash photo quality of Riley eating hibachi. She is wearing a white varsity jacket. She is holding a glass of white wine and smiling at the camera. Restaurant lighting." | |
| "hibachi_plates_v2:Cinematic close up of two plates of fresh hibachi steak and fried rice on a teppanyaki grill. Hot steam and smoke rising. High detail." | |
| "riley_nyc_street_v2:Riley strutting confidently down a New York City street at night. She is wearing a white varsity jacket with black leather sleeves. Fashion photography style, street lights, blurred background." | |
| ) | |
| # 3. THE GENERATION LOOP | |
| API_KEY="AIzaSyDFWAa2Snp3AMHW-5sS1P4hef20zonOZuM" # β οΈ Hardcoded from Session | |
| for shot in "${shots[@]}"; do | |
| filename="${shot%%:*}" | |
| desc="${shot#*:}" | |
| echo "π Generating: $filename" | |
| echo "π Prompt: $desc" | |
| # 4. CONSTRUCTING THE PAYLOAD (The "Secret Sauce") | |
| # Injects the description AND the base64 image data into the multipart request. | |
| # Enforces: "CRITICAL: Maintain Riley EXACT facial structure..." | |
| printf '{ | |
| "contents": [ | |
| { | |
| "role": "user", | |
| "parts": [ | |
| { | |
| "text": "Cinematic 8k photorealistic shot. %s CRITICAL: Maintain Riley EXACT facial structure and long dark wavy hair from reference. OUTFIT CONSISTENCY: She must be wearing the white varsity jacket." | |
| }, | |
| { | |
| "inlineData": { | |
| "mimeType": "image/jpeg", | |
| "data": "%s" | |
| } | |
| } | |
| ] | |
| } | |
| ] | |
| }' "$desc" "$(cat riley_base64.txt)" > "payload_${filename}.json" | |
| # 5. EXECUTING THE API CALL | |
| curl -s -X POST | |
| -H "Content-Type: application/json" | |
| -d @"payload_${filename}.json" | |
| "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent?key=${API_KEY}" > "response_${filename}.json" | |
| # 6. DECODING THE RESPONSE | |
| # Extracts the base64 image from the JSON response and saves it as a PNG. | |
| python3 -c "import json, base64, sys; | |
| try: | |
| data = json.load(open('response_${filename}.json')) | |
| if 'candidates' in data and data['candidates']: | |
| img_data = data['candidates'][0]['content']['parts'][0]['inlineData']['data'] | |
| open('${filename}.png', 'wb').write(base64.b64decode(img_data)) | |
| print('β Saved ${filename}.png') | |
| else: | |
| print('β Error in response:', data) | |
| except Exception as e: | |
| print('β Script Error:', e) | |
| " | |
| echo "---------------------------------------------------" | |
| done | |
| echo "π BATCH COMPLETE." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment