Page 1 of 1

Imagemagick and my unix box crashing????

Posted: 2008-10-01T10:19:08-07:00
by strudel67
First off I am not a unix guy - I am using some scripting that I found on the web to do create real estate flyers using imagemagick version Version: ImageMagick 6.3.9 03/20/08 Q16 - everything seemed to be working fine on testing basis but once we started doing more flyers the unix server would crash. Basically the hosting providers pointed out that once the script was run - sometimes imagemagick would try and devour all the memory on the server and ultimately nothing on the server was accessible. Here is a copy of the php script we are using... obviously there are variables that are set prior to executing the script but was wondering - is there anything going on here that might cause this to happen? Or any suggestions? I am at a loss. A gentleman - Anthony Thyssen recommended to run unix server is single user mode and do some memory checks but I don't know how to do that or what that is... I also have a screen shot which shows IM gobbling up the memory just prior to losing contact with the server so I know that is what is happening. The command that was being executed at that time was where we place some text onto a canvas if that makes a difference... THANKS

/* CREATE DESCRIPTION AREA BACKGROUND TEXT */
$command = IM_PATH."convert -size 850x540 -background none -fill black -font ".SITE_URL."/im/fonts/".$description_font." caption:\"".$description."\" ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas_text.png ";

exec($command);
-------------------------------------------------------------
Full PHP SCRIPT

<?php

/*CREATE CANVAS*/
$command = IM_PATH."convert -size 1200x1600 gradient:\"".$canvas_color."\"-\"".$canvas_color2."\" ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

exec($command);

echo "got here and property ID is ".$property_ID;


/* CREATE TOP ADDRESS BORDER */
$command = IM_PATH."convert -size 1180x120 gradient:\"".$canvas_color."\"-\"".$canvas_color2."\" ".SITE_URL."/im/temp/new/".$property_ID."_addressborder.png";

exec($command);

$command = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID."_addressborder.png -pointsize ".$address_font_size." -font ".SITE_URL."/im/fonts/".$address_font." -gravity North -annotate +5+10 '".$address."' -pointsize ".$city_state_font_size." -font ".SITE_URL."/im/fonts/".$address_font." -gravity North -annotate +0+80 '".$city_state."' -blur 0x4 -font ".SITE_URL."/im/fonts/".$address_font." -pointsize ".$address_font_size." -fill white -stroke black -annotate +0+5 '".$address."' -pointsize ".$city_state_font_size." -font ".SITE_URL."/im/fonts/".$address_font." -gravity North -fill white -stroke black -annotate +0+75 '".$city_state."' ".SITE_URL."/im/temp/new/".$property_ID."_addressborder.png";

exec($command);

$command = IM_PATH."convert ".SITE_URL."im/temp/new/".$property_ID."_addressborder.png -mattecolor peru -frame 10x10+3+3 ".SITE_URL."/im/temp/new/".$property_ID."_addressborder.png";

exec($command);

/*ADD PROPERTY DETAILS, AGENT INFO, PRICE*/

$command = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg -gravity North -pointsize ".$address_font_size." -font Arial -annotate +5+595 '".$price."' -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity South -annotate +5+50 '".$agent_info."' -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity North -annotate +5+1305 '".$details."' -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity North -annotate +5+1340 'View the Virtual Tour at:".$virtual_tour."' -gravity North -blur 0x4 -gravity North -font ".SITE_URL."/im/fonts/".$address_font." -pointsize ".$address_font_size." -font Arial -fill white -stroke black -annotate +0+590 '".$price."' -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity South -fill white -stroke black -annotate +0+55 '".$agent_info."' -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity North -fill white -stroke black -annotate +0+1300 '".$details."' -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity North -fill white -stroke black -annotate +0+1335 'View the Virtual Tour at:".$virtual_tour."' ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

exec($command);

/* CREATE DESCRIPTION AREA BACKGROUND */
$command = IM_PATH."convert -size 900x600 xc:\"".$description_canvas_color."\" ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas.png ";

exec($command);

/* CREATE DESCRIPTION AREA BACKGROUND TEXT*/
$command = IM_PATH."convert -size 850x540 -background none -fill black -font ".SITE_URL."/im/fonts/".$description_font." caption:\"".$description."\" ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas_text.png ";

exec($command);

/*DROP SHADOW ONTO DESCRIPTION CANVAS*/

$command0 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas.png \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas.png";

$good0 = exec($command0);

/*PLACE EQUAL OPP LOGO*/

$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/images/equaloplogo.gif -gravity Southwest -geometry +280+5 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);

/* PLACE EQUAL OPP TEXT */
$command = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg -pointsize 16 -font ".SITE_URL."/im/fonts/".$details_font." -gravity South -fill \"".$inverse_canvas_color."\" -annotate +25+5 '".$equal_opp_text."' ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good = exec($command);

/* PLACE DESCRIPTION CANVAS ONTO MAIN CANVAS - GRAVITY NORTH */

$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas.png -gravity North -geometry +0+695 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);

unlink(SITE_URL."/im/temp/new/".$property_ID."_description_canvas.png");

/* PLACE DESCRIPTION CANVAS TEXT ONTO MAIN CANVAS - GRAVITY NORTH */

$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_description_canvas_text.png -gravity North -geometry +0+735 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);

unlink(SITE_URL."/im/temp/new/".$property_ID."_description_canvas_text.png");

/* ADD VIRTUAL TOUR LINK */
/*
$command = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg -pointsize ".$details_font_size." -font ".SITE_URL."/im/fonts/".$details_font." -gravity North -fill white -stroke black -annotate +0+1340 'View the Virtual Tour at:".$virtual_tour."' ".SITE_URL."/im/temp/new/".$property_ID.".jpg ";

exec($command);
*/

/* Take main image and do a drop shadow */
$command0 = IM_PATH."convert ".SITE_URL."photos/".$image1." -resize 600x400 -border 20x20 \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage ".SITE_URL."/im/temp/new/".$property_ID."_image1.png";

$good0 = exec($command0);

/* PLACE MAIN IMAGE ONTO CANVAS - GRAVITY NORTH */
$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_image1.png -gravity North -geometry +0+145 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);

unlink(SITE_URL."/im/temp/new/".$property_ID."_image1.png");


/* CREATE IMAGE 2 PNG POLAROID */
$command = IM_PATH."convert ".SITE_URL."photos/".$image2." -thumbnail 300x300 -bordercolor white -background black -polaroid -7 ".SITE_URL."/im/temp/new/".$property_ID."_image2.png";
$good = exec($command);

echo $image2."<br>";
$account_dir = strtok($image2,"/");
echo $account_dir."<br>";

/* PLACE IMAGE 2 ONTO CANVAS */
$command21 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_image2.png -gravity Northwest -geometry +10+240 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good21 = exec($command21);


unlink(SITE_URL."/im/temp/new/".$property_ID."_image2.png");

/* CREATE IMAGE 3 PNG POLAROID */
$command = IM_PATH."convert ".SITE_URL."photos/".$image3." -thumbnail 300x300 -bordercolor white -background black -polaroid +4 ".SITE_URL."/im/temp/new/".$property_ID."_image3.png";
$good = exec($command);

/* PLACE IMAGE 3 ONTO CANVAS */
$command21 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_image3.png -gravity Northwest -geometry +10+460 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good21 = exec($command21);


unlink(SITE_URL."/im/temp/new/".$property_ID."_image3.png");

/* CREATE IMAGE 4 PNG POLAROID */
$command = IM_PATH."convert ".SITE_URL."photos/".$image4." -thumbnail 300x300 -bordercolor white -background black -polaroid +4 ".SITE_URL."/im/temp/new/".$property_ID."_image4.png";
$good = exec($command);

/* PLACE IMAGE 4 ONTO CANVAS */
$command21 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_image4.png -gravity Northwest -geometry +830+240 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good21 = exec($command21);


unlink(SITE_URL."/im/temp/new/".$property_ID."_image4.png");

/* CREATE IMAGE 5 PNG POLAROID */
$command = IM_PATH."convert ".SITE_URL."photos/".$image5." -thumbnail 300x300 -bordercolor white -background black -polaroid -7 ".SITE_URL."/im/temp/new/".$property_ID."_image5.png";
$good = exec($command);

/* PLACE IMAGE 5 ONTO CANVAS */
$command21 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_image5.png -gravity Northwest -geometry +830+460 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good21 = exec($command21);


unlink(SITE_URL."/im/temp/new/".$property_ID."_image5.png");



/* AGENT PHOTO SHADOW */
$command0 = IM_PATH."convert ".SITE_URL."photos/".$agent_photo." -resize 150x150 -border 5x5 \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage ".SITE_URL."/im/temp/new/".$account_ID."_agent_photo.png";

$good0 = exec($command0);

/* PLACE AGENT PHOTO */
$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$account_ID."_agent_photo.png -gravity Southwest -geometry +55+55 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);


/* AGENT LOGO SHADOW */
$command0 = IM_PATH."convert ".SITE_URL."photos/".$agent_logo." -resize 150x150 -border 5x5 \( +clone -background black -shadow 80x3+5+5 \) +swap -background none -layers merge +repage ".SITE_URL."/im/temp/new/".$account_ID."_logo_photo.png";

$good0 = exec($command0);



/* PLACE AGENT LOGO */
$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$account_ID."_logo_photo.png -gravity Southeast -geometry +55+55 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);



/* ADD DISCLAIMER MASK*/
/*
$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/disclaimer_mask.png -gravity South -geometry +0+0 -composite ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

$good1 = exec($command1);
*/
/* ADD ADDRESS BORDER */

$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID."_addressborder.png -gravity North -geometry +0+0 -composite ".SITE_URL."/photos/".$account_ID."/".$property_ID."_brochure.jpg";

$good1 = exec($command1);

unlink(SITE_URL."/im/temp/new/".$property_ID."_addressborder.png");
//chmod(SITE_URL."photos/".$account_ID."/".$property_ID."/brochure_".$property_ID.".jpg", 0777);


} /* TESTING MODE */

if (isset($_GET['testing'])) {

/* CREATE JPG */
//$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID.".jpg";

//$good1 = exec($command1);


/* CREATE PDF */
//$command1 = IM_PATH."convert ".SITE_URL."/im/temp/new/".$property_ID.".jpg ".SITE_URL."/im/temp/new/".$property_ID.".pdf";

//$good1 = exec($command1);
} /* end if get property ID */

header("location:../new_brochure_complete.php?property_ID=$property_ID");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<img src="temp/new/<?php echo $property_ID;?>.jpg"" width="800" />
</body>
</html>