| 1 | Introduction |
|---|
| 2 | |
|---|
| 3 | PerlMagick, is an objected-oriented Perl interface to ImageMagick. |
|---|
| 4 | Use the module to read, manipulate, or write an image or image sequence |
|---|
| 5 | from within a Perl script. This makes it suitable for Web CGI scripts. You |
|---|
| 6 | must have ImageMagick 6.5.7 or above installed on your system for this |
|---|
| 7 | module to work properly. |
|---|
| 8 | |
|---|
| 9 | See |
|---|
| 10 | |
|---|
| 11 | http://www.imagemagick.org/script/perl-magick.php |
|---|
| 12 | |
|---|
| 13 | for additional information about PerlMagick. See |
|---|
| 14 | |
|---|
| 15 | http://www.imagemagick.org/ |
|---|
| 16 | |
|---|
| 17 | for instructions about installing ImageMagick. |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | Installation |
|---|
| 21 | |
|---|
| 22 | Get the PerlMagick distribution and type the following: |
|---|
| 23 | |
|---|
| 24 | gunzip ImageMagick-6.5.7-0.tar.gz |
|---|
| 25 | tar xvf ImageMagick-6.5.7 |
|---|
| 26 | |
|---|
| 27 | Follow the ImageMagick installation instructions in INSTALL-unix.txt |
|---|
| 28 | then type |
|---|
| 29 | |
|---|
| 30 | cd PerlMagick |
|---|
| 31 | |
|---|
| 32 | Next, edit Makefile.PL and change LIBS and INC to include the appropriate |
|---|
| 33 | path information to the required libMagick library. You will also need |
|---|
| 34 | library search paths (-L) to JPEG, PNG, TIFF, etc. libraries if they were |
|---|
| 35 | included with your installed version of ImageMagick. If an extension |
|---|
| 36 | library is built as a shared library but not installed in the system's |
|---|
| 37 | default library search path, you may need to add run-path information |
|---|
| 38 | (often -R or -rpath) corresponding to the equivalent library search |
|---|
| 39 | path option so that the library can be located at run-time. |
|---|
| 40 | |
|---|
| 41 | To create and install the dymamically-loaded version of PerlMagick |
|---|
| 42 | (the preferred way), execute |
|---|
| 43 | |
|---|
| 44 | perl Makefile.PL |
|---|
| 45 | make |
|---|
| 46 | make install |
|---|
| 47 | |
|---|
| 48 | To create and install a new 'perl' executable (replacing your existing |
|---|
| 49 | PERL interpreter!) with PerlMagick statically linked (but other libraries |
|---|
| 50 | linked statically or dynamically according to system linker default), |
|---|
| 51 | execute |
|---|
| 52 | |
|---|
| 53 | perl Makefile.PL |
|---|
| 54 | make perl |
|---|
| 55 | make -f Makefile.aperl inst_perl |
|---|
| 56 | |
|---|
| 57 | or to create and install a new PERL interpreter with a different name |
|---|
| 58 | than 'perl' (e.g. 'PerlMagick') and with PerlMagick statically linked |
|---|
| 59 | |
|---|
| 60 | perl Makefile.PL MAP_TARGET=PerlMagick |
|---|
| 61 | make PerlMagick |
|---|
| 62 | make -f Makefile.aperl inst_perl |
|---|
| 63 | |
|---|
| 64 | See the ExtUtils::MakeMaker(3) manual page for more information on |
|---|
| 65 | building PERL extensions (like PerlMagick). |
|---|
| 66 | |
|---|
| 67 | For Windows systems, type |
|---|
| 68 | |
|---|
| 69 | perl Makefile.nt |
|---|
| 70 | nmake install |
|---|
| 71 | |
|---|
| 72 | For Unix, you typically need to be root to install the software. |
|---|
| 73 | There are ways around this. Consult the Perl manual pages for more |
|---|
| 74 | information. You are now ready to utilize the PerlMagick routines from |
|---|
| 75 | within your Perl scripts. |
|---|
| 76 | |
|---|
| 77 | Installation - Win32 Strawberry perl |
|---|
| 78 | |
|---|
| 79 | On Win32 Strawberry perl the prefered way of installing PerlMagick is the |
|---|
| 80 | following: |
|---|
| 81 | |
|---|
| 82 | 1) Download and install ImageMagick Windows binaries from |
|---|
| 83 | http://www.imagemagick.org/script/binary-releases.php#windows |
|---|
| 84 | |
|---|
| 85 | 2) You HAVE TO choose dynamic (DLL) ImageMagick binaries. Note: it is not |
|---|
| 86 | possible to mix 32/64bit binaries of perl and ImageMagick |
|---|
| 87 | |
|---|
| 88 | 3) During installation select that you want to install ImageMagick's |
|---|
| 89 | development files (libraries+headers) |
|---|
| 90 | |
|---|
| 91 | 4) You NEED TO have ImageMagick's directory in your PATH. Note: we are |
|---|
| 92 | checking the presence of convert.exe or identify.exe tools |
|---|
| 93 | |
|---|
| 94 | 5) You might need Visual C++ Redistributable Package installed on your |
|---|
| 95 | system. See instructions on ImageMagick's Binary Release webpage. |
|---|
| 96 | |
|---|
| 97 | 6) If you have all prerequisites 1)...5) you can simply install |
|---|
| 98 | ImageMagick by running: cpan -i Image::Magick |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | Testing PerlMagick |
|---|
| 102 | |
|---|
| 103 | Before PerlMagick is installed, you may want to execute |
|---|
| 104 | |
|---|
| 105 | make test |
|---|
| 106 | |
|---|
| 107 | to verify that PERL can load the PerlMagick extension ok. Chances are |
|---|
| 108 | some of the tests will fail if you do not have the proper delegates |
|---|
| 109 | installed for formats like JPEG, TIFF, etc. |
|---|
| 110 | |
|---|
| 111 | To see a number of PerlMagick demonstration scripts, type |
|---|
| 112 | |
|---|
| 113 | cd demo |
|---|
| 114 | make |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | Example Perl Magick Script |
|---|
| 118 | |
|---|
| 119 | Here is an example script to get you started: |
|---|
| 120 | |
|---|
| 121 | #!/usr/bin/perl |
|---|
| 122 | use Image::Magick; |
|---|
| 123 | |
|---|
| 124 | $q = Image::Magick->new; |
|---|
| 125 | $x = $q->Read("model.gif", "logo.gif", "rose.gif"); |
|---|
| 126 | warn "$x" if $x; |
|---|
| 127 | |
|---|
| 128 | $x = $q->Crop(geom=>'100x100+100+100'); |
|---|
| 129 | warn "$x" if $x; |
|---|
| 130 | |
|---|
| 131 | $x = $q->Write("x.gif"); |
|---|
| 132 | warn "$x" if $x; |
|---|
| 133 | |
|---|
| 134 | The script reads three images, crops them, and writes a single image |
|---|
| 135 | as a GIF animation sequence. |
|---|