Converting Images to ASCII Art

I’ve been playing with Docker a lot lately. Docker is a tool for creating lightweight virtual environments based on Linux containers. They are extremely useful for running services, but you can also use them for running one-off tasks that you don’t want to run on the host system directly. Since a container shares the host machine’s kernel, startup is instantaneous and there’s no extra memory footprint. Think of Linux containers as generalized chroot environments or as extremely lightweight virtual machines.

One nice use case I’ve come across recently was to convert images on the web to ASCII art using aalib. There are very nice Python bindings available for aalib, even though installing them would require installing 17 new packages on my desktop machine. With Docker, I can isolate all that in a dedicated environment that I can easily get rid off later.

I’ve put it up on Github so you can play with it:

$ git clone https://github.com/mafr/docker-aaconvert
$ cd docker-aaconvert
$ docker build -t aaconvert .

Note that depending on your setup, you may need root privileges. Once you’ve built the Docker image (as opposed to a JPEG image), you can run it using the following command:

$ docker run --rm aaconvert http://google.com/favicon.ico

Careful, though: "Containers do not contain". Don’t run random code you found on the Internet, the usual security rules still apply. Containers will protect you to some degree, but there are ways to break out of them.

Advertisements
This entry was posted in linux and tagged , , . Bookmark the permalink.

One Response to Converting Images to ASCII Art

  1. anonymous says:

    Thanks a ton:)
    Also, thanks for creating it using docker, so i don’t install any dependencies on my system.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s