1.3.0 • Published 1 year ago

thumbnailator v1.3.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Thumbnailator - A file preview generator

Will generate a file preview (jpg, png or webp) of about 450 different document formats, with minimum codebase.

Installation

Thumbnailator depends on multiple programs which it uses to operate.

First, you have to install them using your system package manager, e.g.:

sudo apt install libreoffice ffmpeg graphicsmagick

To install thumbnailator using npm:

npm install thumbnailator

Usage

import thumbnailator from 'thumbnailator';

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

You can set more options for the preview generation. All available options are:

OptionDescriptionValueDefault
widthThe target image widthnumber (in pixels)-
heightThe target image heightnumber (in pixels)-
scaleThe target image scale factor in percentage (mutually exclusive with width and height)number (in pixels)-
cropIf set to true the result image will be of exact size given, cropped to centerbooleanfalse
ignoreAspectIf set to true will ignore the aspect ratio of original imagebooleanfalse
oversizeIf set to true will use width and height given as minimum values (with aspect ratio preserved)booleanfalse
shrinkIf set to true will shrink the image if it is larger than the target sizebooleanfalse
enlargeIf set to true enlarge the image if it is smaller than the target sizebooleanfalse
thumbnailResizes the image as quickly as possible, with more concern for speed rather the image quality. Regardless, resulting image quality should be acceptable for many usesbooleanfalse
qualityFor the JPEG and MPEG image formats only. Where 0 is the lowest image quality and highest compression and 100 is the best quality but least effective compressionnumber (0-100)75, normal
densityIf the file format supports it, may be used to update the image resolutionnumber (DPI)72
backgroundThe background colorstring (color hash or rgba)transparent

Document Formats

TODO:

1.2.0

1 year ago

1.3.0

1 year ago

1.1.0

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago