Monday 8 October 2012

How to generate a 1 pixel GIF with dataURL in JavaScript

I recently wanted to use single pixel dataURL images in a project, but on doing some research ( I discovered I would have to create the images first and then convert them to base64, using tools like or

I thought this was somewhat inefficient.

After a little more research, I found a good post on the subject of generating dataURL images for LESS, but it was incomplete, as although there is a jsFiddle, it never actually generates the data and it turns out there are a few bugs.

Time for a quick bit of work.... drum roll please...

Presenting: Single Pixel GIF dataURL Generator (edit)

Basically, I fixed the bugs, and added some UI to make it more useful.
Credit to Michel Jansen, as without his work, this would have been a lot more painful.

No comments:

Post a Comment