| 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.3.2 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.3.2-2.tar.gz |
|---|
| 25 | tar xvf ImageMagick-6.3.2 |
|---|
| 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 | |
|---|
| 78 | Testing PerlMagick |
|---|
| 79 | |
|---|
| 80 | Before PerlMagick is installed, you may want to execute |
|---|
| 81 | |
|---|
| 82 | make test |
|---|
| 83 | |
|---|
| 84 | to verify that PERL can load the PerlMagick extension ok. Chances are |
|---|
| 85 | some of the tests will fail if you do not have the proper delegates |
|---|
| 86 | installed for formats like JPEG, TIFF, etc. |
|---|
| 87 | |
|---|
| 88 | To see a number of PerlMagick demonstration scripts, type |
|---|
| 89 | |
|---|
| 90 | cd demo |
|---|
| 91 | make |
|---|
| 92 | |
|---|
| 93 | |
|---|
| 94 | Example Perl Magick Script |
|---|
| 95 | |
|---|
| 96 | Here is an example script to get you started: |
|---|
| 97 | |
|---|
| 98 | #!/usr/bin/perl |
|---|
| 99 | use Image::Magick; |
|---|
| 100 | |
|---|
| 101 | $q = Image::Magick->new; |
|---|
| 102 | $x = $q->Read("model.gif", "logo.gif", "rose.gif"); |
|---|
| 103 | warn "$x" if $x; |
|---|
| 104 | |
|---|
| 105 | $x = $q->Crop(geom=>'100x100+100+100'); |
|---|
| 106 | warn "$x" if $x; |
|---|
| 107 | |
|---|
| 108 | $x = $q->Write("x.gif"); |
|---|
| 109 | warn "$x" if $x; |
|---|
| 110 | |
|---|
| 111 | The script reads three images, crops them, and writes a single image |
|---|
| 112 | as a GIF animation sequence. |
|---|