Author Topic: [Image Processing] - ASCII-inator  (Read 4089 times)

0 Members and 1 Guest are viewing this topic.

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
[Image Processing] - ASCII-inator
« on: February 05, 2013 »
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:
Code: [Select]
                               ¤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.
« Last Edit: February 06, 2013 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: [Image Processing] - ASCII-inator
« Reply #1 on: February 06, 2013 »
Awesome, works really well! Time for some moving pictures!  :cheers:
www.kirl.nl
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: [Image Processing] - ASCII-inator
« Reply #2 on: February 06, 2013 »
Thanks Kirl, I've been fine tuning it.

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

Online Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [Image Processing] - ASCII-inator
« Reply #3 on: February 23, 2013 »
Phineas and Ferb inspired name? :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: [Image Processing] - ASCII-inator
« Reply #4 on: February 23, 2013 »
Yes, my son loves that show. I quite enjoy it too.
You are our 9001st visitor.
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: [Image Processing] - ASCII-inator
« Reply #5 on: February 28, 2013 »
Thanx mate!
Challenge Trophies Won: