Skip to content

Latest commit

 

History

History
81 lines (74 loc) · 1.37 KB

README.md

File metadata and controls

81 lines (74 loc) · 1.37 KB

yet another filetype checker

kinda similar to filetype.py but:

supported formats

  • flv
  • jxr
  • tif
  • psd
  • psb
  • dds
  • woff
  • woff2
  • ico
  • cur
  • swf
  • 7z (only non splitted archive)
  • pdf
  • 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)

how to use

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")