Help with Shell Script for printing
Posted: 2015-05-13T14:47:27-07:00
Hi All,
I have a printing helper script that is called by my program when a screen shot is taken (using xwd) to print.
Here is what I want it to do:
1) Resize the image so it looks good on Landscape paper, regardless of the input image size
2) Prints a textual header above the input image
3) Prints a textual footer below the input image
4) Formats the output to be printed on a letter sized sheet of paper.
Here is what I currently have, and this IS working, I'm just wondering if there is a better way of doing this. One issue I am running into is the text is somewhat grainy on the printed page:
convert $xwdfile -resize 600x425 xwd:- | \
convert -background white -fill black -pointsize 14 \
-gravity center label:"$header" - -append xwd:- | \
convert - -background white -fill black -pointsize 14 \
-gravity center label:"$trailer" -append -page Letter \
-rotate 90 ps:- | \
lp -n$copies -d$printername -olandscape
In a nutshell, I am first resizing the image to 600x425, which is the smallest screenshot size generated. I then pipe that into convert to add the header. I then pipe it into convert a 3rd time to add the footer and prepare it for printing. Finally it is piped to the printer. The output printout is an image that is centered on the paper with about a 1.25 inch border all around, less the header and footer.
The other common screenshot size is 1200x888.
Can the above mess of convert commands be cleaned up some?
How about make it so the text header and footer look better?
Since 600x425 is the smallest image size, and likely to be the most common as well, is there a way to sharpen this up some when it is printed?
If it helps, here is what is going in for both small and large screenshots:
Small:
identify PrintFile
PrintFile XWD 600x425 600x425+0+0 8-bit sRGB 1.023MB 0.000u 0:00.009
Large:
identify PrintFileLg
PrintFileLg XWD 1200x888 1200x888+0+0 8-bit sRGB 4.266MB 0.010u 0:00.040
Thanks!
I have a printing helper script that is called by my program when a screen shot is taken (using xwd) to print.
Here is what I want it to do:
1) Resize the image so it looks good on Landscape paper, regardless of the input image size
2) Prints a textual header above the input image
3) Prints a textual footer below the input image
4) Formats the output to be printed on a letter sized sheet of paper.
Here is what I currently have, and this IS working, I'm just wondering if there is a better way of doing this. One issue I am running into is the text is somewhat grainy on the printed page:
convert $xwdfile -resize 600x425 xwd:- | \
convert -background white -fill black -pointsize 14 \
-gravity center label:"$header" - -append xwd:- | \
convert - -background white -fill black -pointsize 14 \
-gravity center label:"$trailer" -append -page Letter \
-rotate 90 ps:- | \
lp -n$copies -d$printername -olandscape
In a nutshell, I am first resizing the image to 600x425, which is the smallest screenshot size generated. I then pipe that into convert to add the header. I then pipe it into convert a 3rd time to add the footer and prepare it for printing. Finally it is piped to the printer. The output printout is an image that is centered on the paper with about a 1.25 inch border all around, less the header and footer.
The other common screenshot size is 1200x888.
Can the above mess of convert commands be cleaned up some?
How about make it so the text header and footer look better?
Since 600x425 is the smallest image size, and likely to be the most common as well, is there a way to sharpen this up some when it is printed?
If it helps, here is what is going in for both small and large screenshots:
Small:
identify PrintFile
PrintFile XWD 600x425 600x425+0+0 8-bit sRGB 1.023MB 0.000u 0:00.009
Large:
identify PrintFileLg
PrintFileLg XWD 1200x888 1200x888+0+0 8-bit sRGB 4.266MB 0.010u 0:00.040
Thanks!