Image Generation on Granny Squares

It’s been a while since I’ve done anything significant on my Granny Square Pattern Generator (GSC), and since I’ve already contributed to a game release this week, I figured I hadn’t quite checked enough “public-facing actions” boxes this week until I did some work on GSC.

Biggest missing feature (and biggest complaint!) is that blankets weren’t printable. Now they are!

Log in with something like Facebook or Twitter, generate a blanket, and save the blanket. When you look at the details of the blanket, you can now get it as a printable image, and toggle between the two styles of seeing the blanket.

My next task is to make authentication more seamless.

Techie Bits

The site, by default, shows a blanket as an HTML table of nested background colors. Browsers don’t print background colors by default, so users were like, “Frown.”

Took me plenty long enough, calendar-wise, but now that’s fixed. Technically speaking, generating an image is easy, and storing it is cheap.

The Python Imaging Library is the de facto standard, but if you take a skim of the ImageDraw class, you’ll see the interface listed and described, but only one lonely example at the top. It really is pretty straightforward if you’re comfy with Python, although if you’re new to including PIL in your projects, please save yourself some devops hell and pip pillow instead of the mess we used to need to do. (Check and see if the library was in place; if not, grab the tarball, decompress, install, etc.)

The only thing that tripped me up for a second is that if you’re doing a hex code for the fill color, you need to use ImageColor.getrgb():

draw.rectangle1x1, y1, x2, y2), 
     fill=ImageColor.getrgb(color.color_hex

For storage, I’m continuing with DreamObjects, which we used for “The Whispering Thing“. Again, it’s S3 API-compliant, so boto behaves itself quite nicely.

Footnotes   [ + ]

1, 2. x1, y1, x2, y2), fill=ImageColor.getrgb(color.color_hex
  • Wendy

    I just found this generator and oh my goodness…so awesome!!! I kinda suck with the whole color placement thing so this is a blessing to me. Thank you!!!

  • averymd

    @Wendy Super-glad you’re finding it helpful!

  • thidamony

    This is awesome!