Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for converting pdf to png #21

Open
ankitrshah89 opened this issue May 24, 2016 · 3 comments
Open

Support for converting pdf to png #21

ankitrshah89 opened this issue May 24, 2016 · 3 comments

Comments

@ankitrshah89
Copy link

Hi @eivindfjeldstad ,

Does imagemagick-stream support converting PDFs to images?

I wrote a test for the same :

const im = require('imagemagick-stream');
const fs = require('fs');

const read = fs.createReadStream(__dirname + '/pdfs/samplePdf.pdf');
const write = fs.createWriteStream(__dirname + '/pdfs/image-resized.png');

const resize = im();
read.pipe(resize).pipe(write);

Unfortunately I got this error:
events.js:141
throw er; // Unhandled 'error' event
^

Error: convert: no decode delegate for this image format ' @ error/constitute.c/ReadImage/508. convert: no images defined-' @ error/convert.c/ConvertImageCommand/3235.

at ImageMagick.onerror (/srv/package/node_modules/imagemagick-stream/index.js:273:31)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at Pipe.onread (net.js:523:20)

I tried to use convert which got installed as part of imagemagick through cli and I could successfully convert it.

Any ideas?

Thanks!

@tero
Copy link

tero commented Oct 6, 2017

@ankitrshah89 Did you resolve this? Got same issue when trying to convert svg to jpeg.

@WaldoJeffers
Copy link

WaldoJeffers commented Jun 27, 2018

@ankitrshah89 I think you need to install ghostscript
brew install ghostscript

I had the same issue & this solved it for me

@AlexanderButyaev
Copy link

What about multipage PDFs? how to pipe it in different files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants