A comprehensive collection of simple and efficient file format converters implemented in Python. This project provides easy-to-use tools for converting between various file formats.
- Modular Design: Each converter is self-contained and can be used independently
- Simple CLI: Unified command-line interface for all converters
- Batch Processing: Convert multiple files at once
- Detailed Output: Statistics and progress information during conversion
- Customizable Options: Quality settings, themes, and other format-specific options
| Converter | Description | Input Formats | Output Format |
|---|---|---|---|
| img2webp | Convert images to WebP format | JPG, PNG, GIF, BMP, TIFF, etc. | WebP |
| text2pdf | Convert text files to PDF documents | TXT, MD, etc. | |
| md2html | Convert Markdown to HTML with themes | MD, Markdown | HTML |
| csv2json | Convert CSV files to JSON format | CSV | JSON |
-
Clone this repository:
git clone https://github.com/Lazarev-Cloud/converters.git cd file-converters -
Install the requirements:
pip install -r requirements.txt
Use the included CLI tool to access all converters:
# List all available converters
python cli.py --list
# Convert all images in a folder to WebP
python cli.py img2webp /path/to/images --quality 85
# Convert all text files to PDF
python cli.py text2pdf /path/to/textfiles
# Convert Markdown files to HTML
python cli.py md2html /path/to/markdown --theme github
# Convert CSV files to JSON
python cli.py csv2json /path/to/csvfiles --prettyEach converter can also be used as a standalone module:
from converters.img2webp.main import convert_images_to_webp
# Convert all images in a folder to WebP
convert_images_to_webp('/path/to/images', quality=85)quality: WebP quality (0-100), lower means smaller file size (default: 80)
font_name: Name of the font to use (default: "Courier")font_size: Font size in points (default: 12)margin: Margin in inches (default: 0.5)
theme: CSS theme to apply (options: "default", "github", "dark")
pretty_print: Whether to format the JSON with indentation (default: True)encoding: Encoding to use when reading CSV files (default: 'utf-8')
- Python 3.7+
- Pillow (for image processing)
- ReportLab (for PDF generation)
- Markdown (for Markdown processing)
- BeautifulSoup4 (for HTML formatting)
See requirements.txt for complete dependencies.
To add a new converter:
- Create a new directory in the
convertersfolder - Add a
main.pyfile with a function namedconvert_X_to_Y - Add a
README.mdwith converter-specific documentation - Update the main
requirements.txtif needed
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-converter) - Commit your changes (
git commit -m 'Add some amazing converter') - Push to the branch (
git push origin feature/amazing-converter) - Open a Pull Request