Gradient Relfelction on Transparent Background
Posted: 2010-05-05T07:26:59-07:00
Hello everyone, I found an excellent snippet of code in the ImageMagick forum and can't figure out how to generate it in PerlMagick.
here is the link to the article viewtopic.php?f=1&t=15371&p=58415#p58415
this is what I have written,
I am having a problem with creating the gradient.
this is the error
Which I believe is pretty obvious that I can't use the +level bit directly from the CLI reference in the link.
Can someone help me reproduce the steps to generate the same effect from the CLI in the link into PerlMagick?
thanks
--
JT
here is the link to the article viewtopic.php?f=1&t=15371&p=58415#p58415
this is what I have written,
Code: Select all
sub GlassTable {
# emulate the glasstable effect with ImageMagick
my $base_image=shift;
my $x_offset=shift;
my $y_offset=shift;
my $opacity=shift;
my $percent=shift;
# glasstable is basically just a mirror reflection
# to do a mirror reflection;
# clone, flip and crop the original
# create gradient
# combine the above images
# make semi transparent
# append to bottom of original image
# Clone/Flip/Crop
my ($width, $height) = $base_image->Get('columns', 'rows');
my $first_image=Image::Magick->new();
my $new_height=int($height*$percent/100);
$first_image=$base_image->Clone();
$first_image->Flip();
$first_image->Crop(width=>$width,height=>$new_height);
# Create the Gradient
my $size=sprintf("%dx%d",$width,$new_height);
my $second_image=Image::Magick->new();
$second_image->Set(size=>"$size");
#$second_image->Read("gradient:grey$opacity-black");
print $second_image->Read("gradient: +level 0x$opacity%");
# Combine Flipped image and the gradient
$first_image->Composite(image=>$second_image, compose=>"Overlay", alpha=>"on");
# Make transparent
my $transparency=1-($opacity/100);
$first_image->Evaluate(value=>$transparency, operator=>'Multiply', channel=>'Alpha');
# Append the reflection to the bottom of the image
my $image_ary=Image::Magick->new();
push (@$image_ary, $base_image);
push (@$image_ary, $first_image);
return $image_ary->Append(stack=>"true");
}
this is the error
Code: Select all
Exception 310: unrecognized color `+level 0x90%' @ color.c/GetColorInfo/946
Can someone help me reproduce the steps to generate the same effect from the CLI in the link into PerlMagick?
thanks
--
JT