Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > General

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 9th September 2010, 11:35
angela angela is offline
Junior Member
 
Join Date: Aug 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default PerlMagick aparently failing when called from Apache

I'm migrating some perl scripts to a new server.

Some perl routines manipulate images with PerlMagick. When I run these routines from the command line as root everything works; when I call them from a web page the routine seemingly completes (no error messages) but I get no image served.

Some perl routines serve an image without using PerlMagick and they work just fine. The problem, I'm beginning to think, lies with getting PerlMagick working with Apache. The technique I use is to first write the page header and then write the binary image data back to the requesting browser. There is no HTML as such.

All ImageMagick ownership and group is root with 644 chmod settings.

I compiled ImageMagick and PerlMagick from source. Is there some security mechanism in ISPConfig3 that is preventing these compiled binaries running under Apache? Apache had modules mime and mime-magic loaded as per original configuration.

All the routines run just fine on an old BlueQuartz CentOS 4 system.

Any help to stop this amateur web-coder pulling hair appreciated!
Reply With Quote
Sponsored Links
  #2  
Old 9th September 2010, 12:31
Mark_NL Mark_NL is offline
Senior Member
 
Join Date: Sep 2008
Location: The Netherlands
Posts: 912
Thanks: 12
Thanked 100 Times in 96 Posts
Default

So you're trying to show an image in your browser with a perl script ..

remember that you're not allowed to send a single byte extra besides the image data + it's mime type .. so the browser knows how to interpretate it..

Read an image (png and output as jpeg):
Code:
use strict;
use CGI;
use Image::Magick;

$oCGI = new CGI;

print $oCGI->header( -type => "image/png", -expires => "now" );
my $oImageMagick = new Image::Magick( format => "png" );
$oImageMagick->Read( filename => "/some/imagefile.png" );
binmode STDOUT;
$oImageMagick->Write( "png:-" );
It's from the top of my head, so could not work right away
Reply With Quote
  #3  
Old 9th September 2010, 14:00
angela angela is offline
Junior Member
 
Join Date: Aug 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for wanting to help.

I've got something similar to yourcode. The routines are already proven on my old running server.

The only difference between my code and yours is the image I fetch remains in memory; so I do a blobToImage convert on the fetched data before pushing it out.

Code:
 use LWP::UserAgent;
 use CGI;
 use HTTP::Cookies;
 use CGI::Carp qw/fatalsToBrowser/;
 use strict;
 use Image::Magick

[snip]


      if ($secres->is_success) {
print $query->header(-type => 'image/gif', -expires => 'now');
            binmode STDOUT, ":raw";
            my $image=Image::Magick->new(magick=>'gif');
            $image->BlobToImage($secres->{'_content'});
            $image->Threshold(threshold=>'60%');
            $image->Quantize(colors=>'8');
            $image->Sharpen(0.0x1.0);
            $image->Write('gif:-');
    }
    else {
# bail out gracefully...

 [snip]
I can get the routine to work by doing

Code:
      if ($secres->is_success) {
 print $query->header(-type => 'image/gif', -expires => 'now');
 binmode STDOUT, "raw:";
 print $secres->{'_content'};
}
But I really need ImageMagick for its resizing and optimizations.

And I say, it all runs from the command line just fine. I'm really mystified.

Last edited by angela; 27th September 2010 at 21:36.
Reply With Quote
  #4  
Old 15th September 2010, 14:28
angela angela is offline
Junior Member
 
Join Date: Aug 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

Mmm, perhaps an extreme work-around... but I changed my Linux Distro from Ubuntu to SuSe and started over with a new install.

ImageMagick did its thing with no messing around.
Reply With Quote
Reply

Bookmarks

Tags
apache, ispconfig3 security, perlmagick

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to install roundcubemail ressel Installation/Configuration 13 24th December 2009 20:13
problems with suexec gobokster Installation/Configuration 7 7th May 2009 13:33
CENTOS 5 Ping Problem gAnDo Server Operation 11 28th March 2008 20:58
Centos 4.4 32bit Hangs, High Server load 3cwired_com Server Operation 11 16th November 2006 15:47
Problem with the installation of Dokeos (LMS) in ISPConfig jofranco General 4 28th April 2006 00:45


All times are GMT +2. The time now is 00:24.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.