Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Python PIL problem

  1. #1
    Join Date
    Sep 2006
    Location
    Singapore
    Beans
    518
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Python PIL problem

    I am using the PIL and have this code (very simple):

    import Image
    pic = Image.open('image.jpg')

    pic.show()

    runs 'fine' but show() does nothing. Perhaps I am doing something wrong but in the tutorial it says that this should display the file?

  2. #2
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: Python PIL problem

    I just tried something similar. When I try to use the show() function, I get the error "sh: xv: command not found".

    This tutorial, after mentioning the show() functon, says
    (The standard version of show is not very efficient, since it saves the image to a temporary file and calls the xv utility to display the image. If you don't have xv installed, it won't even work. When it does work though, it is very handy for debugging and tests.)
    The program xv is not installed in dapper, and I couldn't find a package for it. I do have imagemagick installed, which provides the display command, so as a hack, I made a symlink:
    Code:
    sudo ln -s /usr/bin/display /usr/local/bin/xv
    Now running xv actually runs display, and the show() function works.

    I have /usr/local/bin in my PATH. If you don't, and you don't want to bother setting it up, you could make the symlink in /usr/bin:
    Code:
    sudo ln -s /usr/bin/display /usr/bin/xv

  3. #3
    Join Date
    Sep 2006
    Location
    Singapore
    Beans
    518
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Python PIL problem

    I just did as you suggested but no dice. I also have imagemagick installed and do have /usr/bin/display but I get the exact same turnout as before (nothing). The program just runs and finishes and doesn't display anything.
    That 'xv' bit is interesting though. I also don't have it installed nor is there a .deb for it.

  4. #4
    Join Date
    Aug 2006
    Location
    Brazil
    Beans
    4
    Distro
    Ubuntu 7.04 Feisty Fawn

    Re: Python PIL problem

    Quote Originally Posted by WW View Post
    I just tried something similar. When I try to use the show() function, I get the error "sh: xv: command not found".

    This tutorial, after mentioning the show() functon, says

    The program xv is not installed in dapper, and I couldn't find a package for it. I do have imagemagick installed, which provides the display command, so as a hack, I made a symlink:
    Code:
    sudo ln -s /usr/bin/display /usr/local/bin/xv
    Now running xv actually runs display, and the show() function works.

    I have /usr/local/bin in my PATH. If you don't, and you don't want to bother setting it up, you could make the symlink in /usr/bin:
    Code:
    sudo ln -s /usr/bin/display /usr/bin/xv
    Bumping to say it worked for me!

    Thnx a lot!

  5. #5
    Join Date
    Oct 2007
    Location
    kocaeli / turkey
    Beans
    23
    Distro
    Ubuntu 7.10 Gutsy Gibbon

    Re: Python PIL problem

    pic.show() works.
    and something else. what about closing
    how can we close that window with python?

    thanks.

  6. #6
    Join Date
    Jan 2007
    Beans
    1

    Re: Python PIL problem

    I tried something similar with xloadimage which can be installed using the Synaptic package manager or apt-get. After installing, I applied the following symbolic link.

    sudo ln -s /usr/bin/xloadimage /usr/bin/xv

    Then you can display an image by xv <image filename>. However, xloadimage dumps a lot of status to stdout, so I use ImageMagick display like WW suggested above.

  7. #7
    Join Date
    Jun 2007
    Location
    UK
    Beans
    1,386
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Python PIL problem

    I use Eye of Gnome which is installed by default.
    Code:
    sudo ln -s /usr/bin/eog /usr/bin/xv

  8. #8
    Join Date
    Jan 2010
    Beans
    1

    Re: Python PIL problem

    I saw the following information posted by Emrahustun. I am wondering if anybody has realized this function closing this picture with python after showing a picture. My current research needs to realize this function. Please give me some advice. I will very appreciate it.



    pic.show() works.
    and something else. what about closing
    how can we close that window with python?

    thanks.
    __________________
    Emrah ÜSTÜN
    www.emrahustun.com

  9. #9
    Join Date
    Apr 2007
    Location
    Coffee corner
    Beans
    405
    Distro
    Kubuntu 11.04 Natty Narwhal

    Re: Python PIL problem

    @WW: There's an XV package for openSuSE - so I'd be surprised if there's nothing for Ubuntu - but it's a very old app, nevertheless

    @angelachen:
    what about brute force killing the image with popen:
    os.popen('killall display') or os.popen('killall xv'), probably combined with a sleep or wait statement before that?

  10. #10
    Join Date
    Apr 2012
    Beans
    2

    Re: Python PIL problem

    Quote Originally Posted by nick_h View Post
    I use Eye of Gnome which is installed by default.
    Code:
    sudo ln -s /usr/bin/eog /usr/bin/xv
    Worked for me!
    Thanks.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •