Questions tagged [libmagic]

The libmagic library identifies different file types.

The libmagic library is able to identify different types of files by analyzing their contents. It is similar in spirit to the code used in the Unix file command.

50 questions
12
votes
2 answers

python-magic installation challenges for 64-bit Windows 10 running 32-bit Python 2.7 build

Despite following the readme for the module, I continue to get "magic files not found". The readme and "Dependencies" section say: On Windows, copy magic1.dll, regex2.dll, and zlib1.dll onto your PATH from the Binaries and Dependencies zip files…
Suzanne
  • 582
  • 2
  • 11
  • 31
7
votes
1 answer

How do you write a magic file test pattern to match the end of a file?

I am beginning to wonder if this is even possible as multiple searches on SO, Google, Bing and linuxquestions.org have turned up nothing. I am interested in extending the magic patterns located in /usr/share/magic (used by the file(1) utility) to…
jayce
  • 85
  • 4
5
votes
2 answers

How to install libmagic on Heroku?

I have a rails 4 app that uses ruby-filemagic, and so filemagic needs to be installed on the system. I've tried installing it on Heroku by mimicing solutions to this question, but it just won't work. I've tried multiple things, but the one I think…
ben
  • 1,432
  • 12
  • 17
4
votes
0 answers

Generic way to check the architecture of a file

Is there a general way to check the platform (32-bit/64-bit) and architecture (powerpc, arm, etc...) of a binary file (Which can be ELF, Dwarf, PE, etc...)? I know that almost every file (elf or pe) has a header which says which architecture can…
Drxxd
  • 1,860
  • 14
  • 34
4
votes
1 answer

php 7.2 finfo magic file

I have a Laravel 5 project, which let's an user download .ai (illustrator files). The issue is that Laravel detects .ai files as application/pdf. I am detecting mime type with this function $type = File::mimeType( $_path ); I also tried using this…
Karl Johan Vallner
  • 3,980
  • 4
  • 35
  • 46
4
votes
2 answers

Pyinstaller - libmagic not found after compiling app

Problem I'm writing an application in Python. It works just fine in my python environment, but when I compile it with PyInstaller and try to run the resulting executable, I get the following error: ImportError: failed to find libmagic. Check your…
Kevin Damian
  • 151
  • 1
  • 9
3
votes
2 answers

Why .WMV files have mime type 'video/x-ms-asf' instead of 'video/x-ms-wmv'?

I need to accept only MP4 videos and WMV videos in a Django web app I am building. For that, I am checking the mime type of the file once it hits the server. As far as I understand, MP4 files have 'video/mp4' mime type, which is exactly what I am…
Storo
  • 988
  • 1
  • 7
  • 31
3
votes
3 answers

Compiling libmagic statically (c/c++ file type detection)

Thanks to the guys that helped me with my previous question (linked just for reference). I can place the files fileTypeTest.cpp, libmagic.a, and magic in a directory, and I can compile with g++ -lmagic fileTypeTest.cpp fileTypeTest. Later, I'll be…
Kache
  • 15,647
  • 12
  • 51
  • 79
3
votes
1 answer

Which libmagic did python-magic use?

I'm using python-magic and I've installed it using sudo apt-get remove libmagic-dev In order to cite it properly, when i tried to find the authors online, i realized there are multiple libmagic libraries,…
alvas
  • 115,346
  • 109
  • 446
  • 738
3
votes
2 answers

libmagic. text/plain instead of text/javascript text/css

I use libmagic to get the mime type of a file in a web interface of my project. I get text/plain mime type on css and js files. For example chromium shows below warnings: Resource interpreted as Stylesheet but transferred with MIME type text/plain:…
alex_ac
  • 121
  • 8
2
votes
0 answers

Programmatically getting the architecture info `file` produces on macOS?

On macOS, is there any way to programmatically get (from C or Swift) the same architecture info that file produces when run on an executable? E.g.: $ file /Library/Audio/Plug-Ins/HAL/ACE.driver/Contents/MacOS/ACE…
Rick
  • 3,298
  • 3
  • 29
  • 47
2
votes
0 answers

The assertion (COMMON-LISP:= (MAGICFFI::MAGIC-VERSION) MAGICFFI::+MAGIC-VERSION+) failed

When executing a script I get the following error: Unhandled SIMPLE-ERROR in thread #: The assertion (COMMON-LISP:= (MAGICFFI::MAGIC-VERSION) MAGICFFI::+MAGIC-VERSION+) failed with…
RandomFellow
  • 317
  • 1
  • 9
2
votes
3 answers

How to get the file-magic module working on Alpine Linux?

I'm trying to use file-magic on Alpine Linux and it keeps blowing up with AttributeError: Symbol not found: magic_open whenever I import the magic module. I noted that there's two Python modules out there with the same magic namespace, but as most…
Daniel Quinn
  • 6,010
  • 6
  • 38
  • 61
2
votes
0 answers

How to tell if cdfv2 file is encrypted using python?

I have an file which has been encrypted by Zed!. This is identified by file --mime-type test.zed as "application/CDFV2-encrypted" However, when using python and the module filemagic: with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as m: mime =…
Niklas Lindskog
  • 138
  • 1
  • 7
2
votes
3 answers

python-magic WindowsError: [Error 193] %1 is not a valid Win32 application

Hi I'm trying to use python-magic on windows 8 but when I try to import with the command import magic it gives me this error WindowsError: [Error 193] %1 is not a valid Win32 application I have tried both with 64-bit and 32-bit version of Python…
Lorenzo Bottaccioli
  • 441
  • 1
  • 7
  • 20
1
2 3 4