Nodes/ComfyUI-NanoBanana2/NanoBanana - Vision OCR (lossless PNG)
ComfyUI Node

NanoBanana - Vision OCR (lossless PNG)

OCR that actually reads small text — because JPEG smears it

By IxMxAMAR·Created 6 months ago·Updated about a month ago· 4
NanoBanana - Vision OCR (lossless PNG)
  • image
  • network
  • text
api_key
modelgemini-2.5-pro
custom_model
modeplain_text
language_hint

The generic Vision node in this pack defaults to JPEG encoding, and JPEG is quietly the enemy of OCR: it smears small characters, and a few percent of accuracy vanishes on screenshots, receipts, and dense documents. VisionOCR exists because of exactly that - it's an OCR-tuned Vision node that always sends lossless PNG and runs a system prompt written for verbatim extraction. If you've ever had Gemini "read" a screenshot and confidently garble a serial number, this is the fix.

It defaults to gemini-2.5-pro - the strong reader - with three output modes so you can get plain text, structured line data, or Markdown preserving the document's shape. For "I need the text out of this image, exactly as written," it's the node you'll actually reach for over the general Vision one.

How it works

Every image is converted to lossless PNG before it goes over the wire - the node's docstring is blunt that JPEG-95 costs roughly 30% character accuracy on small text. Then it swaps in a task-specific system prompt depending on mode: verbatim extraction preserving line breaks for plain_text, a strict "JSON only" instruction for structured_json, or Markdown-preserving-headings for markdown. It pins temperature to 0.0 so there's no creative drift, and for the JSON mode it sets the response MIME type so you reliably get parseable JSON back.

The inputs

  • api_key, model (35 options, default gemini-2.5-pro), custom_model - standard.
  • image - a single IMAGE input.
  • mode - plain_text, structured_json, or markdown. structured_json returns {lines: [{text, bbox, confidence}, ...]} with bounding boxes normalized 0–1.
  • language_hint - optional, e.g. "Japanese" or "Hindi", helps for non-Latin scripts.

Output: one text STRING. In structured_json mode it's JSON text - wire it to a JSON parser if you want the boxes as real data.

Installing it

ComfyUI Manager → search NanoBanana2, or

cd ComfyUI/custom_nodes
git clone https://github.com/IxMxAMAR/ComfyUI-NanoBanana2
pip install google-genai

Python 3.10+, google-genai >= 0.8.0, API key from aistudio.google.com. No model files.

Where people get burned

Defaulting to gemini-2.5-pro for every OCR job is overkill - for clean screenshots and simple documents, drop to a Flash model and it's a fraction of the cost at near-identical accuracy. Remember structured_json bounding boxes are normalized 0–1, so they need multiplying by image dimensions if you want pixel coordinates. And yes, this pack re-executes every run: a folder of receipts is a billed call per image, per run. The language_hint is the one people forget and it genuinely helps with CJK scripts - a hint is cheap insurance.

CategoryNanoBanana2/Image

Inputs (7)

NameTypeDefaultDescription
api_keySTRING
modelCOMBOgemini-2.5-pro35 options: gemini-pro-latest, gemini-flash-latest, gemini-flash-lite-latest, gemini-3-pro-preview, gemini-3-flash-preview, gemini-3.1-pro-preview, +29
imageIMAGE
custom_modeloptSTRING
modeoptCOMBOplain_textOutput format. structured_json returns {lines: [{text, bbox, confidence}, ...]}.
language_hintoptSTRINGOptional language hint (e.g. 'Japanese', 'Hindi').
networkoptNB_NETWORKOptional. Wire a NanoBanana - Network Route node here to route this request through that proxy (e.g. US egress).

Outputs (1)

NameTypeDescription
textSTRING