- Modifications to compile ImageMagick
BIN
ImageMagick/PerlMagick/demo/Generic.ttf
Normal file
17
ImageMagick/PerlMagick/demo/Makefile
Normal file
|
@ -0,0 +1,17 @@
|
|||
all:
|
||||
perl demo.pl
|
||||
perl button.pl
|
||||
perl shapes.pl
|
||||
perl piddle.pl
|
||||
perl tree.pl
|
||||
perl steganography.pl
|
||||
perl shadow-text.pl
|
||||
perl compose-specials.pl
|
||||
perl pixel-fx.pl
|
||||
perl single-pixels.pl
|
||||
perl annotate.pl
|
||||
perl composite.pl
|
||||
|
||||
clean:
|
||||
/bin/rm -f demo.jpg button.gif model.png shadow.gif tree.gif \
|
||||
compose-specials.jpg single-pixels.gif pixel-fx.gif
|
6
ImageMagick/PerlMagick/demo/README
Normal file
|
@ -0,0 +1,6 @@
|
|||
This directory contains a number of PerlMagick demonstration scripts. Just
|
||||
type
|
||||
|
||||
make
|
||||
|
||||
to exercise the various examples.
|
57
ImageMagick/PerlMagick/demo/Turtle.pm
Normal file
|
@ -0,0 +1,57 @@
|
|||
package
|
||||
Turtle;
|
||||
|
||||
# Written by jreed@itis.com, adapted by Cristy.
|
||||
|
||||
sub new
|
||||
{
|
||||
my $class = shift;
|
||||
my $self = {};
|
||||
|
||||
@{$self}{qw(x y theta mirror)} = @_;
|
||||
bless $self, $class;
|
||||
}
|
||||
|
||||
sub forward
|
||||
{
|
||||
my $self = shift;
|
||||
my ($r, $what) = @_;
|
||||
my ($newx, $newy)=($self->{x}+$r* sin($self->{theta}),
|
||||
$self->{y}+$r*-cos($self->{theta}));
|
||||
if ($what) {
|
||||
&$what($self->{x}, $self->{y}, $newx, $newy); # motion
|
||||
}
|
||||
# According to the coderef passed in
|
||||
($self->{x}, $self->{y})=($newx, $newy); # change the old coords
|
||||
}
|
||||
|
||||
sub turn
|
||||
{
|
||||
my $self = shift;
|
||||
my $dtheta = shift;
|
||||
|
||||
$self->{theta} += $dtheta*$self->{mirror};
|
||||
}
|
||||
|
||||
sub state
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
@{$self}{qw(x y theta mirror)};
|
||||
}
|
||||
|
||||
sub setstate
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
@{$self}{qw(x y theta mirror)} = @_;
|
||||
}
|
||||
|
||||
sub mirror
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
$self->{mirror} *= -1;
|
||||
}
|
||||
|
||||
"Turtle.pm";
|
40
ImageMagick/PerlMagick/demo/annotate.pl
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use Image::Magick;
|
||||
|
||||
#$font = '-adobe-helvetica-medium-r-normal--25-180-100-100-p-130-iso8729-1';
|
||||
#$font = 'Times';
|
||||
$font = 'Generic.ttf';
|
||||
|
||||
$image = Image::Magick->new();
|
||||
$x = 100;
|
||||
$y = 100;
|
||||
for ($angle=0; $angle < 360; $angle+=30)
|
||||
{
|
||||
my ($label);
|
||||
|
||||
print "angle $angle\n";
|
||||
$label=Image::Magick->new(size=>"600x600",pointsize=>24,font=>$font);
|
||||
$label->Read("xc:white");
|
||||
$label->Draw(primitive=>'line',points=>"300,100 300,500",stroke=>'#600');
|
||||
$label->Draw(primitive=>'line',points=>"100,300 500,300",stroke=>'#600');
|
||||
$label->Draw(primitive=>'rectangle',points=>"100,100 500,500",fill=>'none',
|
||||
stroke=>'#600');
|
||||
$label->Annotate(text=>"North West",gravity=>"NorthWest",x=>$x,y=>$y,
|
||||
undercolor=>'yellow',rotate=>$angle);
|
||||
$label->Annotate(text=>"North",gravity=>"North",y=>$y,rotate=>$angle);
|
||||
$label->Annotate(text=>"North East",gravity=>"NorthEast",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
$label->Annotate(text=>"West",gravity=>"West",x=>$x,rotate=>$angle);
|
||||
$label->Annotate(text=>"Center",gravity=>"Center",rotate=>$angle);
|
||||
$label->Annotate(text=>"East",gravity=>"East",x=>$x,rotate=>$angle);
|
||||
$label->Annotate(text=>"South West",gravity=>"SouthWest",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
$label->Annotate(text=>"South",gravity=>"South",y=>$y,rotate=>$angle);
|
||||
$label->Annotate(text=>"South East",gravity=>"SouthEast",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
push(@$image,$label);
|
||||
}
|
||||
$image->Set(delay=>20);
|
||||
$image->Write("annotate.miff");
|
||||
$image->Animate();
|
71
ImageMagick/PerlMagick/demo/annotate_words.pl
Executable file
|
@ -0,0 +1,71 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# annotate_words.pl
|
||||
#
|
||||
# Take the internal string, split it into words and try to annotate each
|
||||
# individual word correctly, so as to control spacing between the words
|
||||
# under program control.
|
||||
#
|
||||
# A demonstration of using QueryFontMetrics(), by passing it exactly the same
|
||||
# arguments as you would for Annotate(), to determine the location of the
|
||||
# text that is/was drawn.
|
||||
#
|
||||
# Example script from Zentara
|
||||
# http://zentara.net/Remember_How_Lucky_You_Are.html
|
||||
#
|
||||
use warnings;
|
||||
use strict;
|
||||
use Image::Magick;
|
||||
|
||||
my $image = Image::Magick->new;
|
||||
$image->Set(size=>'500x200');
|
||||
my $rc = $image->Read("xc:white");
|
||||
|
||||
my $str = 'Just Another Perl Hacker';
|
||||
my (@words) = split ' ',$str;
|
||||
#print join "\n",@words,"\n";
|
||||
|
||||
my ($x,$y) = (50,50);
|
||||
|
||||
foreach my $word (@words){
|
||||
|
||||
$image->Annotate(
|
||||
pointsize => 24,
|
||||
fill => '#000000ff', #last 2 digits transparency in hex ff=max
|
||||
text => $word,
|
||||
gravity => 'NorthWest',
|
||||
align => 'left',
|
||||
x => $x,
|
||||
y => $y,
|
||||
);
|
||||
|
||||
my ( $character_width,$character_height,$ascender,$descender,$text_width,
|
||||
$text_height,$maximum_horizontal_advance, $boundsx1, $boundsy1,
|
||||
$boundsx2, $boundsy2,$originx,$originy) =
|
||||
$image->QueryFontMetrics(
|
||||
pointsize => 24,
|
||||
text => $word,
|
||||
gravity => 'NorthWest',
|
||||
align => 'left',
|
||||
x => $x,
|
||||
y => $y,
|
||||
);
|
||||
|
||||
print "$word ( $character_width, $character_height,
|
||||
$ascender,$descender,
|
||||
$text_width, $text_height,
|
||||
$maximum_horizontal_advance,
|
||||
$boundsx1, $boundsy1,
|
||||
$boundsx2, $boundsy2,
|
||||
$originx,$originy)\n";
|
||||
|
||||
my $n = $x + $originx + $character_width/3; # add a space
|
||||
print "Next word at: $x + $originx + $character_width/3 => $n\n";
|
||||
$x = $n;
|
||||
|
||||
}
|
||||
|
||||
$image->Write("show:");
|
||||
|
||||
exit;
|
||||
|
15
ImageMagick/PerlMagick/demo/button.pl
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Make simple beveled button.
|
||||
#
|
||||
use Image::Magick;
|
||||
|
||||
$q=Image::Magick->new;
|
||||
$q->Set(size=>'30x106');
|
||||
$q->Read('gradient:#00f685-#0083f8');
|
||||
$q->Rotate(-90);
|
||||
$q->Raise('6x6');
|
||||
$q->Annotate(text=>'Push Me',font=>'Generic.ttf',fill=>'black',
|
||||
gravity=>'Center',pointsize=>18);
|
||||
$q->Write('button.gif');
|
||||
$q->Write('win:');
|
252
ImageMagick/PerlMagick/demo/compose-specials.pl
Executable file
|
@ -0,0 +1,252 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Demonstration of some of the fancier Image Composition Methods
|
||||
# including the 'rotate' parameter specific to PerlMagick Composite()
|
||||
#
|
||||
# NOTE: versions of IM older than IM v6.5.3-4 will need to rename the
|
||||
# parameter "args=>" to the mis-named "blend=>" parameter.
|
||||
#
|
||||
# Also not that "composite -watermark" is actually known as the compose
|
||||
# method "Modulate".
|
||||
#
|
||||
# Essentually each image is equivelent to
|
||||
# convert logo: -crop 80x80+140+60 +repage \
|
||||
# -size 60x60 gradient:black-white \
|
||||
# -alpha set miff:- |\
|
||||
# composite - -geometry +10+10 -virtual-pixel gray \
|
||||
# -dissolve 70x30 show:
|
||||
# for various composition methods.
|
||||
#
|
||||
use strict;
|
||||
use Image::Magick;
|
||||
|
||||
# Background or Destination image
|
||||
my $dest=Image::Magick->new();
|
||||
$dest->Read('logo:');
|
||||
$dest->Crop('100x100+400+100'); # wizards hat
|
||||
$dest->Set(page=>'0x0+0+0');
|
||||
$dest->Set(alpha=>'Set');
|
||||
|
||||
# Source, Composite or Overlay image
|
||||
my $src=Image::Magick->new();
|
||||
$src->Set(size=>'80x80');
|
||||
$src->Read('gradient:black-white');
|
||||
$src->Set(alpha=>'Set');
|
||||
|
||||
my $offset="+10+10";
|
||||
|
||||
# Circle Mask Image (same size as Destination)
|
||||
my $circle=Image::Magick->new();
|
||||
$circle->Set(size=>'100x100');
|
||||
$circle->Read('xc:black');
|
||||
$circle->Draw(fill=>'white',primitive=>'circle',points=>'49.5,49.5 10,49.5');
|
||||
|
||||
my $texture=Image::Magick->new();
|
||||
$texture->Read('pattern:checkerboard');
|
||||
|
||||
# List of images generated
|
||||
my $results=Image::Magick->new();
|
||||
|
||||
# Working copy of Destination Image
|
||||
my $clone;
|
||||
|
||||
# ----------------------------------------
|
||||
# Normal Composition Methods
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Over\n(normal compose)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'over',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Multiply\n(add black)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'multiply',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Screen\n(add white)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'screen',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('HardLight\n(light effects)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'hardlight',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
# ---------------
|
||||
# Masked and Blending Demonstartion
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Circle Masked\n(three image)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
mask=>$circle,
|
||||
compose=>'over',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Blend 50x50\n(50% plus 50%)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'blend',
|
||||
args=>'50x50',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Dissolve 50x50\n(50% over 50%)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'dissolve',
|
||||
args=>'50x50',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Dissolve 50\n(50% over 100%)');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'dissolve',
|
||||
args=>'50',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
# ---------------
|
||||
# Displacement Demonstartion
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Displace 50x0\n(displace horiz)');
|
||||
$clone->Set('virtual-pixel'=>'gray');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'displace',
|
||||
args=>'50x0',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Displace 0x50\n(compress vert)');
|
||||
$clone->Set('virtual-pixel'=>'gray');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'displace',
|
||||
args=>'0x50',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Displace 50x50\n(diagonal)');
|
||||
$clone->Set('virtual-pixel'=>'gray');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'displace',
|
||||
args=>'50x50',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Displace 0,-80\n(displace flip)');
|
||||
$clone->Set('virtual-pixel'=>'gray');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'displace',
|
||||
args=>'0,-80',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
# ---------------
|
||||
# Demonstrate rotation
|
||||
# note that offset is automatically adjusted to keep rotated image
|
||||
# centered relative to its '0' rotation position
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Rotate 0\n');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'over',
|
||||
rotate=>0,
|
||||
background=>'none',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Rotate 10\n');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'over',
|
||||
rotate=>10,
|
||||
background=>'none',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Rotate 45\n');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'over',
|
||||
rotate=>45,
|
||||
background=>'none',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
$clone=$dest->Clone();
|
||||
$clone->Label('Rotate 90\n');
|
||||
$clone->Composite(
|
||||
image=>$src,
|
||||
compose=>'over',
|
||||
rotate=>90,
|
||||
background=>'none',
|
||||
geometry=>$offset,
|
||||
);
|
||||
push(@$results, $clone);
|
||||
|
||||
# ----------------------------------------
|
||||
# Output the changed pixels
|
||||
|
||||
# to every image underlay a checkboard pattern
|
||||
# so as to show if any transparency is present
|
||||
for my $image ( @$results ) {
|
||||
$image->Composite(
|
||||
image=>$texture,
|
||||
tile=>'True',
|
||||
compose=>'DstOver',
|
||||
);
|
||||
}
|
||||
|
||||
my $montage=$results->Montage(
|
||||
geometry=>'+10+10',
|
||||
tile=>'4x',
|
||||
frame=>'6x6+2+2',
|
||||
shadow=>'True',
|
||||
);
|
||||
$montage->Write('show:');
|
||||
$montage->Write('compose_specials.jpg');
|
||||
|
44
ImageMagick/PerlMagick/demo/composite.pl
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use Image::Magick;
|
||||
|
||||
#$font = '-adobe-helvetica-medium-r-normal--25-180-100-100-p-130-iso8729-1';
|
||||
#$font = 'Times';
|
||||
$font = 'Generic.ttf';
|
||||
|
||||
$image = Image::Magick->new();
|
||||
$smile = Image::Magick->new();
|
||||
$smile->Read('smile.gif');
|
||||
$smile->Set(background=>'none');
|
||||
$x = 100;
|
||||
$y = 100;
|
||||
for ($angle=0; $angle < 360; $angle+=30)
|
||||
{
|
||||
my ($thumbnail);
|
||||
|
||||
print "angle $angle\n";
|
||||
$thumbnail=Image::Magick->new(size=>"600x600",pointsize=>24,font=>$font,
|
||||
fill=>'black');
|
||||
$thumbnail->Read("xc:white");
|
||||
$thumbnail->Draw(primitive=>'line',points=>"300,100 300,500",stroke=>'#600');
|
||||
$thumbnail->Draw(primitive=>'line',points=>"100,300 500,300",stroke=>'#600');
|
||||
$thumbnail->Draw(primitive=>'rectangle',points=>"100,100 500,500",
|
||||
fill=>'none',stroke=>'#600');
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"NorthWest",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"North",y=>$y,rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"NorthEast",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"West",x=>$x,rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"Center",rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"East",x=>$x,rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"SouthWest",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"South",y=>$y,rotate=>$angle);
|
||||
$thumbnail->Composite(image=>$smile,gravity=>"SouthEast",x=>$x,y=>$y,
|
||||
rotate=>$angle);
|
||||
push(@$image,$thumbnail);
|
||||
}
|
||||
$image->Set(delay=>20);
|
||||
$image->Write("composite.miff");
|
||||
$image->Animate();
|
483
ImageMagick/PerlMagick/demo/demo.pl
Normal file
|
@ -0,0 +1,483 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Overall demo of the major PerlMagick methods.
|
||||
#
|
||||
use Image::Magick;
|
||||
|
||||
#
|
||||
# Read model & smile image.
|
||||
#
|
||||
print "Read...\n";
|
||||
$null=Image::Magick->new;
|
||||
$null->Set(size=>'70x70');
|
||||
$x=$null->ReadImage('NULL:black');
|
||||
warn "$x" if "$x";
|
||||
|
||||
$model=Image::Magick->new();
|
||||
$x=$model->ReadImage('model.gif');
|
||||
warn "$x" if "$x";
|
||||
$model->Label('Magick');
|
||||
$model->Set(background=>'white');
|
||||
|
||||
$smile=Image::Magick->new;
|
||||
$x=$smile->ReadImage('smile.gif');
|
||||
warn "$x" if "$x";
|
||||
$smile->Label('Smile');
|
||||
$smile->Set(background=>'white');
|
||||
#
|
||||
# Create image stack.
|
||||
#
|
||||
print "Transform image...\n";
|
||||
$images=Image::Magick->new();
|
||||
|
||||
print "Adaptive Blur...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Adaptive Blur');
|
||||
$example->AdaptiveBlur('0x1');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Adaptive Resize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Adaptive Resize');
|
||||
$example->AdaptiveResize('60%');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Adaptive Sharpen...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Adaptive Sharpen');
|
||||
$example->AdaptiveSharpen('0x1');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Adaptive Threshold...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Adaptive Threshold');
|
||||
$example->AdaptiveThreshold('5x5+5%');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Add Noise...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Add Noise');
|
||||
$example->AddNoise("Laplacian");
|
||||
push(@$images,$example);
|
||||
|
||||
print "Annotate...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Annotate');
|
||||
$example->Annotate(text=>'Magick',geometry=>'+0+20',font=>'Generic.ttf',
|
||||
fill=>'gold',gravity=>'North',pointsize=>14);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Auto-gamma...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Auto Gamma');
|
||||
$example->AutoGamma();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Auto-level...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Auto Level');
|
||||
$example->AutoLevel();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Blur...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Blur');
|
||||
$example->Blur('0.0x1.0');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Border...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Border');
|
||||
$example->Border(geometry=>'6x6',color=>'gold');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Channel...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Channel');
|
||||
$example->Channel(channel=>'red');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Charcoal...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Charcoal');
|
||||
$example->Charcoal('0x1');
|
||||
push(@$images,$example);
|
||||
|
||||
print "ColorMatrix...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('ColorMatrix');
|
||||
$example->ColorMatrix([1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0.5, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Composite...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Composite');
|
||||
$example->Composite(image=>$smile,compose=>'over',geometry=>'+35+65');
|
||||
$example->Clamp();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Contrast...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Contrast');
|
||||
$example->Contrast();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Contrast Stretch...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Contrast Stretch');
|
||||
$example->ContrastStretch('5%');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Convolve...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Convolve');
|
||||
$example->Convolve([1, 1, 1, 1, 4, 1, 1, 1, 1]);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Crop...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Crop');
|
||||
$example->Crop(geometry=>'80x80+25+50');
|
||||
$example->Set(page=>'0x0+0+0');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Despeckle...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Despeckle');
|
||||
$example->Despeckle();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Distort...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Distort');
|
||||
$example->Distort(method=>'arc',points=>[60],'virtual-pixel'=>'white');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Draw...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Draw');
|
||||
$example->Draw(fill=>'none',stroke=>'gold',primitive=>'circle',
|
||||
points=>'60,90 60,120',strokewidth=>2);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Detect Edges...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Detect Edges');
|
||||
$example->Edge();
|
||||
$example->Clamp();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Emboss...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Emboss');
|
||||
$example->Emboss('0x1');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Encipher...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Encipher');
|
||||
$example->Encipher('Magick');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Equalize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Equalize');
|
||||
$example->Equalize();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Implode...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Explode');
|
||||
$example->Implode(-1);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Flip...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Flip');
|
||||
$example->Flip();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Flop...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Flop');
|
||||
$example->Flop();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Frame...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Frame');
|
||||
$example->Frame('15x15+3+3');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Fx...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Fx');
|
||||
push(@$images,$example->Fx(expression=>'0.5*u'));
|
||||
|
||||
print "Gamma...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Gamma');
|
||||
$example->Gamma(1.6);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Gaussian Blur...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Gaussian Blur');
|
||||
$example->GaussianBlur('0.0x1.5');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Gradient...\n";
|
||||
$gradient=Image::Magick->new;
|
||||
$gradient->Set(size=>'130x194');
|
||||
$x=$gradient->ReadImage('gradient:#20a0ff-#ffff00');
|
||||
warn "$x" if "$x";
|
||||
$gradient->Label('Gradient');
|
||||
push(@$images,$gradient);
|
||||
|
||||
print "Grayscale...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Grayscale');
|
||||
$example->Set(type=>'grayscale');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Implode...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Implode');
|
||||
$example->Implode(0.5);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Level...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Level');
|
||||
$example->Level('20%x');
|
||||
$example->Clamp();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Median Filter...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Median Filter');
|
||||
$example->MedianFilter();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Mode...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Mode');
|
||||
$example->Mode();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Modulate...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Modulate');
|
||||
$example->Modulate(brightness=>110,saturation=>110,hue=>110);
|
||||
push(@$images,$example);
|
||||
$example=$model->Clone();
|
||||
|
||||
print "Monochrome...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Monochrome');
|
||||
$example->Quantize(colorspace=>'gray',colors=>2,dither=>'false');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Morphology...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Morphology');
|
||||
$example->Morphology(method=>'Dilate',kernel=>'Diamond',iterations=>2);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Motion Blur...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Motion Blur');
|
||||
$example->MotionBlur('0x13+10-10');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Negate...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Negate');
|
||||
$example->Negate();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Normalize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Normalize');
|
||||
$example->Normalize();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Oil Paint...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Oil Paint');
|
||||
$example->OilPaint();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Plasma...\n";
|
||||
$plasma=Image::Magick->new;
|
||||
$plasma->Set(size=>'130x194');
|
||||
$x=$plasma->ReadImage('plasma:fractal');
|
||||
warn "$x" if "$x";
|
||||
$plasma->Label('Plasma');
|
||||
push(@$images,$plasma);
|
||||
|
||||
print "Polaroid...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Polaroid');
|
||||
$example->Polaroid(caption=>'Magick',angle=>-5.0,gravity=>'center');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Posterize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Posterize');
|
||||
$example->Posterize(5);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Quantize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Quantize');
|
||||
$example->Quantize();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Radial Blur...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Radial Blur');
|
||||
$example->RadialBlur(10);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Raise...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Raise');
|
||||
$example->Raise('10x10');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Reduce Noise...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Reduce Noise');
|
||||
$example->ReduceNoise();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Resize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Resize');
|
||||
$example->Resize('60%');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Roll...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Roll');
|
||||
$example->Roll(geometry=>'+20+10');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Rotate...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Rotate');
|
||||
$example->Rotate(45);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Sample...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Sample');
|
||||
$example->Sample('60%');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Scale...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Scale');
|
||||
$example->Scale('60%');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Segment...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Segment');
|
||||
$example->Segment();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Shade...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Shade');
|
||||
$example->Shade(geometry=>'30x30',gray=>'true');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Sharpen...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Sharpen');
|
||||
$example->Sharpen('0.0x1.0');
|
||||
$example->Clamp();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Shave...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Shave');
|
||||
$example->Shave('10x10');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Shear...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Shear');
|
||||
$example->Shear('-20x20');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Sketch...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Sketch');
|
||||
$example->Set(colorspace=>'Gray');
|
||||
$example->Sketch('0x20+120');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Sigmoidal Contrast...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Sigmoidal Contrast');
|
||||
$example->SigmoidalContrast("3x50%");
|
||||
push(@$images,$example);
|
||||
|
||||
print "Spread...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Spread');
|
||||
$example->Spread();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Solarize...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Solarize');
|
||||
$example->Solarize();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Swirl...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Swirl');
|
||||
$example->Swirl(90);
|
||||
push(@$images,$example);
|
||||
|
||||
print "Unsharp Mask...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Unsharp Mask');
|
||||
$example->UnsharpMask('0.0x1.0');
|
||||
$example->Clamp();
|
||||
push(@$images,$example);
|
||||
|
||||
print "Vignette...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Vignette');
|
||||
$example->Vignette('0x20');
|
||||
push(@$images,$example);
|
||||
|
||||
print "Wave...\n";
|
||||
$example=$model->Clone();
|
||||
$example->Label('Wave');
|
||||
$example->Wave('25x150');
|
||||
push(@$images,$example);
|
||||
#
|
||||
# Create image montage.
|
||||
#
|
||||
print "Montage...\n";
|
||||
$montage=$images->Montage(geometry=>'128x160+8+4>',gravity=>'Center',
|
||||
tile=>'5x+10+200',compose=>'over',background=>'#ffffff',
|
||||
font=>'Generic.ttf',pointsize=>18,fill=>'#600',stroke=>'none',
|
||||
shadow=>'true');
|
||||
|
||||
$logo=Image::Magick->new();
|
||||
$logo->Read('logo:');
|
||||
$logo->Zoom('40%');
|
||||
$montage->Composite(image=>$logo,gravity=>'North');
|
||||
|
||||
print "Write...\n";
|
||||
$montage->Set(matte=>'false');
|
||||
$montage->Write('demo.jpg');
|
||||
print "Display...\n";
|
||||
$montage->Write('win:');
|
BIN
ImageMagick/PerlMagick/demo/dst.png
Normal file
After Width: | Height: | Size: 437 B |
83
ImageMagick/PerlMagick/demo/lsys.pl
Normal file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# Written by jreed@itis.com, adapted by John Cristy.
|
||||
|
||||
use Image::Magick;
|
||||
use Turtle;
|
||||
|
||||
sub flower
|
||||
{
|
||||
my $flower = shift;
|
||||
my ($width, $height) = $flower->Get('width', 'height');
|
||||
my ($x, $y) = $turtle->state();
|
||||
my ($geometry);
|
||||
|
||||
$geometry = '+' . int($x-$width/2) . '+' . int($y-$height/2);
|
||||
$im->Composite(image=>$flower, compose=>'over', geometry=>$geometry);
|
||||
}
|
||||
|
||||
sub lsys_init
|
||||
{
|
||||
my ($imagesize) = @_;
|
||||
|
||||
%translate =
|
||||
(
|
||||
'S' => sub{ # Step forward
|
||||
$turtle->forward($changes->{"distance"},
|
||||
$changes->{"motionsub"});
|
||||
},
|
||||
'-' => sub{ $turtle->turn(-$changes->{"dtheta"}); }, # counter-clockwise
|
||||
'+' => sub{ $turtle->turn($changes->{"dtheta"}); }, # Turn clockwise
|
||||
'M' => sub{ $turtle->mirror(); }, # Mirror
|
||||
'[' => sub{ push(@statestack, [$turtle->state()]); }, # Begin branch
|
||||
']' => sub{ $turtle->setstate(@{pop(@statestack)}); }, # End branch
|
||||
'{' => sub{ @poly = (); $changes=\%polychanges; }, # Begin polygon
|
||||
'}' => sub{ # End polygon
|
||||
$im->Draw (primitive=>'Polygon', points=>join(' ',@poly),
|
||||
fill=>'light green');
|
||||
$changes = \%stemchanges;
|
||||
},
|
||||
'f' => sub{ flower($pink_flower); }, # Flower
|
||||
'g' => sub{ flower($red_flower); }, # Flower
|
||||
'h' => sub{ flower($yellow_flower); } # Flower
|
||||
);
|
||||
|
||||
# Create the main image
|
||||
$im = new Image::Magick;
|
||||
$im->Set(size=>$imagesize . 'x' . $imagesize);
|
||||
$im->Read('xc:white');
|
||||
|
||||
# Create the flower images
|
||||
$pink_flower = new Image::Magick;
|
||||
$pink_flower->Read('pink-flower.gif');
|
||||
|
||||
$red_flower = new Image::Magick;
|
||||
$red_flower->Read('red-flower.gif');
|
||||
|
||||
$yellow_flower = new Image::Magick;
|
||||
$yellow_flower->Read('yellow-flower.gif');
|
||||
|
||||
# Turtle: the midpoint of the bottom edge of the image, pointing up.
|
||||
$turtle=new Turtle($imagesize/2, $imagesize, 0, 1);
|
||||
}
|
||||
|
||||
sub lsys_execute
|
||||
{
|
||||
my ($string, $repetitions, $filename, %rule) = @_;
|
||||
|
||||
my ($command);
|
||||
|
||||
# Apply the %rule to $string, $repetitions times.
|
||||
for (1..$repetitions)
|
||||
{
|
||||
$string =~ s/./defined ($rule{$&}) ? $rule{$&} : $&/eg;
|
||||
}
|
||||
foreach $command (split(//, $string))
|
||||
{
|
||||
if ($translate{$command}) { &{$translate{$command}}(); }
|
||||
}
|
||||
$im->Write($filename);
|
||||
$im->Write('win:');
|
||||
}
|
||||
|
||||
1;
|
BIN
ImageMagick/PerlMagick/demo/model.gif
Normal file
After Width: | Height: | Size: 23 KiB |
66
ImageMagick/PerlMagick/demo/piddle.pl
Normal file
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/perl
|
||||
# Piddle example using PerlMagick methods.
|
||||
|
||||
use Image::Magick;
|
||||
|
||||
#
|
||||
# Create white canvas.
|
||||
#
|
||||
$image=Image::Magick->new(size=>'300x300');
|
||||
$image->Read('xc:white');
|
||||
#
|
||||
# Draw blue grid
|
||||
#
|
||||
for ($i=0; $i < 300; $i+=10)
|
||||
{
|
||||
$image->Draw(primitive=>'line',points=>"$i,0 $i,300",stroke=>"#ccf");
|
||||
$image->Draw(primitive=>'line',points=>"0,$i 300,$i",stroke=>"#ccf");
|
||||
}
|
||||
#
|
||||
# Draw rounded rectangle.
|
||||
#
|
||||
$image->Draw(primitive=>'RoundRectangle',fill=>'blue',stroke=>'maroon',
|
||||
strokewidth=>4,points=>'30,30 100,100 10,10');
|
||||
#
|
||||
# Draw curve.
|
||||
#
|
||||
$image->Draw(primitive=>'bezier',points=>'20,20, 100,50, 50,100, 160,160',
|
||||
fill=>'none',stroke=>'black',strokewidth=>4);
|
||||
#
|
||||
# Draw line.
|
||||
#
|
||||
$image->Draw(primitive=>'line',points=>"10,200 20,190",stroke=>red);
|
||||
#
|
||||
# Draw arc within a circle.
|
||||
#
|
||||
$image->Draw(primitive=>'circle',stroke=>'none',fill=>'yellow',,
|
||||
points=>"170,70 200,70");
|
||||
$image->Draw(primitive=>'Path',stroke=>'none',fill=>'blue',strokewidth=>4,
|
||||
points=>'M170,70 v-30 a30,30 0 0,0 -30,30 z');
|
||||
$image->Draw(primitive=>'circle',stroke=>'black',fill=>'none',strokewidth=>4,
|
||||
points=>"170,70 200,70");
|
||||
#
|
||||
# Draw pentogram.
|
||||
#
|
||||
$image->Draw(primitive=>'polygon',
|
||||
points=>"160,120 130,190 210,145 110,145 190,190 160,120",stroke=>red,
|
||||
fill=>LimeGreen,strokewidth=>3);
|
||||
#
|
||||
# Draw rectangle.
|
||||
#
|
||||
$image->Draw(primitive=>'line',points=>'200,260 200,200',stroke=>yellow,
|
||||
strokewidth=>5);
|
||||
$image->Draw(primitive=>'line',points=>'200,200 260,200',stroke=>yellow,
|
||||
strokewidth=>5);
|
||||
$image->Draw(primitive=>'line',points=>'260,200 260,260',stroke=>red,
|
||||
strokewidth=>5);
|
||||
$image->Draw(primitive=>'line',points=>'200,260 260,260',stroke=>green,
|
||||
strokewidth=>5);
|
||||
#
|
||||
# Draw text.
|
||||
#
|
||||
$image->Annotate(text=>'This is a test!',geometry=>'+30+140',
|
||||
font=>'Generic.ttf',fill=>'green',pointsize=>24,rotate=>45.0);
|
||||
$image->Write('piddle.gif');
|
||||
$image->Write('piddle.mvg');
|
||||
$image->Write('win:');
|
BIN
ImageMagick/PerlMagick/demo/pink-flower.gif
Normal file
After Width: | Height: | Size: 544 B |
53
ImageMagick/PerlMagick/demo/pixel-fx.pl
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Example of modifying all the pixels in an image (like -fx).
|
||||
#
|
||||
# Currently this is slow as each pixel is being lokedup one pixel at a time.
|
||||
# The better technique of extracting and modifing a whole row of pixels at
|
||||
# a time has not been figured out, though perl functions have been provided
|
||||
# for this.
|
||||
#
|
||||
# Also access and controls for Area Re-sampling (EWA), beyond single pixel
|
||||
# lookup (interpolated unscaled lookup), is also not available at this time.
|
||||
#
|
||||
# Anthony Thyssen 5 October 2007
|
||||
#
|
||||
use strict;
|
||||
use Image::Magick;
|
||||
|
||||
# read original image
|
||||
my $orig = Image::Magick->new();
|
||||
my $w = $orig->Read('rose:');
|
||||
warn("$w") if $w;
|
||||
exit if $w =~ /^Exception/;
|
||||
|
||||
|
||||
# make a clone of the image (preserve input, modify output)
|
||||
my $dest = $orig->Clone();
|
||||
|
||||
# You could enlarge destination image here if you like.
|
||||
# And it is posible to modify the existing image directly
|
||||
# rather than modifying a clone as FX does.
|
||||
|
||||
# Iterate over destination image...
|
||||
my ($width, $height) = $dest->Get('width', 'height');
|
||||
|
||||
for( my $j = 0; $j < $height; $j++ ) {
|
||||
for( my $i = 0; $i < $width; $i++ ) {
|
||||
|
||||
# read original image color
|
||||
my @pixel = $orig->GetPixel( x=>$i, y=>$j );
|
||||
|
||||
# modify the pixel values (as normalized floats)
|
||||
$pixel[0] = $pixel[0]/2; # darken red
|
||||
|
||||
# write pixel to destination
|
||||
# (quantization and clipping happens here)
|
||||
$dest->SetPixel(x=>$i,y=>$j,color=>\@pixel);
|
||||
}
|
||||
}
|
||||
|
||||
# display the result (or you could save it)
|
||||
$dest->Write('win:');
|
||||
$dest->Write('pixel-fx.gif');
|
||||
|
BIN
ImageMagick/PerlMagick/demo/red-flower.gif
Normal file
After Width: | Height: | Size: 694 B |
32
ImageMagick/PerlMagick/demo/settings.pl
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# An example of applying many settings in preparation for image creation.
|
||||
#
|
||||
# Extracted from PerlMagick Discussion forums..
|
||||
# Gravity center, caption and wrapped text
|
||||
# http://www.imagemagick.org/discourse-server/viewtopic.php?f=7&t=17282
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
use Image::Magick;
|
||||
|
||||
my $im = new Image::Magick;
|
||||
my $e = $im->Set(
|
||||
background => 'none',
|
||||
fill => 'white',
|
||||
stroke => 'black',
|
||||
strokewidth => 2,
|
||||
Gravity => 'East',
|
||||
pointsize => 48,
|
||||
size => '200x300',
|
||||
);
|
||||
die $e if $e;
|
||||
|
||||
$e = $im->Read("caption:Lorem ipsum etc etc");
|
||||
die $e if $e;
|
||||
|
||||
$e = $im->Trim();
|
||||
die $e if $e;
|
||||
|
||||
$e = $im->Write('settings.png');
|
||||
die $e if $e;
|
15
ImageMagick/PerlMagick/demo/shadow-text.pl
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Make simple text with a shadow.
|
||||
#
|
||||
use Image::Magick;
|
||||
|
||||
$image=Image::Magick->new(size=>'500x120');
|
||||
$image->Read('xc:white');
|
||||
$image->Annotate(font=>'Generic.ttf',fill=>'rgba(100,100,100,0.8)',
|
||||
pointsize=>60, text=>'Works like magick!',geometry=>'+30+90');
|
||||
$image->Blur('0x1');
|
||||
$image->Annotate(font=>'Generic.ttf',fill=>'red',stroke=>'blue',pointsize=>60,
|
||||
text=>'Works like magick!',geometry=>'+26+86');
|
||||
$image->Write('shadow.gif');
|
||||
$image->Write('win:');
|
40
ImageMagick/PerlMagick/demo/shapes.pl
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/perl
|
||||
# GD example using PerlMagick methods.
|
||||
|
||||
use Image::Magick;
|
||||
|
||||
#
|
||||
# Create a 300x300 white canvas.
|
||||
#
|
||||
$image=Image::Magick->new;
|
||||
$image->Set(size=>'300x300');
|
||||
$image->Read('xc:white');
|
||||
#
|
||||
# Draw shapes.
|
||||
#
|
||||
$tile=Image::Magick->new;
|
||||
$tile->Read('tile.gif');
|
||||
$image->Draw(primitive=>'Polygon',tile=>$tile,fill=>'none',
|
||||
points=>'30,30 100,10 190,290 30,290');
|
||||
$image->Draw(stroke=>'red',primitive=>'Ellipse',stroke=>'black',fill=>'red',
|
||||
strokewidth=>5,points=>'100,100 50,75 0,360');
|
||||
$image->Draw(primitive=>'Polygon',fill=>'none',stroke=>'black',strokewidth=>5,
|
||||
points=>'30,30 100,10 190,290 30,290');
|
||||
$image->FloodfillPaint(geometry=>'+132+62',fill=>'blue',bordercolor=>'black',
|
||||
invert=>'true');
|
||||
#
|
||||
# Draw text.
|
||||
#
|
||||
$image->Annotate(fill=>'red',geometry=>'+150+20',font=>'Generic.ttf',
|
||||
pointsize=>18,text=>'Hello world!');
|
||||
$image->Annotate(fill=>'blue',geometry=>'+150+38',font=>'Generic.ttf',
|
||||
pointsize=>14,text=>'Goodbye cruel world!');
|
||||
$image->Annotate(fill=>'black',geometry=>'+280+120',font=>'Generic.ttf',
|
||||
pointsize=>14,text=>"I'm climbing the wall!",rotate=>90.0);
|
||||
#
|
||||
# Write image.
|
||||
#
|
||||
print "Write image...\n";
|
||||
$image->Write('shapes.gif');
|
||||
print "Display image...\n";
|
||||
$image->Write('win:');
|
48
ImageMagick/PerlMagick/demo/single-pixels.pl
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Methods for to Get and Set single pixels in images using PerlMagick
|
||||
#
|
||||
use strict;
|
||||
use Image::Magick;
|
||||
|
||||
# read image
|
||||
my $im=Image::Magick->new();
|
||||
$im->Read('logo:');
|
||||
|
||||
# ---
|
||||
|
||||
# Get/Set a single pixel as a string
|
||||
my $skin=$im->Get('pixel[400,200]');
|
||||
print "Get('pixel[x,y]') = ", $skin, "\n";
|
||||
|
||||
$im->Set('pixel[1,1]'=>'0,0,0,0');
|
||||
$im->Set('pixel[2,1]'=>$skin);
|
||||
$im->Set('pixel[3,1]'=>'green');
|
||||
$im->Set('pixel[4,1]'=>'rgb(255,0,255)');
|
||||
|
||||
# ---
|
||||
|
||||
# More direct single pixel access
|
||||
my @pixel = $im->GetPixel( x=>400, y=>200 );
|
||||
print "GetPixel() = ", "@pixel", "\n";
|
||||
|
||||
# modify the pixel values (as normalized floats)
|
||||
$pixel[0] = $pixel[0]/2; # darken red value
|
||||
$pixel[1] = 0.0; # junk green value
|
||||
$pixel[2] = 0.0; # junk blue value
|
||||
|
||||
# write pixel to destination
|
||||
# (quantization and clipping happens here)
|
||||
$im->SetPixel(x=>5,y=>1,color=>\@pixel);
|
||||
|
||||
# ---
|
||||
|
||||
# crop, scale, display the changed pixels
|
||||
$im->Crop(geometry=>'7x3+0+0');
|
||||
$im->Set(page=>'0x0+0+0');
|
||||
$im->Scale('1000%');
|
||||
|
||||
# Output the changed pixels
|
||||
$im->Write('win:');
|
||||
$im->Write('single-pixels.gif');
|
||||
|
BIN
ImageMagick/PerlMagick/demo/smile.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
ImageMagick/PerlMagick/demo/src.png
Normal file
After Width: | Height: | Size: 400 B |
26
ImageMagick/PerlMagick/demo/steganography.pl
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use Image::Magick;
|
||||
|
||||
#
|
||||
# Hide an image within an image
|
||||
#
|
||||
$watermark=Image::Magick->new;
|
||||
$watermark->ReadImage('smile.gif');
|
||||
($width, $height)=$watermark->Get('width','height');
|
||||
#
|
||||
# Hide image in image.
|
||||
#
|
||||
$image=Image::Magick->new;
|
||||
$image->ReadImage('model.gif');
|
||||
$image->SteganoImage(image=>$watermark,offset=>91);
|
||||
$image->Write('model.png');
|
||||
$image->Write('win:');
|
||||
#
|
||||
# Extract image from image.
|
||||
#
|
||||
$size="$width" . "x" . "$height" . "+91";
|
||||
$stegano=Image::Magick->new(size=>$size);
|
||||
$stegano->ReadImage('stegano:model.png');
|
||||
$stegano->Write('stegano.gif');
|
||||
$stegano->Write('win:');
|
BIN
ImageMagick/PerlMagick/demo/tile.gif
Normal file
After Width: | Height: | Size: 1.5 KiB |
33
ImageMagick/PerlMagick/demo/tree.pl
Normal file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Example of using a lsys fractal,
|
||||
# which in turm used Turtle Graphics
|
||||
#
|
||||
require "lsys.pl";
|
||||
|
||||
%rule = (
|
||||
'A' => 'S[---LMA][++++B]',
|
||||
'B' => 'S[++LBg][--Cg]',
|
||||
'C' => 'S[-----LB]GS[+MC]',
|
||||
'g' => '',
|
||||
'L' => '[{S+S+S+S+S+S}]'
|
||||
);
|
||||
|
||||
%stemchanges = (
|
||||
distance => 18.5,
|
||||
dtheta => 0.1,
|
||||
motionsub => sub{
|
||||
$im->Draw ( primitive=>'line', points=>join(' ',@_),
|
||||
stroke=>'dark green', strokewidth=>1 );
|
||||
}
|
||||
);
|
||||
|
||||
%polychanges = (
|
||||
distance => 3,
|
||||
dtheta => 0.4,
|
||||
motionsub => sub{ push( @poly, @_[0..1] ); }
|
||||
);
|
||||
|
||||
$changes = \%stemchanges;
|
||||
lsys_init(400);
|
||||
lsys_execute('A', 10, "tree.gif", %rule);
|
BIN
ImageMagick/PerlMagick/demo/yellow-flower.gif
Normal file
After Width: | Height: | Size: 565 B |