All Projects → nicofuccella → pdf-thumbnail

nicofuccella / pdf-thumbnail

Licence: MIT license
npm package to create the preview of a pdf file

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pdf-thumbnail

Docker Nginx Image Proxy
on the fly image cropping with gravity, resize and compression microservice
Stars: ✭ 79 (+243.48%)
Mutual labels:  resize, crop
Mergi
go library for image programming (merge, crop, resize, watermark, animate, ease, transit)
Stars: ✭ 127 (+452.17%)
Mutual labels:  resize, crop
Lipo
👄 Free image manipulation API service built on top of Sharp (an alternative to Jimp, Graphics Magic, Image Magick, and PhantomJS)
Stars: ✭ 101 (+339.13%)
Mutual labels:  resize, crop
Sharp
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Stars: ✭ 21,131 (+91773.91%)
Mutual labels:  resize, crop
Imagemagick
🧙‍♂️ ImageMagick 7
Stars: ✭ 6,400 (+27726.09%)
Mutual labels:  imagemagick, resize
Php Image Resize
PHP library to resize, scale and crop images. Cloud solution available at:
Stars: ✭ 955 (+4052.17%)
Mutual labels:  resize, crop
Cdn
Content Delivery Network on the top of MongoDb GridFs with on-the-fly image crop/resize
Stars: ✭ 117 (+408.7%)
Mutual labels:  resize, crop
downscale
Better image downscale with canvas.
Stars: ✭ 80 (+247.83%)
Mutual labels:  resize, crop
crops
🌄 Image thumbnail generation server
Stars: ✭ 37 (+60.87%)
Mutual labels:  imagemagick, crop
FotoKilof
GUI for ImageMagick
Stars: ✭ 114 (+395.65%)
Mutual labels:  imagemagick, crop
RCE-python-oneliner-payload
Python bind shell single line code for both Unix and Windows, used to find and exploit RCE (ImageMagick, Ghostscript, ...)
Stars: ✭ 23 (+0%)
Mutual labels:  ghostscript, imagemagick
pdfScale
Bash Script to Scale and Resize PDFs using Ghostscript
Stars: ✭ 131 (+469.57%)
Mutual labels:  ghostscript, imagemagick
Imaging
Imaging is a simple image processing package for Go
Stars: ✭ 4,023 (+17391.3%)
Mutual labels:  resize, crop
Nova Advanced Image Field
🌄📐 A Laravel Nova advanced image field with cropping and resizing using Cropper.js and Intervention Image
Stars: ✭ 67 (+191.3%)
Mutual labels:  resize, crop
node-imaginary
Minimalist node.js command-line & programmatic API client for imaginary
Stars: ✭ 94 (+308.7%)
Mutual labels:  resize, crop
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+5960.87%)
Mutual labels:  resize, crop
image-php
很多PHP框架竟然没有图片设定宽高居中剪裁的功能,比如CodeIgniter,所以我自己封装了一个图片处理类:可设定宽高居中剪裁、设定宽高等比缩放、创建缩略图
Stars: ✭ 17 (-26.09%)
Mutual labels:  resize, crop
Gimage
A PHP library for easy image handling. 🖼
Stars: ✭ 148 (+543.48%)
Mutual labels:  resize, crop
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (+3213.04%)
Mutual labels:  imagemagick, crop
Magick.net
The .NET library for ImageMagick
Stars: ✭ 2,071 (+8904.35%)
Mutual labels:  imagemagick, resize

pdf-thumbnail

NPM version Downloads Issues Dependency Status

Installation

$ npm i pdf-thumbnail

Getting started

This module works with gm, so you have to install imagemagick and ghostscript on your pc.

On Mac OS X:

$ brew install imagemagick
$ brew install ghostscript

On Linux:

$ sudo apt-get install imagemagick
$ sudo apt-get install ghostscript

What is pdf-thumbnail?

pdf-thumbnail creates a thumbnail of the first page of a pdf file. You can also manipulate the image:

  • You can resize it
  • You can compress it with less quality
  • You can crop it

How to use it

pdf-thumbnail returns a Promise:

const pdf = require('pdf-thumbnail');
const pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');

pdf(
  pdfBuffer, /*Buffer or stream of the pdf*/
  options
)
  .then(data /*Stream of the image*/ => {
    // ...
  })
  .catch(err => console.log(err))

Options

An object where you can put the operations you would like to do on the thumbnail. The current available operations are:

  • Compress
  • Crop
  • Resize

Compress

const pdf = require('pdf-thumbnail');
const pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');

pdf(pdfBuffer, {
  compress: {
    type: 'JPEG',  //default
    quality: 70    //default
  }
})
  .then(data => {
    // ...
  })
  .catch(err => console.log(err))

Crop

const pdf = require('pdf-thumbnail');
const pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');

pdf(pdfBuffer, {
  crop: {
    width: 200,
    height: 400,
    x: 0,
    y: 0
  }
})
  .then(data => {
     // ...
  })
  .catch(err => console.log(err))

If you want to crop the image keeping the aspect ratio, yuo have to add another key to the object:

crop: {
  width: 200,
  height: 400,
  x: 0,
  y: 0,
  ratio: true  //default true
 }

Resize

const pdf = require('pdf-thumbnail');
const pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');

pdf(pdfBuffer, {
  resize: {
    width: 200,   //default
    height: 200,  //default
  }
})
  .then(data => {
    // ...
  })
  .catch(err => console.log(err))

Example

See a few examples here

People

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].