Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brhaka/imagetoascii

Lightweight ImageToASCII converter written in C
https://github.com/brhaka/imagetoascii

ascii ascii-arts c command-line conversion converter fun image lightweight

Last synced: 8 days ago
JSON representation

Lightweight ImageToASCII converter written in C

Awesome Lists containing this project

README

        

# ImageToASCII

[![License](https://img.shields.io/github/license/brhaka/ImageToASCII?style=for-the-badge)](https://github.com/brhaka/ImageToASCII/blob/master/LICENSE)
[![Release](https://img.shields.io/github/v/release/brhaka/ImageToASCII?color=%234DC820&style=for-the-badge)](https://github.com/brhaka/ImageToASCII)
[![Size](https://img.shields.io/github/languages/code-size/brhaka/ImageToASCII?style=for-the-badge)](https://github.com/brhaka/ImageToASCII)

[![GitHub stars](https://img.shields.io/github/stars/brhaka/ImageToASCII.svg?style=social&label=Star)](https://github.com/brhaka/ImageToASCII)

## Usage

`ImageToASCII` runs on the Command-Line.
You must provide a path to the image you want to convert. You can do this by passing it as a Command-Line argument (`./ImageToASCII "./image.png"`). In the case where no argument is passed, ImageToASCII will prompt you to write the image path on the command-line.

Another input that `ImageToASCII` requires is the `Image Resize Factor`. You can enter a value between `1` and `50`. The image will be resized according to the entered value. E.g.: With a resize factor of 10, a 3840x2160 (pixels) image becomes a 384x216 (characters) ASCII art.

There are also other inputs ImageToASCII will ask you, such as wether you want to store the path to the image for later use and also wether you want to use the stored path (if previously stored).

The ASCII art is saved to a file named `ascii.brk`. The extension is symbolic, but since NotePad has a limit of 1024 characters per line, to avoid confusion, it is not saved as a `.txt` file. You can open the `.brk` file with any text editor. Personally, I use [NotePad++](https://github.com/notepad-plus-plus/notepad-plus-plus).

Since the program has no control over which font the ASCII art is being visualized, a whitespace is inserted after each character. E.g.: '@' becomes '@ '

*Please have in mind that the larger your ASCII art is, the more detailed it can be. It will be also heavier. E.g.: 1 character = 1 byte, so a 384x216 ASCII art weights 82.944 bytes PLUS whitespaces between columns. Total of 165.888 bytes.*

## Installation

ImageToASCII is compiled to a single file, for easier use. There is a specific file for each OS version. If you wish to use ImageToASCII on **Linux**, download the `ImageToASCII-Linux` file. On **MacOS**, download the `ImageToASCII-MacOS` file and on **Windows**, download the `ImageToASCII-Windows_x86_x64.exe` file. You can start your download at the [Releases](https://github.com/brhaka/ImageToASCII/releases) section. It's also possible to [compile the source code](https://github.com/brhaka/ImageToASCII#compiling).

To start the program, all you need to do is execute it via command-line. E.g: `./ImageToASCII-Linux "./image.png"`

### Branches

The **[master](https://github.com/brhaka/ImageToASCII/tree/master)** branch contains the most recent stable release source code. The **[development](https://github.com/brhaka/ImageToASCII/tree/development)** branch contains the current development source code. It may be unstable.

### Compiling

It's also possible to download the source code and compile it yourself. First, you must clone or fork this repository into an empty directory. Then, via command-line, you can run the following commands:

`make LINUX` and `make MACOS` will compile the **Linux** and **MacOS** versions of the program. The output files are named `ImageToASCII-Linux` and `ImageToASCII-MacOS`, respectively. This command uses `gcc`. In order to execute it on Linux, it must be compiled on **Linux** and the same rule is applied to **MacOS**.

`make WIN` will compile the **Windows** (x86 and x64) version of the program. The output file is named `ImageToASCII-Windows_x86_x64.exe`. This command uses **mingw**.

The `make`, `make all`, `make re` and `make ImageToASCII` commands will compile the **Linux**, **MacOS** and **Windows** versions of the program.

To compile a version that won't use ANSI colors on the output, add `USE_COLORS=0` to your `make *` command. E.g: `make WIN USE_COLORS=0`

## Features

* Supports JPG, JPEG, PNG, TGA, BMP, PSD, HDR, PIC
* Works with **any** image resolution
* Clean and detailed ASCII arts
* **Linux**, **MacOS** and **Windows** versions
* Lightweight
* Open Source

## Showcase

### High character count

![Beliaikin](https://user-images.githubusercontent.com/32342284/114232473-d7752700-9973-11eb-9889-dc30f1bb69d8.jpg)
![Antelope Close-Up](https://user-images.githubusercontent.com/32342284/114233077-b2cd7f00-9974-11eb-932e-b95f23102268.jpg)
![Leitisvatn](https://user-images.githubusercontent.com/32342284/114232421-c5938400-9973-11eb-8f8b-ac16a543ade0.jpg)
![Girl Holding Leaf](https://user-images.githubusercontent.com/32342284/114232397-b90f2b80-9973-11eb-9958-1dd4f8296875.jpg)

### Low character count

![Pear Low](https://user-images.githubusercontent.com/32342284/114232801-5d916d80-9974-11eb-88f5-a94218a8a622.jpg)
![Antelope Close-Up Low](https://user-images.githubusercontent.com/32342284/114232569-f673b900-9973-11eb-874c-675369ebe6ea.jpg)

*Images by [pexels.com](https://www.pexels.com/collections/imagetoascii-vk9vgay/) and [Eirik Sørstrømmen](https://500px.com/photo/122484453/the-cliffs-of-leitisvatn-by-eirik-sorstrommen)*

## Contributing
**Like what you see?** Please, feel free to fork this repository, and make any change you like. If you
want to propose a nice feature, please create a separate branch on your fork,
named after the feature you want to implement, then make a pull request from that
branch. Thank you!