Coder Social home page Coder Social logo

victorqribeiro / imgtoascii Goto Github PK

View Code? Open in Web Editor NEW
388.0 13.0 33.0 622 KB

A JavaScript implementation of a image to Ascii code

Home Page: https://victorqribeiro.github.io/imgToAscii/

License: MIT License

HTML 10.08% JavaScript 89.92%
ascii ascii-art ascii-graphics image-manipulation image-processing javascript image-to-ascii

imgtoascii's Introduction

imgToAscii

A JavaScript implementation of a image to ascii converter.

Live example

How to use

Include the imgToAscii.js file

<script src="src/imgToAscii.js"></script>

or

<script src="https://raw.githubusercontent.com/victorqribeiro/imgToAscii/v1.3/src/imgToAscii.js"></script>

then just create a new imgToAscii object with the image address and optionaly the alphabet: (0 - simpler shades, 1 - more complex shades) - default is 0

let ele = new imgToAscii('elefante.png');
ele.display();

You can also resize your image passing a second parameter between 0 and 1 as percentage. e.g.: 0.5 = 50% - Will reduce the size of your image in 50% both vertical and horizontal (width, height).

let eu = new imgToAscii('eu.png',0.5);
eu.display();

To display the ASCII image with color just call the method displayColor(). You can set the background color of your image passing a color parameter to the method. e.g.: gray, white, black, #fff, rgb(10,10,10). Default is transparent.

eu.displayColor('gray');

Note that on the code above the same 'eu' image was used. Once you load an image, you can display it with or without color, without the need to reload the image data.

Important

The ascii art depends on a monospace font to work properly. You should consider that 1 pixel in your image is going to be translated to 1 char in Ascii. e.g.: if a image is 100 pixels wide, it's going to take 100 chars of space on your page, unless you do something about it.

The imgToAscii should work with remote images:

let img = new imgToAscii('http://site.com/image.png');

but it might not because of cross-origin settings. Keep that in mind.


A similar code is running on my photoEditor to generate a image of the ascii code (what?!)

result

result

result

Open Source Helpers

Donations

imgtoascii's People

Contributors

victorqribeiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgtoascii's Issues

space width difference between color and black on ios

Describe the bug

Space width difference between color and black on ios, color mode's width is shorter than black's

but it's normal on PC

To Reproduce

  1. run server
  2. open in ios's brower like Safari or Chrome
  3. the space's width in color pic is wrong

Expected behavior

the shape of color's should be like black's

Screenshots

5bc288075ed7048ee09d735422620e2

d2882a4ac52fa2930695f1281d0c7ab

Smartphone :

  • Device: iPhone11 pro
  • OS: iOS13.6
  • Browser: Chrome, safari and Firefox all the same
  • Version: latest

AMD / CommonJS support

Is your feature request related to a problem? Please describe.
This could me imported as an module

Describe the solution you'd like
Add AMD / CommonJS / ES modules support

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.