ImageMagick and PerlMagick V 5.3.9

Compilation under Windows NT

This file: http://savage.net.au/ImageMagick/html/perl-magick.html


Note
====
1)
AFAIK, the binary distribution of ImageMagick cannot be used
to build PerlMagick because compiling the Perl interface, *.xs,
requires ImageMagick C/C++ header files, and these are not shipped
as part of the ImageMagick binaries.

2)
Thus, if you wish to build PerlMagick, you must download the
source of ImageMagick, which simply increases the load on
ImageMagick's host server.

3)
Lines which start with # are now comments, and should be ignored.

1 Prepare
=========
This method no longer needs:
        FreeType
        FreeType2
        GNUmake.exe
        gzip.exe
        tar.exe
        zip.exe

For details on installing those, see http://savage.net.au/Ron/html/GNU-Utils.html

However, if you are trying to install on a system without access to a C/C++
compiler, eg on a web server, you will then need them. In that case, proceed
via installation method 6 (b).

2 Package: ImageMagick
======================
Current method:
URI: http://ftp.nluug.nl/graphics/ImageMagick/
Navigate to the file: ImageMagick-5.3.9.zip
File size: 19,048,431
Unzip into C:\
Rename the directory C:\ImageMagick-5.3.9 to C:\ImageMagick

And now for the good news. I work on D:, and it does work. Just change C: to D:.

#Previous method:
# This part no longer needed.
#URI: http://www.simplesystems.org/ImageMagick/www/cvs.html
#Download:
#shell>cd \
#shell>set CVSROOT=:pserver:anonymous@cvs.imagemagick.org:/pathos/cvs
#shell>cvs login			(Password in anonymous)
#shell>cvs -r ImageMagick_5_3_9 ImageMagick-NT

3 Use Visual C++ to build ImageMagick
=====================================
o Open workspace:
	c:\ImageMagick\VisualMagick\configure\configure.dsw
o Options:
	Build/Set active configuration to:
	o configure - Win32 Release
o Build it:
        Build/Clean
        Build/Build
o Run it:
        I changed 2 options. I ticked:
        [x] Generate a font map file. (No, I have no idea what this does.)
        [x] Include all demos
	Click Next/Next/Finish
o Open workspace:
	c:\ImageMagick\VisualMagick\VisualDynamicMT.dsw
#o Add freetype2:
#       This part no longer needed.
#	Tools/Options/Directories/Include files. Add:
#	o c:\freetype2-beta8\include\freetype
#	o c:\freetype2-beta8\include
#	Fileview/Core_magick_files/Right click/Add file to project:
#	o c:\freetype2-beta8\obj\freetype.lib
o Options:
	Build/Set active configuration:
	o All - Win32 Release
	Build/Clean
	Build/Build

Note: This will produce errors in NtMagick, and 134 Warnings. Ignore them.
NtMagick is a contributed program, and not part of ImageMagick.

4 Errata and Errata and ...
===========================
a. Something old:
Recent documentation mentions these environment variables:
DELEGATE_PATH
HOME
MAGICK_DELEGATE_PATH
MAGICK_MODULE_PATH
LIB
There is no need to edit your values of these. I don't use any of them.

b. Something new:
Here are my settings:
MAGICK_CACHE_THRESHOLD=50
        I believe this is optional.
        I use 50 (Mb) since my office PC only contains 196Mb.
        See C:\ImageMagick\QuickStart.txt
MAGICK_HOME=C:\ImageMagick\VisualMagick\bin
        This is _absolutely needed_ for PerlMagick. Without it you'll get the dreaded:
        'No delegates for this image format' message.
PATH+=C:\ImageMagick\VisualMagick\bin
TEMP=C:\Temp
TMP=C:\Temp
TMPDIR=C:\Temp
        I don't know which the Windows version uses, so I used a sledgehammer.
        The docs mention TMPDIR.
As you can see, there is really not much which needs to be done.

c. Something borrowed:
These next 3 changes (c1 .. c3) are only required if you use installation method 6 (b) below.
Really, c1 and c2 indicate the makefile should examine the environment
variable %OS%, and tailor the delete command to the version of Windows detected.

But, you should read Makefile.nt carefully, since the comment starting at line 6
could well apply to you. ActivePerl build 626 seems to fix this particular problem,
since nothing in Config.pm needs to be changed now. Of course, I _may_ have compensated
by fixing my environment earlier.

c1) Change line 39 from this:
        if exist x86 del x86 /y
        to this:
        if exist x86 del x86 /q

c2) Change line 40 from this:
        if exist x86 rd x86
        to this:
        if exist x86 rd x86 /q /s

#Previous method:
# This part no longer needed.
#c3) Change line 45 from this:
#        $(ZIP) -rP PerlMagick.zip readme Image-Magick.ppd x86/Image-Magick.tar$(SUFFIX)
#        to this:
#        $(ZIP) -r  PerlMagick.zip readme Image-Magick.ppd x86/Image-Magick.tar$(SUFFIX)

d. Something blue:
My language, after a few false starts.

e. The file C:\ImageMagick\ReadMe.txt contains a few more red herrings :-(:
        1. Lines 784 .. 792 look like this:
>The C:\ImageMagick folder should contain the following files:
>
>  1) magic.mgk
>  2) delegates.mgk (derived from nt.mgk)
>  3) modules.mgk
>  4) rgb.txt
>
>The "bin" folder should contains all EXE's and DLL's as well as the
>very important "modules.mgk" file.

        The reference to C:\ImageMagick should read C:\ImageMagick\VisualMagick\bin.
        Since the aforementioned files already reside in this directory,
        there is nothing to do!

        2. Line 823 looks like this:
> D:\CVS\ImageMagick\VisualMagick\bin
        Ignore it. Patch PATH as explained above.

        3. Line 846 looks like this:
> D:\\ImageMagick\coders
        Ignore it. Patch MAGICK_HOME as explained above.

5 Use Perl and nmake to build PerlMagick
========================================
shell>cd c:\ImageMagick\PerlMagick

Note: You just edited Makefile.nt as explained above, right?

shell>perl Makefile.nt (not PL!)
shell>nmake

Note: This will product 4 scary warnings (eg: incompatible types). Ignore them.

shell>nmake test

Note: 2 tests will fail catastrophically, in that Perl will abort. I have not
investigated.

6 Installing Image::Magick
==========================
Now, there are 2 ways to install it.
6 a)
shell>nmake install
That was painless, wasn't it?

6 b)
Prepare tar.exe, gzip.exe, and zip.exe.
See http://savage.net.au/Ron/html/GNU-Utils.html for details.
Unzip C:\ImageMagick\PerlMagick\PerlMagick.zip into C:\ImageMagick\PerlMagick\x
shell>cd x
shell>nmake ppm
shell>ppm install --location=. Image-Magick
shell>cd ..
shell>rd /q /s x

7 Testing Image::Magick
=======================
Hint: Choose 7 (b).
7 a) The bad news:
shell>cd demo
shell>nmake

Note: This fails catastrophically as above, in that Perl will abort. I have still not
investigated.

7 b) The good news:
shell>cd C:\Temp
shell>copy C:\ImageMagick\PerlMagick\demo\piddle.pl

Edit C:\Temp\piddle.pl. Change the last line from:
        $image->Display();
to
        $image->Write('png:piddle.png');

shell>perl piddle.pl

Now, in Windows Explorer, double-click on C:\Temp\piddle.png. This does not fail.

Phew!

8 Other Installation Instructions
=================================
Hit http://www.dylanbeattie.net/magick/