imagemagick-stream
imagemagick-stream copied to clipboard
Support for converting pdf to png
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!
@ankitrshah89 Did you resolve this? Got same issue when trying to convert svg to jpeg.
@ankitrshah89 I think you need to install ghostscript
brew install ghostscript
I had the same issue & this solved it for me
What about multipage PDFs? how to pipe it in different files?