Page 1 of 1

A Print Delegate -- FYI

Posted: 2017-03-15T19:10:37-07:00
by anthony
I recently needed to grab a window on my display an print it... This is what I came up with, just throwing it out there...

Printing Delegate

One of the most useful delegates I have ever created was to let me easily print images to a postscript printer. The printer was already set up using the linux "lpr" command and it could accept either a PNG format image, or a postscript file.
Here is the simple "PRT: delegate I decided to create.
<delegate decode="ps" encode="prt" command='lpr "%i"'/>
Notice I decided to use postscript format ("decode="ps"") for the image being passed to the "lpr" command on my system. I chose that as I can then use options such as "-density" to adjust the size of the output image.

For example I can create a command to grab a window form my screen, modify the image, so as to fit on printed page (as I want it) then print it.
convert x:Loopy -shave 6 -chop 0x24 -modulate 220,0 \
-bordercolor white -border 50x150 -density 130 prt:
I could have also used "decode="png"", however my system would then enlarge or shrink the image to always completely fill the A4 page. You however may like this.
<delegate decode="png" encode="prt" command='lpr "%i"'/>

I have added this to IM Examples (Update in a hour or two)
http://www.imagemagick.org/Usage/files/#delegate_print