Coder Social home page Coder Social logo

ascii-art's Introduction

Convert images to ASCII art with Python

About ASCII-ART

ASCII-ART is a python script that converts images to ASCII art.

For example, when the following image of a dinosaur - dinosaur

will be converted to an image such as (width of image can be adjusted)-

                                                           ,::.                                     
                                                       .@@&*++:@@:                                  
                                                     ,@&,,,,,,,,,*@                                 
                                                    #8,,,,,,,,,,,,,@,                               
                                                   #:,,,,,,,,,,,,,,,@.                              
                                                  #*,,,,,,,,,,,,,,,,,@                              
                                                 oo+,,,,,,,,,,,,,,,,,,#                             
                                                .@+,,,,,,,,,,,,,,,,,,,@+                            
                                                @++,,,,,,+++:o::*,,,,,,@                            
                                               +&++,,,,,++:o8@@@@&+,,,,8.                           
                                               @*++,,,+++:o@@+   +@+,,,+8 +o&888&:+.                
                                              .8*+++++++*o@@       @+,,,@8:++,,,++:&@@#*            
                                              8**+++++++o&@     .,  *,,+@,,,,,,,,,,,,,+8@#.         
                                             *#**++++++*o@&     ,::,8+++8,,,,,,,,,,,,,,,,,##        
                                            .@***++++++oo@      ::::.+++*,,,+,,,,,,,,,,,,,,+@       
                                            @****++++++o8@      ::::::+++,++++,+,,,,,,,,,,,,+@      
                                           8:***+++++++o@&     :&&o:::+++++++++++,,,,,,,,,,,,8,     
                                           @****+++++++o@:   *:&&&&::*++++++++++++++,,,,,,,,:,#     
                                          @****++++++++o@*   ::&&&&::*+++++++++++++++++,,,,&@:@     
                                          @****++++++++o#o   :::&&o::*+++++++++++++++++++++#@o8     
                                         +:****++++++++oo@   ::::::::*+++++++++++++++++++++&@oo.    
                                         @::**+++++++++:o@   .::::::,+++++++++++++++++++++++@oo.    
                                         @::::+++++++++*o#+   +::.  ,+++++++++++++++++++++++**&.    
                                         #::::**++++++++oo@    .*   ++++++++++++++++++++++++++8     
                                         8:::******++++++oo@       :++++++++++++++++++++++++++@     
                                         &::::*******+*++*oo#.   .o+++++++++++++++++++++++++++@     
                                         8::::**********+*+oooooo*++++++++++++++++++++++++++++&     
                                         8::::**************+***+++++++++++++++++++++++++++++&.     
                                         @:::::+,,,,,,,,,+****++***++++++++++++++++++++++++++@      
                                        ,#:::8+,........,,.*&::::::****++++++++++++++++++++++8      
                                        @,::o+,............,,*@:::::::****++++++++++++++++++#.      
                                        @+*@++,...,..........,,##:::::::**:***++++++++++++++#       
                                       ::+o++++,,,,,,,,,..,,....,@@@@@@#&@@******++++++++++@        
                                       @,+@++++,,,,,,,,,,,,,,,,,.,&@#: .#. @@#:*:::**+++**&:        
                                       @++@+++++,,,,,,,,,,,,,,,,,,,,.&@@8+.@# *@8,8:*****&8         
                                       @++8++++++,,,,,,,,,,,,,,,,,,,,,,,.*#@@88&. @&@@@@@+          
                                      .#++*:++++++,,,,,,,,,,,,,,,,,,,,,,,,,,,,*&@@@@@@@@@           
                                      +o+++@++++++++,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..,,8           
                                      o*+++&*+++++++++,,,,,,++++,,,,,,,,,,,,,,,,,,,,,,,+@           
                                      &+++++@++++++++++++++++++++++,,,,,,,,,,,,,,,,,,++*&           
                                      8++++++@:+++++++++++++++++++++++++++++,,,,,,++++*@            
                                      #+++++++&@+++++++++++++++++++++++++++++++++++++@&             
                                      8++++++++*#@o++++++++++++++++*o&&&8888#@@@@@@@:               
                                      &+++&+++++**:#@@@o:**:o@@@8o+....                             
                                      o*+@+,,,++*o*,,,,,*::@.                                       
                                      o*&+,,,,,+*:&+,,,,,,,:8                                       
                                      :*@,,,,,,+*:@*,,,,,,,,@.                                      
                                      :88,,,,,+**:&o,,,,,,,,,@                                      
                                      o@+,,,,++*::&8+,,,,,,,,:#                                     
                                      8@+,,,++**::@:+,,,,,,,,,@,                                    
     8,                               @@+++++**:::@+++,,,,,,,,,@                                    
    @+#8                              @*+++++**::@o++++,,,,,,,,:8                                   
   *&,+&@                            +@+++++**::@8+++++,,,,,,,,,@                                   
   @.,++*@.                         .@o+++*:**:@#+++++++,,,,,,,,,#                                  
   @..++++@,                        @@+++++*@::@++++++++,,,,,,..,@                                  
   @...++++@@                      #:@+++++*:@@:+++++++++,,,,,..,+&                                 
   #+,,++++++@#                  .@*:@+,++++*#@++++++++++,,,,....,@                                 
   ::,,,+++++++@@*             o@#8++@,,,++++:@:+++++++++,,,,....,#.                                
   .@+,,++++++++,o@@@@#88##@@@#+++++*:@,,++++*o@**++++++++,,......,8 .                              
    @+,,,++++++++++++++++++++++++**:++@+,++++*:#@@@@&+++++,.......,@#8@@                            
    .#+,,,+++++++++++++++++++++++:++++*@+,+++**::::#,@@+++,.......,@,,,*:                           
     @++,,,+++++++++++++++++++++#++++++@8,++++++***#, ::*+,,,...,,,@,,,8.                           
     .@+,,,++++++++++++++++++++8++++++++@+,+++++***:@.88*+,,,,,,,,,@,,,@                            
      #*+,,,,+++++++++++++++++oo++++++++@:,,++++****@##,@,,,,,,,,,,@#,@@                            
       @++,,,,++++++++++++++++@*++++++++:@,,,++++***:@,++#+,,,,,,,,@@#o#o                           
       .@++,,,,,+++++++++++++*&*+++++++++@+,,,+++***:@,+++#,,,,,,,,@*@@#@+                          
        *#+++,,,.,+++++++++++8:*+++++++++@+,,,++++**:@:++++@,,,,,,,@*o#,,8o                         
         &8+++,,,,,,+++++++++#:*+++++++++@,,,,++++**o@@+++++@,,,,,+8**@,,,#.                        
          &8++++,,,,,,,+*++++#:**++++++++8#+,++****:@,.@++++oo,,,,@***:@,,o+                        
           o@+++++,,,,,,,,,++#:**+++++++++@+++++**:&@  @,++++@,,,,@*+**@,8@                         
            ,@*+++++,,,,,,,,,*o:**++++++++*@*+++**&@..o@+++++o:,,@*+++*o8,                          
              @&++++++,,,,,,,.#:::+++++++++:@@**:@@@@@&+,,,,,+@,o#*++++:&                           
               *@o++++++++,,,,@::::*+++++++++&@@@+@++++,,,,,,+@+@+++++**#                           
                 +@@#+++++++++:o::::***+++++++*@  #++++,,,,,,+#@:*++++**#                           
                     8@*+++++++@:::::**+++++++++8@@+++++,,,,,+8*:::**:*:#                           
                       ,@@:+++++#:::::*****++++++++++++++,,,++8:::::::::o                           
                          .&@@#:oo:::::******+++++++++++++++++@::::::::#                            
                               ,o@:::::::*****+*+++**+++++++++@o:::::::@                            
                                  ::::::::::*****:*****++++++*#ooo::::@+                            
                                   +o:::::::::::::::****+++++@ooooooo#@                             
                                     8::::::::::::::::******&#oooooo#@                              
                                      .&::::::::::::::::***o@ooooo&#8                               
                                       @:o::::::::::::::::#8oooo:*@*                                
                                       @:::::::::::::::::@:******@.                                 
                                       @::**++++****++++@*******@                                   
                                       @::**++++++++++:@******o@                                    
                                       @:***+++++++++@#******88                                     
                                       @:***++++++++@&:*****&#                                      
                                       @o:*+++++*:*@:*****o88.                                      
                                      @++,,,,,,,,,++,*8#:++*****#8.                                 
                                    ,@+,,,,,,,,,,,,,++++*&@:*****::8@.                              
                                    @++,,,,,,,,,,,,++++**8*.@8***oo@++@&                            
                                   @+++++++++++++++++:#:*8.  .@8@o#+,,,,@*                          
                                  .8++++++++++++++++**&@8#...  +@&@8++,,,:@                         
                                  #:*+++++++++++++++*#:  .#8,,  .@+,@o++,,,@.                       
                                  @::***************:@,..  *@.,  .@+,#@++,,,@.                      
                                  #::::::**********:::,...  *@..  .@,,#@+,,,+@                      
                                 .8:::::::::::::::::&+,,,,   &#,   .@,,#o+,,,+@                     
                                 ,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#  

Installation and Usage of ASCII-ART

$ git clone https://github.com/KhorSL/ASCII-ART.git
$ cd ASCII-ART
$ pip install -r requirements.txt
$ python ascii-art.py samples/images/dino.png

Artifacts generated will be in output/.

Adjustments to Output Images

Adjust FIXED_NEW_WDITH and large_font to fine tune the image.

Example Adjustment

''' other codes... '''

FIXED_NEW_WIDTH = 200

  ''' other codes... '''

def string_image(string, font_path=None):

  ''' other codes... '''
  large_font = 20  # get better resolution with larger size

  ''' other codes... '''

Example Result

Clearer Dino


Future Plans

  • No future plans as of now.

References

ascii-art's People

Contributors

dependabot[bot] avatar khorsl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.