Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mablay/pdf-export-images
Export images from PDF files via CLI
https://github.com/mablay/pdf-export-images
Last synced: 8 days ago
JSON representation
Export images from PDF files via CLI
- Host: GitHub
- URL: https://github.com/mablay/pdf-export-images
- Owner: mablay
- Created: 2022-01-31T21:49:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-03T21:16:08.000Z (9 months ago)
- Last Synced: 2024-10-14T01:48:28.735Z (about 1 month ago)
- Language: TypeScript
- Size: 111 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PDF Export Images
Exports images in their native resolution from a PDF file to disk.
## Use via CLI
```
Usage: npx pdf-export-images [dir]Arguments:
file path to PDF file
dir image destination directory (default: ".")
```
You can also install the package globally via `npm i -g pdf-export-images` to run the command without `npx`## Programatic use
```sh
# Install
npm i pdf-export-images
``````js
import { exportImages, exportImagesEvents } from 'pdf-export-images'// Export via promise
exportImages('file.pdf', 'output/dir')
.then(images => console.log('Exported', images.length, 'images'))
.catch(console.error)// Export via EventEmitter
exportImagesEvents('file.pdf', 'output/dir')
.on('load', event => console.log('Exporting images from', event.pageCount, 'pages...'))
.on('image', ({ file, width, height }) => console.log(file, `(${width}x${height})`))
.on('error', console.error)
.on('done', images => console.log(images.length, 'images exported'))
```See: [cli.js](https://github.com/mablay/pdf-export-images/blob/main/cli.js#L23) for progress details during export.
## Change Notes
* v1.2.0 added typescript support
* v1.1.0 improved image extraction