'A version of ``Thumbnailer.get_thumbnail_name`` that produces a
reproducible thumbnail name that can be converted back to the original
filename.'

def get_thumbnail_name(self, thumbnail_options, transparent=False, high_resolution=False):

    (path, source_filename) = os.path.split(self.name)
    source_extension = os.path.splitext(source_filename)[1][1:]
    if ((self.thumbnail_preserve_extensions is True) or (self.thumbnail_preserve_extensions and (source_extension.lower() in self.thumbnail_preserve_extensions))):
        extension = source_extension
    elif transparent:
        extension = self.thumbnail_transparency_extension
    else:
        extension = self.thumbnail_extension
    extension = (extension or u'jpg')
    thumbnail_options = thumbnail_options.copy()
    size = tuple(thumbnail_options.pop(u'size'))
    quality = thumbnail_options.pop(u'quality', self.thumbnail_quality)
    initial_opts = [(u'%sx%s' % size), (u'q%s' % quality)]
    opts = list(thumbnail_options.items())
    opts.sort()
    opts = [(u'%s' % (((v is not True) and (u'%s-%s' % (k, v))) or k)) for (k, v) in opts if v]
    all_opts = u'_'.join((initial_opts + opts))
    basedir = self.thumbnail_basedir
    subdir = self.thumbnail_subdir
    all_opts = all_opts.replace(u'__', u'_')
    if high_resolution:
        try:
            all_opts += self.thumbnail_highres_infix
        except AttributeError:
            all_opts += u'@2x'
    filename = (u'%s__%s.%s' % (source_filename, all_opts, extension))
    return os.path.join(basedir, path, subdir, filename)
