error_reporting(0);
include("functions.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Add Noise";
#### Start edge detect
if ( $_GET[addnoise] == "$h2" )
{
$image = new Imagick($_SESSION[path]);
switch ( $_GET[channel] )
{
case "red":
$channel = imagick::CHANNEL_RED;
break;
case "green":
$channel = imagick::CHANNEL_GREEN;
break;
case "blue":
$channel = imagick::CHANNEL_BLUE;
break;
case "yellow":
$channel = imagick::CHANNEL_YELLOW;
break;
case "cyan":
$channel = imagick::CHANNEL_CYAN;
break;
case "magenta":
$channel = imagick::CHANNEL_MAGENTA;
break;
case "alpha":
$channel = imagick::CHANNEL_ALPHA;
break;
case "opacity":
$channel = imagick::CHANNEL_OPACITY;
break;
case "matte":
$channel = imagick::CHANNEL_MATTE;
break;
case "gray":
$channel = imagick::CHANNEL_GRAY;
break;
case "black":
$channel = imagick::CHANNEL_BLACK;
break;
case "index":
$channel = imagick::CHANNEL_INDEX;
break;
case "all":
$channel = imagick::CHANNEL_ALL;
break;
default:
$channel = imagick::CHANNEL_ALL;
break;
}
####
switch ( $_GET[noise_type] )
{
case "Uniform":
$noise_type = imagick::NOISE_UNIFORM;
break;
case "Gaussian":
$noise_type = imagick::NOISE_GAUSSIAN;
break;
case "Multiplicative Gaussian":
$noise_type = imagick::NOISE_MULTIPLICATIVEGAUSSIAN;
break;
case "Impulse":
$noise_type = imagick::NOISE_IMPULSE;
break;
case "Laplacian":
$noise_type = imagick::NOISE_LAPLACIAN;
break;
case "Poisson":
$noise_type = imagick::NOISE_POISSON;
break;
}
####
foreach ($image as $frame)
{ $frame->addNoiseImage( $noise_type, $channel ); }
$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 settings
$_SESSION[path] = $path;
$_SESSION[edge] = $edge;
header("Location: display.php");
exit;
} # end add noise
include("top.php");
?>