Command line tool for printing images?

My program needs to print a curve, my solution changes the curve to an image, and this image file (xxx.png) can be printed using the default Windows image printing tool (right-click on the file and select print).

but I don’t want the user to perform this task manually, for this I need a command line tool:

printPicture xxx.png 

Is there such a tool?

ps: free / open source

edit: right-click the file and select "print", then I can print this file. How to do this on the command line?

+6
command-line windows printing
source share
7 answers

I finally found out!

Use Windows Image Viewer and Fax Viewer.

 rundll32 shimgvw.dll ImageView_PrintTo /pt xxx.png "printer name" 
+9
source share

IrfanView can do this. Here is a list of command line options for this application.

The following should work:

 i_view32 xxx.png /print 

If you want to print on a printer other than the default printer, specify the name of the printer:

 i_view32 xxx.png /print="PrinterName" 
+7
source share

This link had a simpler solution:

mspaint / pt [image file name]

+2
source share
 rundll32 C:\WINDOWS\system32\shimgvw.dll,ImageView_PrintTo "c:\mydir\my.bmp" "Fictional HP Printer" 
+2
source share

I had a similar problem, but I also need a way to control the scaling (necessary for working with a barcode) and always have a centered image.

I wrote an Open Source tool called ImagePrint to do what you want. It is written on VB.Net as a console application. At the moment, it prints only the default printer.

+1
source share
 rundll32 C:\WINDOWS\system32\shimgvw.dll,ImageView_PrintTo "c:\mydir\my.bmp" "Fictional HP Printer" 

This prints an image file (.png in my case) to the specified printer WITHOUT a pop-up dialog box. Also ... works without elevated command line privileges.

+1
source share

You can call ShellExecute from your program using the print operation:

 ShellExecute(NULL,"print","c:\\test.png",NULL,NULL,SW_HIDE); 
0
source share

All Articles