command line tool for print picture?

2020-02-12 05:39发布

My program need to print a curve, my solution is changing the curve into a picture, and this picture file (xxx.png) can be printed by using the default windows picture printing tool(right click the mouse on top of the file, and select print).

but I don't want user do this job manually, I need a command line tool to do this:

printPicture xxx.png

is there a tool like this?

ps: free/open source

edit: right click the file, and select "print", then I can print this file, How can I do it in command line ?

7条回答
贪生不怕死
2楼-- · 2020-02-12 05:46

You can call ShellExecute from your program with print operation:

ShellExecute(NULL,"print","c:\\test.png",NULL,NULL,SW_HIDE);
查看更多
做自己的国王
3楼-- · 2020-02-12 05:47

This link had a simpler solution:

mspaint /pt [image filename]

查看更多
Root(大扎)
4楼-- · 2020-02-12 05:47

I had a similar problem but I also needed way to control scaling (needed for barcode work) and always have the image centered.

I wrote an Open Source tool called ImagePrint to do just what you want. It's written in VB.Net as a console app. At the moment, it only prints to the default printer.

查看更多
该账号已被封号
5楼-- · 2020-02-12 05:51
rundll32 C:\WINDOWS\system32\shimgvw.dll,ImageView_PrintTo "c:\mydir\my.bmp" "Fictional HP Printer"
查看更多
家丑人穷心不美
6楼-- · 2020-02-12 05:57

I finally found out!

use windows image and fax viewer.

rundll32    shimgvw.dll    ImageView_PrintTo /pt   xxx.png   "printer name"
查看更多
对你真心纯属浪费
7楼-- · 2020-02-12 06:08
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 a specified printer WITHOUT a dialog box popping up. Also... works without elevated command prompt privileges.

查看更多
登录 后发表回答