rpbissonnette / thebigpicture

Automatically exported from code.google.com/p/thebigpicture
0 stars 0 forks source link

Metadata should only be loaded when needed #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, the Tiff and Jpeg classes load every possible form of metadata
when initializing. However, for performance reasons it is better to load
metadata segments only when they are needed.

For example, when a user only wants to know something about the GPS
information, it is needed to load IFD0 and the GPS IFD, but not the
Makernote, IPTC, Jpeg comments.

When the metadata is changed, most of the metadata blocks still need to be
loaded because it has to be rewritten. But when a user only needs to read
info, the performance might benefit.

Original issue reported on code.google.com by p.edel...@gmail.com on 6 Apr 2007 at 6:12

GoogleCodeExporter commented 9 years ago
One thing that has to be taken in account when implementing this is that the 
exif and
iptc variables in the MetaInfoFile classes may be empty because they aren't 
loaded,
or because there is no such metadata. One possible way to solve this is to use 
False
when it not there and None when it's not loaded. But maybe a more explicit way 
is to
keep an extra boolean which tells whether we've tried to load the data.

Original comment by p.edel...@gmail.com on 6 Apr 2007 at 6:23

GoogleCodeExporter commented 9 years ago

Original comment by p.edel...@gmail.com on 6 Apr 2007 at 9:47

GoogleCodeExporter commented 9 years ago
One interesting thing to note is that this trick only works when the user 
specifies a
record when querying for a tag, otherwise still all records need to be loaded 
to make
sure the tag doesn't hide in there. So there's a bit of a trade-off performance 
and
usability.

This should be documented.

Original comment by p.edel...@gmail.com on 6 Apr 2007 at 9:51

GoogleCodeExporter commented 9 years ago

Original comment by p.edel...@gmail.com on 6 Apr 2007 at 9:54

GoogleCodeExporter commented 9 years ago
This is implemented in revision 41 and 42.

Accessing records in a MetaInfoBlock should now be done through its
getRecord(rec_num) method, which returns the record object. This way, the 
method can
load the specified record on request.

On a larger level, the image classes only load the Exif or IPTC data when 
needed.

This implementation does indeed have a beneficial effect on the reading speed. A
simple test suggests that loading of the GPSMapDatum occurs almost three times 
as fast.

Original comment by p.edel...@gmail.com on 8 Apr 2007 at 11:20

GoogleCodeExporter commented 9 years ago
This is now documented in the Wiki.

Original comment by p.edel...@gmail.com on 8 Apr 2007 at 12:36