For every user, there must be exactly one place where all generated thumbnails are stored. This thumbnails directory is located in the user's XDG Cache Home, as defined by the XDG Base Directory Specification. Namely, if the environment variable $XDG_CACHE_HOME is set and not blank then the directory $XDG_CACHE_HOME/thumbnails will be used, otherwise $HOME/.cache/thumbnails will be used.
The thumbnails directory will have the following internal structure:
$XDG_CACHE_HOME/thumbnails/ $XDG_CACHE_HOME/thumbnails/normal $XDG_CACHE_HOME/thumbnails/large/ $XDG_CACHE_HOME/thumbnails/fail/
The meaning of the directories are as follows:
Normal: The default place for storing thumbnails. The image size must not exceed 128x128 pixel. Programs which need smaller resolutions should read and write the 128x128 thumbnails and downscale them afterwards to the desired dimension. See Thumbnail Creation for more details.
Large: The previous notes apply to this directory too, except that the thumbnail size must be 256x256 pixel.
Fail: This directory is used to store information about files where a thumbnail couldn't be generated. See Thumbnail Generation Failure for more details.
You must not create/save thumbnails for any files you will find in these directories. Instead load and use these files directly.