• Welcome to Dark Bit Factory & Gravity.
 

[Image Processing] - ASCII-inator

Started by combatking0, February 05, 2013

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

combatking0

Just for fun, I thought I'd try to build an image-to-ASCII-art converter in JS.

To use it, you'll need to unzip the archive, and place a GIF, JPG or PNG file in the same directory as the HTM file.
Next open the program under Firefox or IE9 and type the complete file-name of the image into the form.
Then press the Generate button. If the file-name is correct, the image should be converted into ASCII art.

It's only been successfully tested under Firefox and IE9. Chrome doesn't work due to a false-positive in its default security settings.

(edit) I have improved the code for better contrast handling, but only slightly.

Here's an output sample:

                               ¤xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx•                                     
                               ¤xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx•                                     
                               ¤xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx•                                     
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx·                 
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx·                 
                         xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx·                 
                         NNNNNNNNNNNNNNNNNNX¤¤¤¤¤¤¤¤¤¤¤¤NMMMMMX¤¤¤¤¤•············                   
                         MMMMMMMMMMMMMMMMMMN••••••••••••NMMMMMX••••••                               
                         MMMMMMMMMMMMMMMMMMN••••••••••••NMMMMMX••••••                               
                  ·xxxxxxxxxxxxNMMMMMXxxxxxx••••••••••••NMMMMMX••••••............·                 
                  .MMMMMM••••••NMMMMMX••••••••••••••••••NMMMMMX••••••••••••••••••·                 
                  .MMMMMM••••••NMMMMMX••••••••••••••••••NMMMMMX••••••••••••••••••·                 
                  .MMMMMM••••••NMMMMMNxxxxxx••••••••••••xXXXXXXXXXXXx••••••••••••......·           
                  .MMMMMM••••••NMMMMMMMMMMMN••••••••••••••••••XMMMMMN••••••••••••••••••.           
                  .MMMMMM••••••NMMMMMMMMMMMN••••••••••••••••••XMMMMMN••••••••••••••••••.           
                  ·xxxxxxxxxxxxXXXXXXXXXXXXx••••••••••••xxxxxxNMMMMMMxxxxxxxxxxxx•.....·           
                         MMMMMM¤••••••••••••••••••••••••NMMMMMMMMMMMMMMMMMMMMMMMM.                 
                         MMMMMM¤••••••••••••••••••••••••NMMMMMMMMMMMMMMMMMMMMMMMM.                 
                         XXXXXX¤•••••¤•••••¤••••••••••••XNNNNNNNNNNNNXXXXXXXXXXXX.                 
                               ••••••••••••••••••••••••••••••••••••••                               
                               ••••••••••••••••••••••••••••••••••••••                               
                         ·     •¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤•     ·                         
                         xxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxx                         
                         xxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxx                         
                         xxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxx                         
                  ·xxxxxxxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxxxxxxx·                 
                  ·xxxxxxxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxxxxxxx·                 
                  ·xxxxxxxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxXXXXXXXxxxxxxxxxxxxxxxxxx·                 
            .xxxxxxxxxxxxxxxxxxxxxxxxXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxx.           
            •xxxxxxxxxxxxxxxxxxxxxxxxXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxx•           
            •xxxxxxxxxxxxxxxxxxxxxxxxXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxxxxxxxxxxxxxxxxxxxx•           
            .¤¤¤¤¤¤¤¤¤¤¤¤xxxxxxXXXXXXx¤¤¤¤¤¤XXXXXXXXXXXX¤¤¤¤¤¤xXXXXXXxxxxxx¤¤¤¤¤¤¤¤¤¤¤¤.           
            .••••••••••••xxxxxxXXXXXX¤•••••¤XXXXXXXXXXXX¤•••••¤XXXXXXxxxxxx••••••••••••.           
            .••••••••••••xxxxxxXXXXXX¤•••••¤XXXXXXXXXXXX¤•••••¤XXXXXXxxxxxx••••••••••••.           
            .•••••¤••••••¤¤¤¤¤¤xXXXXXxxxxxxxXXXXXXXXXXXXxxxxxxxXXXXXx¤¤¤¤¤¤••••••¤•••••.           
            .••••••••••••••••••xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx••••••••••••••••••.           
            .••••••••••••••••••xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx••••••••••••••••••.           
            .•••••¤••••••xxxxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXxxxxxx••••••¤•••••.           
            .••••••••••••XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX••••••••••••.           
            .••••••••••••XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX••••••••••••.           
            ·............XXXXXXXXXXXXXXXXXXx¤¤¤¤¤¤¤¤¤¤¤¤xXXXXXXXXXXXXXXXXXX............·           
                         XXXXXXXXXXXXXXXXXX¤            ¤XXXXXXXXXXXXXXXXXX                         
                         XXXXXXXXXXXXXXXXXX¤            ¤XXXXXXXXXXXXXXXXXX                         
                   ......XXXXXXXXXXXXx¤¤¤¤¤•            •¤¤¤¤¤xXXXXXXXXXXXX......                   
                  .MMMMMMMMMMMMMMMMMM¤                        ¤MMMMMMMMMMMMMMMMMM.                 
                  .MMMMMMMMMMMMMMMMMM¤                        ¤MMMMMMMMMMMMMMMMMM.                 
            ······•MMMMMMMMMMMMMMMMMM¤                        ¤MMMMMMMMMMMMMMMMMM•······           
            ¤MMMMMMMMMMMMMMMMMMMMMMMM¤                        ¤MMMMMMMMMMMMMMMMMMMMMMMM¤           
            ¤MMMMMMMMMMMMMMMMMMMMMMMM¤                        ¤MMMMMMMMMMMMMMMMMMMMMMMM¤           
            ¤MMMMMMMMMMMMMMMMMMMMMMMM¤                        ¤MMMMMMMMMMMMMMMMMMMMMMMM¤           


I may need to make some adjustments.

(edit) I've updated again - I should really do more testing before I release :)
Charset 10 is now the default, non-existent files are handled better, and you can now choose between 3 scaling options. Also, the courier font aspect ratio is better catered for.
You are our 9001st visitor.
Challenge Trophies Won:

Kirl

Awesome, works really well! Time for some moving pictures!  :cheers:
www.kirl.nl
Challenge Trophies Won:

combatking0

Thanks Kirl, I've been fine tuning it.

A moving demo is definitely on the cards.
You are our 9001st visitor.
Challenge Trophies Won:

Shockwave

Phineas and Ferb inspired name? :)
Shockwave ^ Codigos
Challenge Trophies Won:

combatking0

Yes, my son loves that show. I quite enjoy it too.
You are our 9001st visitor.
Challenge Trophies Won:

jace_stknights

Challenge Trophies Won: