This project provides a Python tool to encode standard image files (like PNG, JPG) into the custom Pixtess text-based image format, and decode Pixtess files back into viewable PNG images.
Pixtess is a conceptual format designed to represent image data as structured text, incorporating a color palette and run-length encoding (via coordinate ranges) for compression. It uses an abstract color model based on 6 base components (Blue, Green, Red, Yellow, White, Black) and allows specifying percentage mixes using a modulation system.
- Encode: Convert standard image files (readable by Pillow) into
.pixtesstext files. - Decode: Convert
.pixtesstext files back into viewable.pngimage files. - Internal Compression: Uses Palette encoding and Run-Length Encoding (via coordinate ranges) within the text format itself.
- Color Model: Implements the Pixtess color model with 6 bases and percentage modulation (current encoding uses a "Phase 2" heuristic algorithm - see
pixtess_utils.py). - Command-Line Interface: Simple CLI for encode/decode operations.
pixtess_main/
├── requirements.txt # Python dependencies
├── pixtess_utils.py # Core Pixtess logic (parsing, color conversion)
├── pixtess_converter.py # Main script with CLI, file I/O
└── README.md # This file
-
Clone or Download: Get the project files.
# Example using git: # git clone https://github.com/necat101/pixtess.git # cd pixtess_main
(Or simply download
pixtess_converter.py,pixtess_utils.py, andrequirements.txtinto the same folder). -
Install Dependencies: Navigate to the project folder in your terminal and install the required library (Pillow) using pip:
pip install -r requirements.txt
Run the converter from your terminal within the project directory.
Encoding (Image File -> Pixtess File):
python pixtess_converter.py encode -i <input_image_path> -o <output_pixtess_path>- Replace
<input_image_path>with the path to your image (e.g.,my_cat.png,photos/landscape.jpg). - Replace
<output_pixtess_path>with the desired name for the output Pixtess file (e.g.,my_cat.pixtess). - If
-ois omitted, the Pixtess string will be printed directly to the console.
Decoding (Pixtess File -> PNG Image):
python pixtess_converter.py decode -i <input_pixtess_path> -o <output_image_path>- Replace
<input_pixtess_path>with the path to your.pixtessfile (e.g.,my_cat.pixtess). - Replace
<output_image_path>with the desired name for the output PNG image (e.g.,decoded_cat.png). - If
-ois omitted, the output file will be nameddecoded_<input_base_name>.png(e.g., decodingmy_cat.pixtesscreatesdecoded_my_cat.png).
If you're using Windows 11 and are less familiar with the command line, follow these steps:
-
Install Python:
- The easiest way is often via the Microsoft Store. Search for "Python" (choose the latest stable version, e.g., Python 3.11 or 3.12) and install it. This usually sets up
pipand adds Python to your system PATH automatically. - Alternatively, download from python.org, run the installer, and make sure to check the box that says "Add Python to PATH" during installation.
- Verify: Open Command Prompt (search for
cmdin the Start menu) and typepython --versionthen press Enter. You should see a version number. Typepip --versionand press Enter. You should see pip's version. If these commands don't work, Python wasn't added to your PATH correctly during installation.
- The easiest way is often via the Microsoft Store. Search for "Python" (choose the latest stable version, e.g., Python 3.11 or 3.12) and install it. This usually sets up
-
Download Project Files:
- Create a folder for the project, for example,
C:\Users\YourUsername\Documents\PixtessConverter. - Save the three files (
pixtess_converter.py,pixtess_utils.py,requirements.txt) into that folder.
- Create a folder for the project, for example,
-
Open Command Prompt in Your Project Folder:
- Navigate to your project folder in File Explorer (e.g.,
Documents\PixtessConverter). - Click in the address bar at the top of the File Explorer window.
- Type
cmdand press Enter. This will open Command Prompt directly in that folder.
- Navigate to your project folder in File Explorer (e.g.,
-
Install Dependencies:
- In the Command Prompt window you just opened, type the following command and press Enter:
pip install -r requirements.txt
- Wait for it to download and install Pillow.
- In the Command Prompt window you just opened, type the following command and press Enter:
-
Run the Converter:
- Make sure the image file you want to encode (or the
.pixtessfile you want to decode) is accessible. You can either place it in the samePixtessConverterfolder or use its full path. - Encoding Example (Saving to a file):
(Replace
python pixtess_converter.py encode -i "C:\Path\To\Your Pictures\my_image.png" -o "encoded_image.pixtess"
"C:\Path\To\Your Pictures\my_image.png"with the actual path to your image. Use quotes if the path contains spaces. The output fileencoded_image.pixtesswill be saved in yourPixtessConverterfolder unless you specify a different path for-o). - Encoding Example (Printing to screen):
python pixtess_converter.py encode -i "my_image_in_same_folder.jpg" - Decoding Example:
(This assumes
python pixtess_converter.py decode -i "encoded_image.pixtess" -o "decoded_image.png"
encoded_image.pixtessis in the current folder. It will savedecoded_image.pngin the same folder). - Decoding Example (Default Output Name):
(This will create
python pixtess_converter.py decode -i "encoded_image.pixtess"decoded_encoded_image.png).
- Make sure the image file you want to encode (or the
The Pixtess format stores image data textually within a PIXTESS[...] structure containing:
- Metadata: A dictionary with image info, including the mandatory
"RESOLUTION": "WxH". - Palette: An ordered list of all unique Pixtess color codes (
"0x...") used in the image. - Data: A dictionary mapping each palette index to a list of
(start, end)pixel coordinate ranges where that color appears (using row-major pixel indexing).
(See Pixtess Format Specification document for full details on the structure and color code definitions).
- The current RGB -> Pixtess encoding algorithm (
rgb_to_pixtess_codeinpixtess_utils.py) uses heuristics (based on HSL) to map colors. While better than simple quantization, it may not perfectly represent all complex color mixes or subtle gradients. Further refinement of this algorithm could improve color fidelity. - Error handling for malformed Pixtess files during decoding could be enhanced.
- Consider adding support for RGBA (handling transparency).
This format was designed for an upcoming update to my MFANN models, where i try to train previously text-only models on pixtess data, and have a handler program run on the frontend to convert back into a standard rgb png/jpg. however, this format can very well be used for other things!
MIT License
Copyright (c) [2025] [Makhi Burroughs]