Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitmaps #8

Closed
Narrat opened this issue Jan 24, 2016 · 13 comments
Closed

Bitmaps #8

Narrat opened this issue Jan 24, 2016 · 13 comments
Labels

Comments

@Narrat
Copy link
Owner

Narrat commented Jan 24, 2016

Stumpled upon bitmaps (.bmp) and was kinda suprised pim didn't open those.

Explicit calling those behaved like giving a directory

@Narrat Narrat added the Issue label Jan 24, 2016
@karlch
Copy link

karlch commented Jan 30, 2016

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.

@Narrat
Copy link
Owner Author

Narrat commented Jan 30, 2016

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

@aeosynth
Copy link
Collaborator

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

@Narrat
Copy link
Owner Author

Narrat commented Jul 10, 2016

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

@aeosynth
Copy link
Collaborator

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

@karlch
Copy link

karlch commented Jul 10, 2016

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.

@aeosynth
Copy link
Collaborator

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

@karlch
Copy link

karlch commented Jul 12, 2016

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.

@aeosynth
Copy link
Collaborator

aeosynth commented Jul 12, 2016

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

@karlch
Copy link

karlch commented Jul 12, 2016

Just rename any images of your choice accordingly 😃

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

@aeosynth
Copy link
Collaborator

oh, i thought mimetypes actually read from disk

@aeosynth
Copy link
Collaborator

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

@karlch
Copy link

karlch commented Jul 14, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants