By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,846 Members | 1,803 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,846 IT Pros & Developers. It's quick & easy.

PIL + show() + Vista

P: n/a
Hi!

This code:
import Image
img = Image.open(r"D:\ParisNude.jpg")
img.show()

Don't run on my Vista computer.

I have a solution:
import Image,os
img = Image.open(r"D:\FLundhNoNude.jpg")
os.startfile(img.filename)

It's only in my case?
It's censure? ;-)
PIL does not approve humour?
A solution soon?

@-salutations

Michel Claveau

Nov 30 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
This code:
import Image
img = Image.open(r"D:\ParisNude.jpg")
img.show()

Don't run on my Vista computer.

I have a solution:
import Image,os
img = Image.open(r"D:\FLundhNoNude.jpg")
os.startfile(img.filename)
....
Michel ....

As an alternative you might also try passing the path
to your favorite image viewer as a parameter to the
command argument of the image show method ....

iview = "/mnt/win_c/Program Files/IrfanView/i_view32.exe"

im.show( command = iview )
--
Stanley C. Kitching
Human Being
Phoenix, Arizona

Nov 30 '07 #2

P: n/a
Hi!

Not a true solution ; because people who don't have IrfanView don't use
it.

@-salutations

Michel Claveau

Nov 30 '07 #3

P: n/a
Re!

I have found the problem. On Vista, the Windows-Photo-Galery (soft
default displayer) don't wait. Even with START /WAIT (in Image.py &
_showxv), it don't wait.

Then, like the preview don't wait, the (next) "DEL" run prior the end of
the launch of the software ; and Windows-Photo-Galery don't found the
file...

I don't have a good solution. For force view of image, it's possible to
delete the "DEL /F %s" part ; but that will involve many BMP/temporary
files.

@+ & sorry for my bad english

Michel Claveau
Nov 30 '07 #4

P: n/a
Méta-MCI (MVP) wrote:
Re!

I have found the problem. On Vista, the Windows-Photo-Galery (soft
default displayer) don't wait. Even with START /WAIT (in Image.py &
_showxv), it don't wait.

Then, like the preview don't wait, the (next) "DEL" run prior the end of
the launch of the software ; and Windows-Photo-Galery don't found the
file...

I don't have a good solution. For force view of image, it's possible to
delete the "DEL /F %s" part ; but that will involve many BMP/temporary
files.
I was going to suggest using FindExecutable to find out whatever
your system uses to show pictures... but then I tried it out and
found out that the association is actually via the shimgvw DLL.
So I suppose you'll have to special-case that.

<code>
import win32api
import subprocess

filepath = r"c:\temp\test.jpg"
res, exe = win32api.FindExecutable (filepath)
if exe.endswith ("shimgvw.dll"):
cmd = "rundll32.exe %s,ImageView_Fullscreen %s" % (exe, filepath)
else:
cmd = "%s %s" % (exe, filepath)

subprocess.call (cmd)

</code>

On my XP machine this waits for the ImageViewer to return.
Be interesting to see if that's different under Vista. At
least it offers you a little more control, perhaps?

TJG
Nov 30 '07 #5

P: n/a
Hi!
Sorry, I don't understand english. But, with Babelfish-translation, I
recovered essence...
(you should learn French ; yes! yes! yes!)

I'm glad you found a solution
Thank you for your solicitude

if that executable doesn't honour the wait
I have just try on another CPU, with a very new Vista-premium
(configuration of exit of factory). The assoc est made with the
WindowsPhotoGallery.exe who don't respect the WAIT

universally is the solution.
The universal solution, it's... you!
With forthcoming once.
--
Michel Claveau

Nov 30 '07 #6

P: n/a
Méta-MCI (MVP) wrote:
[Excuse my execrable French below]
Sorry, I don't understand english. But, with Babelfish-translation, I
recovered essence...
(you should learn French ; yes! yes! yes!)
Vraiment!
I have just try on another CPU, with a very new Vista-premium
(configuration of exit of factory). The assoc est made with the
WindowsPhotoGallery.exe who don't respect the WAIT
Ceci fonctionne sur XP et Vista, esperant jusqu'a que
termine le ImageViewer. C'est possible de utiliser le
subprocess, mais j'oublie toujours les options differents.

This works on XP and Vista, waiting until the ImageViewer
has exited. You could use the subprocess module, but I
never remember the different options.

<code>
import os

filepath = "c:/temp/test.jpg"
assoc = os.popen ("assoc .jpg").read ().splitlines ()[0]
_, filetype = assoc.split ("=")
ftype = os.popen ("ftype %s" % filetype).read ().splitlines ()[0]
_, exe = ftype.split ("=")

#
# NB *must* use correct slashes
#
cmd = exe.replace ("%1", os.path.normpath (filepath))
os.system (cmd)

</code>

TJG
Nov 30 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.