PIL + show() + Vista

M

Méta-MCI \(MVP\)

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
 
C

Cousin Stanley

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 )
 
M

Méta-MCI \(MVP\)

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
 
M

Méta-MCI \(MVP\)

Hi!

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

@-salutations

Michel Claveau
 
M

Méta-MCI \(MVP\)

Re!

I have found a (very) poor solution:

in Image.py, inside _showxv function,
replace
command = "start /wait %s && del /f %s" % (file, file)
by
command = 'start "%s" /wait "%s\\System32\\mshta.exe" "%s" && del /f
"%s" ' % (title,os.environ['WINDIR'],file,file)

For zoom in preview, use Ctrl+mouse_roller (good english term?) or
Ctrl + Ctrl - Ctrl 0 (keyboard)


This solution will be replace by Fredrick Lundh, when he awakes...
;-)))



@+

Michel Claveau
 
T

Tim Golden

Méta-MCI (MVP) said:
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
 
M

Méta-MCI \(MVP\)

Hi, Tim!

You are right, for shimgvw.dll (on XP / 2000, or some Vista). But
others Vista (ou users practice) had associate images with
WindowsPhotoGallery.exe.

But shimgvw.dll already exist.

I found that this line:

command = 'start "%s" /wait %s\\System32\\rundll32.exe
%s\\System32\\shimgvw.dll ImageView_Fullscreen %s && del /f "%s" ' %
(title,os.environ['SYSTEMROOT'],os.environ['SYSTEMROOT'],file,file)

launch a "Photo Gallery" who respect the WAIT.

For me (and my users), it's a solution. Perhaps others PIL's users can
read that with interest.

Have a good day.

Michel Claveau
 
T

Tim Golden

Méta-MCI (MVP) said:
Hi, Tim!

You are right, for shimgvw.dll (on XP / 2000, or some Vista). But
others Vista (ou users practice) had associate images with
WindowsPhotoGallery.exe.

But shimgvw.dll already exist.

I found that this line:

command = 'start "%s" /wait %s\\System32\\rundll32.exe
%s\\System32\\shimgvw.dll ImageView_Fullscreen %s && del /f "%s" ' %
(title,os.environ['SYSTEMROOT'],os.environ['SYSTEMROOT'],file,file)

launch a "Photo Gallery" who respect the WAIT.

For me (and my users), it's a solution. Perhaps others PIL's users can
read that with interest.

I'm glad you found a solution. I think my point was that
you can use the FindExecutable API to determine whatever
is associated and use that (special-casing the shimgvw DLL
to use RunDLL). Obviously, if that executable doesn't
honour the wait then you're stuck, so maybe using shimgvw
universally is the solution.

TJG
 
M

Méta-MCI \(MVP\)

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.
 
T

Tim Golden

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
 
Joined
Jan 27, 2010
Messages
27
Reaction score
0
FindExecutable API

Following is the sample code in [VB.NET]

'--Declaration
Public Declare Auto Function FindExecutable Lib "shell32.dll" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Int32

'--
Dim intRetval As Integer = FindExecutable(PDF FILE FULL PATH NAME, "", "")

If intRetval < = 32

MessageBox.Show("The Adobe Reader, which is required to view this file, may not be correctly installed.", "Adobe Reader Not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top