Package: magika
Magika Python packageUse Magika in your Python code!Installing MagikapipinstallmagikaUsing Magika as a command-line tool.$magikaexamples/*

code.asm:Assembly(code)code.py:Pythonsource(code)doc.docx:MicrosoftWord2007+document(document)doc.ini:INIconfigurationfile(text)elf64.elf:ELFexecutable(executable)flac.flac:FLACaudiobitstreamdata(audio)image.bmp:BMPimagedata(image)java.class:Javacompiledbytecode(executable)jpg.jpg:JPEGimagedata(image)pdf.pdf:PDFdocument(document)pe32.exe:PEexecutable(executable)png.png:PNGimagedata(image)README.md:Markdowndocument(text)tar.tar:POSIXtararchive(archive)webm.webm:WebMdata(video)Here's the full usage:magika --help
Usage: magika [OPTIONS] [FILE]...

  Magika - Determine type of FILEs with deep-learning.

Options:
  -r, --recursive                 When passing this option, magika scans every
                                  file within directories, instead of
                                  outputting "directory"
  --json                          Output in JSON format.
  --jsonl                         Output in JSONL format.
  -i, --mime-type                 Output the MIME type instead of a verbose
                                  content type description.
  -l, --label                     Output a simple label instead of a verbose
                                  content type description. Use --list-output-
                                  content-types for the list of supported
                                  output.
  -c, --compatibility-mode        Compatibility mode: output is as close as
                                  possible to `file` and colors are disabled.
  -s, --output-score              Output the prediction's score in addition to
                                  the content type.
  -m, --prediction-mode [best-guess|medium-confidence|high-confidence]
  --batch-size INTEGER            How many files to process in one batch.
  --no-dereference                This option causes symlinks not to be
                                  followed. By default, symlinks are
                                  dereferenced.
  --colors / --no-colors          Enable/disable use of colors.
  -v, --verbose                   Enable more verbose output.
  -vv, --debug                    Enable debug logging.
  --generate-report               Generate report useful when reporting
                                  feedback.
  --version                       Print the version and exit.
  --list-output-content-types     Show a list of supported content types.
  --model-dir DIRECTORY           Use a custom model.
  -h, --help                      Show this message and exit.

  Send any feedback to magika-dev@google.com or via GitHub issues.Using Magika in PythonfrommagikaimportMagikamagika=Magika()result=magika.identify_bytes(b"# Example\nThis is an example of markdown!")print(result.output.ct_label)# Output: "markdown"Reporting false positivesPlease open an issue on Github.CitationIf you use this software for your research, please cite it as:@software{magika,author={Fratantonio, Yanick and Bursztein, Elie and Invernizzi, Luca and Zhang, Marina and Metitieri, Giancarlo and Kurt, Thomas and Galilee, Francois and Petit-Bianco, Alexandre and Farah, Loua and Albertini, Ange},title={{Magika content-type scanner}},url={https://github.com/google/magika}}