error_reporting(0);
include("functions.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Wave";
##### Start Wave
if ( $_GET[wave_amplitude] && $_GET[wave_length] )
{
$wave_amplitude = trim( $_GET[wave_amplitude] );
$wave_length = trim( $_GET[wave_length] );
$error = "";
$error_bad_amp = "Amplitude is numbers only.
";
$error_bad_len = "Wave length is numbers only.
";
##### Validate ampltude & wave length
if ( preg_match( "#[^0-9\-\.]#", "$wave_amplitude", $x) )
{ $error .= "$error_bad_amp"; }
if ( preg_match( "#[^0-9\-\.]#", "$wave_length", $x) )
{ $error .= "$error_bad_len"; }
if ( $error != "" )
{
echo "$errormsgtop";
echo "$error";
echo "$errormsgbottom";
exit;
}
# end validation
$wave_amplitude = (float)$wave_amplitude;
$wave_length = (float)$wave_length;
# make imagick object
$image = new Imagick($_SESSION[path]);
# if bgcolor entered then validate
if ($_GET[wave_bgcolor])
{
# trim input
$wave_bgcolor = trim($_GET[wave_bgcolor]);
## validate color
if ( !key_exists( "$wave_bgcolor", $color_names) && ( !preg_match( "@#[0-9a-f]{6}@i", $wave_bgcolor, $b) || strlen($wave_bgcolor) != 7 ) )
{ $error .= "Color is invalid."; }
# if invalid, error msg & exit
if ( $error != "")
{ echo "$errormsgtop $error $errormsgbottom";
exit;
}
## end validate
}
# if no color entered, set to transparent
else
{ $wave_bgcolor = "transparent"; }
# do the wave
foreach ( $image as $frame )
{
$frame->setimagebackgroundcolor("$wave_bgcolor");
$frame->waveImage($wave_amplitude, $wave_length);
}
#############
# write image xxx
$format = strtolower( $image->getimageformat() );
$path = "temp/$ID.$_SESSION[views].$format";
$image->writeimages("$path", TRUE );
# save settings & exit
$_SESSION[path] = $path;
$_SESSION[wave_amplitude] = $wave_amplitude;
$_SESSION[wave_length] = $wave_length;
$_SESSION[wave_bgcolor] = $wave_bgcolor;
header("Location: display.php?url=$path");
exit;
}
######### end wave
include("top.php");
?>