Socket
Book a DemoInstallSign in
Socket

doc-thumbnail

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

doc-thumbnail

A generator for thumbnails of document and image files.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

doc-thumbnail

This utility creates a preview thumbnail from a document. It requires unoconv and ImageMagick (convert) to be installed.

API

interface BaseConfig{
	width?: number;
	height?: number;
	imagemagickPath?: string;
}
interface DocPreviewConf extends BaseConfig{
	unoconvPath?: string;
}
async function docPreview(filepath: string, conf: DocPreviewConf = {}): NodeJS.ReadableStream;
async function imgPreview(filepath: string, conf: BaseConfig = {})

To generate a preview of a PDF file you can use the imgPreview function, since the underlying ImageMagick can handle PDF files directly.

Example

const {docPreview, imgPreview} = require("doc-thumbnail");
let ws = FS.createWriteStream("example.odt.jpg");
let ts = await docPreview("example.odt", {height: 200});
ts.pipe(ws);

let ws2 = FS.createWriteStream("example.png.jpg");
let ts2 = await docPreview("example.png", {height: 200});
ts2.pipe(ws2);

Keywords

doc

FAQs

Package last updated on 28 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts