From: Esmail on 30 Nov 2009 17:48 On Nov 30, 4:37 pm, David Bolen <db3l....(a)gmail.com> wrote: > Esmail <ebo...(a)gmail.com> writes: > > I dug around in the docs and found a named parameter that I can set > > when I > > call show. > > > Definition: im.show(self, title=None, command=None) > > > I installed irfanview and specified it/its path in the parameter, > > but that didn't work either. It's really quite puzzling in the > > case of Vista since that's been around for quite a few years now. > > But I thought everyone was sticking their fingers in their ears and > humming to try to forget Vista had been released, particularly now > that Windows 7 is out :-) > > Perhaps there's an issue with the temporary file location. I don't > have a Vista system to test on, but the show() operation writes the > image to a temporary file as returned by tempfile.mktemp(), and then > passes the name on to the external viewer. The viewing command is > handed to os.system() with the filename embedded without any special > quoting. So if, for example, the temporary location has spaces or > "interesting" characters, it probably won't get parsed properly. > > One easy debugging step is probably to add a print just before the > os.system() call that views the image (bottom of _showxv function in > Image.py in my copy of 1.1.6). That way at least you'll know the > exact command being used. > > If that's the issue, there are various ways around it. You could > patch PIL itself (same function) to quote the filename when it is > constructing the command. Alternatively, the tempfile module has a > tempdir global you could set to some other temporary directory before > using the show() function (or any other code using tempfile). > > -- David Thanks for the pointers David, this will give me some things to investigate. As for me, I'm a long time and regular Linux user with some XP tossed in. I use the PIL under XP at times, but this problem is happening to someone I know who is using both Vista and Windows and can't get the basic thing to work so I am trying to help. (I have access to a Win 7 VM for testing purposes at least). If I find a work-around or fix or concrete cause I'll post. In the meantime if anyone has any other ideas or fixes/suggestions, please don't be shy :-) Thanks, Esmail
From: Terry Reedy on 30 Nov 2009 18:40 Esmail wrote: > On Nov 30, 4:37 pm, David Bolen <db3l....(a)gmail.com> wrote: >> If that's the issue, there are various ways around it. You could >> patch PIL itself (same function) to quote the filename when it is >> constructing the command. Alternatively, the tempfile module has a >> tempdir global you could set to some other temporary directory before >> using the show() function (or any other code using tempfile). >> >> -- David > > Thanks for the pointers David, this will give me some things to > investigate. > As for me, I'm a long time and regular Linux user with some XP tossed > in. > I use the PIL under XP at times, but this problem is happening to > someone > I know who is using both Vista and Windows and can't get the basic > thing > to work so I am trying to help. (I have access to a Win 7 VM for > testing > purposes at least). > > If I find a work-around or fix or concrete cause I'll post. In the > meantime > if anyone has any other ideas or fixes/suggestions, please don't be > shy :-) How about forget PIL's show and its automagic behavior. Use PIL's image save to write the image to a nice, known location, such as C:/temp/pic.jgp -- nothing but alphanumerics + ':/.' Next test how to run a known external viewer from a command window. Then use os.system or subprocess to run it with the same command line. Package the two lines as a myshow(params) function.
From: David Robinow on 1 Dec 2009 10:38
On Mon, Nov 30, 2009 at 12:57 PM, Esmail <ebonak(a)hotmail.com> wrote: > Hello all. > > I am using the PIL 1.1.6 and Python 2.6.x under XP without any > problems. However, I can't display any images under Vista > or Windows 7. I could understand Windows 7 as it's relatively > new, but Vista has been around for a bit. > > Sample code: > > import Image > > im = Image.open('c://mypic.jpg') > im.show() > > > this will work fine under XP, but under Windows 7 and Vista > the default image viewer will come up with some error message > that the image can't be found. > > I tried with an external image view program and tried to supply > it via the command parameter to show - but that too didn't work. > > Definition: im.show(self, title=None, command=None) > > Any suggestions/help/workarounds? If you can get this to work > with Vista or Windows 7 I'd love to hear from you. > > Thanks! > Esmail > > -- > http://mail.python.org/mailman/listinfo/python-list > show() executes a command like: os.system("start /wait TempFile.BMP && del /f TempFile.BMP") On Vista, HELP START displays the following: ... If Command Extensions are enabled, external command invocation through the command line or the START command changes as follows: ... When executing an application that is a 32-bit GUI application, CMD.EXE does not wait for the application to terminate before returning to the command prompt. This new behavior does NOT occur if executing within a command script. ... The "/wait" apparently does nothing and the image file is deleted before the image viewer gets a chance to open it. (I think) [I don't understand why it works in XP since "HELP START" says basically the same thing] I haven't tried to fix it yet but a likely solution is to split up the command. os.system("start TempFile.BMP") wait a second os.system(del /f TempFile.BMP") |