Space Cat, Prince Among Thieves

Damn Simple PHP ASCII Art Generator

So yesterday I was bored and asked my friend what I should do. She replied "I don't know, draw ASCII art or something!" and sitting there with the terminal open I kind of wondered what it would take to write one of those image to ASCII scripts.

20 minutes later I had the following PHP Shell Script! It works by simply sampling the saturation of every Xth pixel and mapping that saturation to a character from an array. There is no nearest-neighboring or anything like that, just straight up sampling.

Huzzah!

ASCII JORIE is made of ASCII

And there you have it! A whopping 35 lines of code. There is a ton of tweaking you can do like changing the array of characters, or adjusting the $scale variable which is simply how wide of a sample it makes. Setting it to 1 for instance should sample every pixel on the Y and every other pixel on the X (so it scales propperly). To the right is a sample output of the script.

Do You Trust Me?

The script accepts local or remote image paths as the first argument. The following is a simple usage example you can use to get you started.

./ascii.php "http://donatstudios.com/images/site/JesseDonat.jpg"

It was a fun little project and I look forward to seeing if/what the internet comes up with for it. Fork me on Github, or post links in the comments! Happy hacking!



Comment by: A Name on

A Name GravatarNice work man. A simple and clean little thing that is quite a catalyst for the old thought bubbles.

Comment by: cyan on

cyan GravatarA simple code but prospective. This website http://meapage.com/htart/ may be used a similar methods to generate ASCII Art

Comment by: cyan on

cyan Gravatarsorry, i mean http://meapage.com/txtart/

Comment by: oguzhan on

oguzhan GravatarI think your not codder. You're artist! :) very funny 34 lines hah!

Comment by: Evan Toder on

Evan Toder GravatarHow creative can you get with all these symbols? http://www.scrapersnbots.com/blog/content/special-characters-and-symbols-for-copy-paste.php

Email address will never be publicly visible.