Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Image::Magick slowness in CGI

by ForgotPasswordAgain (Deacon)
on Oct 03, 2007 at 12:57 UTC ( #642391=perlquestion: print w/replies, xml ) Need Help??
ForgotPasswordAgain has asked for the wisdom of the Perl Monks concerning the following question:

I have a command-line script that resizes images with Image::Magick. When running this script it takes a second or two to Resize an image. However, when putting this into a CGI script, it takes a couple minutes (still completes successfully). Does anyone have any idea why it would be different? Like an environment variable, path, I dunno.

Replies are listed 'Best First'.
Re: Image::Magick slowness in CGI
by bradenshep (Beadle) on Oct 03, 2007 at 14:55 UTC
    Well, you could try logging a timestamp when you start the Image::Magick work and again when you finish it. Make sure it really is the IM tasks that are slow.

    Also, somemonk please correct me if I'm wrong, but I believe Image::Magick is outdated and using IM with system() may give better performance/compatibility. It's at least worth a try to see if it gives better performance when you're running in CGI.

      ImageMagick is comparatively slower than other Graphics Packages. It is NOT the problem of PerlMagick (Image::Magick).

      A possible problem is Environment variables. The CGI has a different environment than that of command-line. The environment variables are set in two ways.

      1. Set directly by Apache
      2. Passed by OS
      In some cases apache will suppress some environment variables from being passed. It can caused problems.

      you can workaround this problem by passing environment using PassEnv directive in your httpd.conf ( in your virtual host section ) to pass the named environment variables to CGI scripts instead of suppressing them.
      Try using

      PassEnv MAGICK_HOME
      and its value, will become available to CGI scripts.

      check with your /ImageMagick/im-faq.tgz or /ImageMagick/ for more details.
      The zip file contains im-faq.pod and .html, im-faq-1.cgi and env.cgi.

      This FAQ is available here

      Cheers !


Re: Image::Magick slowness in CGI
by mr_mischief (Monsignor) on Oct 03, 2007 at 15:24 UTC
    One possibility, at least on Unixy systems, is that the web server may have a CPU or memory limit overall or per subprocess. You might need to check the ulimits and the web server config. I know this might sound like a silly question, but we are talking about the same computer in both instances, right?
      Yes, same computer. And only one install of Image::Magick. I was thinking maybe a terminal-related problem.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://642391]
Approved by grinder
[Lotus1]: hi

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-06-18 15:44 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (110 votes). Check out past polls.