0

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")

  • print where? You can use opencv for image work, they allow to open and save images to files. – Mahrkeenerh Nov 12 '21 at 15:07
  • 1
    Does this answer your question? [Print to standard printer from Python?](https://stackoverflow.com/questions/12723818/print-to-standard-printer-from-python)? If not, could you elaborate on what you have tried, and why it didn't work? – Brian61354270 Nov 12 '21 at 15:08
  • Print with a printer – Gil Keidar Nov 12 '21 at 15:08
  • That's the exact question I went before I wrote mine, someone answered on how to print text, I meant pictures – Gil Keidar Nov 12 '21 at 15:11

2 Answers2

2

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

jahantaila
  • 840
  • 5
  • 26
-4

first thing first type pip install Pillow in your terminal and hit enter then

from PIL import Image
myImage=Image.open("Your Image here");
myImage.show()

as simple as uploading question on stackOverflow

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – jahantaila Nov 12 '21 at 16:04