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
2
votes
3 answers

trying to use 3rd part library, libmagic

i try use this code: #include #include int main(void) { char *actual_file = "/file/you/want.yay"; const char *magic_full; magic_t magic_cookie; magic_cookie = magic_open(MAGIC_MIME); if (magic_cookie ==…
user2050969
  • 21
  • 1
  • 2
2
votes
1 answer

is lib magic thread-safe?

I've been searching around, trying to find an answer. I know that I can create multiple libmagic instances, one for each thread, and that is thread-safe. But can I have a single instance shared between multiple threads?
vy32
  • 28,461
  • 37
  • 122
  • 246
1
vote
1 answer

Installing libmagic with pip fails

After installing in my Jupyter Notebook (as a container of JupyterLab as jovan user without access to root) the libmagic while having cmake 3.26.4 already installed in the conda env. I try to install install libmagic with pip: pip install…
mCs
  • 2,591
  • 6
  • 39
  • 66
1
vote
2 answers

Difficulty importing module in Python that was installed via homebrew on M1 Pro Mac

I'm currently developing a script called script.py that makes use of the libmagic package. I used homebrew (3.5.9) to install it via ZSH shell on an M1 Pro Mac. As with any homebrew package installation, I used brew install libmagic and it installed…
1
vote
1 answer

Convert mime type from freededesktop spec to libmagic format

After read shared-mime-info spec and add my own types in /usr/share/mime/packages. I have refreshed the database: $ update-mime-database /usr/share/mime I have try with gvfs-info, it return the right mime. So unix command file use libmagic and…
bioinfornatics
  • 1,749
  • 3
  • 17
  • 36
1
vote
0 answers

Using python magic to filter files based on MIME type

I have a set of files in a directory and I'm making use of python-magic library to filter out files that are of type "text/plain" and remove all the non 'text/plain' files. Below is the code I'm using import os import magic def ftype(path): …
dmorgan
  • 73
  • 1
  • 11
1
vote
1 answer

Django with python-magic (libmagic) to verify uploaded files

I'm trying to save the mime type of an uploaded file in django. I don't need to reject certain types of files, I just need to keep track of the mime type of uploaded files. I'm doing this: class Foo(models.Model): document =…
Alex
  • 2,270
  • 3
  • 33
  • 65
1
vote
1 answer

Conditional requirements in setup.py

I'm writing a library that's dependent on file-magic, which works just fine for most platforms, but in Alpine Linux, file-magic won't work so I need to instead use the python-magic library. Now I know how to write my own code to handle the different…
Daniel Quinn
  • 6,010
  • 6
  • 38
  • 61
1
vote
1 answer

How to write a magic file for libmagic to detect srt (subtitle) files

hhvm use libmagic to detect mime types of files. When i upload a subtitle file in srt format with the keyword "extern" as first word of a line hhvm (libmagic) detect it as text/x-c and the validation in symfony dont except the file. That's why I…
micha
  • 161
  • 1
  • 2
  • 14
1
vote
0 answers

How to detect file mime by file header on Nginx?

I want to return a file stored without extension name. But nginx returns it with application/octet-stream. I want return a file with correct mime, based on file header but not extension name, like using file --mime-type -b How should I…
Zz Tux
  • 600
  • 1
  • 5
  • 18
1
vote
0 answers

Safely parsing the output of file (or libmagic)

I'm writing some code where I rely on the file utility to determine the file type of arbitrary files, typically audio files. For the most part, it works great, an ogg file for example might give the following output: Ogg data, Vorbis audio, mono,…
1
vote
1 answer

Memory leak in libmagic?

Trynig some test code for libmagic: #include #include int main(int argc, char **argv) { magic_t cookie; cookie = magic_open(MAGIC_MIME_TYPE); if (cookie == NULL) { perror(magic_error(cookie)); …
lash
  • 746
  • 1
  • 7
  • 23
1
vote
1 answer

Use magic.mgc from another language

I'm currently working on a project which involves reading file's magic files (without bindings). I'd like to know how it would be possible to read the file tests from the compiled binary magic.mgc directly, in another language (like Go), as I'm…
David Castillo
  • 4,266
  • 4
  • 23
  • 25
1
vote
3 answers

Pushbullet on python throws import error due to python-magic unable to find libmagic?

I'm trying to use PushBullet.py which uses python-magic which in turn uses libmagic. I have followed the dependencies instructions and installed Cygwin and copied the three files to Windows\system32 directory but still getting the following…
Ryflex
  • 5,559
  • 25
  • 79
  • 148
0
votes
0 answers

Can't load library Android 13

I have been facing an error in my android app since I upgraded the target SDK to 33 and I can't find anything about this specific error. The exception is: “E/FBI: Can’t load library: dlopen failed: library “libmagtsync.so” not found”. Here's the…