A Print Delegate -- FYI

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

A Print Delegate -- FYI

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply