Giter Site home page Giter Site logo

Bitmaps about pim HOT 13 CLOSED

narrat avatar narrat commented on August 19, 2024
Bitmaps

from pim.

Comments (13)

aeosynth avatar aeosynth commented on August 19, 2024 1

http://lazka.github.io/pgi-docs/GdkPixbuf-2.0/classes/Pixbuf.html#GdkPixbuf.Pixbuf.get_file_info

Parses an image file far enough to determine its format and size.

i believe this can be used instead of imghdr

from pim.

karlch avatar karlch commented on August 19, 2024

First of all thanks for your great work on Pim, I have highly enjoyed working with the codebase.

I did a quick debug on this. Looks like not all .bmp mimetypes are included in GdkPixbuf.Pixbuf.get_formats(). In my specific case, I tested with a few bitmaps exported from gimp, the "image/x-ms-bmp" type was missing. Simply appending that type to the supported ones solved the issue.

The problem is, I have no idea how many more types are missing and how one could find out what they are.

from pim.

Narrat avatar Narrat commented on August 19, 2024

Such kind words :D Although James Campos (aeosynth) should be praised mostly. As I just worked on his ToDo entries later.
And it was nice to see, someone taking this as base and enhancing it with various features.

And thanks for debugging this. Currently I don't have the time to check on this.
And if it's related to GdkPixbuf dunno what's the best thing to do.

Maybe some kind of regex, if the first check returned as unsupported, check if there are similar ones --> will be added and failure will be sorted out later as it could be covered by the routine with broken images.
Whatever hell pit such a handling will open :D Just some quick thought on this

from pim.

aeosynth avatar aeosynth commented on August 19, 2024

can you share some failing bitmaps? would checking extension (.bmp) instead of mime type fix this?

from pim.

Narrat avatar Narrat commented on August 19, 2024

https://paste.archlinux.de/m-gObM/

Well. Checking the extension would open the problem with non image files with an .bmp ending (for whatever reason those could exist)

Edit: Or without any extension

from pim.

aeosynth avatar aeosynth commented on August 19, 2024

those have the type image/x-ms-bmp; GdkPixbuf supports image/x-MS-bmp. a quick fix would be to lowercase the types (x-MS-bmp is the only type using caps). using extensions is easier tho; users can rename their files if they have issues

from pim.

karlch avatar karlch commented on August 19, 2024

Just for sharing information: I had someone open an issue for opening images without any extension
karlch/vimiv#17

In general I agree with him, just filtering images by mimetype is not very sophisticated. Using the imghdr module might be a better alternative. I plan on testing that sometime this or next month, still pretty busy at the moment.

If it works and you are interested, I could probably implement a PR for Pim afterwards as well.

from pim.

aeosynth avatar aeosynth commented on August 19, 2024

you'd have to convince me by showing images which are only recognizable with that module

from pim.

karlch avatar karlch commented on August 19, 2024

Got to it earlier than expected.

Say you have a correct imagefile called "myimage" and a textfile called "text.png". The extension version wouldn't work whereas imghdr filters correctly.

As the opened issue shows the first case happens, the second one is rather esoteric but nice to be protected against. Sure, one could rename the files manually, but this shouldn't be necessary.

I have yet to find a file that imghdr does not handle correctly.

from pim.

aeosynth avatar aeosynth commented on August 19, 2024

The extension version wouldn't work whereas imghdr filters correctly.

what about the mimetype version?

i'd like to see real images which are detected differently

from pim.

karlch avatar karlch commented on August 19, 2024

Just rename any images of your choice accordingly 😃

I don't have a favourite pastebin yet...

from pim.

aeosynth avatar aeosynth commented on August 19, 2024

oh, i thought mimetypes actually read from disk

from pim.

karlch avatar karlch commented on August 19, 2024

Nice catch! First tests with it seem to go perfectly well.

from pim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.