How can "show:", "win:" be made to work

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

How can "show:", "win:" be made to work

Post by djd »

"win:"/"show:" used to work and were very useful when debugging a command or script.
However they don't seem to work with Windows XP.

Are there files in an existing installation that can be patched (eg by me) in order
to make one of win:/show: work?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How can "show:", "win:" be made to work

Post by fmw42 »

I am not a Windows user, but I believe that they may all be for unix and not for Windows (though I am not totally sure about win:). See http://www.imagemagick.org/Usage/files/#show


Can you be more specific about how it is not working? Can you provide the exact command and image you used that failed?

Also what version of IM are you using?

Perhaps a Windows user may be able to clarify about win:
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can "show:", "win:" be made to work

Post by snibgo »

The file to hack is delegates.xml, in the same directory as convert.exe.

The lines to hack are those with:
encode="show"
or
encode="win"

I can't remember what the commands should be hacked to. There was a thread about this, I think.

This entry ...

Code: Select all

<delegate decode="bmp" encode="show" mode="encode" command="cmd.exe /C %%SystemRoot%%/System32/rundll32.exe "%%ProgramFiles%%/Windows Photo Viewer/PhotoViewer.dll", ImageView_Fullscreen file:///%i" />
... from the v6.7.9 delegates.xml works (using IM v6.7.9), bringing up Windows Photo Viewer. Doubtless it could bring up any viewer you want.

On a more positive note, "clipboard:" works, which is cute, though I've only found one use for it.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can "show:", "win:" be made to work

Post by snibgo »

Here we go. In the directory that contains convert.exe, I make a backup of delegates.xml. Then I changed the following three lines from ...

Code: Select all

  <delegate decode="png" encode="launch" spawn="True" mode="encode" command="cmd.exe /C start "%m" file:///"%i."" />
  <delegate decode="png" encode="show" spawn="True" mode="encode" command="cmd.exe /C start "%m" file:///"%i."" />
  <delegate decode="png" encode="win" spawn="True" mode="encode" command="cmd.exe /C start "%m" file:///"%i."" />
... to ...

Code: Select all

  <delegate decode="png" encode="launch" mode="encode" command="cmd.exe /C %%SystemRoot%%/System32/rundll32.exe "%%ProgramFiles%%/Windows Photo Viewer/PhotoViewer.dll", ImageView_Fullscreen file:///%i" />
  <delegate decode="png" encode="show" mode="encode" command="cmd.exe /C %%SystemRoot%%/System32/rundll32.exe "%%ProgramFiles%%/Windows Photo Viewer/PhotoViewer.dll", ImageView_Fullscreen file:///%i" />
  <delegate decode="png" encode="win" mode="encode" command="cmd.exe /C %%SystemRoot%%/System32/rundll32.exe "%%ProgramFiles%%/Windows Photo Viewer/PhotoViewer.dll", ImageView_Fullscreen file:///%i" />
Note that old versions of IM used decode="bmp". I never use BMP files but I often use PNG files.
Now commands like ...

Code: Select all

convert -verbose -size 100x100 gradient: show:
... bring up the image in Windows Photo Viewer, which is my favoured image viewer.

("-debug all" suggests that IM also looks for delegates.xml in "%HOMEPATH%\.magick". However, it doesn't seem to load it.)
snibgo's IM pages: im.snibgo.com
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Re: How can "show:", "win:" be made to work

Post by djd »

Thanks for the replies.

I have XP and it does not have Windows Photo Viewer but it has a viewer
the title bar of which declares "Windows Picture and Fax Viewer".
Actually, to run other than clicking on a file that is associated with it is
to execute: C:/WINDOWS/system32/rundll32.exe "c:/windows/system32/shimgvw.dll,ImageView_Ful
lscreen". It can be opened using that command line, although a file name argument (eg star.gif)
was not displayed. Perhaps it was my fault. Inserting it in delegates.xml and trying:
convert -size 100x100 xc: white win: resulted in an error message to do with
...missing entry:...ImageView_Fullscreen. I cannot remember exactly and it would be
time consuming to go back before trying IrfanView.
IrfanView does open and display an image using ...i_view32.exe strar.gif
However with win:, an error message similar to that with "Windows Picture..."
is displayed. It seems the line in the xml file is not quite right for either of these programs,
but must be close, at least for IrfanView.
Any ideas?

Regards
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Re: How can "show:", "win:" be made to work

Post by djd »

In the previous post, the error message was a windows message board with title RUNDLL.

But OOPS! I failed to use `verbose' and so missed the IM error messages which are:

convert -verbose -size 100x100 xc:white "win:"
xc:white=>white XC 100x100 100x100+0+0 16-bit sRGB 0.000u 0:00.031
xc:white=>C:/WINDOWS/TEMP/magick-1080iEPYjo66Gtyw PNG 100x100 100x100+0+0 8-bit
sRGB 1c 263B 0.156u 0:00.406
cmd.exe /C %SystemRoot%/System32/rundll32.exe "%ProgramFiles%/IrfanView/i_view32
.exe", ImageView_Fullscreen file:///C:/WINDOWS/TEMP/magick-10800bcAHldRDWCt
xc:white=>win: PNG 100x100 100x100+0+0 8-bit sRGB 1c 263B 0.047u 0:07.562

convert -verbose -size 100x100 xc:white white.png

Then on the command line
"c:\Program Files\IrfanView\i_view32.exe" white.png

Displayed OK in IrfanView

Regards
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Re: How can "show:", "win:" be made to work - 1/2way there?

Post by djd »

The following batch files work in the XP command shell:

myview1.bat:
@echo off
C:\programs\ifanview\i_view32.exe %~s1

myview2.bat:
@echo off
C:/WINDOWS/system32/rundll32.exe c:/windows/system32/shimgvw.dll,ImageView_Fullscreen %~s1

i_view32 is a free GUI
The second batch file invokes "Windows Picture and Fax Viewer", an XP version of Window 7 "Windows Photo Viewer"
It (rather rundll32) must be presented with short file names to be able to display the contents thus the %~s1 argument.

The batch files display the contents of image file arguments.

Following upon the suggestion of snibgo, the following lines were used in delegates.xml

<delegate decode="png" encode="show" spawn="True" mode="encode" command="cmd.exe
/C "C:/myview1.bat" "%i"" />

<delegate decode="png" encode="win" spawn="True" mode="encode" command="cmd.exe
/C "C:/myview2.bat" "%i"" />

Then convert was invoked, first with "show:", then with "win:".
Errors were produced, however the problem appears to be merely syntax.

convert -verbose -size 100x100 xc:white show:
xc:white=>white XC 100x100 100x100+0+0 16-bit sRGB 0.000u 0:00.000
xc:white=>C:/WINDOWS/TEMP/magick-3336ljMK2b3yqLhU PNG 100x100 100x100+0+0 8-bit
sRGB 1c 263B 0.125u 0:00.235
cmd.exe /C "C:/myview1.bat" "C:/WINDOWS/TEMP/magick-33366izR0xkmtjqJ"
The filename, directory name, or volume label syntax is incorrect.
xc:white=>show: PNG 100x100 100x100+0+0 8-bit sRGB 1c 263B 0.031u 0:10.358

convert -verbose -size 100x100 xc:white win:
xc:white=>white XC 100x100 100x100+0+0 16-bit sRGB 0.000u 0:00.000
xc:white=>C:/WINDOWS/TEMP/magick-3780Q4sZi6o-0oTJ PNG 100x100 100x100+0+0 8-bit
sRGB 1c 263B 0.109u 0:00.139
cmd.exe /C "C:/myview2.bat" "C:/WINDOWS/TEMP/magick-3780Mcl8w24IfoCF"
The filename, directory name, or volume label syntax is incorrect.
xc:white=>win: PNG 100x100 100x100+0+0 8-bit sRGB 1c 263B 0.016u 0:10.360

There is a mixture of Unix forward slashes (in the delegates file) and windows back slashes
(in the batch files) which confuses me and no doubt IM as well.

Would appreciate a description of what is required.


Regards
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can "show:", "win:" be made to work

Post by snibgo »

My notes above are for Windows 7.

Have you checked that commands like ...

Code: Select all

cmd /C "C:/myview2.bat" test.jpg
... work in Windows XP, where test.jpg is an image in your current directory?
snibgo's IM pages: im.snibgo.com
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Re: How can "show:", "win:" be made to work

Post by djd »

These all work:

C:\>cmd /C myview2.bat star.gif

C:\>cmd /C myview1.bat star.gif

C:\>cmd /C myview2.bat "C:\Documents and Settings\djd\star.gif"

C:\>cmd /C myview1.bat "C:\Documents and Settings\djd\star.gif"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can "show:", "win:" be made to work

Post by snibgo »

Hmm. It's worth trying the command exactly as ImageMagic issues it, with "C:" and forward slashes. Copy star.gif to C:/WINDOWS/TEMP/ and try:

Code: Select all

cmd /C "C:/myview2.bat" "C:/WINDOWS/TEMP/star.gif"
snibgo's IM pages: im.snibgo.com
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Re: How can "show:", "win:" be made to work

Post by djd »

I remain confused:

C:\>cmd /C "C:/myview2.bat" "C:/windows/TEMP/star.gif"
The filename, directory name, or volume label syntax is incorrect.

C:\>cmd /C C:/myview2.bat "C:/windows/TEMP/star.gif" % Works!

C:\>cmd /C "C:/myview2.bat" C:/windows/TEMP/star.gif % Works!

C:\>cmd /C C:/myview2.bat C:/windows/TEMP/star.gif % Works

I noticed this before when experimenting, there are some uses of `"'
that XP does not like.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How can "show:", "win:" be made to work

Post by snibgo »

Excellent. It looks as if you have cracked it. Don't put quotes around C:/myview2.bat. You can see that quotes are represented in delegates.xml by "
snibgo's IM pages: im.snibgo.com
djd
Posts: 41
Joined: 2011-11-12T22:20:18-07:00
Authentication code: 8675308

Re: How can "show:", "win:" be made to work

Post by djd »

Thanks for the help snibgo and chris (who is elsewhere).
The use of the batch file myview.bat in delegates.xml does allow "win:" to work.
The problem has been around a long time with no `fix' I have seen. So I have
created a new post to describe this fix more directly and how it arose.
The title is: "show:" and "win:" can be made to work this way on Windows XP


Regards
Post Reply