Software Video Blog About

Tonight's Moon Is

Paste this page's URL (almost) anywhere to embed an image of the current lunar phase.

What Is This

I often need an image of the moon. As a software developer interested in the cosmic I find myself regularly searching "what is tonight's moon phase", and then cross referencing a folder full of images on my machine to find the right one.

As "Don't Repeat Yourself" is a hallowed development principle I thought I would build a system that makes sharing an image of the current moon phase as easy as sharing a link; this page is that system.

Paste this URL (almost) anywhere and it'll show an up-to-date image of the moon.

How Is It Used

Social Media & MMS

Just copy the link from the url bar and paste it into most platforms. The link will embed a formatted preview that shows the current phase and date. It's that easy. Here's a Twitter example

HTML/Image URLs

If you want to use just the image itself - for example in your email signature, as I do - you can embed a direct link to the image. I can't confirm that this works everywhere, but it does work in gmail which is very neat. It comes in two sizes: [20x20] [300x300].

How Does It Work?

Imprecisely calculating the lunar phase is actually a pretty easy problem (one that gets crazy difficult when you want specificity) and, luckily, a bunch of people have open sourced their approaches.

I adapted a phase-calculation approach from Ben Daglish and, based on the current phaes, redraw the image that lives at a specific path on my server. By doing this I can change the image every evening without changing the URL, allowing me to easily embed an updating image. After that, it's just doing some Oembed/Open Graph stuff to make the image look nice when it's shared.