xdg-thumbnails

Generate file thumbnails (image previews) with system workers using freedesktop.org DBus specification

Usage no npm install needed!

<script type="module">
  import xdgThumbnails from 'https://cdn.skypack.dev/xdg-thumbnails';
</script>

README

xdg-thumbnails

Generate file thumbnails (image previews) with system workers using freedesktop.org DBus specification

Installation

npm install xdg-thumbnails

Usage

const thumbnailer = new (require('xdg-thumbnails').Thumbnailer);

thumbnailer.connect((error) => {
    if (error)
        return console.error(error);

    thumbnailer.queueFile('image.jpg', (error, path) => {
        if (error)
            return console.error(error);

        console.log(`Newly generated thumbnail: ${path}`);
    });

    // or, with options

    thumbnailer.queueFile({
        file_path: 'image.jpg',
        scheduler: 'default',  // Options: 'background', 'default', 'foreground'
        flavor:    'normal',   // Options: 'large', 'normal'
    }, (error, path) => {
        if (error)
            return console.error(error);

        console.log(`Newly generated thumbnail: ${path}`);
    });
});