naturtag.storage.remote_images module¶
- class naturtag.storage.remote_images.ImageFetcher(cache_path=PosixPath('/home/docs/.local/share/Naturtag/images.db'))¶
Bases:
objectFetches and caches remote images (mainly taxon and observation thumbnails)
- cache_size()¶
Get the total cache size in bytes, and the number of cached files
- Return type:
str
- get_image(photo, url=None, size=None)¶
Get an image from the cache, if it exists; otherwise, download and cache a new one
- Return type:
bytes
- get_pixmap(path=None, photo=None, url=None, size=None)¶
Fetch a pixmap from either a local path or remote URL. Must be called from the GUI thread since QPixmap is a paint device.
- Return type:
QPixmap
- get_qimage(path=None, photo=None, url=None, size=None)¶
Fetch a QImage from either a local path or remote URL (thread-safe)
- Return type:
QImage
- precache_image(urls)¶
Fetch and cache images at the given URLs, suppressing any errors.
Intended for background preloading where individual failures should not interrupt the overall process.
- naturtag.storage.remote_images.get_url_hash(url)¶
Generate a hash to use as a cache key from an image URL, appended with the file extension
- Parameters:
source – File path or URI for image source
- Return type:
str