The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

MRAB python at mrabarnett.plus.com
Wed May 30 16:29:39 EDT 2018


On 2018-05-30 21:01, Paul St George wrote:
> True, but I wanted to have some control over the image window,
> fullscreen, colour depth, etc. I am also exploring pygame. I will try
> your suggestion as it is so much simpler.
> 
> Being a novice, I had been frightened off using shell=True. See
> <https://docs.python.org/2/library/subprocess.html#frequently-used-arguments>.
> 
> Is this equivalent?
> p = subprocess.Popen('display',  + imagepath)
> 
p = subprocess.Popen(['display',  imagepath])

> so
> 
> p = subprocess.Popen('display',  'test.png')
> 
p = subprocess.Popen(['display',  'test.png'])

Remembering to provide the full paths (unless it's/they're on the 
system's search path).

> 
> On 30/05/2018 03:04, Ian Kelly wrote:
>> On Sat, May 26, 2018 at 9:17 AM, Paul St George <email at paulstgeorge.com> wrote:
>>> Thank you.
>>> You are very right. The show() method is intended for debugging purposes and
>>> is useful for that, but what method should I be using and is PIL the best
>>> imaging library for my purposes? I do not want to manipulate images, I only
>>> want to show images (full screen) on an external display. I want to use
>>> Python to control the timing of the images.
>> You probably shouldn't be using PIL at all then. Why open the file in
>> Python just to export it and re-open it in an image viewer? It would
>> be simpler just to point whichever image viewer you prefer at the
>> original file directly. Your entire script could just be something
>> like this:
>>
>> import subprocess
>>
>> # Some timing logic
>>
>> subprocess.call("display " + imagepath, shell=True)
>>
> 




More information about the Python-list mailing list