MS Windows and convert.exe

Table of contents

MS Windows and convert.exe
Solutions
Open DOS boxes
Credits
Author
Licence

MS Windows and convert.exe

If you run convert, and get an error message, like this:

        C:\Temp>convert x.gif x.png
        Invalid Parameter - x.png

then you have inadvertently run the MS Windows program called convert.exe, rather than the ImageMagick program of the same name.

This problem will only arise under WinNT/2k/XP, since Win9*/ME does not ship with convert.exe.

You can check thus:

        C:\Temp>convert /?

The MS convert.exe will output the following:

        Converts FAT volumes to NTFS.

        CONVERT volume /FS:NTFS [/V]

          volume      Specifies the drive letter (followed by a colon),
              mount point, or volume name.
          /FS:NTFS    Specifies that the volume to be converted to NTFS.
          /V          Specifies that Convert should be run in verbose mode.

BTW, I'm writing this on a Win2K machine, where I am not logged on as the administrator.

Solutions

Choose one of the following options:

Create a batch file to run ImageMagick convert.exe

This is a simplest solution, and should be tried first. Samples (both 1 liners):

        @D:\path\to\ImageMagick\convert.exe %*

        @%MAGICK_HOME%\convert.exe %*

Either of these can be called, say, im.cmd, and as long as im.cmd is saved into a directory on the PATH, it can be run by just using:

        D:\>im ...

However now that MAGICK_HOME has been converted into RETIREMENT_HOME (joke!) the first alternative should be used.

Rename the ImageMagick convert.exe to, say, im-convert.exe

This is a simple solution.

Rename the MS convert.exe to, say, ms-convert.exe

You need administrative access to do this.

Not only that, but under WinXP the original file will be reconstituted automatically by the operating system within about 10 seconds, from one of two hidden backup copies.

Such a process by the OS is both for general OS stability, and as an anti-trojan manoeuvre, and is to be encouraged. I do not recommend attempting to pervert this process, although it can be done.

Let me add here a note about the editor UltraEdit, since there is no other appropriate place for such information:

UltraEdit (which I use) has a free add-on called notepad.exe, which is used to replace the version of notepad.exe shipped with Win*. When programs run Notepad by force, meaning they refuse to give you the option of naming your own editor, this substitute notepad.exe will be run, and will just pass the file being edited to UltraEdit. It's a good idea, but will clearly interfere with the above-mentioned mechanism built in to WinXP. Now you know.

Edit the PATH

Put the ImageMagic installation directory into the PATH environment variable in front of the Windows directory (probably C:\WinNT\System32) which contains the MS convert.exe.

This way, Windows will find the ImageMagick convert.exe before it finds the Windows convert.exe.

You may need administrative access to achieve this, since Windows normally puts its own system directories at the start of the PATH.

Edit the registry

This is a very neat solution, and does not require administrative access.

It does, however, require you to be very careful indeed.

Backup the registry before embarking on this procedure.

Firstly, a mouse-driven recipe is provided, followed by the equivalent in a text-file-driven recipe.

Steps:

Click on Start/Run
Type in 'regedt32' (without the quotes)

You can also use 'regedit' for this, but the precise actions may be slightly different.

Click OK
Click on the window titled 'HKEY_CURRENT_USER on Local Machine'
Double-click on Software
Double-click on Microsoft
Double-click on Command Processor
On the main menu, click on 'Edit/Add value'
For 'Value name' enter 'AutoRun' (without the quotes)
Click OK
For 'String', enter the following
        doskey convert=<ImageMagick installation directory>\convert.exe $*

being sure to replace the text <ImageMagick installation directory> with the path to ImageMagick's convert.exe.

On my PC, the path I use is C:\Ron\ImageMagick-5.4.8-Q16.

So, I add

        doskey convert=C:\Ron\ImageMagick-5.4.8-Q16\convert.exe $*
Click OK

Alternately, a text file can be prepared which will update the registry.

Warnings:

The environment variable MAGICK_HOME

This recipe is presented assuming you are still using a version of ImageMagick which uses MAGICK_HOME. If you are using the self-installing version of the ImageMagick binaries, first shipped with V 5.4.8, note that MAGICK_HOME is no longer used, so you will need to edit the following sample file according to the explanation just above, where it talks about the doskey line.

The current AutoRun command

This recipe immediately overwrites any AutoRun that you or someone else may have set up.

Because of this, I recommend you go through at least part of the above recipe, to find out if any such AutoRun has been previously defined.

Now, the recipe: The following five lines (including the blanks) can be saved to disk and imported into the registry by double-clicking the file.

        ---- begin im-convert.reg ----
        REGEDIT4

        [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
        "AutoRun"="doskey convert=%MAGICK_HOME%\\convert.exe $*"

        ---- end im-convert.reg ----

Open DOS boxes

DOS boxes which are already open will not see the edit you have just made.

You will need to open a new DOS box, via:

Click on Start/Run
Type in 'cmd' (without the quotes)
Click OK

before 'convert' at the DOS command line will run the ImageMagick convert.exe.

Credits

Thanks to Andrew Graham and Rick Mabry for suggestions.

Author

Ron Savage .

Home page: http://savage.net.au/index.html

Version: 1.01 01-Jun-2006

This version disguises my email address.

Version: 1.00 The year dot

Original version.

Licence

Australian Copyright © 2002 Ron Savage. All rights reserved.

        All Programs of mine are 'OSI Certified Open Source Software';
        you can redistribute them and/or modify them under the terms of
        The Artistic License, a copy of which is available at:
        http://www.opensource.org/licenses/index.html