- tools/bundle.py: every module a function in __FILES with a cached __include; requires become __include calls, so only the API and its load-time requires run on require. Rosetta._internal(path) includes any module by its src path. --!native modules get @native on each function (NATIVE re-checked on the bundle); linemaps map bundle lines back to sources (--where). LuaJIT bundle inlines the compat prelude. - tools/build.py: the multi-file trees move to build/_modules (gitignored); each target also writes its bundle. - tools/test.sh: api + docs/example tests also run against both bundles; fails when build/ is stale. - default.project.json mounts build/Rosetta.luau; examples/love loads build/rosetta.lua. - README: one line, install, quick start, doc links, generated format table and codec list (tools/gen_registry.py), licence TODO. DOCS lint checks the generated sections and the links.
250 lines
11 KiB
Markdown
250 lines
11 KiB
Markdown
# rosetta
|
|
|
|
Read, write and convert file formats in pure Luau, on Roblox, LuaJIT / LÖVE and the Luau CLI.
|
|
|
|
## Install
|
|
|
|
- **Roblox:** put [`build/Rosetta.luau`](build/Rosetta.luau) in a ModuleScript (e.g. ReplicatedStorage.Rosetta),
|
|
or mount it with Rojo (`"Rosetta": { "$path": "rosetta/build/Rosetta.luau" }`; this repo's `default.project.json`
|
|
does). Then `local F = require(ReplicatedStorage.Rosetta)`.
|
|
- **LÖVE / LuaJIT:** copy [`build/rosetta.lua`](build/rosetta.lua). `local F = require("rosetta")` with its folder on
|
|
`package.path`, or `local F = dofile("rosetta.lua")`.
|
|
- **Luau CLI:** alias the sources in `.luaurc` (`"rosetta": "rosetta/src/Rosetta"`), then
|
|
`local F = require("@rosetta")`.
|
|
|
|
Internal modules are reachable as `F._internal("codecs/video/Mpeg1")` (bundles) or `require("@rosetta/codecs/video/Mpeg1")`
|
|
(CLI).
|
|
|
|
## Quick start
|
|
|
|
```luau
|
|
local img, err = F.load(pngBytes) -- buffer | string | path; errors are values, nothing throws
|
|
if not img then error(tostring(err)) end
|
|
local small = F.ops.image.resize(img, 64, 64, "lanczos")
|
|
local webp = F.save(small, nil, { format = "webp" }) -- a buffer
|
|
local png = F.convert(jpegBytes, "png") -- load + save
|
|
local dec = F.audio.open(flacBytes) -- streaming: dec:read(n) -> interleaved f32 buffer, frames
|
|
local scene = F.model.load(glbBytes) -- every model format loads as a Scene
|
|
local v = F.video.open(mp4Bytes) -- v:nextFrame() -> frame
|
|
print(F.detect(webp), #F.formats()) -- "webp", the format list
|
|
```
|
|
|
|
## Docs
|
|
|
|
- Guide: [overview, install, inputs, errors, options](docs/guide/README.md), [images](docs/guide/image.md),
|
|
[audio](docs/guide/audio.md), [music](docs/guide/music.md), [video](docs/guide/video.md),
|
|
[3D scenes](docs/guide/scene.md), [Roblox files](docs/guide/roblox.md), [CAD](docs/guide/cad.md),
|
|
[fonts](docs/guide/font.md), [archives](docs/guide/archive.md), [data](docs/guide/data.md),
|
|
[Minecraft and voxels](docs/guide/voxel.md), [vector](docs/guide/vector.md), [layered images](docs/guide/layered.md),
|
|
[tile maps](docs/guide/tilemap.md), [subtitles](docs/guide/subtitles.md), [playlists](docs/guide/playlist.md),
|
|
[recipes](docs/guide/recipes.md)
|
|
- [docs/API.md](docs/API.md): the API reference
|
|
- [docs/STYLE.md](docs/STYLE.md): code layout, rules and tooling (`bash tools/test.sh` runs everything)
|
|
|
|
## Formats
|
|
|
|
<!-- formats:begin -->
|
|
174 formats. Generated from the format contracts by `tools/gen_registry.py`; [docs/FORMATS.md](docs/FORMATS.md)
|
|
adds each format's capabilities.
|
|
|
|
| Category | Format | Extensions | Read | Write |
|
|
|---|---|---|---|---|
|
|
| Images | ani | .ani | yes | yes |
|
|
| Images | blp | .blp | yes | yes |
|
|
| Images | bmp | .bmp .dib | yes | yes |
|
|
| Images | dds | .dds | yes | yes |
|
|
| Images | exr | .exr | yes | yes |
|
|
| Images | gif | .gif | yes | yes |
|
|
| Images | hdr | .hdr .pic .rgbe | yes | yes |
|
|
| Images | icns | .icns | yes | yes |
|
|
| Images | ico | .ico .cur | yes | yes |
|
|
| Images | ilbm | .iff .ilbm .lbm .pbm | yes | yes |
|
|
| Images | jpeg | .jpg .jpeg .jpe .jfif | yes | yes |
|
|
| Images | ktx | .ktx2 .ktx | yes | yes |
|
|
| Images | pcx | .pcx .pcc .dcx | yes | yes |
|
|
| Images | png | .png .apng | yes | yes |
|
|
| Images | pnm | .pnm .pbm .pgm .ppm .pam .pfm | yes | yes |
|
|
| Images | qoi | .qoi | yes | yes |
|
|
| Images | sgi | .sgi .rgb .rgba .bw .int .inta | yes | yes |
|
|
| Images | sunras | .ras .sun .rs .im1 .im8 .im24 .im32 | yes | yes |
|
|
| Images | tga | .tga .icb .vda .vst .tpic | yes | yes |
|
|
| Images | tiff | .tif .tiff | yes | yes |
|
|
| Images | tim | .tim | yes | yes |
|
|
| Images | vtf | .vtf | yes | - |
|
|
| Images | webp | .webp | yes | yes |
|
|
| Images | xbm | .xbm .bm | yes | yes |
|
|
| Images | xpm | .xpm .pm | yes | yes |
|
|
| Audio | aac | .aac .adts | yes | - |
|
|
| Audio | ac3 | .ac3 .a52 | yes | - |
|
|
| Audio | adpcm | .adpcm .ima | yes | yes |
|
|
| Audio | adx | .adx | yes | yes |
|
|
| Audio | aiff | .aiff .aif .aifc .afc | yes | yes |
|
|
| Audio | ape | .ape | yes | - |
|
|
| Audio | au | .au .snd | yes | yes |
|
|
| Audio | brstm | .brstm .bcstm .bfstm | yes | - |
|
|
| Audio | caf | .caf .caff | yes | yes |
|
|
| Audio | flac | .flac .oga | yes | yes |
|
|
| Audio | m4a | .m4a .m4b .m4r | yes | yes |
|
|
| Audio | mp3 | .mp3 .mp2 .mp1 .mpga | yes | yes |
|
|
| Audio | mpc | .mpc .mp+ .mpp | yes | - |
|
|
| Audio | opus | .opus | yes | yes |
|
|
| Audio | qoa | .qoa | yes | yes |
|
|
| Audio | tta | .tta | yes | - |
|
|
| Audio | vag | .vag | yes | yes |
|
|
| Audio | voc | .voc | yes | yes |
|
|
| Audio | vorbis | .ogg .oga | yes | yes |
|
|
| Audio | wav | .wav .wave .rf64 .bw64 | yes | yes |
|
|
| Audio | wavpack | .wv | yes | - |
|
|
| Video | avi | .avi | yes | yes |
|
|
| Video | fli | .fli .flc .flx | yes | - |
|
|
| Video | flv | .flv | yes | yes |
|
|
| Video | h264 | .h264 .264 .avc .jsv .26l .jvt | yes | yes |
|
|
| Video | mkv | .mkv .webm .mka .mk3d | yes | yes |
|
|
| Video | mp4 | .mp4 .m4v .mov .qt .3gp .3g2 .mj2 | yes | yes |
|
|
| Video | mpegps | .mpg .mpeg .vob .m1v .mpv .dat | yes | - |
|
|
| Video | mpegts | .ts .m2ts .mts .tsv | yes | - |
|
|
| Video | ogv | .ogv .ogg | yes | yes |
|
|
| Video | smk | .smk | yes | - |
|
|
| Video | y4m | .y4m | yes | yes |
|
|
| 3D models | 3ds | .3ds | yes | yes |
|
|
| 3D models | 3mf | .3mf | yes | yes |
|
|
| 3D models | b3d | .b3d | yes | - |
|
|
| 3D models | bsp | .bsp | yes | - |
|
|
| 3D models | dae | .dae .zae | yes | yes |
|
|
| 3D models | fbx | .fbx | yes | yes |
|
|
| 3D models | gltf | .gltf .glb | yes | yes |
|
|
| 3D models | iqm | .iqm | yes | yes |
|
|
| 3D models | ldraw | .ldr .mpd .dat | yes | - |
|
|
| 3D models | lwo | .lwo .lxo | yes | - |
|
|
| 3D models | mca | .mca .mcr | yes | - |
|
|
| 3D models | md2 | .md2 | yes | - |
|
|
| 3D models | md3 | .md3 | yes | - |
|
|
| 3D models | md5 | .md5mesh .md5anim | yes | - |
|
|
| 3D models | mdl | .mdl | yes | - |
|
|
| 3D models | ms3d | .ms3d | yes | yes |
|
|
| 3D models | obj | .obj | yes | yes |
|
|
| 3D models | off | .off | yes | yes |
|
|
| 3D models | ply | .ply | yes | yes |
|
|
| 3D models | pmx | .pmx .pmd | yes | - |
|
|
| 3D models | qb | .qb | yes | yes |
|
|
| 3D models | rbxm | .rbxm .rbxl | yes | yes |
|
|
| 3D models | rbxmx | .rbxmx .rbxlx | yes | yes |
|
|
| 3D models | robloxmesh | .mesh | yes | yes |
|
|
| 3D models | schematic | .schem .schematic .litematic | yes | yes |
|
|
| 3D models | smd | .smd | yes | yes |
|
|
| 3D models | stl | .stl | yes | yes |
|
|
| 3D models | usda | .usda .usd .usdz | yes | yes |
|
|
| 3D models | vox | .vox | yes | yes |
|
|
| 3D models | vrml | .wrl .wrz .vrml | yes | yes |
|
|
| 3D models | x | .x | yes | - |
|
|
| 3D models | x3d | .x3d .x3dv .x3dz .x3dvz .x3db | yes | yes |
|
|
| CAD | step | .step .stp .p21 | yes | yes |
|
|
| Fonts | bdf | .bdf | yes | yes |
|
|
| Fonts | bmfont | .fnt | yes | yes |
|
|
| Fonts | eot | .eot | yes | yes |
|
|
| Fonts | fon | .fon .fnt | yes | - |
|
|
| Fonts | hershey | .jhf | yes | - |
|
|
| Fonts | pcf | .pcf | yes | - |
|
|
| Fonts | psf | .psf .psfu | yes | yes |
|
|
| Fonts | ttf | .ttf .otf .ttc .otc | yes | - |
|
|
| Fonts | type1 | .pfb .pfa .t1 | yes | - |
|
|
| Fonts | woff | .woff | yes | - |
|
|
| Fonts | woff2 | .woff2 | yes | - |
|
|
| Archives | 7z | .7z | yes | - |
|
|
| Archives | adf | .adf | yes | - |
|
|
| Archives | applesingle | .as .applesingle .appledouble | yes | yes |
|
|
| Archives | ar | .a .ar .deb .lib | yes | yes |
|
|
| Archives | arj | .arj | yes | - |
|
|
| Archives | binhex | .hqx .hcx | yes | yes |
|
|
| Archives | br | .br | yes | - |
|
|
| Archives | bz2 | .bz2 .tbz2 .tbz | yes | - |
|
|
| Archives | cab | .cab | yes | yes |
|
|
| Archives | cpio | .cpio | yes | yes |
|
|
| Archives | d64 | .d64 .d71 .d81 | yes | yes |
|
|
| Archives | fat | .img .ima .vfd .flp .fat | yes | yes |
|
|
| Archives | grp | .grp | yes | yes |
|
|
| Archives | gzip | .gz .tgz .gzip | yes | yes |
|
|
| Archives | iso | .iso | yes | - |
|
|
| Archives | lha | .lzh .lha .lzs | yes | yes |
|
|
| Archives | lz4 | .lz4 .tlz4 | yes | yes |
|
|
| Archives | macbinary | .bin .macbin | yes | yes |
|
|
| Archives | mpq | .mpq .w3x .w3m .sc2map .sc2data .s2ma .scm .scx | yes | - |
|
|
| Archives | pak | .pak .sin | yes | yes |
|
|
| Archives | rpm | .rpm | yes | - |
|
|
| Archives | tar | .tar | yes | yes |
|
|
| Archives | uu | .uu .uue .xxe .b64 | yes | yes |
|
|
| Archives | vpk | .vpk | yes | yes |
|
|
| Archives | wad | .wad | yes | yes |
|
|
| Archives | xz | .xz .txz .lzma | yes | - |
|
|
| Archives | yenc | .yenc .ync | yes | yes |
|
|
| Archives | z | .z .taz .tz | yes | yes |
|
|
| Archives | zip | .zip .wsz | yes | yes |
|
|
| Archives | zoo | .zoo | yes | - |
|
|
| Archives | zst | .zst .tzst | yes | - |
|
|
| Data | cbor | .cbor | yes | yes |
|
|
| Data | csv | .csv .tsv | yes | yes |
|
|
| Data | ini | .ini .cfg .conf .inf .desktop | yes | yes |
|
|
| Data | json | .json .jsonl .ndjson .geojson | yes | yes |
|
|
| Data | msgpack | .msgpack .mpk | yes | yes |
|
|
| Data | nbt | .nbt .dat .mcstructure .dat_old | yes | yes |
|
|
| Data | plist | .plist | yes | yes |
|
|
| Data | snbt | .snbt | yes | yes |
|
|
| Data | toml | .toml | yes | yes |
|
|
| Data | xml | .xml .xsd .xsl .xslt .rss .atom .xhtml | yes | yes |
|
|
| Data | yaml | .yaml .yml | yes | yes |
|
|
| Vector graphics and tile maps | svg | .svg | yes | yes |
|
|
| Vector graphics and tile maps | tiled | .tmx .tmj .tsx .tsj | yes | yes |
|
|
| Layered images | aseprite | .aseprite .ase | yes | yes |
|
|
| Layered images | ora | .ora | yes | yes |
|
|
| Layered images | psd | .psd .psb | yes | yes |
|
|
| Subtitles | ass | .ass .ssa | yes | yes |
|
|
| Subtitles | srt | .srt | yes | yes |
|
|
| Subtitles | vtt | .vtt .webvtt | yes | yes |
|
|
| Music | 669 | .669 | yes | - |
|
|
| Music | ahx | .ahx .thx | yes | - |
|
|
| Music | far | .far | yes | - |
|
|
| Music | hmp | .hmp .hmi | yes | - |
|
|
| Music | hvl | .hvl | yes | - |
|
|
| Music | it | .it | yes | - |
|
|
| Music | med | .med .mmd0 .mmd1 .mmd2 .mmd3 .omed | yes | - |
|
|
| Music | midi | .mid .midi .smf .kar .rmi | yes | yes |
|
|
| Music | mod | .mod .m15 .stk .nst | yes | yes |
|
|
| Music | mtm | .mtm | yes | - |
|
|
| Music | mus | .mus | yes | - |
|
|
| Music | okt | .okt .okta | yes | - |
|
|
| Music | ptm | .ptm | yes | - |
|
|
| Music | s3m | .s3m | yes | - |
|
|
| Music | sf2 | .sf2 | yes | - |
|
|
| Music | stm | .stm | yes | - |
|
|
| Music | ult | .ult | yes | - |
|
|
| Music | umx | .umx | yes | - |
|
|
| Music | xm | .xm | yes | yes |
|
|
| Music | xmi | .xmi .xmidi | yes | - |
|
|
| Playlists | m3u | .m3u .m3u8 | yes | yes |
|
|
| Playlists | pls | .pls | yes | yes |
|
|
| Playlists | xspf | .xspf | yes | yes |
|
|
<!-- formats:end -->
|
|
|
|
## Codecs and containers
|
|
|
|
<!-- codecs:begin -->
|
|
Shared by the formats, not loadable on their own (`src/Rosetta/codecs/<domain>/`, `src/Rosetta/containers/`;
|
|
[docs/FORMATS.md](docs/FORMATS.md) describes each). The bundles reach them as `F._internal("codecs/video/Mpeg1")`.
|
|
|
|
| Domain | Modules |
|
|
|---|---|
|
|
| audio | Aac, Ac3, Adpcm, Alac, Ape, ApeTag, Flac, Hively, Mdct, MidiRender, Mpa, Musepack, Opus, Pcm, Qoa, Resample, SoundFont, Stream, Tracker, Tta, Vorbis, VorbisComment, WavPack |
|
|
| compress | Brotli, Bzip2, Deflate, Explode, Lz4, Lzh, Lzma, Lzw, Lzx, PackBits, Quantum, UnixCompress, Xxh32, Zstd |
|
|
| entropy | Huffman, RangeCoder |
|
|
| font | Bitmap, Cff, GlyphNames, TrueType |
|
|
| image | Bcn, Blend, Dct, Etc, Half, Jpeg, Pixels, Quantize, Raster, Texel, Texture, Vp8, Vp8L, Yuv |
|
|
| model | Draco, Mat4, MeshFlatten, Minecraft, Polygon, Rbx, Rig, Sampler, Vrml |
|
|
| text | Json, Nbt, Text, Url, Xml |
|
|
| video | Dsp, H263, H264, Legacy, Mpeg1, Mpeg2, Theora, Video |
|
|
| containers | Archive, AudioWrap, Avi, Chunks, Cpio, Demux, Ebml, Fat, Iso9660, IsoBmff, MacFile, MpegEs, MpegPs, MpegTs, Ogg, Riff, Tar, Zip |
|
|
<!-- codecs:end -->
|
|
|
|
## Licence
|
|
|
|
TODO: no licence chosen yet. Third-party notices: [licenses/NOTICE.md](licenses/NOTICE.md).
|