error_reporting(0);
include("functions.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Buttonize";
#### Start Buttonize
if ( $_GET[bevel] )
{
$bevel_type == "$_GET[bevel_type]";
if ( !$_GET[bevel_width] ) { $error = "No bevel width entered."; }
$bevel_width = (int)trim($_GET[bevel_width]);
if ( $_GET[bevel_color] )
{
$bevel_color = trim($_GET[bevel_color] );
$bevel_color = colors( $bevel_color, "validate" );
if ( !$bevel_color )
{
$_SESSION[error] .= "
Color is invalid";
header("location:$self");
exit;
}
}
if ( $error )
{
$_SESSION[error] = $error;
header("location:$self");
#echo "$error";
exit;
}
else {
$blob = file_get_contents("$_SESSION[path]");
$type = "$_SESSION[type]";
$image = new imagick();
$image->readImageBlob("$blob");
$width = $image->getImageWidth();
$height = $image->getImageheight();
# Get iterator
foreach ($image as $frame)
{
$it = $image->getPixelIterator();
$x = 0;
$y = 0;
# Loop through pixel rows
foreach( $it as $row => $pixels )
{
$y++;
# Loop trough the pixels in the row (columns)
foreach ( $pixels as $column => $pixel )
{
$x++;
# find shortest distance to an edge
$dist = min( abs($x-$width), $x, abs($y-$height), $y );
$sin = ($dist/$bevel_width);
$theta = asin($sin);
$cos = cos($theta);
if ( $_GET[bevel_type] == "frame" )
{ $bevel = $cos; }
else { $bevel = $sin; }
if ( $bevel >1 )
{ $bevel = 1; }
# get a pixel object
$point = $image->getImagePixelColor( $x, $y);
# get color as array
$color = $point->getColor();
$r = $color[r]*$bevel;
$g = $color[g]*$bevel;
$b = $color[b]*$bevel;
# Paint pixel
if ( !$bevel_color && $dist>$bevel_width )
{ $pixel->setColor( "rgb( $color[r], $color[g], $color[b])" ); }
elseif ( $bevel_color && $dist>$bevel_width )
{ $pixel->setColor( "$bevel_color" ); }
else { $pixel->setColor( "rgb($r,$g,$b)" ); }
}
$x = 0;
$it->syncIterator();
}
}
$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[bevel_width] = $bevel_width;
$_SESSION[bevel_type] = $_GET[bevel_type];
$_SESSION[bevel_color] = $bevel_color;
$_SESSION[path] = "$path";
header("Location: display.php?url=$path");
exit;
}
}
#### End Buttonize
include("top.php");
?>
Creates a rounded bevel around the image with an optional fill.
![]() Starting image |
|
![]() Button |
![]() Filled Button |
![]() Frame |
![]() Filled Frame |
red or a hex like #0000ff.