After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 326411 - Imagefile should use file magic to load images
Imagefile should use file magic to load images
Status: RESOLVED FIXED
Product: f-spot
Classification: Other
Component: General
0.1.x
Other Linux
: Normal normal
: ---
Assigned To: F-spot maintainers
F-spot maintainers
: 491193 564817 (view as bug list)
Depends on:
Blocks: 342288
 
 
Reported: 2006-01-10 05:02 UTC by Larry Ewing
Modified: 2009-08-11 10:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use the file magic to choose the loader (4.63 KB, patch)
2006-06-12 11:28 UTC, Stephane Delcroix
needs-work Details | Review
use the mimetype to choose a loader (4.00 KB, patch)
2006-06-12 11:53 UTC, Stephane Delcroix
needs-work Details | Review
ImageFile.cs patch which uses both mime info and extensions (2.41 KB, patch)
2006-07-09 15:36 UTC, Johan Zaxmy
needs-work Details | Review

Description Larry Ewing 2006-01-10 05:02:03 UTC
right now ImageFile uses just the filename to pick the loader, it should use the files magic numbers.
Comment 1 Stephane Delcroix 2006-06-09 13:05:19 UTC
Are you aware of an implementation of file(1) in C# ?
Comment 2 Larry Ewing 2006-06-09 23:04:20 UTC
gnome-vfs has the needed function, and I'll make certain the shared-mime-info database has valied magic for all the formats we load.  It really just needs to be hooked up.
Comment 3 Stephane Delcroix 2006-06-10 07:56:06 UTC
In the meantime, I've started a implementation of this.
It's a very short number of lines.

It's working now, just need some time to be integrated with f-spot. Once it is ready, I'll send it to you and it's yours to decide...
Comment 4 Stephane Delcroix 2006-06-12 11:28:01 UTC
Created attachment 67178 [details] [review]
Use the file magic to choose the loader

This code replace the extension based loader.

For now, it only detect png, gif and jpg. If there is any interest, I can easily extend the table to support the other formats.

Comments are welcome.
Comment 5 Stephane Delcroix 2006-06-12 11:53:32 UTC
Created attachment 67180 [details] [review]
use the mimetype to choose a loader

This patch has exactly the same functionality as the previous.
It uses the mime type provided by the GnomeVfs instead of reading the file magic.

I guess Larry will prefer this one.

(Same comment: for now, only for jpg, gif, png, but I can extend the table)
Comment 6 Stephane Delcroix 2006-07-07 12:00:26 UTC
I'm planning to extend the patch 67180 to support the whole list of files F-spot handle.

But I don't have the mime type (as reported by nautilus > properties) for the following files:

.svg .gif .cr2 .nef .pef .raw .tiff .tif .orf .srf .dng .crw .ppm .mrw .raf .x3f

I can probably find out some of them, but I know nothing at all about nef, pef, raw, orf, srf, dng, mrw, raf, x3f

please comment to this bug if you had some...
Comment 7 Johan Zaxmy 2006-07-08 17:57:20 UTC
Nautilus reports .nef as image/tiff  
Comment 8 Johan Zaxmy 2006-07-08 21:23:18 UTC
I think you will run into problems as .dng is also reported as image/tiff most raw files seems to be reported as image/tiff
Comment 9 Johan Zaxmy 2006-07-09 15:36:32 UTC
Created attachment 68674 [details] [review]
ImageFile.cs patch which uses both mime info and extensions

My dirty patch which first checks for a legal mime type and then uses the extension to associate it with the right image loader.

Based on Stephane Delcroix patch.

Seems to work (I mostly reused the old code). The mime types are still not complete...
Comment 10 Stephane Delcroix 2006-07-09 18:57:47 UTC
Zaxmy (comment #8), I'm aware of this, and still don't know exactly how to solve it (but there is a way, I'm sure of that).

Zaxmy again (comment #9 and patch), good try, but your patch is simply useless. You 're checking the mime type and then return the type only defined by the extension...

Zaxmy again and again (comment #7), thanks for the mime type of the nef file.
Comment 11 Johan Zaxmy 2006-07-09 19:48:56 UTC
(In reply to comment #10)
> Zaxmy again (comment #9 and patch), good try, but your patch is simply useless.
> You 're checking the mime type and then return the type only defined by the
> extension...

I think useless is a bit of over statement, it's more useful than your orginal patch ;-)

I looked up how libgnomevfs does it, they have a own implementation of file...

gthumb relies on gdk-pixbuf's ability to detect the right file format when displaying images, they just check that it is a mime type containing the magic "image" word.
Comment 12 Larry Ewing 2006-07-10 16:41:06 UTC
Gnome-vfs uses the freedesktop spec for shared mime info.  I have a patch for shared-mime-info that has magic for most of the raw types here, I sent it upstream a while ago but it died after a little discussion.  Things like .nef and .cr2 are in fact tiff files in that they are aranged using the same ifd concept with some extensions/modifications.  The ImageFile tiff loader can be cleaned up and made generic enough to deal with all the variants without too much trouble.
Comment 13 Johan Zaxmy 2006-07-10 17:03:38 UTC
Sounds like the best solution.
Comment 14 Stephane Delcroix 2006-09-18 12:34:27 UTC
interesting related bug: https://bugs.freedesktop.org/show_bug.cgi?id=8170

I'm currently testing it...
Comment 15 Stephane Delcroix 2006-09-18 13:31:08 UTC
ok, it works !

I copied the attachment as /usr/share/mime/packages/raw.xml, updated the mime infos with update-mime-database /usr/share/mime, and the raw files are detected correctly (tested with nautilus)

Apparently, there's still a problem with .cr2. Can f-spot install its own mime xml file or wait for the inclusion of that in shared-mime-info ?
Comment 16 Maxxer 2007-11-22 16:59:40 UTC
*** Bug 491193 has been marked as a duplicate of this bug. ***
Comment 17 Bengt Thuree 2007-11-22 17:07:48 UTC
Any news on this bug, after Stephane's "ok it works !" comment in comment #15

It's been over one year with a workable solution or?
Comment 18 Stephane Delcroix 2007-12-10 11:27:53 UTC
no, no news. the "official" mime db still doesn't recognize all the raw formats :(
Comment 19 Maxxer 2008-12-17 08:47:43 UTC
*** Bug 564817 has been marked as a duplicate of this bug. ***
Comment 20 Ruben Vermeersch 2009-08-11 10:56:40 UTC
Should be fixed:

commit a41352f10074d4acc7b1e7eafe5a1484ee70bed4
Author: Gabriel Burt <gabriel.burt@gmail.com>
Date:   Mon Aug 10 16:55:04 2009 -0700

    Support loading files with no extensions