pythonimageprintingprinters

Is There a way to print pictures With a printer using python?


I Saw there's an option to use the OS library, but how do i print pictures with it? For example, .png files? I don't want to see the image, I want to print it with a printer using Python

import os

os.startfile("C:/Users/gilke/Downloads/File1.txt", "print")


Solution

  • This will only work on windows (10 or 11):

    You can do the following:

    import os
    
    os.startfile("C:/Users/TestFile.txt", "print")
    

    This will start the file, in its default opener, with the verb 'print', which will print to your default printer. Only requires the os module which comes with the standard library