Last active
November 13, 2017 17:46
-
-
Save yrps/e206c8f0f4cdecd6608b86445e4177f0 to your computer and use it in GitHub Desktop.
Overlay image and text on a PDF with imagemagick and ghostscript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
srcfile1="$1" | |
srcfile2="out.pdf" | |
out="${srcfile1%\.*}-signed.${srcfile1##*\.}" | |
gs -dBATCH -dNOPAUSE -dQUIET -sDEVICE=pdfwrite \ | |
-dLastPage=1 -sOutputFile="$out" "$srcfile1" "$srcfile2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu | |
srcfile="$1" | |
pg="1" # 0-based index | |
size_img="24%" | |
sigfile="signature.png" | |
pnt="12" | |
txt=" $(date '+%d-%h-%y') " # spaces for bigger bounding box | |
geom_img="+600+880" | |
geom_txt="+550+950" | |
outfile="out.pdf" | |
convert \ | |
-density "${dens:-400}" \ | |
"$srcfile[$pg]" \( \ | |
-resize "$size_img" \ | |
-gravity "${grav_img:-northwest}" \ | |
-geometry "$geom_img" \ | |
"$sigfile" \) \ | |
-compose over -composite \ | |
-gravity "${grav_txt:-northeast}" \ | |
-box "${bounding:-white}" \ | |
-pointsize "$pnt" \ | |
-draw "text $geom_txt '$txt'" \ | |
"$outfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment