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

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

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.1.0.tar.gz (4.5 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.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for nanopng-0.1.0.tar.gz
Algorithm Hash digest
SHA256 04c535b16da8fce0d00ef4e08d1d59f6a4a464dae748ea41eee9365590b5a8c9
MD5 4451749ba1b53d5dc4fe613473b5843c
BLAKE2b-256 1476fa5d86742f8a1a71fe5c0b4a17c34eea32bbf33156c3042b808984e45c84

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for nanopng-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50ace79ab5a55d568839cbf531b92b4092a81f4b539782184ea120de12d693a6
MD5 24c2c41b9636f7205255c3de1620a8b7
BLAKE2b-256 abd8c5384b5a3ed3a30dc4c81c64d39f7eb92559983705dffbf40379dfaa8279

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