Small and dependency-free Julia package to infer file and MIME type checking the magic numbers signature.
MIT License
Small and dependency free Julia package to infer file and MIME type checking the magic numbers signature.
currently under developement.
Take a look on contribution
using FileTypes
julia> kind = matcher("example.gif")
FileType.Types("gif", "image/gif")
julia> kind.extension
"gif"
julia> kind.mime
"image/gif"
using FileTypes
julia> Is(FileType.Image,"example.gif")
true
using FileTypes
julia> is_mime_supported("image/jpeg")
true
julia> is_extension_supported("png")
true
julia> using FileTypes
julia> FileType
FileTypes.FileType
julia> FileType.Image
Dict{FileTypes.FileType.Type, Function} with 12 entries:
Type("gif", MIME type image/gif) => Gif
Type("cr2", MIME type image/x-canon-cr2) => CR2
Type("jp2", MIME type image/jp2) => Jpeg2000
Type("psd", MIME type image/vnd.adobe.photoshop) => Psd
Type("bmp", MIME type image/bmp) => Bmp
Type("tif", MIME type image/tiff) => Tiff
Type("jpg", MIME type image/jpeg) => Jpeg
Type("ico", MIME type image/vnd.microsoft.icon) => Ico
Type("png", MIME type image/png) => Png
Type("webp", MIME type image/webp) => Webp
Type("jxr", MIME type image/vnd.ms-photo) => Jxr
Type("dwg", MIME type image/vnd.dwg) => Dwg
image/jpeg
image/png
image/gif
image/webp
image/x-canon-cr2
image/tiff
image/bmp
image/heif
image/vnd.ms-photo
image/vnd.adobe.photoshop
image/vnd.microsoft.icon
image/vnd.dwg
video/x-m4v
video/webm
video/quicktime
video/x-msvideo
video/x-ms-wmv
video/mpeg
video/x-flv
video/3gpp
audio/midi
audio/mpeg
audio/m4a
audio/ogg
audio/x-flac
audio/x-wav
audio/amr
audio/aac
application/epub+zip
application/zip
application/x-tar
application/vnd.rar
application/gzip
application/x-bzip2
application/x-7z-compressed
application/x-xz
application/pdf
application/vnd.microsoft.portable-executable
application/x-shockwave-flash
application/rtf
application/x-iso9660-image
application/octet-stream
application/postscript
application/vnd.sqlite3
application/x-nintendo-nes-rom
application/x-google-chrome-extension
application/vnd.ms-cab-compressed
application/vnd.debian.binary-package
application/x-unix-archive
application/x-compress
application/x-lzip
application/x-rpm
application/x-executable
application/dicom
application/msword
application/vnd.ms-excel
application/vnd.ms-powerpoint
application/font-woff
application/font-woff
application/font-sfnt
application/font-sfnt
application/wasm
application/vnd.android.dex
application/vnd.android.dey
Is
API takes a parameter as FileType.Images.Image
which is a dictionary of all the supported image. I think it should be an (immutable)namedtuple as the custom filetype should be of unknown type only.Is
API like FileType.Unknown.FileType.Images.Image
should be FileType.Images
system info: SMP Debian 5.8.7-1kali1 (2020-09-14) x86_64 GNU/Linux Intel(R) Core(TM) i3-6006U CPU @ 2.00GHz
julia> @benchmark matcher("example.png")
BenchmarkTools.Trial:
memory estimate: 1.69 KiB
allocs estimate: 16
--------------
minimum time: 12.304 μs (0.00% GC)
median time: 12.859 μs (0.00% GC)
mean time: 14.708 μs (0.00% GC)
maximum time: 329.586 μs (0.00% GC)
--------------
samples: 10000
evals/sample: 1
MIT - Prince Roshan