Happy Easter!

Let's find a script that enables us to change image to ascii text!

To The Point

Img2Txt

Firstly let's check img2txt.

Installation

To install that type of utility I use pipsi. Install using:

pipsi install img2txt.py

Testing img2txt

Since it's Easter I decided to check some of the Easter-Bunny pictures as in this blog to use it with img2txt.

Image I'm going to use to check img2txt: bunny_eggs.

And the result looks like this:

---------;;-;------:::::::-:::::;;;;;;.;;;;;;;--:!>>7777777777777777777>7777777777777777777777777777
-------;;;;;;------------------;;......;;;;;;;;;-:::!!!!!!!!!!>>>>7>>>!::!>>777777777777777777777777
-----;;;;;;;------------------;..................;;;;:!:::::::!!!!:-;;;...;;;:7777777777777777777777
-;;;;;;;;;;;------------------;......................;-:::::::::::;..........;77777777>>>77777777777
;;;;;;;;;;;-----------;;-----;;......................;;::::::::--;..........;;-7777>>>>>>>>>77777777
;;;;;;;;;;----------;;----;--;;.............;.......;;---------;..............;>>>>>>!!!>>>>>7777777
;;;;;;;;;;;;------;;;-;;;;;--;;;..........;;..........;;-------;...............-!!!!!!!!!>>>>>>7777>
;;;;;;;;;;;;;;-;;;;;;;;;;;;;-;..;;;;;;;;;;;;;.............;;--;................;-::::::::!!!>>>>>>>>
;;;;;;;;;;;;;;-;;;;-;;->>!;7Q?!;.!!.!..;;;;;;..............;;;;................;------::::::!!!!!>>>
;;;;;;;;;;;;;;;;;;;;;.....:$?!>$C;>7!:;!.;;;;..............;;;;...............;;;-;;----::::::::::::
;;;;;;;;;;;;;;;;-;..;:!7CO$$C!7$C$O;OC>!7-;;;;;;...........;;;;...............;;....;;----:::::::---
;;;;;;;;;;;;;;;;;7:-;!7COOOO$OC$$OO?O!$O;;-.;;;;............;;;......................;--------------
;;;;;;;;;;;;;;;!.>?>-$$O$Q$O$$O$Q?!?!O$7C7C;:;;;;;;.........;;;;;...................;;--------------
;;;;;;;;;;;;;;.>?-;7$$$$O$C!C?!>O77!?$$>>CC!;;;;;;;;;;;...;;;;;;;;;...............;;;;;;----;;;;;;;;
;;;;;;;;;;;;;-O.:O$OOQ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C!>?!:>?>C$!!?7CO$$C>>>:....;;;;.....;;;;;;;;;;;;;;;;;;;;;;;;..........
.......-C:??!O7:C$?:OOO-..?OC>$HH??QC>>>--:O$$O$O?!77;............;;;;;;;;;;;;;;;.;;;;;;;;..........
;.....;:;7:$O?C7;7O$OC:..;?C7-$HHO>C7!;:::!!CQ$OO?>>C;............;;;;..;..;;...;....;;;;;..........
;;;;;..>>!>QO$OC7;Q$$?-..->C!:O$HO!!:!!::-!::O$COC7-$;............;;;;..................;;..........
;;;;;..:>:!$$;-!OQ$?77;..!77?!>O>!?!>:-!!;!!-!$$OC:-C;................................;;......;;;.;.
;;;;...:!7>OO!!7CO7::!...-:!:-!7?!------!-7:-:?CO?:7!;...............................;......;;;;;.;.
;;.....>!-7$OC$Q$7--:;...;77:7!>!!:---!!!!>!::>?O7!!-;.....................................;;;;;....
;......>!;:C7C$O?>:!!;;-;.!C?-77!!-::>>!:7>-!-!>?7>!-...............................................
;;;;;;.>!;-C-O$??>:7!-.!;;-CO?!?C>!7!>!:!>-!-!->C7>-?..;.;;;;;;;....................................
;-;;;;;!!;;?!O$C>7>7>:;:.;->7?C7>>>77:!!!-:!!!:?C!!!:..;.;;;;;;;;;;;;;;;;.;;;-;;;;;.................
-:-;::;:>-.??$O7>7??!!:-;;;->!OC>?7>!---;:>!:-->C>::;;;;;.;;;;;;;;;;;;;;;;--:!:>>!:--;;-;;;;;.....;;
7CC?CC>?>-::$!O?>7!>7>>!--;;::>7?>:--;-!!!:>>::>?:O7-::>:->:--!>!!::!!>!!7>77?????C77>77>>!!!!::::!!
OCO?>;-?:--7O$CO>!>>>>!>::7-:->!!:--;;-:C>7:!:-7>>-;?7?7????77777?????77?????CCCCC????C???C??7?7??77
?7;;. ;--::;$O>;   ;>>>!:;..;-!!:--;;;;!::!!;.   .>!77?C?7777777?C??????CCC??C??CC?CC?CCC??C???7?C77
7------:::7-;;.      :?!:>>;-. ;--;;;;;-:7!...!!!!;;7>777>! ; !.77????7??????C????C77?77777>>>>>7777
-  -::-. !!   .7 ? ;  :;>>>;- : ;;-;;;;;-!..>>!----!:7>77 !;  !. !????77?>7?7777?7>?7?77>>7>>>777>>7
   :!!:. ::   .: !:  !>77777.-;-; --;;---.>>:-;;;..;-:?>  ->!!>>>!!7?7C7??777777??7???777>C7>77>>777
   ..!-!!C    ;  ?  ;77777777.-- 7!----;-7:-.    .-;. 7!:>7;!>!>!:--7>>77C77C??CC?>CCC?C?7777?7>7??7
;    :.;!     . ?   > .777. 777777. .::-7-;  .:!!!!!!!;?7>-::?77??!!::?77?>7C7>777!?777777?7>>7777??
!.    ;;   >       >.:;777.;:7777?7  :!:-;.;!!!!!!!!!!!?7?C777??77?77!!777>C7C??7>C7:?7>>7>?77??COC?
    : - :         .>;.7777777?????: !!!;..!!!!!!!!!!!!!:C?C??????!!;?7>>>C777>7>7777>7777?>C??!7CQC7
      :    ..  > .777777777???????- >.>7;!!!!!!!!!!!!!!!CCC??????7:-7?>;>:77OC77?7?>?7!77>??CC7?>?77
 ?    .  .: ! .  .7???????????>???; 7.!!!!!!!!!!!!!::!!!OOC???????????7777?OCC?C!??7?>?7COOC7?7?>7!7
 C    .  ! ..>.. ;?!;????????.:.?C7 ?.;:!!!!!::-;;;;;-;-:OOOC????????7777?C?7>$>C?7>>>!7:OO??>OCO:>:
.....;;  ..-....;>?!?????????.!>CC!.C;>:!!!!:--;;;;;-----CCO>CCCCC???????O$CC7O>O7:7>!CO!7>7-O>$!7??
....O-....!.>...;????- !..???->:CO?;O-7!>>!:--;!C???CC---$$>>7OOOCC???C?$C?7>>O7>>?>7?!7?7-7?CCO?7C?
...;;>.>.;.7...;;>CC. .. .?CCC>7OO$:$7;7>>!:;C??C????CCO-Q$>Q?O$OOOOOOCCOO:O>?7!7:C?:?O-O7:C7?>C>??O
.;;-!Q;....;..;-:!C:.777>..:CCCOO$OQQ--H7>!CC???C?C????CQHQQ$$$Q$$Q$O7$$77>!7?CC7>!C?7?>?>!!?7>?>7?>
;:-!OQ;:;..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7!77
?CC$?C???::7:?CC?Q>7C?C>7C7:7CCOOCCOO$CCO!?OO$CC>?>>77??7??OOCCCOC$?!?O7C?>??OC?77:>CC?O?CCOO?>7>!77
$OOCO?C?7>!7?CC7C>>?!??OC?7??OO$OQ$OQO>7?!C7$???C??7??7777>?COOCOCC7C??CC??7C$C??7!CCCC??>7CO?>>?7??

IMHO it does not look great.

Let's give it a second shot with this image:

Easter Bunny with Egg hand-draw

The output:


                                                                         :           

                                                                        M            
                                                                       M >           
                                                                      M  C           
                                                                    !    Q           
                                                                   M     H           
                                                                 :C      !           
                                                                M                    
                                                              -H                     
                                                             M     M  M              
                                                            M    M                   
                                                           ?    !                    
                                                         ;    M        -             
                                                             M           !           
                                                        :   ?            M           
                                  MMMMC                M   .          M  -           
                              M?        M             M  Q           !  M            
                            M.           O                              -            
                          M         M-CM.O           M  M              M             
                         M         M M                 M                             
                       .;             :             M  ;              M              
                       ;          M   M             - :              M               
                      >               M  7            M             Q                
                     H           M    N  M         M               H                 
                    M                    !         M                                 
                                M    >  >          Q M           H                   
                   M            ;    M  M            M          Q                    
                               M     M  .            ?         M                     
                  M            $     ;               -        M                      
                  M           ; ;      Q                     H                       
                  7           M M      M             -     O                         
                  ;                  ; M  MM> M      ;    M                          
                  :          M   M   M M   ? M MM        7                           
                  M         M     M    M M-     M  H   :CC.                          
                  M       M        M    MQ             M   ;M                        
                         H        M>                          $                      
                   M    M       M                              $                     
                    M  Q      M                 O                                    
                     . H     M              MM MM               M                    
                      M     M       M       MM  M-                                   
                           !         M      -MMM        M        Q                   
             C?;                   MM  N     MMMH       :$      MM                   
         M77    ?MMM      M           ;O C    MM    ;CM         MM                   
      .M   M. M:MMM. M7   QM             $ M  !   M7   QMCCM     M                   
     C  ?MM?.  M    M  M   !     >.    CM  .M O  M  H  ;M        .                   
    M    M  M?. M .M   MM;Q         .       - C M:    -           ;                  
       MMHM M  >M M  >MMM MM        M Q       N                 M    ;-              
   M   Q.    M   M  Q:  M MO        M   -     M      ?          HM  M                
        M MMMHM M   M   !M                    M     M           OH     -             
  M   MMMM M   M   MMQ M.  M              .  :     M               O      ?          
  M   ;H    M  M  M .MN                    7 NMMMM!               M       M          
  M    M M$MMMM  M   N?  ;  M               M   M              M :                   
  M  MMM.:N  O  C!   M    : Q              M    M              M         $           
  M  H    M  M  MH  M    HM7>7          ->M     MQ            M           N          
  M   M MMMMQ  M MM?   >M  : O        M;          M                       ?          
    ?MMM!   M  H   M    M :M  M      M             M         M            M          
    M    M N  M   M     M O    M                            M           !M           
   M$ MMMMMM  7   ?   M:  O    MM   ;                     ;!      MM;                
   M M M   ; M-M M    M MM.    $  :M               M    -M      M                    
    CM >  M  M   M    M M         M              MMMMMO      .N                     .
    M   M M  -  M   MN  MM MM MM M               >    H     M                        
     MMMMMM H   M   M MM  M  N  M                    MM    H                         
      M   O M?M C   - MM        N                     !   MM  M;                     
      OM  - M M    MM>          M                     M   Q     ;     HM             
       MM 7 M  ?   M C         MM        M>CM7  :$    M  M      !    N !            .
        H M M   MM  $>       C          MQ  H $M                 M   ;M              
         OM M OM MMMM.M     O    O      M    M  :   O>           >  M .              
           M 7MQ  MM M           !     !         M   M            ;  M M             
            $M    - :H     M      M   MM         >M               MM MMM   M:        
              NQM  MMM              M M          ;MM              MC MM M?  MN       
                MMMMNCM   :                                       M   MMM   MM.      
                 MM> MM   Q                         M             M   MM    M .      
             >N.NM N   MM ?        ;                M             M    M   M  Q ;MM  
               H7C M  O   M                         M             M     ;$.          
                           7                        :             M                  
                           M     M                                M                  
                                                   M              M                  
                            M   7                 MM           -M M                . 
     .                       M  M    M !          ;.       H>    MM                  
                                M   M   M;       M        M      ;                  .
                              ! !   M            CM M    >      O                    
       .                       M    !           M  M M   ;        ?                  
                              MMN    M         H    H      MNNM   M >M               
 .                             ;M>    ?   M          :           : M$                
             .               ;$MMM     .M.    !                  . :MO               
                          MMMMMM  M          .         .:       M    NMM:M;          
                         :         M       M             M    :$                     
                                     M7:$M                MMMM                       
                                                                              .      

                                            OM.                                      
                                          7M !                                       
                                      CMMMM M                                        
                                       ; MM M 7.MMM.                                 
                              .                                            .         


MotionDesignStudio script

There is also another ascii movie image ver 1 py.

The Readme is very convenient to know how to use it.

Fixing issues with script

Well... I tried to use the script itself, but unfortunatelly after a bit of digging I've found it lacks proper information about package used and has some issues.

First of all I had few TabsError (inconsistent use of tabs and spaces in identation).

So I went to vim and used vim command :retab. Saved file.

Then I needed to fix dependencies problem.

So I figure out why not create project out of it to have all the relevant files in one place.

As the result here is the link to project at github. It contains Pipfile and Pipfile.lock - for easier usage with pipenv.

Usage

I suggest you to get the version from my github project since it has fixed some issues.

git clone https://github.com/anselmos/ascii_movie_image_ver1.git

Then :

cd ascii_movie_image_ver1 && pipenv install --python 3.6
pipenv shell

Using on pipenv shell:

python ascii_movie_image_ver_1.py image.img 4 16

Results of using:

Easter Bunny converted

Acknowledgements

Auto-promotion

Related links

Thanks!

That's it :) Comment, share or don't - up to you.

Any suggestions what I should blog about? Post me a comment in the box below or poke me at Twitter: @anselmos88.

See you in the next episode! Cheers!



Comments

comments powered by Disqus