This project is a command-line interface (CLI) tool that converts BMP images into grayscale and maps the grayscale values to ASCII or UTF-8 characters to create visual art. The CLI offers options to customize the output and is built using PicoCLI, a framework for command-line applications in Java.
Ensure you have the following installed:
- Java 8 or later
- Maven
- Clone the repository:
git clone https://github.com/GianniCecchetto/dai-practical-work-1
cd dai-practical-work-1
- Build the project using Maven:
./mvnw dependency:resolve clean install package
This will download dependencies, compile the code, and create a JAR file in the target/ directory.
Run the CLI to convert a BMP image into a text-based version (ASCII or UTF-8) with default settings:
java -jar ./target/DAI-PW1-1.0-SNAPSHOT.jar <inputFilename> <outputFilename> -e <encoding>
-h, --help
: Display the help message.-V, --version
: Show version information.-c, --compression
: specify a compression factor (integer).-r, --reverse
: invert the grayscale (dark <-> light).-e, --encoding
: Specify the text encoding for the conversion, eitherASCII
orUTF8
(required).
inputFilename
: The name of the BMP file you want to convert (required).outputFilename
: The name of the file where the ASCII/UTF-8 art will be saved (required).
- Convert a BMP file to ASCII art:
java -jar ./target/ImageToChar-1.0.jar image.bmp output.txt -e ASCII
- Convert a BMP file to ASCII art and reverse the shades:
java -jar ./target/ImageToChar-1.0.jar image.bmp output.txt -e ASCII -r
- Convert a BMP file to UTF-8 art and compress it by half:
java -jar ./target/ImageToChar-1.0.jar image.bmp output.txt -e UTF8 -c 2
These examples demonstrate how to convert an input BMP image into a text file using either ASCII or UTF-8 encoding.