Search code examples
pythonimagescipyimshow

How to change the image viewer in Python


Up to now, when I read and show an image in Python:

from scipy import misc
img = misc.imread("myimage.png")
misc.imshow(img)

it opens it by using ImageMagick.

How could I change the reader from ImageMagick to, say, Image Viewer? I guess I should change the Python environment, but I do not have any further clue.


Solution

  • The docstring for misc.imshow says

    In [10]: misc.imshow?
    Signature: misc.imshow(arr)
    Docstring:
    Simple showing of an image through an external viewer.
    
    Uses the image viewer specified by the environment variable
    SCIPY_PIL_IMAGE_VIEWER, or if that is not defined then `see`,
    to view a temporary file generated from array data.
    

    Therefore, set the SCIPY_PIL_IMAGE_VIEWER environment variable to the path of your eog (Image Viewer) executable.