Python Forum
Closing an image opened by Pillow in Window Photo Viewer
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closing an image opened by Pillow in Window Photo Viewer
#11
You can do it like this,i use use webbrowser module.
If not given a url but a path it open my default image viewer(IrfanView) on Windows.
So it will show image for 3-sec and close IrfanView ect..
I do this with subprocess module.
import webbrowser
import subprocess
import os, time

for file in os.scandir('.'):
    if file.name.endswith(('.jpg', '.png')):
        webbrowser.open(file.name)
        time.sleep(3)
        subprocess.run(['taskkill', '/f', '/im', 'i_view32.exe'])
Output:
E:\1py_div\image_loop λ python img.py SUCCESS: The process "i_view32.exe" with PID 15912 has been terminated. SUCCESS: The process "i_view32.exe" with PID 20024 has been terminated. SUCCESS: The process "i_view32.exe" with PID 7376 has been terminated. SUCCESS: The process "i_view32.exe" with PID 11028 has been terminated. SUCCESS: The process "i_view32.exe" with PID 13252 has been terminated.
You see it close process,you most find process name for Windows Photo Viewer.
Reply


Messages In This Thread
RE: Closing an image opened by Pillow in Window Photo Viewer - by snippsat - May-02-2017, 05:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,796 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  aoigram, pil Help with photo processing kolpac21 0 577 Aug-07-2023, 04:59 PM
Last Post: kolpac21
  does not save in other path than opened files before icode 3 917 Jun-23-2023, 07:25 PM
Last Post: snippsat
  Tkinter Pillow Resize Image Looks Choppy While Resizing AaronCatolico1 2 1,400 Jan-03-2023, 05:41 PM
Last Post: AaronCatolico1
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,183 Jun-13-2022, 08:59 AM
Last Post: Shena76
Question How to get html information from a tab of my default browser opened with webbrowser? noahverner1995 2 4,511 Jan-14-2022, 10:02 AM
Last Post: noahverner1995
  Closing Threads and the chrome window it spawned from Tkinter close button law 0 1,714 Jan-08-2022, 12:13 PM
Last Post: law
  Rmarkdown opened by python code - errors Rav013 0 2,096 Apr-27-2021, 03:13 PM
Last Post: Rav013
  Invert Pillow image colours chesschaser 5 3,812 Jul-11-2020, 02:59 PM
Last Post: chesschaser
  Add Photo in Python adninqasifa 4 5,983 Nov-26-2018, 06:06 PM
Last Post: adninqasifa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020