freeai-convert 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- freeai_convert-0.1.0/LICENSE +21 -0
- freeai_convert-0.1.0/PKG-INFO +205 -0
- freeai_convert-0.1.0/README.md +128 -0
- freeai_convert-0.1.0/freeai_convert.egg-info/PKG-INFO +205 -0
- freeai_convert-0.1.0/freeai_convert.egg-info/SOURCES.txt +16 -0
- freeai_convert-0.1.0/freeai_convert.egg-info/dependency_links.txt +1 -0
- freeai_convert-0.1.0/freeai_convert.egg-info/entry_points.txt +2 -0
- freeai_convert-0.1.0/freeai_convert.egg-info/requires.txt +52 -0
- freeai_convert-0.1.0/freeai_convert.egg-info/top_level.txt +1 -0
- freeai_convert-0.1.0/freeconvert/__init__.py +92 -0
- freeai_convert-0.1.0/freeconvert/__main__.py +4 -0
- freeai_convert-0.1.0/freeconvert/cli.py +96 -0
- freeai_convert-0.1.0/freeconvert/handlers.py +760 -0
- freeai_convert-0.1.0/pyproject.toml +67 -0
- freeai_convert-0.1.0/setup.cfg +4 -0
- freeai_convert-0.1.0/tests/test_data.py +53 -0
- freeai_convert-0.1.0/tests/test_dispatch.py +76 -0
- freeai_convert-0.1.0/tests/test_subtitle.py +54 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Free.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: freeai-convert
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Universal file format converter — one HANDLERS table, ~80 format pairs (image/audio/video/pdf/office/ebook/csv/srt/archive/3d).
|
|
5
|
+
Author-email: "Free.ai" <hello@free.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://free.ai/convert/
|
|
8
|
+
Project-URL: Repository, https://github.com/freeaigit/free-convert
|
|
9
|
+
Project-URL: Issues, https://github.com/freeaigit/free-convert/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/freeaigit/free-convert/releases
|
|
11
|
+
Keywords: converter,pdf,docx,ffmpeg,libreoffice,image,audio,video,ebook,csv,srt
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Operating System :: MacOS
|
|
19
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Topic :: Multimedia
|
|
28
|
+
Classifier: Topic :: Office/Business :: Office Suites
|
|
29
|
+
Classifier: Topic :: Utilities
|
|
30
|
+
Requires-Python: >=3.9
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: click>=8.1
|
|
34
|
+
Provides-Extra: image
|
|
35
|
+
Requires-Dist: Pillow>=10; extra == "image"
|
|
36
|
+
Provides-Extra: heic
|
|
37
|
+
Requires-Dist: Pillow>=10; extra == "heic"
|
|
38
|
+
Requires-Dist: pillow-heif>=0.16; extra == "heic"
|
|
39
|
+
Provides-Extra: svg
|
|
40
|
+
Requires-Dist: cairosvg>=2.7; extra == "svg"
|
|
41
|
+
Provides-Extra: pdf
|
|
42
|
+
Requires-Dist: pdfplumber>=0.10; extra == "pdf"
|
|
43
|
+
Requires-Dist: pdf2docx>=0.5; extra == "pdf"
|
|
44
|
+
Requires-Dist: python-docx>=1.1; extra == "pdf"
|
|
45
|
+
Requires-Dist: openpyxl>=3.1; extra == "pdf"
|
|
46
|
+
Requires-Dist: python-pptx>=0.6; extra == "pdf"
|
|
47
|
+
Requires-Dist: pdf2image>=1.17; extra == "pdf"
|
|
48
|
+
Provides-Extra: office
|
|
49
|
+
Requires-Dist: openpyxl>=3.1; extra == "office"
|
|
50
|
+
Requires-Dist: python-docx>=1.1; extra == "office"
|
|
51
|
+
Requires-Dist: python-pptx>=0.6; extra == "office"
|
|
52
|
+
Requires-Dist: reportlab>=4; extra == "office"
|
|
53
|
+
Provides-Extra: archive
|
|
54
|
+
Requires-Dist: py7zr>=0.20; extra == "archive"
|
|
55
|
+
Provides-Extra: mesh
|
|
56
|
+
Requires-Dist: trimesh>=4; extra == "mesh"
|
|
57
|
+
Provides-Extra: all
|
|
58
|
+
Requires-Dist: Pillow>=10; extra == "all"
|
|
59
|
+
Requires-Dist: pillow-heif>=0.16; extra == "all"
|
|
60
|
+
Requires-Dist: cairosvg>=2.7; extra == "all"
|
|
61
|
+
Requires-Dist: pdfplumber>=0.10; extra == "all"
|
|
62
|
+
Requires-Dist: pdf2docx>=0.5; extra == "all"
|
|
63
|
+
Requires-Dist: python-docx>=1.1; extra == "all"
|
|
64
|
+
Requires-Dist: openpyxl>=3.1; extra == "all"
|
|
65
|
+
Requires-Dist: python-pptx>=0.6; extra == "all"
|
|
66
|
+
Requires-Dist: pdf2image>=1.17; extra == "all"
|
|
67
|
+
Requires-Dist: reportlab>=4; extra == "all"
|
|
68
|
+
Requires-Dist: py7zr>=0.20; extra == "all"
|
|
69
|
+
Requires-Dist: trimesh>=4; extra == "all"
|
|
70
|
+
Provides-Extra: dev
|
|
71
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
72
|
+
Requires-Dist: Pillow>=10; extra == "dev"
|
|
73
|
+
Requires-Dist: openpyxl>=3.1; extra == "dev"
|
|
74
|
+
Requires-Dist: build; extra == "dev"
|
|
75
|
+
Requires-Dist: twine; extra == "dev"
|
|
76
|
+
Dynamic: license-file
|
|
77
|
+
|
|
78
|
+
# freeai-convert
|
|
79
|
+
|
|
80
|
+
**Universal file format converter.** One dispatch table, ~80 format pairs across image / audio / video / pdf / office / ebook / csv / srt / archive / 3d.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install freeai-convert
|
|
84
|
+
freeconvert resume.pdf resume.docx
|
|
85
|
+
freeconvert song.flac song.mp3
|
|
86
|
+
freeconvert photo.heic photo.jpg
|
|
87
|
+
freeconvert deck.pptx deck.pdf
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Same converter that backs every `/convert/<pair>/` page on [free.ai](https://free.ai/convert/), extracted into a standalone CLI + Python library.
|
|
91
|
+
|
|
92
|
+
## Why this exists
|
|
93
|
+
|
|
94
|
+
Most "universal converters" are either thin wrappers around `pandoc` (great for text, useless for images) or trillion-dependency monsters that take a `pip install` over a coffee break. `freeai-convert` is a **dispatch table**: one `(src_ext, dst_ext) → handler` map. Each handler is a 5–30 line wrapper around the right tool for the job — Pillow for images, ffmpeg for media, libreoffice for office, pdf2docx / pdfplumber for PDF, calibre for e-books, trimesh for 3D meshes, stdlib for csv/json/srt/vtt.
|
|
95
|
+
|
|
96
|
+
Adding a new format pair = one function + one line in `HANDLERS`. No abstraction, no plugin system, no class hierarchy.
|
|
97
|
+
|
|
98
|
+
## What's supported
|
|
99
|
+
|
|
100
|
+
Run `freeconvert --list` to see the full set. Highlights:
|
|
101
|
+
|
|
102
|
+
| From | To | Tool |
|
|
103
|
+
|------|----|----|
|
|
104
|
+
| jpg/png/webp/heic/bmp/tiff/ico/gif | any image format | Pillow (+ `pillow-heif` for HEIC) |
|
|
105
|
+
| any image | pdf | Pillow |
|
|
106
|
+
| svg | png/jpg | cairosvg |
|
|
107
|
+
| mp3/wav/flac/m4a/aac/ogg/opus/wma | any audio | ffmpeg |
|
|
108
|
+
| mp4/webm/mov/avi/mkv/flv | any video | ffmpeg |
|
|
109
|
+
| any video | any audio | ffmpeg (strip + re-encode) |
|
|
110
|
+
| any video | gif | ffmpeg (palette-gen, 2-pass) |
|
|
111
|
+
| pdf | docx / xlsx / pptx / txt / png / jpg | pdf2docx / pdfplumber / pdf2image |
|
|
112
|
+
| docx/xlsx/pptx/odt/ods/rtf/html | pdf | libreoffice --headless |
|
|
113
|
+
| docx ↔ odt / rtf / html / txt, xlsx ↔ ods, pptx ↔ odp | | libreoffice |
|
|
114
|
+
| md → html / pdf / docx | | stdlib regex / libreoffice |
|
|
115
|
+
| txt → pdf / docx | | reportlab / python-docx |
|
|
116
|
+
| csv ↔ json, xlsx ↔ csv / json, csv ↔ xlsx | | stdlib + openpyxl |
|
|
117
|
+
| srt ↔ vtt, srt → txt | | stdlib |
|
|
118
|
+
| epub/mobi/azw3/fb2/lit ↔ each other ↔ pdf/docx/html/md/txt/rtf | | calibre + pandoc |
|
|
119
|
+
| zip ↔ tar/tar.gz/7z | | stdlib + py7zr |
|
|
120
|
+
| obj ↔ stl ↔ ply ↔ glb ↔ gltf | | trimesh |
|
|
121
|
+
|
|
122
|
+
## Install
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Minimal install — CLI + dispatch table + stdlib-only handlers (csv/json/srt/vtt):
|
|
126
|
+
pip install freeai-convert
|
|
127
|
+
|
|
128
|
+
# Plus pure-Python image/PDF/office support:
|
|
129
|
+
pip install 'freeai-convert[image,pdf,office]'
|
|
130
|
+
|
|
131
|
+
# Everything pip-installable:
|
|
132
|
+
pip install 'freeai-convert[all]'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Several handlers shell out to system tools — install them via your OS package manager:
|
|
136
|
+
|
|
137
|
+
| Handler | System dep | Debian/Ubuntu | macOS (brew) |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| audio / video / gif | `ffmpeg` | `apt install ffmpeg` | `brew install ffmpeg` |
|
|
140
|
+
| pdf → pptx, pdf → png/jpg | `poppler-utils` | `apt install poppler-utils` | `brew install poppler` |
|
|
141
|
+
| office ↔ office, office → pdf | `libreoffice` | `apt install libreoffice` | `brew install --cask libreoffice` |
|
|
142
|
+
| ebook (mobi/azw3/fb2/lit) | `calibre` | `apt install calibre` | `brew install --cask calibre` |
|
|
143
|
+
| ebook (epub fast-path) | `pandoc` | `apt install pandoc` | `brew install pandoc` |
|
|
144
|
+
|
|
145
|
+
If you call a handler whose system tool is missing, you'll get a clear `RuntimeError` naming what failed.
|
|
146
|
+
|
|
147
|
+
## Python API
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from freeconvert import convert, lookup, supported_pairs, UnsupportedConversionError
|
|
151
|
+
|
|
152
|
+
# Easiest — formats inferred from extensions:
|
|
153
|
+
info = convert("/tmp/in.pdf", "/tmp/out.docx")
|
|
154
|
+
# {'src': 'pdf', 'dst': 'docx', 'category': 'pdf_to_word', 'cost': 1000}
|
|
155
|
+
|
|
156
|
+
# Explicit src/dst when extensions are wrong or missing:
|
|
157
|
+
convert("/tmp/blob", "/tmp/out.png", src="jpg", dst="png")
|
|
158
|
+
|
|
159
|
+
# Probe before running:
|
|
160
|
+
resolved = lookup("heic", "jpg")
|
|
161
|
+
if resolved is None:
|
|
162
|
+
raise UnsupportedConversionError(...)
|
|
163
|
+
handler, category, cost, src, dst = resolved
|
|
164
|
+
|
|
165
|
+
# Or inspect the dispatch table directly:
|
|
166
|
+
("pdf", "docx") in supported_pairs() # True
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The `cost` field is an arbitrary relative-compute estimate (200 = light Pillow work, 1500 = libreoffice reflow). Useful for queue backpressure on a server; safe to ignore in scripts.
|
|
170
|
+
|
|
171
|
+
## Extending it
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from freeconvert.handlers import HANDLERS
|
|
175
|
+
|
|
176
|
+
def _yaml_to_json(in_path, out_path, src, dst):
|
|
177
|
+
import yaml, json
|
|
178
|
+
with open(in_path) as f: data = yaml.safe_load(f)
|
|
179
|
+
with open(out_path, "w") as f: json.dump(data, f, indent=2)
|
|
180
|
+
|
|
181
|
+
HANDLERS[("yaml", "json")] = (_yaml_to_json, "data")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
That's it — your new pair is now reachable via `convert()` and the CLI.
|
|
185
|
+
|
|
186
|
+
## Project layout
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
freeconvert/
|
|
190
|
+
├── __init__.py # convert(), exports
|
|
191
|
+
├── handlers.py # HANDLERS dispatch table + handler functions
|
|
192
|
+
├── cli.py # click CLI
|
|
193
|
+
└── __main__.py # python -m freeconvert
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT — see [LICENSE](LICENSE).
|
|
199
|
+
|
|
200
|
+
## Related
|
|
201
|
+
|
|
202
|
+
- [free-scene](https://github.com/freeaigit/free-scene) — multi-scene AI movie maker
|
|
203
|
+
- [free-code](https://github.com/freeaigit/free-code) — agentic coding CLI
|
|
204
|
+
- [free-sdk](https://github.com/freeaigit/free-sdk) — Python SDK for the Free.ai API
|
|
205
|
+
- [free.ai](https://free.ai) — 400+ AI tools, the home of this codebase
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# freeai-convert
|
|
2
|
+
|
|
3
|
+
**Universal file format converter.** One dispatch table, ~80 format pairs across image / audio / video / pdf / office / ebook / csv / srt / archive / 3d.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install freeai-convert
|
|
7
|
+
freeconvert resume.pdf resume.docx
|
|
8
|
+
freeconvert song.flac song.mp3
|
|
9
|
+
freeconvert photo.heic photo.jpg
|
|
10
|
+
freeconvert deck.pptx deck.pdf
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Same converter that backs every `/convert/<pair>/` page on [free.ai](https://free.ai/convert/), extracted into a standalone CLI + Python library.
|
|
14
|
+
|
|
15
|
+
## Why this exists
|
|
16
|
+
|
|
17
|
+
Most "universal converters" are either thin wrappers around `pandoc` (great for text, useless for images) or trillion-dependency monsters that take a `pip install` over a coffee break. `freeai-convert` is a **dispatch table**: one `(src_ext, dst_ext) → handler` map. Each handler is a 5–30 line wrapper around the right tool for the job — Pillow for images, ffmpeg for media, libreoffice for office, pdf2docx / pdfplumber for PDF, calibre for e-books, trimesh for 3D meshes, stdlib for csv/json/srt/vtt.
|
|
18
|
+
|
|
19
|
+
Adding a new format pair = one function + one line in `HANDLERS`. No abstraction, no plugin system, no class hierarchy.
|
|
20
|
+
|
|
21
|
+
## What's supported
|
|
22
|
+
|
|
23
|
+
Run `freeconvert --list` to see the full set. Highlights:
|
|
24
|
+
|
|
25
|
+
| From | To | Tool |
|
|
26
|
+
|------|----|----|
|
|
27
|
+
| jpg/png/webp/heic/bmp/tiff/ico/gif | any image format | Pillow (+ `pillow-heif` for HEIC) |
|
|
28
|
+
| any image | pdf | Pillow |
|
|
29
|
+
| svg | png/jpg | cairosvg |
|
|
30
|
+
| mp3/wav/flac/m4a/aac/ogg/opus/wma | any audio | ffmpeg |
|
|
31
|
+
| mp4/webm/mov/avi/mkv/flv | any video | ffmpeg |
|
|
32
|
+
| any video | any audio | ffmpeg (strip + re-encode) |
|
|
33
|
+
| any video | gif | ffmpeg (palette-gen, 2-pass) |
|
|
34
|
+
| pdf | docx / xlsx / pptx / txt / png / jpg | pdf2docx / pdfplumber / pdf2image |
|
|
35
|
+
| docx/xlsx/pptx/odt/ods/rtf/html | pdf | libreoffice --headless |
|
|
36
|
+
| docx ↔ odt / rtf / html / txt, xlsx ↔ ods, pptx ↔ odp | | libreoffice |
|
|
37
|
+
| md → html / pdf / docx | | stdlib regex / libreoffice |
|
|
38
|
+
| txt → pdf / docx | | reportlab / python-docx |
|
|
39
|
+
| csv ↔ json, xlsx ↔ csv / json, csv ↔ xlsx | | stdlib + openpyxl |
|
|
40
|
+
| srt ↔ vtt, srt → txt | | stdlib |
|
|
41
|
+
| epub/mobi/azw3/fb2/lit ↔ each other ↔ pdf/docx/html/md/txt/rtf | | calibre + pandoc |
|
|
42
|
+
| zip ↔ tar/tar.gz/7z | | stdlib + py7zr |
|
|
43
|
+
| obj ↔ stl ↔ ply ↔ glb ↔ gltf | | trimesh |
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Minimal install — CLI + dispatch table + stdlib-only handlers (csv/json/srt/vtt):
|
|
49
|
+
pip install freeai-convert
|
|
50
|
+
|
|
51
|
+
# Plus pure-Python image/PDF/office support:
|
|
52
|
+
pip install 'freeai-convert[image,pdf,office]'
|
|
53
|
+
|
|
54
|
+
# Everything pip-installable:
|
|
55
|
+
pip install 'freeai-convert[all]'
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Several handlers shell out to system tools — install them via your OS package manager:
|
|
59
|
+
|
|
60
|
+
| Handler | System dep | Debian/Ubuntu | macOS (brew) |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| audio / video / gif | `ffmpeg` | `apt install ffmpeg` | `brew install ffmpeg` |
|
|
63
|
+
| pdf → pptx, pdf → png/jpg | `poppler-utils` | `apt install poppler-utils` | `brew install poppler` |
|
|
64
|
+
| office ↔ office, office → pdf | `libreoffice` | `apt install libreoffice` | `brew install --cask libreoffice` |
|
|
65
|
+
| ebook (mobi/azw3/fb2/lit) | `calibre` | `apt install calibre` | `brew install --cask calibre` |
|
|
66
|
+
| ebook (epub fast-path) | `pandoc` | `apt install pandoc` | `brew install pandoc` |
|
|
67
|
+
|
|
68
|
+
If you call a handler whose system tool is missing, you'll get a clear `RuntimeError` naming what failed.
|
|
69
|
+
|
|
70
|
+
## Python API
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from freeconvert import convert, lookup, supported_pairs, UnsupportedConversionError
|
|
74
|
+
|
|
75
|
+
# Easiest — formats inferred from extensions:
|
|
76
|
+
info = convert("/tmp/in.pdf", "/tmp/out.docx")
|
|
77
|
+
# {'src': 'pdf', 'dst': 'docx', 'category': 'pdf_to_word', 'cost': 1000}
|
|
78
|
+
|
|
79
|
+
# Explicit src/dst when extensions are wrong or missing:
|
|
80
|
+
convert("/tmp/blob", "/tmp/out.png", src="jpg", dst="png")
|
|
81
|
+
|
|
82
|
+
# Probe before running:
|
|
83
|
+
resolved = lookup("heic", "jpg")
|
|
84
|
+
if resolved is None:
|
|
85
|
+
raise UnsupportedConversionError(...)
|
|
86
|
+
handler, category, cost, src, dst = resolved
|
|
87
|
+
|
|
88
|
+
# Or inspect the dispatch table directly:
|
|
89
|
+
("pdf", "docx") in supported_pairs() # True
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The `cost` field is an arbitrary relative-compute estimate (200 = light Pillow work, 1500 = libreoffice reflow). Useful for queue backpressure on a server; safe to ignore in scripts.
|
|
93
|
+
|
|
94
|
+
## Extending it
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from freeconvert.handlers import HANDLERS
|
|
98
|
+
|
|
99
|
+
def _yaml_to_json(in_path, out_path, src, dst):
|
|
100
|
+
import yaml, json
|
|
101
|
+
with open(in_path) as f: data = yaml.safe_load(f)
|
|
102
|
+
with open(out_path, "w") as f: json.dump(data, f, indent=2)
|
|
103
|
+
|
|
104
|
+
HANDLERS[("yaml", "json")] = (_yaml_to_json, "data")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
That's it — your new pair is now reachable via `convert()` and the CLI.
|
|
108
|
+
|
|
109
|
+
## Project layout
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
freeconvert/
|
|
113
|
+
├── __init__.py # convert(), exports
|
|
114
|
+
├── handlers.py # HANDLERS dispatch table + handler functions
|
|
115
|
+
├── cli.py # click CLI
|
|
116
|
+
└── __main__.py # python -m freeconvert
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## License
|
|
120
|
+
|
|
121
|
+
MIT — see [LICENSE](LICENSE).
|
|
122
|
+
|
|
123
|
+
## Related
|
|
124
|
+
|
|
125
|
+
- [free-scene](https://github.com/freeaigit/free-scene) — multi-scene AI movie maker
|
|
126
|
+
- [free-code](https://github.com/freeaigit/free-code) — agentic coding CLI
|
|
127
|
+
- [free-sdk](https://github.com/freeaigit/free-sdk) — Python SDK for the Free.ai API
|
|
128
|
+
- [free.ai](https://free.ai) — 400+ AI tools, the home of this codebase
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: freeai-convert
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Universal file format converter — one HANDLERS table, ~80 format pairs (image/audio/video/pdf/office/ebook/csv/srt/archive/3d).
|
|
5
|
+
Author-email: "Free.ai" <hello@free.ai>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://free.ai/convert/
|
|
8
|
+
Project-URL: Repository, https://github.com/freeaigit/free-convert
|
|
9
|
+
Project-URL: Issues, https://github.com/freeaigit/free-convert/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/freeaigit/free-convert/releases
|
|
11
|
+
Keywords: converter,pdf,docx,ffmpeg,libreoffice,image,audio,video,ebook,csv,srt
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Operating System :: MacOS
|
|
19
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
27
|
+
Classifier: Topic :: Multimedia
|
|
28
|
+
Classifier: Topic :: Office/Business :: Office Suites
|
|
29
|
+
Classifier: Topic :: Utilities
|
|
30
|
+
Requires-Python: >=3.9
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
33
|
+
Requires-Dist: click>=8.1
|
|
34
|
+
Provides-Extra: image
|
|
35
|
+
Requires-Dist: Pillow>=10; extra == "image"
|
|
36
|
+
Provides-Extra: heic
|
|
37
|
+
Requires-Dist: Pillow>=10; extra == "heic"
|
|
38
|
+
Requires-Dist: pillow-heif>=0.16; extra == "heic"
|
|
39
|
+
Provides-Extra: svg
|
|
40
|
+
Requires-Dist: cairosvg>=2.7; extra == "svg"
|
|
41
|
+
Provides-Extra: pdf
|
|
42
|
+
Requires-Dist: pdfplumber>=0.10; extra == "pdf"
|
|
43
|
+
Requires-Dist: pdf2docx>=0.5; extra == "pdf"
|
|
44
|
+
Requires-Dist: python-docx>=1.1; extra == "pdf"
|
|
45
|
+
Requires-Dist: openpyxl>=3.1; extra == "pdf"
|
|
46
|
+
Requires-Dist: python-pptx>=0.6; extra == "pdf"
|
|
47
|
+
Requires-Dist: pdf2image>=1.17; extra == "pdf"
|
|
48
|
+
Provides-Extra: office
|
|
49
|
+
Requires-Dist: openpyxl>=3.1; extra == "office"
|
|
50
|
+
Requires-Dist: python-docx>=1.1; extra == "office"
|
|
51
|
+
Requires-Dist: python-pptx>=0.6; extra == "office"
|
|
52
|
+
Requires-Dist: reportlab>=4; extra == "office"
|
|
53
|
+
Provides-Extra: archive
|
|
54
|
+
Requires-Dist: py7zr>=0.20; extra == "archive"
|
|
55
|
+
Provides-Extra: mesh
|
|
56
|
+
Requires-Dist: trimesh>=4; extra == "mesh"
|
|
57
|
+
Provides-Extra: all
|
|
58
|
+
Requires-Dist: Pillow>=10; extra == "all"
|
|
59
|
+
Requires-Dist: pillow-heif>=0.16; extra == "all"
|
|
60
|
+
Requires-Dist: cairosvg>=2.7; extra == "all"
|
|
61
|
+
Requires-Dist: pdfplumber>=0.10; extra == "all"
|
|
62
|
+
Requires-Dist: pdf2docx>=0.5; extra == "all"
|
|
63
|
+
Requires-Dist: python-docx>=1.1; extra == "all"
|
|
64
|
+
Requires-Dist: openpyxl>=3.1; extra == "all"
|
|
65
|
+
Requires-Dist: python-pptx>=0.6; extra == "all"
|
|
66
|
+
Requires-Dist: pdf2image>=1.17; extra == "all"
|
|
67
|
+
Requires-Dist: reportlab>=4; extra == "all"
|
|
68
|
+
Requires-Dist: py7zr>=0.20; extra == "all"
|
|
69
|
+
Requires-Dist: trimesh>=4; extra == "all"
|
|
70
|
+
Provides-Extra: dev
|
|
71
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
72
|
+
Requires-Dist: Pillow>=10; extra == "dev"
|
|
73
|
+
Requires-Dist: openpyxl>=3.1; extra == "dev"
|
|
74
|
+
Requires-Dist: build; extra == "dev"
|
|
75
|
+
Requires-Dist: twine; extra == "dev"
|
|
76
|
+
Dynamic: license-file
|
|
77
|
+
|
|
78
|
+
# freeai-convert
|
|
79
|
+
|
|
80
|
+
**Universal file format converter.** One dispatch table, ~80 format pairs across image / audio / video / pdf / office / ebook / csv / srt / archive / 3d.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
pip install freeai-convert
|
|
84
|
+
freeconvert resume.pdf resume.docx
|
|
85
|
+
freeconvert song.flac song.mp3
|
|
86
|
+
freeconvert photo.heic photo.jpg
|
|
87
|
+
freeconvert deck.pptx deck.pdf
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Same converter that backs every `/convert/<pair>/` page on [free.ai](https://free.ai/convert/), extracted into a standalone CLI + Python library.
|
|
91
|
+
|
|
92
|
+
## Why this exists
|
|
93
|
+
|
|
94
|
+
Most "universal converters" are either thin wrappers around `pandoc` (great for text, useless for images) or trillion-dependency monsters that take a `pip install` over a coffee break. `freeai-convert` is a **dispatch table**: one `(src_ext, dst_ext) → handler` map. Each handler is a 5–30 line wrapper around the right tool for the job — Pillow for images, ffmpeg for media, libreoffice for office, pdf2docx / pdfplumber for PDF, calibre for e-books, trimesh for 3D meshes, stdlib for csv/json/srt/vtt.
|
|
95
|
+
|
|
96
|
+
Adding a new format pair = one function + one line in `HANDLERS`. No abstraction, no plugin system, no class hierarchy.
|
|
97
|
+
|
|
98
|
+
## What's supported
|
|
99
|
+
|
|
100
|
+
Run `freeconvert --list` to see the full set. Highlights:
|
|
101
|
+
|
|
102
|
+
| From | To | Tool |
|
|
103
|
+
|------|----|----|
|
|
104
|
+
| jpg/png/webp/heic/bmp/tiff/ico/gif | any image format | Pillow (+ `pillow-heif` for HEIC) |
|
|
105
|
+
| any image | pdf | Pillow |
|
|
106
|
+
| svg | png/jpg | cairosvg |
|
|
107
|
+
| mp3/wav/flac/m4a/aac/ogg/opus/wma | any audio | ffmpeg |
|
|
108
|
+
| mp4/webm/mov/avi/mkv/flv | any video | ffmpeg |
|
|
109
|
+
| any video | any audio | ffmpeg (strip + re-encode) |
|
|
110
|
+
| any video | gif | ffmpeg (palette-gen, 2-pass) |
|
|
111
|
+
| pdf | docx / xlsx / pptx / txt / png / jpg | pdf2docx / pdfplumber / pdf2image |
|
|
112
|
+
| docx/xlsx/pptx/odt/ods/rtf/html | pdf | libreoffice --headless |
|
|
113
|
+
| docx ↔ odt / rtf / html / txt, xlsx ↔ ods, pptx ↔ odp | | libreoffice |
|
|
114
|
+
| md → html / pdf / docx | | stdlib regex / libreoffice |
|
|
115
|
+
| txt → pdf / docx | | reportlab / python-docx |
|
|
116
|
+
| csv ↔ json, xlsx ↔ csv / json, csv ↔ xlsx | | stdlib + openpyxl |
|
|
117
|
+
| srt ↔ vtt, srt → txt | | stdlib |
|
|
118
|
+
| epub/mobi/azw3/fb2/lit ↔ each other ↔ pdf/docx/html/md/txt/rtf | | calibre + pandoc |
|
|
119
|
+
| zip ↔ tar/tar.gz/7z | | stdlib + py7zr |
|
|
120
|
+
| obj ↔ stl ↔ ply ↔ glb ↔ gltf | | trimesh |
|
|
121
|
+
|
|
122
|
+
## Install
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Minimal install — CLI + dispatch table + stdlib-only handlers (csv/json/srt/vtt):
|
|
126
|
+
pip install freeai-convert
|
|
127
|
+
|
|
128
|
+
# Plus pure-Python image/PDF/office support:
|
|
129
|
+
pip install 'freeai-convert[image,pdf,office]'
|
|
130
|
+
|
|
131
|
+
# Everything pip-installable:
|
|
132
|
+
pip install 'freeai-convert[all]'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Several handlers shell out to system tools — install them via your OS package manager:
|
|
136
|
+
|
|
137
|
+
| Handler | System dep | Debian/Ubuntu | macOS (brew) |
|
|
138
|
+
|---|---|---|---|
|
|
139
|
+
| audio / video / gif | `ffmpeg` | `apt install ffmpeg` | `brew install ffmpeg` |
|
|
140
|
+
| pdf → pptx, pdf → png/jpg | `poppler-utils` | `apt install poppler-utils` | `brew install poppler` |
|
|
141
|
+
| office ↔ office, office → pdf | `libreoffice` | `apt install libreoffice` | `brew install --cask libreoffice` |
|
|
142
|
+
| ebook (mobi/azw3/fb2/lit) | `calibre` | `apt install calibre` | `brew install --cask calibre` |
|
|
143
|
+
| ebook (epub fast-path) | `pandoc` | `apt install pandoc` | `brew install pandoc` |
|
|
144
|
+
|
|
145
|
+
If you call a handler whose system tool is missing, you'll get a clear `RuntimeError` naming what failed.
|
|
146
|
+
|
|
147
|
+
## Python API
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from freeconvert import convert, lookup, supported_pairs, UnsupportedConversionError
|
|
151
|
+
|
|
152
|
+
# Easiest — formats inferred from extensions:
|
|
153
|
+
info = convert("/tmp/in.pdf", "/tmp/out.docx")
|
|
154
|
+
# {'src': 'pdf', 'dst': 'docx', 'category': 'pdf_to_word', 'cost': 1000}
|
|
155
|
+
|
|
156
|
+
# Explicit src/dst when extensions are wrong or missing:
|
|
157
|
+
convert("/tmp/blob", "/tmp/out.png", src="jpg", dst="png")
|
|
158
|
+
|
|
159
|
+
# Probe before running:
|
|
160
|
+
resolved = lookup("heic", "jpg")
|
|
161
|
+
if resolved is None:
|
|
162
|
+
raise UnsupportedConversionError(...)
|
|
163
|
+
handler, category, cost, src, dst = resolved
|
|
164
|
+
|
|
165
|
+
# Or inspect the dispatch table directly:
|
|
166
|
+
("pdf", "docx") in supported_pairs() # True
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The `cost` field is an arbitrary relative-compute estimate (200 = light Pillow work, 1500 = libreoffice reflow). Useful for queue backpressure on a server; safe to ignore in scripts.
|
|
170
|
+
|
|
171
|
+
## Extending it
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
from freeconvert.handlers import HANDLERS
|
|
175
|
+
|
|
176
|
+
def _yaml_to_json(in_path, out_path, src, dst):
|
|
177
|
+
import yaml, json
|
|
178
|
+
with open(in_path) as f: data = yaml.safe_load(f)
|
|
179
|
+
with open(out_path, "w") as f: json.dump(data, f, indent=2)
|
|
180
|
+
|
|
181
|
+
HANDLERS[("yaml", "json")] = (_yaml_to_json, "data")
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
That's it — your new pair is now reachable via `convert()` and the CLI.
|
|
185
|
+
|
|
186
|
+
## Project layout
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
freeconvert/
|
|
190
|
+
├── __init__.py # convert(), exports
|
|
191
|
+
├── handlers.py # HANDLERS dispatch table + handler functions
|
|
192
|
+
├── cli.py # click CLI
|
|
193
|
+
└── __main__.py # python -m freeconvert
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT — see [LICENSE](LICENSE).
|
|
199
|
+
|
|
200
|
+
## Related
|
|
201
|
+
|
|
202
|
+
- [free-scene](https://github.com/freeaigit/free-scene) — multi-scene AI movie maker
|
|
203
|
+
- [free-code](https://github.com/freeaigit/free-code) — agentic coding CLI
|
|
204
|
+
- [free-sdk](https://github.com/freeaigit/free-sdk) — Python SDK for the Free.ai API
|
|
205
|
+
- [free.ai](https://free.ai) — 400+ AI tools, the home of this codebase
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
freeai_convert.egg-info/PKG-INFO
|
|
5
|
+
freeai_convert.egg-info/SOURCES.txt
|
|
6
|
+
freeai_convert.egg-info/dependency_links.txt
|
|
7
|
+
freeai_convert.egg-info/entry_points.txt
|
|
8
|
+
freeai_convert.egg-info/requires.txt
|
|
9
|
+
freeai_convert.egg-info/top_level.txt
|
|
10
|
+
freeconvert/__init__.py
|
|
11
|
+
freeconvert/__main__.py
|
|
12
|
+
freeconvert/cli.py
|
|
13
|
+
freeconvert/handlers.py
|
|
14
|
+
tests/test_data.py
|
|
15
|
+
tests/test_dispatch.py
|
|
16
|
+
tests/test_subtitle.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
click>=8.1
|
|
2
|
+
|
|
3
|
+
[all]
|
|
4
|
+
Pillow>=10
|
|
5
|
+
pillow-heif>=0.16
|
|
6
|
+
cairosvg>=2.7
|
|
7
|
+
pdfplumber>=0.10
|
|
8
|
+
pdf2docx>=0.5
|
|
9
|
+
python-docx>=1.1
|
|
10
|
+
openpyxl>=3.1
|
|
11
|
+
python-pptx>=0.6
|
|
12
|
+
pdf2image>=1.17
|
|
13
|
+
reportlab>=4
|
|
14
|
+
py7zr>=0.20
|
|
15
|
+
trimesh>=4
|
|
16
|
+
|
|
17
|
+
[archive]
|
|
18
|
+
py7zr>=0.20
|
|
19
|
+
|
|
20
|
+
[dev]
|
|
21
|
+
pytest>=7
|
|
22
|
+
Pillow>=10
|
|
23
|
+
openpyxl>=3.1
|
|
24
|
+
build
|
|
25
|
+
twine
|
|
26
|
+
|
|
27
|
+
[heic]
|
|
28
|
+
Pillow>=10
|
|
29
|
+
pillow-heif>=0.16
|
|
30
|
+
|
|
31
|
+
[image]
|
|
32
|
+
Pillow>=10
|
|
33
|
+
|
|
34
|
+
[mesh]
|
|
35
|
+
trimesh>=4
|
|
36
|
+
|
|
37
|
+
[office]
|
|
38
|
+
openpyxl>=3.1
|
|
39
|
+
python-docx>=1.1
|
|
40
|
+
python-pptx>=0.6
|
|
41
|
+
reportlab>=4
|
|
42
|
+
|
|
43
|
+
[pdf]
|
|
44
|
+
pdfplumber>=0.10
|
|
45
|
+
pdf2docx>=0.5
|
|
46
|
+
python-docx>=1.1
|
|
47
|
+
openpyxl>=3.1
|
|
48
|
+
python-pptx>=0.6
|
|
49
|
+
pdf2image>=1.17
|
|
50
|
+
|
|
51
|
+
[svg]
|
|
52
|
+
cairosvg>=2.7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
freeconvert
|