http://www.perlmonks.org?node_id=990111

fgsfds100 has asked for the wisdom of the Perl Monks concerning the following question:

Are Image::Magick and/or GD compatible with Perl v5.10.0?

Is it possible to build dynamic images, specifically out of other resized images resulting in a collage, that can be delivered via webserver?

A "Hello World" picture, if you will.

Here is an example of the type of thing I want to eventually make. NO I'M NOT LOOKING FOR SOMEONE TO CODE THIS SPECIFICALLY.

http://card.psnprofiles.com/1/someone01.png

I've heard about things like Image::Magick and GD, but as with all modules and things, I'm never really sure which ones will work for me or how I'm supposed to install them. I've tried downloading various different archive files and sticking the PM files into perl/bin and I've tried various different installers but I can never get any of it to work because the instructions aren't clear enough. I'm using Windows XP SP2, an apache 2.2 webserver and perl v5.10.0

Also it would be nice to see some sample code that can do the basics: generate an image of a particular size, with some background color or image, insert an existing image, insert some random text in some random color, and maybe draw a line or shape or something (much less important). All in particular positions, sizes and opacity.

I just need something to get me started. All the stuff I've found on google has been a bit too generalized, ambiguous and over my head.

------------------------ EDIT ------------------------

This is what brief, concise help might look like.

- Hey dude, I think this module would be better for you
- download it here (direct link or link to site and specify which version I should get, ie: is compatible and has all the basics of point 2...)
- run the installer -- or -- put the files here and type this in the command prompt to compile it
- here's a quick sample set of basic functions

use blah; $img = new image; $img -> insertImage(paramenters); $img -> changeColor(paramenters); $img -> insertText(paramenters); $img -> changeColor(paramenters); $img -> insertLine(paramenters); binmode; # necessary ??? print $img;

Then when someone goes to site.com/cgi/hello.pl, it generates something for them.

Replies are listed 'Best First'.
Re: Dynamic image collages delivered by webserver
by Corion (Patriarch) on Aug 28, 2012 at 06:32 UTC
    If you are looking for good/saner alternatives to ImageMagick and GD, maybe consider looking at Imager. It provides a smaller featureset than ImageMagick, but with a saner and more stable API. I won't post any code, as the documentation is quite extensive.
Re: Dynamic image collages delivered by webserver
by aitap (Curate) on Aug 28, 2012 at 09:40 UTC
    I've tried downloading various different archive files and sticking the PM files into perl/bin and I've tried various different installers but I can never get any of it to work because the instructions aren't clear enough.
    Did you try cpan? (or ppm if you use Active Perl)? (BTW, you didn't state which Perl do you actually use. There are many Perl builds for Windows with different abilities)
    - Hey dude, I think this module would be better for you
    GD and Image::Magick are good enough.
    - download it here (direct link or link to site and specify which version I should get, ie: is compatible and has all the basics of point 2...)
    Both of them can be downloaded via cpan.
    - run the installer -- or -- put the files here and type this in the command prompt to compile it
    cpan will install them, too.
    - here's a quick sample set of basic functions
    Here you are: GD Image::Magick
    Sorry if my advice was wrong.
Re: Dynamic image collages delivered by webserver
by Mr. Muskrat (Canon) on Aug 28, 2012 at 03:53 UTC

    This isn't a code writing service. You have to show some effort or you will not get good responses.

    You should start by reading the docs for GD and Image::Magick. Study and try out all of the demos and test cases (they both include those). Search this site for posts about those modules and learn more about them. Then when you've done all of that, you should be in a position to write the script you want. If it doesn't work, you can make a new post that not only tells what is and isn't working but also shows the code so that we can help you with it.

      I'm not looking for a code writing service. What is it with you people? Where do you get this belief that people like me are looking for a polished script?

      I'm not asking for the moon here. I'm only asking for two things.

      .

      1. A suggestion of which module you think would be better suited for my goal and a concise tutorial on how to install them.

      -- One that provides a WORKING link to a WORKING (Perl v5.10 compatible) installer, pm file or archive file, and explains exactly how to install it if it isn't already an wrapped in an installer itself.......... rather than the usual "tutorial by bibliography" list of (often dead) links a la "you might find it here or here or here or here, and tips on how to install it here or here or here or here." --

      - Hey dude, I think this module would be better for you
      - download it here (direct link or link to site and specify which version I should get, ie: is compatible and has all the basics of point 2...)
      - run the installer -- or -- put the files here and type this

      .

      2. Basic functions that I can play with. To build an image consisting of smaller images and colored text and lines.

      use blah; $img = new image; $img -> insertImage(paramenters); $img -> changeColor(paramenters); $img -> insertText(paramenters); $img -> changeColor(paramenters); $img -> insertLine(paramenters);

      A "Hello World" picture, if you will. That's all I'm after. Is that so hard?

      If you just plain don't know but don't want to come right out and say it, that's fine to. Just don't reply.

        That's all I'm after. Is that so hard?

        Each one of the modules you mentioned comes with all those things, instructions on how to install, hundreds of examples.

Re: Dynamic image collages delivered by webserver
by zentara (Archbishop) on Aug 28, 2012 at 10:09 UTC
Re: Dynamic image collages delivered by webserver
by philiprbrenan (Monk) on Aug 28, 2012 at 12:07 UTC

    Both ImageMagick and GD are compatible with perl 5.10.

    If you have ImageMagick installed on your system you can run it like this:

    my $imageMagick = "C:/Phil/ImageMagick-6.7.3-Q16/convert.exe"; + # Convert images say for qx($imageMagick \"$source\" -resize x$Y $\"target\");

    You can find extensive documentation at: http://www.imagemagick.org/script/command-line-options.php

    GD is also excellent. You might try GD::Simple first.

    I would suggest you spend time initially with ImageMagick due to its very broad applicability, deep documentation base, and exhaustive list of examples, and then move to GD in the (unlikely) event that you cannot find a solution to a specific problem.

Re: Dynamic image collages delivered by webserver
by Anonymous Monk on Aug 28, 2012 at 07:00 UTC