Files
TarkovMaps/tools/gemini_image.py
lucioandClaude Fable 5 472c983287 Commit build outputs via LFS; right-click markers, inline edit box, panel pin
Make a fresh clone servable after `git lfs pull` alone, and rebuildable with
`tools/build.py` without re-rendering unchanged PSDs:

- Track build/ (rendered base PNGs, previews, world composites), web/tiles/,
  web/tiles-trimmed/, web/data/world.json and web/data/markers/. Large PNGs
  and the tile pyramids go through Git LFS (.gitattributes); JSON stays plain.
- build.py: decide PSD re-export from build/<id>/base.stamp.json (PSD size,
  mtime, SHA-256 recorded at export time) instead of file mtimes, which are
  meaningless after an LFS checkout. Same size + new mtime hashes once and
  refreshes the stamp; --stamp-only writes stamps for existing base.pngs.
- Ignore .DS_Store and .env files; track sources/**/*.jpg through LFS.

Viewer:
- Right-click (long-press) the map for a category menu that drops a draft
  marker under the pointer and enters marker edit mode for that map.
- Marker editing moves out of the side panel into a box anchored next to the
  marker: Enter or a left click anywhere else saves, Esc cancels, Delete
  inside the box; drags save position plus the box contents.
- Maps panel expands on hover, header click pins/unpins (status shown in the
  header), unpinned collapses 2 s after the pointer leaves; Overview is the
  first list entry instead of a separate button. Only the panel scrolls; the
  page never grows past the viewport. Hover tooltips render above markers.

Also includes the pending source additions (overall square base, skirt
textures, AI regeneration tooling and notes), service worker, Caddyfile and
map config updates.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-22 09:46:02 -07:00

62 lines
2.2 KiB
Python

"""Generate an image with Google Gemini (experiment scaffold).
.venv/bin/python tools/gemini_image.py
.venv/bin/python tools/gemini_image.py --prompt "..." --out build/test.png
Dependencies: google-genai, Pillow (pip install -r tools/requirements-ai.txt)
Put your Google API key in GOOGLE_API_KEY below (or export GEMINI_API_KEY /
GOOGLE_API_KEY in the environment -- the client picks either up automatically
when GOOGLE_API_KEY here is left empty).
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
from google import genai
from google.genai import types # noqa: F401 (kept for editing: config, image parts, etc.)
# ---------------------------------------------------------------------------
GOOGLE_API_KEY = "" # <- paste your key here, e.g. "AIza..."
MODEL = "gemini-3.1-flash-image"
DEFAULT_PROMPT = "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme"
DEFAULT_OUT = Path("generated_image.png")
# ---------------------------------------------------------------------------
def main(argv: list[str]) -> None:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--prompt", default=DEFAULT_PROMPT)
parser.add_argument("--out", type=Path, default=DEFAULT_OUT)
parser.add_argument("--model", default=MODEL)
args = parser.parse_args(argv)
# With an empty key the client falls back to GEMINI_API_KEY / GOOGLE_API_KEY.
client = genai.Client(api_key=GOOGLE_API_KEY) if GOOGLE_API_KEY else genai.Client()
response = client.models.generate_content(
model=args.model,
contents=[args.prompt],
)
saved = 0
for part in response.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = part.as_image()
args.out.parent.mkdir(parents=True, exist_ok=True)
image.save(args.out)
saved += 1
print(f"saved {args.out}")
if not saved:
print("no image part in the response", file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":
main(sys.argv[1:])