kinda similar to filetype.py but:
- at first reads 8 bytes and reads more if needed
- everything in single file
- only output file extension (maybe i will add MIME type output too, idk)
- only works with files (not with bytearray and other stuff)
- flv
- jxr
- tif
- psd
- psb
- dds
- woff
- woff2
- ico
- cur
- swf
- 7z (only non splitted archive)
- jpg
- gif
- jif
- png
- apng
- qoi
- bmp
- mov
- avif
- heic
- mp4
- m4v
- m4a
- 3gp
- 3g2
- epub
- ora
- aac
- mp3
- flac
- mkv
- webm
- webp
- avi
- wav
- ani
- ts
- mpg
- torrent
- jxl
- html
- blank (fake extension, file filled with zeros/null bytes)
as standalone app:
.\filetype_checker.py sample.png
apng
as library:
import os.path
import filetype_checker
file_path = "sample.png"
if (os.path.isfile(file_path)):
# if extension was not found it will return None
file_extension = filetype_checker.guess_ext(file_path)
if (file_extension):
print("File extension:", file_extension)
else:
print("Cant guess file extension")
else:
print("Given path is not a file")