lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
29.21k stars 1.29k forks source link

Add support for processing PDF without system installs/binaries #3661

Closed jakeleventhal closed 1 year ago

jakeleventhal commented 1 year ago

Feature request

What are you trying to achieve?

I want to be able to input a PDF as a Buffer and resize it/save it to a DPF

When you searched for similar feature requests, what did you find that might be related?

There are no open issues like this

What would you expect the API to look like?

Same as all the other APIs

What alternatives have you considered?

Other libraries. They are slow

Please provide sample image(s) that help explain this feature

N/A

jakeleventhal commented 1 year ago
await sharp(pdfBuffer, { page: 1, pages: 1 })
              .jpeg({
                quality: this.compressedImageQuality
              })
              .resize(this.compressedImageSize, this.compressedImageSize)
              .toBuffer();
[Error: Input file contains unsupported image format]

Same issue with a path to the PDF file

lovell commented 1 year ago

sharp can read PDF files when using a globally-installed libvips compiled with support for either poppler or pdfium.

https://sharp.pixelplumbing.com/install#custom-libvips https://github.com/libvips/libvips/#optional-dependencies