Image Transcoder is a Node.js-based project designed to encode and decode binary data into images and vice versa. It leverages libraries like sharp for image processing and provides a modular, worker-thread-based architecture for efficient parallel processing of files.
- Binary to Image Conversion: Converts binary data into images using a custom color mapping system.
- Image to Binary Conversion: Decodes images back into binary data, supporting file reconstruction.
- Parallel Processing: Utilizes worker threads to process multiple files simultaneously for improved performance.
- Customizable Output: Supports flexible image dimensions and output directories.
- File Metadata Encoding: Encodes file names and metadata into images for easy identification during decoding.
- Error Handling: Includes robust error handling for file operations and processing.
- 
Clone the repository: git clone https://github.com/mrFavoslav/image-transcoder.git cd image-transcoder
- 
Install dependencies: npm install 
To convert a binary file into images:
node main/ftb.js <input_file>- Input: Specify the file or directory to be converted.
- Output: Images will be saved in the outdirectory.
To decode images back into binary files:
node main/btf.js- Input: Images from the outdirectory.
- Output: Decoded files will be saved in the outputdirectory.
- -ct: Clears the temporary folder before processing.
- -co: Clears the output folder before processing.
- main/: Contains the main scripts for binary-to-image (- ftb.js) and image-to-binary (- btf.js) conversion.
- workers/: Includes worker scripts for parallel processing (- imageWorker.js,- progressWorker.js).
- OLD/: Legacy scripts and files for reference.
- out/: Stores generated images during binary-to-image conversion.
- output/: Stores reconstructed files during image-to-binary conversion.
- temp/: Temporary storage for intermediate files.
The project uses the following Node.js libraries:
- sharp: For image processing.
- fs-extra: For enhanced file system operations.
- prompt-sync: For command-line input.
- worker_threads: For parallel processing.
To view all dependencies, check the package.json file.
- File Reading: Reads the binary data from the input file.
- Nibble Conversion: Splits each byte into two 4-bit nibbles.
- Color Mapping: Maps each nibble to a specific RGB color.
- Image Generation: Creates images with the encoded data and saves them in the outdirectory.
- Image Decoding: Reads images from the outdirectory.
- Color Matching: Matches pixel colors to their corresponding nibbles.
- Binary Reconstruction: Reconstructs the binary data and saves the output files in the outputdirectory.
node main/ftb.js example.txt- Input: example.txt
- Output: Images in the out/directory.
node main/btf.js- Input: Images from the out/directory.
- Output: Reconstructed files in the output/directory.
Contributions are welcome! If you have ideas for improvements or find any issues, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
Created with ❤️ by Ondřej Chmelíček (a.k.a. Favoslav_).
Check out more about me on my website.