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

plugin to cache the exif data of images #236

Merged
merged 1 commit into from Feb 5, 2017

Conversation

t-animal
Copy link
Contributor

Decreases the time needed to build large galleries (e.g.: 25k images in 2.5s instead of 30s)

This plugin allows extended caching, which is useful for large galleries. Once a gallery has
been built it caches the exif-data of the contained images in the gallery target folder.
Before the next run it restores them so that the image does not have to be parsed again. For
large galleries this can speed up the creation of index files dramatically.

Copy link
Owner

@saimn saimn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, and nice improvement !

logger.debug("Loaded cache with %d entries", len(gallery.exifCache))
else:
gallery.exifCache = {}
except Exception as e:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this try/except around the pickle.load line ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended, as the file might exist but not be readable for the user.

if hasattr(gallery, "exifCache"):
cache = gallery.exifCache
else:
cache = gallery.exifCache = {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified with getattr(gallery, "exifCache", {}) and always use cache below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhm, I would have to change the test cases, as they assume gallery.exifCache exists...

@saimn
Copy link
Owner

saimn commented Feb 1, 2017

@t-animal - Can you rebase on master to get rid of the conflict on tests/sample/sigal.conf.py ?

cache = album.gallery.exifCache

for media in album.medias:
if media.type == "image":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot this, you can use album.images.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@saimn
Copy link
Owner

saimn commented Feb 1, 2017

It would also be useful to add your plugins to the related documentation page, with a quick description: http://sigal.saimon.org/en/latest/plugins.html

@krylovsk
Copy link

krylovsk commented Feb 2, 2017

This is neat, I've been experiencing long rebuild times with my moderate (~5k) gallery.
Documentation would be welcome.

@t-animal t-animal force-pushed the extended_caching_plugin branch 2 times, most recently from d5d5790 to 56c4aae Compare February 2, 2017 16:57
@t-animal
Copy link
Contributor Author

t-animal commented Feb 2, 2017

@krylovsk simply include the plugin in your config (plugins=['sigal.plugins.extended_caching']) and after you've build the gallery the next time, a cache-file will be put in your gallery from where the cached data will be loaded upon the build after that.

@saimn saimn merged commit e246646 into saimn:master Feb 5, 2017
@saimn
Copy link
Owner

saimn commented Feb 5, 2017

Merging, thanks @t-animal !

@saimn saimn added this to the 1.4.0 milestone Feb 5, 2017
kontza pushed a commit to kontza/sigal that referenced this pull request Aug 28, 2020
plugin to cache the exif data of images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants