question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't find a way to check image file type.

See original GitHub issue

Can’t find a safe way to get image file type, e.g jpg, png, bmp or other type. I tried get metadata with pyvips.Image.get_fields and pyvips.Image.get("vips_loader"), but worried about its reliablity.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jcupittcommented, Oct 4, 2019

I would use something like:

def format(image):
    formats = {
        "jpegload": "JPEG",
        "tiffload": "TIFF",
        etc.
    }
    loader = image.get("vips-loader")
    return formats[loader] if loader in formats else "unknown"
0reactions
2h4dlcommented, Oct 4, 2019

Haha, not convinced, but work. Thank you @jcupitt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I check the actual format of an image file? - Super User
Alternatively, open the suspected PNG in Notepad. If it's truly a PNG, it will have ‰PNG on the first line. Jpeg's will have...
Read more >
Determine file type of an image - Stack Overflow
If you want to find out how to sense almost any file, look at the database behind the file command on a UNIX,...
Read more >
How to Check the File Format of a Document or Photo on iPhone
On the menu that pops up, tap Info. You can then see the file format listed next to the file name. You can...
Read more >
Determine an image's file size and dimensions
File Explorer (Windows 10)​​ Open the image in File Explorer to check dimensions and file size: Type "File Explorer" into the search bar....
Read more >
How To Use Google Image Search Like A Pro - Setapp
Luckily, there's a way within Google to specify that: just type filetype: + the format you need right into the search field with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found