flying-anvil / fileinfo
Get information about files. Focused on exotic file types.
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/flying-anvil/fileinfo
Requires
- php: ^8.0
- ext-json: *
- ext-mbstring: *
- flying-anvil/libfa: ^0.2.2
- psr/container: ^1.0
- ulrichsg/getopt-php: ^3.4
Requires (Dev)
- phpunit/phpunit: ^9.0
- roave/security-advisories: dev-master
- dev-master
- 0.2.0
- 0.1.0
- dev-dev
- dev-feature-FI-36
- dev-feature-FI-12
- dev-feature-FI-19
- dev-feature-FI-23
- dev-feature-FI-24
- dev-feature-FI-26
- dev-feature-FI-27
- dev-feature-FI-25
- dev-feature-FI-7
- dev-feature-FI-22
- dev-feature-FI-21
- dev-feature-FI-18
- dev-feature-FI-15
- dev-feature-FI-14
- dev-feature-FI-3
- dev-feature-FI-13
- dev-feature-FI-2
- dev-feature-FI-6
- dev-feature-FI-5
- dev-feature-FI-1
This package is auto-updated.
Last update: 2025-09-29 02:22:42 UTC
README
Get information about files. Focused on exotic file types.
Supported Filetypes
| extension | description |
|---|---|
| Application | |
| Dev Tools | |
| diff | Output of the diff command (and git diff) |
| patch | Output of the diff command (and git diff) |
| Games | |
| lvlx | SMBX2 Level |
| gma | GMod Mod |
| d2s | Diablo 2 savegame |
| ROMs | |
| rpx | Wii U Application |
| spc | SPC700 Dump |
| smc | SNES Rom |
| sfc | Super Famicom Rom |
| z64 | Nintendo 64 Rom |
| nds | Nintendo DS Rom |
| gba | Nintendo GameBoy Advance Rom |
| gb | Nintendo GameBoy Rom |
| nes | NES ROM |
| Archive | |
| zip | Lossless compressed archive |
| jar | Java Archivce |
| Media | |
| Audio | |
| xm | Extended Module Audio File |
| mod | Module Audio File |
| wav | Uncompressed Wave audio |
| Video | |
| bik | Bink Video/Audio Container |
| bik2 | Bink Video/Audio Container |
| bk2 | Bink Video/Audio Container |
| Image | |
| png | Portable Network Graphic |
| bmp | Bitmap |
| gif | Graphics Interchange Format |
| jpg | Joint Photographic (Experts) Group |
| jpeg | Joint Photographic Experts Group |
| jfif | JPEG File Interchange Format |
| aseprite | Aseprite project file |
| Geometry | |
| obj | Wavefront OBJ |
| Misc | |
| url | Windows shortcuts that point to a webstite |
Restore Extension From Content
Can scan files to try to recognize the type and its file extension. Works for a ton of types.
CLI Usage
This package contains a script (fileinfo) that can be run from the CLI.
Usage: fileinfo [options] <file> [<file>...] [options]
See fileinfo --help for more information
List of supported options:
| short | long | description |
|---|---|---|
| h | help | Prints help text |
| v | version | Prints version text |
| a | all | Show all possible information |
| full | Same as all | |
| e | extension | Override extension |
| c | context | Use context instead of extension |
| r | reconstruct | Try to reconstruct extension for file by content |
| f | format | Format of the output |
| d | debug | Throw Exceptions (if not specified, print the message) |
Does work with multiple input files (fileinfo samples/*), however,
the output differs and might not be considered stable when multiple files are shown.
Development Notes
Adding a new FileInfoExtractor
- Create a new class in
src/InfoExtractor/Extractor/[…] - Implement
InfoExtractor- Try to use keys from
InfoCommonKeys
- Try to use keys from
- Create a new
KnownExtensionandContext - Register it in
DefaultDefinition
Adding a new ExtensionReader
For simple, non-offset magic bytes, add an entry to FileExtensionMagicByteSupplier::DEFAULT_SIMPLE_MAGIC.
For more complex ones:
- Create a new class in
src/FileExtension/Reader/[…] - Implement
FileExtensionMagicByteReader - Register it in
FileExtensionMagicByteSupplier::DEFAULT_READERS
Acquiring sample files
Run the following command and give it an extension: bin/download-samples.php $extension
--all can be used to download all available samples.
Note that not all extensions have samples to download, due to practical or copyright reasons.
Local docker testing
dcd run --rm php bin/fileinfo ./samples/$file