Get rid of quality issues when modifying a PDF with ImageMagick -


our goal take user uploaded pdf , put "stamp" (a box background color + text) on top left corner. "stamp" part works well, pass pdf through imagemagick quality problems - when original pdf had kind of artefacts.

this screenshot source pdf (black areas added privacy reasons). https://dl.dropboxusercontent.com/u/6271307/screen%20shot%202016-09-22%20at%2015.18.49.png can see quality isn't because scanned copy machine.

after being processed imagemagick result looks this: https://dl.dropboxusercontent.com/u/6271307/screen%20shot%202016-09-22%20at%2015.19.15.png

this call being made:

'/usr/bin/convert' +profile '*' -compress jpeg -quality 90 -density 180 -pointsize 10 -fill 'rgba(220, 220, 220, 0.75)' -stroke 'rgba(220, 220, 220, 0.75)' -draw 'rectangle 40,20,491,100' -stroke '#000000' -font courier -draw "text 48,47 'vermittlernummer gesellschaft'" -draw "text 48,81 '70_202_3297'" mysource.pdf mytarget.pdf 
  • if leave out "-compress jpeg -quality 90" parameters result looks same, it's bit bigger in file size.
  • if leave out "-density 180" parameter result looks lot worse

what options of imagemagick can me better result?

try first converting pdf png. reason because downloaded .png image:

https://dl.dropboxusercontent.com/u/6271307/screen%20shot%202016-09-22%20at%2015.18.49.png

and ran code:

  convert -density 180  +profile '*' -compress jpeg -quality 90 -pointsize 10 -fill 'rgba(220, 220, 220, 0.75)' -stroke 'rgba(220, 220, 220, 0.75)' -draw 'rectangle 40,20,491,100' -stroke '#000000' -font courier -draw "text 48,47 'vermittlernummer gesellschaft'" -draw "text 48,81 '70_202_3297'" test.png mytarget.png 

and got result:

enter image description here

which looks me. outputted .png using code pdf looks -- stackoverflow doesn't seem allow pdf uploads.

let me know if doesn't work!

cheers.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -