1 ) { $stroke_alpha = 1; } } # set stroke opacity if ($_GET[stroke_opacity]) { $stroke_opacity = trim($_GET[stroke_opacity] ); $stroke_opacity = (float)$stroke_opacity; if ( $stroke_opacity < 0 ) { $stroke_opacity = 0; } if ( $stroke_opacity > 1 ) { $stroke_opacity = 1; } } # set stroke fill opacity if ($_GET[fill_opacity]) { $fill_opacity = trim($_GET[fill_opacity] ); $fill_opacity = (float)$fill_opacity; if ( $fill_opacity < 0 ) { $fill_opacity = 0; } if ( $fill_opacity > 1 ) { $fill_opacity = 1; } } # set stroke fill alpha if ($_GET[fill_alpha]) { $fill_alpha = trim($_GET[fill_alpha] ); $fill_alpha = (float)$fill_alpha; if ( $fill_alpha < 0 ) { $fill_alpha = 0; } if ( $fill_alpha > 1 ) { $fill_alpha = 1; } } #### validate color ## if ( $_GET[fill_color] ) { $fill_color = trim($_GET[fill_color] ); $fill_color = colors( $fill_color, "validate" ); if ( !$fill_color ) { $error .= "Fill color is invalid
"; } } ## if ( $_GET[stroke_color] ) { $stroke_color = trim($_GET[stroke_color] ); $stroke_color = colors( $stroke_color, "validate" ); if ( !$stroke_color ) { $error .= "Stroke color is invalid
"; } } if ( $error ) { $_SESSION[error] = $error; header("location:$self"); } #### end validate colors ## #### if all vars set, make image & draw object $image = new Imagick($_SESSION[path]); $draw = new ImagickDraw; if ( $_GET[ul_x] && $_GET[ul_y] && $_GET[lr_x] && $_GET[lr_y] && $_GET[action] ) { $ul_x = (int)$_GET[ul_x]; $ul_y = (int)$_GET[ul_y]; $lr_x = (int)$_GET[lr_x]; $lr_y = (int)$_GET[lr_y]; $x_round = (float)$_GET[x_round]; $y_round = (float)$_GET[y_round]; # set colors if ( $fill_color ) { $draw->setfillcolor("$fill_color"); } if ( $stroke_color ) { $draw->setstrokecolor($stroke_color); } # set width $stroke_width = trim($_GET[stroke_width] ); $stroke_width = (int)$stroke_width; if ( $stroke_width ) { $draw->setstrokewidth($stroke_width); } # set stroke alpha/opacity & fill alpha/opacity if ( $stroke_alpha ) { $draw->setstrokealpha($stroke_alpha); } if ( $stroke_opacity ) { $draw->setstrokeopacity($stroke_opacity); } if ( $fill_opacity ) { $draw->setfillopacity($fill_opacity); } if ( $fill_alpha ) { $draw->setfillalpha($fill_alpha); } # set line cap switch ($_GET[line_cap]) { case "BUTT"; $cap = imagick::LINECAP_BUTT; break; case "ROUND"; $cap = imagick::LINECAP_ROUND; break; case "SQUARE"; $cap = imagick::LINECAP_SQUARE; break; default: $cap = imagick::LINECAP_UNDEFINED; } $draw->setStrokeLineCap($cap); ##### draw Round Rectangle #### if ( $_GET[action] == "Round Rectangle" ) { $draw->roundrectangle( $ul_x, $ul_y, $lr_x, $lr_y, $x_round, $y_round); foreach ($image as $frame) { $frame->drawimage($draw); } } ############################ ########## draw circle ######### if ( $_GET[action] == "Circle" ) { $draw->circle( $ul_x,$ul_y, $lr_x, $lr_y); foreach ($image as $frame) { $frame->drawimage($draw); } } ############################ ########## draw line ######### if ( $_GET[action] == "Line" ) { $draw->line( $ul_x,$ul_y, $lr_x, $lr_y); foreach ($image as $frame) { $frame->drawimage($draw); } } ############################ ####### draw rectangle ######## if ( $_GET[action] == "Rectangle" ) { $draw->rectangle( $ul_x,$ul_y, $lr_x, $lr_y); foreach ($image as $frame) { $frame->drawimage($draw); } } ############################ $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[stroke_width] = $stroke_width; $_SESSION[fill_alpha] = $fill_alpha; $_SESSION[fill_opacity] = $fill_opacity; $_SESSION[stroke_alpha] = $stroke_alpha; $_SESSION[stroke_opacity] = $stroke_opacity; $_SESSION[path] = $path; $_SESSION[fill_color] = $fill_color; $_SESSION[stroke_color] = $stroke_color; $_SESSION[x_round] = $x_round; $_SESSION[y_round] = $y_round; header("Location: display.php"); exit; # end draw } ############ step 2 # if 2nd coorids not set, set var for form if ( $_GET[crop_image_x] && $_GET[crop_image_y] && $_GET[ul_x] && $_GET[ul_y] && !$_GET[lr_x] && !$_GET[lr_y] ) { $ul_x = $_GET[ul_x]; $ul_y = $_GET[ul_y]; $lr_x = $_GET[crop_image_x]; $lr_y = $_GET[crop_image_y]; header("location:$self?ul_x=$ul_x&ul_y=$ul_y&lr_x=$lr_x&lr_y=$lr_y"); exit; } # Step 1. # Vars shouldn't be set at this point # if 1st coorids not set, set vars for form if ($_GET[crop_image_x] && $_GET[crop_image_y] && !$_GET[ul_x] && !$_GET[ul_x] && !$_GET[lr_x] && !$_GET[lr_x] ) { $ul_x = $_GET[crop_image_x]; $ul_y = $_GET[crop_image_y]; header("location:$self?ul_x=$ul_x&ul_y=$ul_y"); exit; } ?> <? echo "$h1: $h2"; ?>

"; echo "No image"; echo ""; } if ( isset($_SESSION[path]) ) { echo "
"; echo "
"; echo "
"; list($width, $height, $type, $attr) = getimagesize("$_SESSION[path]"); echo "

Width = $width; Height = $height
"; ### Show file size $filesize = filesize("$_SESSION[path]"); echo "File size: $filesize bytes
Your Image
"; } ?>

Point 1 Point 2

Fill Color
Stroke Color
Stroke Width
Stroke Opacity Stroke Alpha
Fill Opacity Fill Alpha
X-Round Y-Round
Line
Draws lines. Point 1 is an end point. Point 2 is the other end.
Circle
Draws circles. Point 1 is the center. Point 2 is a point on te circumference.
Rechangle
Draws rectangles. Point 1 is the upper left corner. Point 2 is the lower right corner.
Round Rectangle
Draws rectangles with round corners. Point 1 is the upper left corner. Point 2 is the lower right corner.
Stroke Color
The color of the lines
Stroke Width
The thickness of the lines
Fill Color
Color inside of shapes.
X-Round
Rounding on X axis for Round Rectangles
Y-Round
Rounding on Y axis for Round Rectangles

Instructions

  1. Click Point 1.
    or
    Enter the x,y cooridinates of Point 1
  2. Click Point 2.
    or
    Enter the x,y cooridinates of Point 2.
  3. Enter Stroke Color. Can be valid color name or hex.
  4. Enter Stroke Width. (optional)
  5. Select Line Cap style for lines. (optional)
  6. Enter Fill Color for shapes. Can be valid color name or hex.(optional)
  7. Enter Stroke Opacity. Range: 0-1 (optional)
  8. Enter Stroke Alpha. Range: 0-1 (optional)
  9. Enter Fill Opacity for rectangles. Range: 0-1 (optional)
  10. Enter Fill Alpha for rectangles. Range: 0-1 (optional)
  11. Click Line,Circle, Rectangle or Round Rectangle.
  12. Your settings (except for cooridinates) will be saved. Clicking Reset will delete your settings