{"id":23403436,"url":"https://github.com/nicofuccella/pdf-thumbnail","last_synced_at":"2025-04-11T20:50:35.978Z","repository":{"id":28049605,"uuid":"116024641","full_name":"nicofuccella/pdf-thumbnail","owner":"nicofuccella","description":"npm package to create the preview of a pdf file","archived":false,"fork":false,"pushed_at":"2022-02-11T05:02:44.000Z","size":669,"stargazers_count":29,"open_issues_count":4,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T10:42:55.377Z","etag":null,"topics":["crop","ghostscript","imagemagick","nodejs","npm-package","pdf","pdf-thumbnail","pdf-thumbnails","resize"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicofuccella.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-02T14:39:18.000Z","updated_at":"2024-08-03T10:45:12.000Z","dependencies_parsed_at":"2022-08-07T13:15:12.028Z","dependency_job_id":null,"html_url":"https://github.com/nicofuccella/pdf-thumbnail","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicofuccella%2Fpdf-thumbnail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicofuccella%2Fpdf-thumbnail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicofuccella%2Fpdf-thumbnail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicofuccella%2Fpdf-thumbnail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicofuccella","download_url":"https://codeload.github.com/nicofuccella/pdf-thumbnail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480512,"owners_count":21110936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crop","ghostscript","imagemagick","nodejs","npm-package","pdf","pdf-thumbnail","pdf-thumbnails","resize"],"created_at":"2024-12-22T12:47:51.811Z","updated_at":"2025-04-11T20:50:35.929Z","avatar_url":"https://github.com/nicofuccella.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pdf-thumbnail\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Issues][issues-image]][issues-url] [![Dependency Status][dependencies-image]][dependencies-url]\n\n[npm-url]: https://www.npmjs.com/package/pdf-thumbnail\n[npm-image]: http://img.shields.io/npm/v/pdf-thumbnail.svg?style=flat\n[downloads-image]: https://img.shields.io/npm/dm/pdf-thumbnail.svg?style=flat-square\n[dependencies-image]: https://david-dm.org/nicofuccella/pdf-thumbnail.svg\n[dependencies-url]: href=\"https://david-dm.org/nicofuccella/pdf-thumbnail\n[issues-image]: https://img.shields.io/github/issues/nicofuccella/pdf-thumbnail.svg\n[issues-url]: https://github.com/nicofuccella/pdf-thumbnail/issues\n\n## Installation\n\n    $ npm i pdf-thumbnail\n\n## Getting started\n\nThis module works with gm, so you have to install imagemagick and ghostscript on your pc.\n\nOn Mac OS X:\n\n    $ brew install imagemagick\n    $ brew install ghostscript\n\nOn Linux:\n\n    $ sudo apt-get install imagemagick\n    $ sudo apt-get install ghostscript\n\n## What is pdf-thumbnail?\n\npdf-thumbnail creates a thumbnail of the first page of a pdf file. You can also manipulate the image:\n\n  * You can resize it\n  * You can compress it with less quality\n  * You can crop it\n\n## How to use it\n\npdf-thumbnail returns a Promise:\n\n```javascript\nconst pdf = require('pdf-thumbnail');\nconst pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');\n\npdf(\n  pdfBuffer, /*Buffer or stream of the pdf*/\n  options\n)\n  .then(data /*Stream of the image*/ =\u003e {\n    // ...\n  })\n  .catch(err =\u003e console.log(err))\n```\n\n### Options\n\nAn object where you can put the operations you would like to do on the thumbnail. The current available operations are:\n\n* Compress\n* Crop\n* Resize\n\n#### Compress\n\n```javascript\nconst pdf = require('pdf-thumbnail');\nconst pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');\n\npdf(pdfBuffer, {\n  compress: {\n    type: 'JPEG',  //default\n    quality: 70    //default\n  }\n})\n  .then(data =\u003e {\n    // ...\n  })\n  .catch(err =\u003e console.log(err))\n```\n\n#### Crop\n\n```javascript\nconst pdf = require('pdf-thumbnail');\nconst pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');\n\npdf(pdfBuffer, {\n  crop: {\n    width: 200,\n    height: 400,\n    x: 0,\n    y: 0\n  }\n})\n  .then(data =\u003e {\n     // ...\n  })\n  .catch(err =\u003e console.log(err))\n```\n\nIf you want to crop the image keeping the aspect ratio, yuo have to add another key to the object:\n\n    crop: {\n      width: 200,\n      height: 400,\n      x: 0,\n      y: 0,\n      ratio: true  //default true\n     }\n\n#### Resize\n\n```javascript\nconst pdf = require('pdf-thumbnail');\nconst pdfBuffer = require('fs').readFileSync('/some/path/example.pdf');\n\npdf(pdfBuffer, {\n  resize: {\n    width: 200,   //default\n    height: 200,  //default\n  }\n})\n  .then(data =\u003e {\n    // ...\n  })\n  .catch(err =\u003e console.log(err))\n```\n\n## Example\n\nSee a few examples [here](test/)\n\n## People\n\n- [Nicolò Fuccella](https://github.com/nicoFuccella)\n- [Nicola Guerra](https://github.com/Ng2k)\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicofuccella%2Fpdf-thumbnail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicofuccella%2Fpdf-thumbnail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicofuccella%2Fpdf-thumbnail/lists"}