Giter Site home page Giter Site logo

image-to-ascii's Introduction

image-to-ascii

License stb_image stb_image_write stb_image_resize2 Cross Platform

Overview

A command line tool for converting images to ASCII art.

Installation

  1. Clone this project
git clone https://github.com/Oakamoore/image-to-ascii.git
  1. Step into the repository
cd image-to-ascii
  1. Build the project using CMake
# Configure the build
cmake -S . -B build

# Build project binaries 
cmake --build build

Specifying a Build Configuration

Depending on the type of CMake generator being used, a build configuration (Debug, Release etc.) can be specified as follows:

Single Configuration Generator

# Configure a release build
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release

# Build release binaries
cmake --build build

Multi-Configuration Generator

# Configure the build
cmake -S . -B build 

# Build release binaries
cmake --build build --config Release

Disabling Testing

To prevent tests from being built, append -D ENABLE_TESTING=0 to the build configuration command.

Usage

Once the project is built, navigate to the newly created build directory, image-to-ascii/build/, and locate the executable.

  1. Run the program once, to create the input/ and output/ directories (if they do not already exist):
./image-to-ascii
  1. Populate the input/ directory with the images to be converted

  2. Run the program again, this time supplying command line arguments - in the form of the names of images with their file extensions:

./image-to-ascii apple.png banana.png 

If the arguments provided are valid image names, the output/ directory will be populated as follows:

# Place images to be converted here
input/
	apple.png
	banana.png

# Creates a directory based on the image's file name
# Holds the intermediate conversion steps (defaulted to 'png')
output/	
	apple/
		apple_resized.png
		apple_greyscale.png
		apple_ascii.txt
	banana/
		banana_resized.png
		banana_greyscale.png
		banana_ascii.txt

For subsequent uses the first step can be skipped, so long as the intput/ directory exists.

Testing

Catch2

Once the project is built, navigate to image-to-ascii/build/tests/, and locate the testing executable.

The tests/../input/ directory should be populated by a sample image - if this isn't the case, then delete the image-to-ascii/build/ directory and rebuild the project.

Run the test(s) with the following command:

./image-to-ascii-tests

Known Issues

Secure Functions

MSVC defaults to its implementation of secure _s functions (that are poorly supported).

stb_image_write.h (as of this commit ) defines __STDC_LIB_EXT1__ to determine whether or not to use these _s functions, though certain versions of Visual Studio require __STDC_WANT_SECURE_LIB__ to function.

This project's workaround is defining _CRT_SECURE_NO_WARNINGS in image.cpp, to suppress deprecation warnings, in favour of the non _s functions.

Warnings as Errors

This project was built with Visual Studio, and has both Warnings as Errors (/WX) and Warning Level Four (/W4) enabled. This project also makes use of the stb image processing header libraries, which don't compile cleanly with /W4.

This project's solution is wrapping the offending third party header library includes in #pragma warning(push, n) and #pragma warning(pop) to temporarily disable warnings:

#pragma warning(push, 0)
#include "stb_image.h"
#include "stb_image_write.h"
#include "stb_image_resize2.h"
#pragma warning(pop)

This is of course implementation defined, so not all compilers will support this. If this doesn't work for your specific compiler, consider temporarily disabling your equivalent of /W4 when using this project.

image-to-ascii's People

Contributors

oakamoore avatar

Watchers

 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.