Skip to main content

Generate transparent PNG images from text prompts using Nano Banana Pro + background removal

Project description

nanopng logo

nanopng

PyPI License Python

CLI to generate transparent PNG images from text prompts. Describe what you want, get a cutout PNG in ~12 seconds.

CLI demo

Install

uv tool install nanopng

On first run, nanopng will prompt for your Gemini API key and save it to ~/.nanopng/.env. Get a key at aistudio.google.com/apikey.

Usage

nanopng "fire breathing dragon"
nanopng "cat wizard" -n 4
nanopng "samurai warrior" --style anime --size 9:16
nanopng "crystal sword" --model standard -o sword.png

# With reference image (uses Gemini 3.1 Flash Image)
nanopng "character in this style" -i reference.png -o output.png

# Multiple reference images (up to 14)
nanopng "combine these elements" -i img1.png -i img2.png -i img3.png

# From stdin (for piping image data)
cat reference.jpg | nanopng -i - "prompt" -o output.png

Claude Code Integration

When using nanopng with Claude Code, you can send images directly in chat:

  1. Send an image in the conversation
  2. Claude finds it in /var/folders/.../T/tos_*.png
  3. Pipes it directly: cat [temp-file] | nanopng -i - "prompt"
  4. Instant generation with your reference image!

Update

uv tool upgrade nanopng

Options

Flag Description Default
-o, --output Output file path Auto from prompt
-n Number of images (1-4) 1
--size Aspect ratio: 1:1, 16:9, 9:16, 4:3, 3:4 1:1
--style Style preset (see below) None
--model fast (~10s) or standard (~17s) fast

Styles

pixel-art watercolor 3d-render photorealistic cartoon anime oil-painting flat

Tech Stack

Component Tools
Language Python 3.12
Image Gen Google Imagen 4 Fast
BG Removal rembg (isnet-general-use)
CLI argparse (stdlib)

Architecture

[User Input]                [System Boundary: nanopng]              [External]

┌──────────────┐                                            ┌───────────────┐
│   Terminal   │                                            │  Google API   │
│              │                                            │  (Imagen 4)   │
│ $ nanopng    │                                            └───────┬───────┘
│   "prompt"   │                                                    │
└──────┬───────┘                                                    │ HTTPS
       │                                                            │
       │ CLI Command                                                │
       ▼                                                            │
┌─────────────────────────────────────────────────────────┐         │
│              Python CLI (argparse)                       │         │
│                                                         │         │
│  ┌──────────────────────────────────────────────────┐   │         │
│  │           cli.py                                 │   │         │
│  │                                                  │   │         │
│  │  Parse args (prompt, -n, --size, --style, etc.) │   │         │
│  └──────────────┬───────────────────────────────────┘   │         │
│                 │                                       │         │
│                 ▼                                       │         │
│  ┌──────────────────────────────────────────────────┐   │         │
│  │           core.py                                │   │◀────────┘
│  │                                                  │   │ Generate
│  │  1. Build prompt + chroma key suffix             │   │
│  │  2. Call Imagen 4 Fast (google-genai)            │   │
│  │  3. Remove background (rembg, local)             │   │
│  │  4. Save RGBA transparent PNG                    │   │
│  └──────────────────────────────────────────────────┘   │
└─────────────────────────────────────────────────────────┘
                 │
                 ▼
         prompt-slug.png
         (transparent RGBA)

Imagen 4 Fast (~10s) • rembg local inference (~2s) • ~12s total

Storage

~/.nanopng/.env                      # API key (saved on first run)
~/.u2net/isnet-general-use.onnx      # BG removal model (one-time download, ~179MB)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nanopng-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nanopng-0.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file nanopng-0.2.0.tar.gz.

File metadata

  • Download URL: nanopng-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for nanopng-0.2.0.tar.gz
Algorithm Hash digest
SHA256 282f3ef1304762015e9940204377575c8a28b56cc72cb2f93b9cd1bd0e84a928
MD5 a802810d457b0543de6e5487c144eb5b
BLAKE2b-256 733c2c4fabe7463697976dc7a5960f15185bd661075f6ee7bd6ab3ab02b26042

See more details on using hashes here.

File details

Details for the file nanopng-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: nanopng-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.3

File hashes

Hashes for nanopng-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 befdfaf9c1b039caa22b6742e51117414d17a2e563a44408edc9171a6db1be91
MD5 a49dd4bdf4ee6ba4da468dbf9e29cfcf
BLAKE2b-256 9bdd2dd2f24b0b83114e4dafec17c667af8431f26585887dcd4a6c9125c32b71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page