npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

thumbnailator

v1.4.0

Published

A file preview generator

Downloads

69

Readme

Thumbnailator - A file preview generator

Thumbnailator generates image previews (JPG, PNG, or WebP) for approximately 450 different document formats with a minimal codebase.

Installation

Thumbnailator relies on several external programs. You need to install these dependencies using your system's package manager.

For example, on a Debian-based system:

sudo apt install libreoffice ffmpeg graphicsmagick

Then, install Thumbnailator using npm:

npm install thumbnailator

Usage

import thumbnailator from 'thumbnailator';

await thumbnailator('file.docx', 'preview.jpg', {thumbnail: true});

You can customize the preview generation with various options.

Options

| Option | Description | Value | Default | |----------------|----------------------------------------------------------------------------------------------------------------------------------|-----------------------------|---------------| | width | The target image width. | Number (in pixels) | - | | height | The target image height. | Number (in pixels) | - | | scale | The target image scale factor in percentage. This option is mutually exclusive with width and height. | Number | - | | crop | If set to true, the resulting image will be cropped to the exact dimensions specified, focusing on the center. | Boolean | false | | ignoreAspect | If set to true, the original image's aspect ratio will be disregarded. | Boolean | false | | oversize | If set to true, the specified width and height will be treated as minimum values, preserving the aspect ratio. | Boolean | false | | shrink | If set to true, the image will be shrunk if it is larger than the target dimensions. | Boolean | false | | enlarge | If set to true, the image will be enlarged if it is smaller than the target dimensions. | Boolean | false | | thumbnail | Fast resize, prioritizing speed over image quality. The resulting image quality should still be acceptable for common uses. | Boolean | false | | quality | Applies to JPEG and MPEG image formats only. 0 = low quality/high compression, 100 = high quality/low compression. | Number (0-100) | 75 | | density | If supported by the file format, this option can be used to update the image resolution. | Number (DPI) | 72 | | background | The background color for the generated image. | String (color hash or RGBA) | transparent |

Supported Document Formats

Thumbnailator supports a wide range of document formats by leveraging external tools like LibreOffice, FFmpeg, and GraphicsMagick. The exact list of supported formats depends on the capabilities of these underlying programs installed on your system. Generally, you can expect support for:

  • PDF Documents: .pdf (via GraphicsMagick)
  • Office Documents: .docx, .xlsx, .pptx, .odt, .ods, .odp, etc. (via LibreOffice)
  • Images: .jpg, .png, .gif, .bmp, .tiff, .webp, etc. (via GraphicsMagick)
  • Videos: .mp4, .avi, .mov, .mkv, etc. (previews generated from frames via FFmpeg)
  • Audio: .mp3, .ogg (audio waveforms or cover images via FFmpeg)

For a comprehensive list, please refer to the documentation of the respective tools and the source code.

TODO:

  • [ ] Smart crop
  • [ ] Compress images, e.g. with https://github.com/Lymphatus/caesium-clt