luthraG / image-watermark

A powerful watermark library for single page images, multipage images, and pdf files based on ImageMagick for node.js
https://www.npmjs.com/package/image-watermark
MIT License
102 stars 33 forks source link

This seems to execute unreliably. #6

Closed mdaronco closed 7 years ago

mdaronco commented 7 years ago

Error output from the module:

Uncaught exception: Error: Image-Watermark::embedWatermark : Unable to process image file : Error: Command failed: err.stack=Error: Image-Watermark::embedWatermark : Unable to process image file : Error: Command failed: at /home/ubuntu/app/node_modules/image-watermark/watermark.js:196:11 at null.callback (/home/ubuntu/app/node_modules/imagemagick/imagemagick.js:165:5) at Accumulator.finish (/home/ubuntu/app/node_modules/imagemagick/imagemagick.js:60:55) at ChildProcess. (/home/ubuntu/app/node_modules/imagemagick/imagemagick.js:93:11) at ChildProcess.EventEmitter.emit (events.js:98:17) at maybeClose (child_process.js:743:16) at Process.ChildProcess._handle.onexit (child_process.js:810:5)

The process seems to complete the watermarking roughly 50% of the time (on the same PDF file). Can you please advise? Has this been encountered before?

mdaronco commented 7 years ago

Ended up just editing the source code.

stguitar commented 7 years ago

@mdaronco what did you change? i am seeing this sometimes as well...

mdaronco commented 7 years ago

I wish I could remember off the top of my head, I'll see if I can find what I did differently

stguitar commented 7 years ago

@mdaronco actually, I may have found what my issue was. In case anyone else stumbles over here, the issue for me was that my PDF was bigger than the maxBuffer option provided to the underlying imagemagick module supported.

It seems that this module should support passing this option at the least to imagemagick.

@luthraG would this be a worthy pull request? Just thinking that you could pass options to the underlying imagemagick... something perhaps like a nested object within the existing objects parameter to the embedWatermark* functions.

stguitar commented 7 years ago

@luthraG upon looking further, this configuration may be needed in the imagemagick module a bit too...

piraveen commented 6 years ago

Hi

I am having the same issue. It was working as expected for images and PDFs. But suddenly, it doesn't work for any size of PDF files.

Error: Image-Watermark::embedWatermarkWithCb : Unable to process image file : Error: Command failed: identify: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72'  '-sOutputFile=/var/folders/f3/c573p8k10g337zt_0lmh24tr0000gn/T/magick-32807wo6rHBJzo3ER%d' '-f/var/folders/f3/c573p8k10g337zt_0lmh24tr0000gn/T/magick-32807h51JlAw20brd' '-f/var/folders/f3/c573p8k10g337zt_0lmh24tr0000gn/T/magick-32807h6Knp8RBgnjE'' (1) @ error/pdf.c/InvokePDFDelegate/291.

Error: Image-Watermark::embedWatermarkWithCb : Unable to process image file : Error: Command failed: identify: FailedToExecuteCommand `'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' '-sOutputFile=/var/folders/f3/c573p8k10g337zt_0lmh24tr0000gn/T/magick-32807wo6rHBJzo3ER%d' '-f/var/folders/f3/c573p8k10g337zt_0lmh24tr0000gn/T/magick-32807h51JlAw20brd' '-f/var/folders/f3/c573p8k10g337zt_0lmh24tr0000gn/T/magick-32807h6Knp8RBgnjE'' (1) @ error/pdf.c/InvokePDFDelegate/291.

@mdaronco what did you change in the source file ?

piraveen commented 6 years ago

Apparently for me, this issue was caused by a missing dependancy "Ghostscript" which is required to convert PDFs.

On macOS just do brew install ghostscript

Hope this helps someone