dsandler.org

This article (and ensuing thread) about lightweight Sparklines in Ruby reminded me that I’d intended to write a super-lightweight PNG library (for those times when you want a quick and dirty Web graphic and don’t have a proper graphics toolkit handy).

I don’t really speak Ruby yet (any more than I do Japanese…konban wa, watashi wa dsandler), so here’s minipng.py. Requires: Python 2.x, and nothing else. Currently supported: 8bpp RGB, with optional single-color transparency (tRNS). Sample code:

# should result in a black smiley face on yellow background
from minipng import MiniPNG, Color
mp = MiniPNG(9, 6, Color.YELLOW)
for pt in [(2,1), (6,1), (1,3), (7,3), (2,4), (3,4), (4,4), (5,4), (6,4)]:
    mp.plot(pt, Color.BLACK)
pngdata = mp.to_png()

I’ll probably add grayscale, gray+alpha, and RGBA soon (next time I’m bored and near a computer). [ :) ]

Leave a Reply

To prove you're not a spammer, what's 14 ÷ 2?


subscribe to dsandler.org

  •  
  • for faster updates, subscribe with FeedTree

mac software made on premises

toastycode.com: toasty software for the mac pyrotheque: a new (old) fireworks screensaver for the mac
Cuckoo—the bell tolls for your Mac.

twitter/dsandler [RSS]

    loading…

elsewhere

highlights

between the couch cushions

strongly connected

  • erinmak is not to be trifled with
  • pixelknave says moof when upside-down
  • dave is dangerous
  • rod is one groovy mother
  • adam is googling us all
  • amar is not really a pirate
  • angi sees little blue dots
  • harbinger lets you know it's coming
  • jason looks like an idiot in that hat
  • jeff is keeping austin weird
  • regan seems to tolerate jason
  • emann will not abide your IM-speak
  • jim is a stranger in ein anderes Land
  • liscio is pronounced "lee-show"
  • darryl has no need of identifying objects
  • friends as they appear on dsandler.org
  • sportsgirl reports…on all the pro courts

Search

Recent

Archives

dsandler.org is Dan Sandler's website and notebook.

Powered by WordPress and here's why.