error_reporting(0);
include("functions.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Paint";
$rand = rand(1,99999);
if ( $_SESSION[path] &&
$_GET[action] &&
( $_GET[action] != "none")
)
{
$image = new Imagick($_SESSION[path]);
$point = $image->getImagePixelColor( $_GET[x], $_GET[y]);
$q = $image->getQuantumRange();
$q = $q[quantumRangeLong];
$fuzz = (int)$_GET[fuzz];
$fuzz = ($fuzz*$q)/100;
$paint_alpha = (float)$_GET[paint_alpha];
if ( $paint_alpha < 0 ) { $paint_alpha = 0; }
if ( $paint_alpha > 1 ) { $paint_alpha = 1; }
## validate color ##
if ( $_GET[paint_color])
{
$paint_color = trim($_GET[paint_color] );
$paint_color = colors( $paint_color, "validate" );
if ( !$paint_color )
{ $error = "($_GET[paint_color]) Paint color is invalid"; }
}
if ( $_GET[border_color])
{
$border_color = trim($_GET[border_color] );
$border_color = colors( $border_color, "validate" );
if ( !$border_color )
{ $error .= "
Border color is invalid"; }
}
if ( $error )
{
$_SESSION[error] = $error;
header("location:$self");
exit;
}
## end validate ##
####### setopacity #######
if ( $_GET[action] == "setopacity" )
{
foreach ($image as $frame)
{ $image->setimageopacity( $paint_alpha ); }
}
##### end setopacity #####
####### paintflood #######
if ( $_GET[action] == "paintflood" )
{
foreach ($image as $frame)
{
$image->paintfloodfillimage( $paint_color, $fuzz,
$border_color, $_GET[x], $_GET[y] );
}
}
##### end paintflood #####
##### colorfloodfill ######
if ( $_GET[action] == "colorflood" )
{
foreach ($image as $frame)
{
$image->colorfloodfillimage( $paint_color, $fuzz,
$border_color, $_GET[x], $_GET[y] );
}
}
##### end colorfloodfill ######
###### painttransparent ######
if ( $_GET[action] == "painttransparent" )
{
foreach ($image as $frame)
{ $image->painttransparentimage( $point, $paint_alpha, $fuzz); }
}
###### end painttransparent ######
###### paintopaque ######
# xxx need to add channel
if ( $_GET[action] == "paintopaque" )
{
foreach ($image as $frame)
{ $image->paintopaqueimage( $point, $paint_color,
$fuzz, $channel); }
}
###### end paintopaque ######
$format = strtolower( $image->getimageformat() );
$path = "temp/$ID.$_SESSION[views].$format";
$frames = $image->getNumberImages();
if ( $frames > 1) { $image->writeImages("$path", TRUE); }
else { $image->writeImage("$path"); }
# save set settings
$_SESSION[path] = $path;
$_SESSION[paint_color] = $paint_color;
$_SESSION[border_color] = $border_color;
$_SESSION[fuzz] = $_GET[fuzz];
$_SESSION[paint_alpha] = $paint_alpha;
header("location:display.php");
exit;
}
?>