Skip to content

ccianos/byterep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ByteRep

This is a simple command-line tool for encoding and decoding JPEG and PNG images to and from bytes, with an option to display images on the command-line using Unicode characters.

Installation

Clone the repository and build the executable:

git clone https://github.com/ccianos/byterep.git
cd byterep
go build -o byterep

Usage

Encode an Image

Encode an image to bytes. The original format (JPEG or PNG) is preserved in the byte output.

# Encode a JPEG
./byterep -encode -input input_image.jpg > encoded_image.txt

# Encode a PNG
./byterep -encode -input input_image.png > encoded_image.txt

Decode an Image (Smart Output)

The -decode command is now TTY-aware. It changes behavior based on whether you're viewing it in a terminal or redirecting the output to a file.

  1. Display as Unicode (in Terminal) When you run -decode and the output is your terminal, it will display the image using Unicode characters.
# Display an encoded file as Unicode
./byterep -decode -input encoded_image.txt

# You can also display an original image file directly as Unicode
./byterep -decode -input input_image.jpg

./byterep -decode -input input_image.png
  1. Reconstruct Image File (Redirected Output) When you redirect the output (using >), the command writes the raw image bytes, reconstructing the original file.

Note: Ensure your output file extension (.jpg or .png) matches the format of the original image you encoded.

# Reconstruct a JPEG image
./byterep -decode -input encoded_image.txt > decoded_image.jpg

# Reconstruct a PNG image
./byterep -decode -input encoded_image.txt > decoded_image.png
  1. Force Display of Unicode Text (Redirected Output)
# You can force Unicode text on redirected output
./byterep -decode -unicode -input input_image.jpg > unicode_output.txt

./byterep -decode -unicode -input input_image.png > unicode_output.txt

./byterep -decode -unicode -input encoded_image.txt > unicode_output.txt

Options

  • -encode: Encode the input JPEG or PNG image to bytes
  • -decode: Decode the encoded data. Displays as Unicode to a terminal, or writes raw image bytes if redirected.
  • -unicode: Force Unicode text output, even when redirecting.
  • -input: Input file path
  • -help: Show help message

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Encode and decode jpg images and display them using Unicode representation.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages