Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6469831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:02:21+00:00 2026-05-25T06:02:21+00:00

In another question here I’ve read that python-magic should output the correct mime type

  • 0

In another question here I’ve read that python-magic should output the correct mime type of a file. I’ve added python-magic = 0.4.0 to my Django project, but here’s what it detects:

In [2]: import magic
In [3]: m = magic.Magic(mime_encoding=True)
In [4]: m.from_file('/home/culebron/Documents/chapter2.pdf')
Out[4]: 'binary'

In [5]: m.from_file('/home/culebron/bok.jpg')
Out[5]: 'binary'

What am I doing wrong?

I need to distinguish between images and other binary file types, without relying on file extensions. So, I want to take a file content and in the end get an information that it is either jpeg, or png, or audio or something else. It may be python-magic, or suggest another module if you know.

I’ve tried python-hachoir from pypi, but its documentation state is appaling, and I couldn’t find anything useful examining their modules.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:02:22+00:00Added an answer on May 25, 2026 at 6:02 am

    Looking at the examples in the readme, it seems that you need to use mime=True instead of mime_encoding=True to get the mime type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw from another question here : Determine iPhone user's country that it is
Here's another question of How would I do this in Java? In Python, I
I found (after another question here on StackOverflow) this interesting library written in Python
Here's another C#/.NET question based merely on curiousity more than an immediate need ...
In another question , a user pointed out that the new keyword was dangerous
Edit: From another question I provided an answer that has links to a lot
While reading through another question here, on creating a URL shortening service, it was
In response to another question here on stackoverflow ( How do you select every
Ok I have another question HERE for my Logging Class but I wanted to
I got an answer to another question here: DB Schema For Chats? It's a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.