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

Paul St George email at paulstgeorge.com
Sat May 26 11:17:42 EDT 2018


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.
And, out of curiosity, as I will probably use a different method - how 
do I find out what commands can be used as parameters for show()? I read 
the docs at 
<https://pillow.readthedocs.io/en/5.1.x/reference/Image.html#PIL.Image.Image.show>, 
but I am none the wiser.
On 26/05/2018 01:02, boB Stepp wrote:
> On Fri, May 25, 2018 at 6:04 AM, Paul St George <email at paulstgeorge.com> wrote:
>> I am using the Python Imaging Library (PIL), Python 2 and Raspberry Pi 3 B+
>>>> My code is simply:
>>>> from PIL import Image
>>>> im = Image.open(‘somepic.jpg’)
>> im.show() # display image
>>>>>> But the show() method looks for the default viewer (probably xv). How do I
>> change this (in the code, or in some settings) to a different viewer (of my
>> choice)?
> In the PIL docs for show() at
> https://pillow.readthedocs.io/en/5.1.x/reference/Image.html#PIL.Image.Image.show
> it says:
>> <quote>
> Image.show(title=None, command=None)
>> Displays this image. This method is mainly intended for debugging purposes.
>> On Unix platforms, this method saves the image to a temporary PPM
> file, and calls either the xv utility or the display utility,
> depending on which one can be found.
>> On macOS, this method saves the image to a temporary BMP file, and
> opens it with the native Preview application.
>> On Windows, it saves the image to a temporary BMP file, and uses the
> standard BMP display utility to show it (usually Paint).
>> Parameters:
>> title – Optional title to use for the image window, where possible.
> command – command used to show the image
> </quote>
>> I have not had occasion to use PIL, but perhaps this command parameter
> can be used to do what you want? If not then perhaps you can write
> your own function to load your image into your favorite image viewer.
>>


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /