Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#917 closed patch (fixed)

MythGallery Fast thumbnail loading using EXIF

Reported by: Grant Gardner <grant@…> Owned by: Isaac Richards
Priority: minor Milestone: 0.20
Component: mythgallery Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

Most digital cameras store thumbnail images in the EXIF info and they are trivially parsed out and very fast compared to loading the whole image and rescaling, especially in the age of 7MP + cameras.

In most arrangements I believe this would remove the need to have a thumbnail cache for everything except movie files.

Attached patch is against 0.18.1

Cheers,

Grant.

Attachments (2)

fastthumbs.patch (1.6 KB) - added by Grant Gardner <grant@…> 14 years ago.
fastthumbs.2.patch (1.3 KB) - added by Grant Gardner <grant@…> 14 years ago.
Patch against svn trunk

Download all attachments as: .zip

Change History (9)

Changed 14 years ago by Grant Gardner <grant@…>

Attachment: fastthumbs.patch added

Changed 14 years ago by Grant Gardner <grant@…>

Attachment: fastthumbs.2.patch added

Patch against svn trunk

comment:1 Changed 14 years ago by Grant Gardner <grant@…>

Version: 0.18.1head

comment:2 Changed 14 years ago by danielk

Milestone: 0.20

comment:3 Changed 14 years ago by Isaac Richards

Resolution: invalid
Status: newclosed

This doesn't look like it's using libexif right at all - it's treating a data structure as raw image data?

comment:4 Changed 14 years ago by Grant Gardner <grant@…>

I found it hard to believe it was that simple too!!

The trick is that the data attached to the first IFD is raw thumbnail JPG data!. Everything else is a tag (retrieved via the tag functions).

I would personally like to see libexif better documented and the structure more clearly named, but it is the way it is and I'm sitting here watching MythGallery generate thumbnails on my 3000 image collection at lightning speed!

GG

comment:5 Changed 14 years ago by Grant Gardner <grant@…>

Resolution: invalid
Status: closedreopened

Hi apologies for spamming trac.

I realise I've got no mythtv cred/karma and my c++ is a bit rusty. Anyway, the code below is from the exif demo provided on the libexif site and shows how to extract thumbnails using libexif. This is what I used to work out how to do it.

...
  } else if (extract_thumbnail) {
     /* No thumbnail? Exit. */
     if (!ed->data) {
        fprintf (stderr, _("'%s' does not contain a thumbnail!"), *args);
        fputc ('\n', stderr);
        return (1);
    }

    /* Save the thumbnail */
    f = fopen (fname, "wb");
    if (!f) {
          fprintf (stderr, _("Could not open '%s' for writing (%m)!"), fname);
          fputc ('\n', stderr);
          return (1);
    }
    fwrite (ed->data, 1, ed->size, f);
    fclose (f);
    fprintf (stdout, _("Wrote file '%s'."),
    fname);

I'll re-open the ticket with this new info. Happy for you to close it again if you don't like the way it is done in which case I'll see if anyone on the dev list knows a better way of getting the thumbnails out.

Cheers,

Grant

comment:6 Changed 14 years ago by Isaac Richards

Resolution: fixed
Status: reopenedclosed

(In [8596]) Close #917 by applying patch (and fix mem leak). Apparently libexif really _is_ that broken.

comment:7 Changed 14 years ago by tino.keitel@…

As I unserstand the comments here, the current SVN (8625) should display thumbnails really fast. However, it doesn't do this here. The pictures are fresh from a Canon EOS 300D and it generates ~1 thumbnail per second on an Athlon XP 2500+.

How can I see what goes wrong here?

Note: See TracTickets for help on using tickets.