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
Tue May 29 14:02:22 EDT 2018


Is there, somewhere, a list of viewers and their names (for the purposes 
of this script)?

I am assuming that if I want to ImageMagick (for example), there would 
be some shorter name - such as 'magick' - and it would be lower case .


On 29/05/2018 08:58, Peter Otten wrote:
> Paul St George wrote:
>
>> This is very helpful indeed, thank you. Awe-inspiring.
>>
>> It occurred to me that I could edit the PIL/ImageShow.py, replacing ‘xv’
>> (in five places) with the utility of my choice and using ‘executable’ as
>> the command.
>>
>> Or, is this just not done?
> No, this tends to become a maintenance problem. Instead write a little
> module of your own
>
>
> from PIL import ImageShow
>
> class MyViewer(ImageShow.UnixViewer):
>      def __init__(self, command):
>          self.command = command
>      def get_command_ex(self, file, **options):
>          return (self.command,) * 2
>
> ImageShow.register(MyViewer("gwenview"), -1)
>
>
> (replace "gwenview" with your favourite viewer) and import it before using
> Image.show().
>
>

-- 
Paul St George
http://www.paulstgeorge.com
http://www.devices-of-wonder.com

+44(0)7595 37 1302




More information about the Python-list mailing list