view release on metacpan or search on metacpan
package Image::Magick;
# Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization
# dedicated to making software imaging solutions freely available.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at
#
# https://imagemagick.org/script/license.php
#
# Unless required by applicable law or agreed to in writing, software
}
else {
my($pack,$file,$line) = caller;
die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}
bootstrap Image::Magick $VERSION;
# Preloaded methods go here.
sub new
{
my $this = shift;
my $class = ref($this) || $this || "Image::Magick";
my $self = [ ];
bless $self, $class;
$self->set(@_) if @_;
return $self;
}
sub New
{
my $this = shift;
my $class = ref($this) || $this || "Image::Magick";
my $self = [ ];
bless $self, $class;
$self->set(@_) if @_;
return $self;
}
# Autoload methods go after =cut, and are processed by the autosplit program.
END { UNLOAD () };
1;
__END__
=head1 NAME
Image::Magick - objected-oriented Perl interface to ImageMagick. Use it to read, manipulate, or write an image or image sequence from within a Perl script.
=head1 SYNOPSIS
use Image::Magick;
$p = new Image::Magick;
$p->Read("imagefile");
$p->Set(attribute => value, ...)
($a, ...) = $p->Get("attribute", ...)
$p->routine(parameter => value, ...)
$p->Mogrify("Routine", parameter => value, ...)
$p->Write("filename");
=head1 DESCRIPTION
This Perl extension allows the reading, manipulation and writing of
Magick.pm.in view on Meta::CPAN
package Image::Magick;
# Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
# dedicated to making software imaging solutions freely available.
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at
#
# http://www.imagemagick.org/script/license.php
#
# Unless required by applicable law or agreed to in writing, software
Magick.pm.in view on Meta::CPAN
}
else {
my($pack,$file,$line) = caller;
die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
}
}
eval "sub $AUTOLOAD { $val }";
goto &$AUTOLOAD;
}
bootstrap Image::Magick $VERSION;
# Preloaded methods go here.
sub new
{
my $this = shift;
my $class = ref($this) || $this || "Image::Magick";
my $self = [ ];
bless $self, $class;
$self->set(@_) if @_;
return $self;
}
sub New
{
my $this = shift;
my $class = ref($this) || $this || "Image::Magick";
my $self = [ ];
bless $self, $class;
$self->set(@_) if @_;
return $self;
}
# Autoload methods go after =cut, and are processed by the autosplit program.
END { UNLOAD () };
1;
__END__
=head1 NAME
Image::Magick - objected-oriented Perl interface to ImageMagick. Use it to read, manipulate, or write an image or image sequence from within a Perl script.
=head1 SYNOPSIS
use Image::Magick;
$p = new Image::Magick;
$p->Read("imagefile");
$p->Set(attribute => value, ...)
($a, ...) = $p->Get("attribute", ...)
$p->routine(parameter => value, ...)
$p->Mogrify("Routine", parameter => value, ...)
$p->Write("filename");
=head1 DESCRIPTION
This Perl extension allows the reading, manipulation and writing of
#define dTHX
#endif
#define DegreesToRadians(x) (MagickPI*(x)/180.0)
#define EndOf(array) (&array[NumberOf(array)])
#define MagickPI 3.14159265358979323846264338327950288419716939937510
#define MaxArguments 34
#ifndef na
#define na PL_na
#endif
#define NumberOf(array) (sizeof(array)/sizeof(*array))
#define PackageName "Image::Magick"
#if PERL_VERSION <= 6
#define PerlIO FILE
#define PerlIO_importFILE(f, fl) (f)
#define PerlIO_findFILE(f) NULL
#endif
#ifndef sv_undef
#define sv_undef PL_sv_undef
#endif
#define AddImageToRegistry(sv,image) \
length;
};
struct PackageInfo
{
ImageInfo
*image_info;
};
typedef void
*Image__Magick; /* data type for the Image::Magick package */
/*
Static declarations.
*/
static struct
Methods
{
const char
*name;
% %
% %
% I m a g e : : M a g i c k %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
*/
MODULE = Image::Magick PACKAGE = Image::Magick
PROTOTYPES: ENABLE
BOOT:
MagickCoreGenesis("PerlMagick",MagickFalse);
SetWarningHandler(NULL);
SetErrorHandler(NULL);
magick_registry=NewSplayTree((int (*)(const void *,const void *))
NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
# #
# A n i m a t e #
# #
# #
# #
###############################################################################
#
#
void
Animate(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
AnimateImage = 1
animate = 2
animateimage = 3
PPCODE:
{
ExceptionInfo
*exception;
Image
# #
# A p p e n d #
# #
# #
# #
###############################################################################
#
#
void
Append(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
AppendImage = 1
append = 2
appendimage = 3
PPCODE:
{
AV
*av;
char
# #
# A v e r a g e #
# #
# #
# #
###############################################################################
#
#
void
Average(ref)
Image::Magick ref=NO_INIT
ALIAS:
AverageImage = 1
average = 2
averageimage = 3
PPCODE:
{
AV
*av;
char
# #
# B l o b T o I m a g e #
# #
# #
# #
###############################################################################
#
#
void
BlobToImage(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
BlobToImage = 1
blobtoimage = 2
blobto = 3
PPCODE:
{
AV
*av;
char
# #
# C h a n n e l F x #
# #
# #
# #
###############################################################################
#
#
void
ChannelFx(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
ChannelFxImage = 1
channelfx = 2
channelfximage = 3
PPCODE:
{
AV
*av;
char
# #
# C l o n e #
# #
# #
# #
###############################################################################
#
#
void
Clone(ref)
Image::Magick ref=NO_INIT
ALIAS:
CopyImage = 1
copy = 2
copyimage = 3
CloneImage = 4
clone = 5
cloneimage = 6
Clone = 7
PPCODE:
{
# #
# C o a l e s c e #
# #
# #
# #
###############################################################################
#
#
void
Coalesce(ref)
Image::Magick ref=NO_INIT
ALIAS:
CoalesceImage = 1
coalesce = 2
coalesceimage = 3
PPCODE:
{
AV
*av;
ExceptionInfo
# #
# C o m p a r e #
# #
# #
# #
###############################################################################
#
#
void
Compare(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
CompareImages = 1
compare = 2
compareimage = 3
PPCODE:
{
AV
*av;
char
# #
# C o m p l e x I m a g e s #
# #
# #
# #
###############################################################################
#
#
void
ComplexImages(ref)
Image::Magick ref=NO_INIT
ALIAS:
ComplexImages = 1
compleximages = 2
PPCODE:
{
AV
*av;
char
*attribute,
# #
# C o m p a r e L a y e r s #
# #
# #
# #
###############################################################################
#
#
void
CompareLayers(ref)
Image::Magick ref=NO_INIT
ALIAS:
CompareImagesLayers = 1
comparelayers = 2
compareimagelayers = 3
PPCODE:
{
AV
*av;
char
# #
# D e s t r o y #
# #
# #
# #
###############################################################################
#
#
void
DESTROY(ref)
Image::Magick ref=NO_INIT
PPCODE:
{
SV
*reference;
PERL_UNUSED_VAR(ref);
if (sv_isobject(ST(0)) == 0)
croak("ReferenceIsNotMyType");
reference=SvRV(ST(0));
switch (SvTYPE(reference))
# #
# D i s p l a y #
# #
# #
# #
###############################################################################
#
#
void
Display(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
DisplayImage = 1
display = 2
displayimage = 3
PPCODE:
{
ExceptionInfo
*exception;
Image
# #
# E v a l u a t e I m a g e s #
# #
# #
# #
###############################################################################
#
#
void
EvaluateImages(ref)
Image::Magick ref=NO_INIT
ALIAS:
EvaluateImages = 1
evaluateimages = 2
PPCODE:
{
AV
*av;
char
*attribute,
# #
# F e a t u r e s #
# #
# #
# #
###############################################################################
#
#
void
Features(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
FeaturesImage = 1
features = 2
featuresimage = 3
PPCODE:
{
#define ChannelFeatures(channel,direction) \
{ \
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
channel_features[channel].angular_second_moment[direction]); \
# #
# F l a t t e n #
# #
# #
# #
###############################################################################
#
#
void
Flatten(ref)
Image::Magick ref=NO_INIT
ALIAS:
FlattenImage = 1
flatten = 2
flattenimage = 3
PPCODE:
{
AV
*av;
char
# #
# F x #
# #
# #
# #
###############################################################################
#
#
void
Fx(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
FxImage = 1
fx = 2
fximage = 3
PPCODE:
{
AV
*av;
char
# #
# G e t #
# #
# #
# #
###############################################################################
#
#
void
Get(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
GetAttributes = 1
GetAttribute = 2
get = 3
getattributes = 4
getattribute = 5
PPCODE:
{
char
*attribute,
# #
# G e t A u t h e n t i c P i x e l s #
# #
# #
# #
###############################################################################
#
#
void *
GetAuthenticPixels(ref,...)
Image::Magick ref = NO_INIT
ALIAS:
getauthenticpixels = 1
GetImagePixels = 2
getimagepixels = 3
CODE:
{
char
*attribute;
ExceptionInfo
# #
# G e t V i r t u a l P i x e l s #
# #
# #
# #
###############################################################################
#
#
void *
GetVirtualPixels(ref,...)
Image::Magick ref = NO_INIT
ALIAS:
getvirtualpixels = 1
AcquireImagePixels = 2
acquireimagepixels = 3
CODE:
{
char
*attribute;
const void
# #
# G e t A u t h e n t i c M e t a c o n t e n t #
# #
# #
# #
###############################################################################
#
#
void *
GetAuthenticMetacontent(ref,...)
Image::Magick ref = NO_INIT
ALIAS:
getauthenticmetacontent = 1
GetMetacontent = 2
getmetacontent = 3
CODE:
{
ExceptionInfo
*exception;
Image
# #
# G e t V i r t u a l M e t a c o n t e n t #
# #
# #
# #
###############################################################################
#
#
void *
GetVirtualMetacontent(ref,...)
Image::Magick ref = NO_INIT
ALIAS:
getvirtualmetacontent = 1
CODE:
{
ExceptionInfo
*exception;
Image
*image;
# #
# H i s t o g r a m #
# #
# #
# #
###############################################################################
#
#
void
Histogram(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
HistogramImage = 1
histogram = 2
histogramimage = 3
PPCODE:
{
AV
*av;
char
# #
# G e t P i x e l #
# #
# #
# #
###############################################################################
#
#
void
GetPixel(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
getpixel = 1
getPixel = 2
PPCODE:
{
AV
*av;
char
*attribute;
# #
# G e t P i x e l s #
# #
# #
# #
###############################################################################
#
#
void
GetPixels(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
getpixels = 1
getPixels = 2
PPCODE:
{
AV
*av;
char
*attribute;
# #
# I m a g e T o B l o b #
# #
# #
# #
###############################################################################
#
#
void
ImageToBlob(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
ImageToBlob = 1
imagetoblob = 2
toblob = 3
blob = 4
PPCODE:
{
char
filename[MagickPathExtent];
# #
# L a y e r s #
# #
# #
# #
###############################################################################
#
#
void
Layers(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
Layers = 1
layers = 2
OptimizeImageLayers = 3
optimizelayers = 4
optimizeimagelayers = 5
PPCODE:
{
AV
*av;
# #
# M a g i c k T o M i m e #
# #
# #
# #
###############################################################################
#
#
SV *
MagickToMime(ref,name)
Image::Magick ref=NO_INIT
char *name
ALIAS:
magicktomime = 1
CODE:
{
char
*mime;
PERL_UNUSED_VAR(ref);
PERL_UNUSED_VAR(ix);
# #
# M o g r i f y #
# #
# #
# #
###############################################################################
#
#
void
Mogrify(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
Comment = 1
CommentImage = 2
Label = 3
LabelImage = 4
AddNoise = 5
AddNoiseImage = 6
Colorize = 7
ColorizeImage = 8
Border = 9
# #
# M o n t a g e #
# #
# #
# #
###############################################################################
#
#
void
Montage(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
MontageImage = 1
montage = 2
montageimage = 3
PPCODE:
{
AV
*av;
char
# #
# M o r p h #
# #
# #
# #
###############################################################################
#
#
void
Morph(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
MorphImage = 1
morph = 2
morphimage = 3
PPCODE:
{
AV
*av;
char
# #
# M o s a i c #
# #
# #
# #
###############################################################################
#
#
void
Mosaic(ref)
Image::Magick ref=NO_INIT
ALIAS:
MosaicImage = 1
mosaic = 2
mosaicimage = 3
PPCODE:
{
AV
*av;
ExceptionInfo
# #
# P i n g #
# #
# #
# #
###############################################################################
#
#
void
Ping(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
PingImage = 1
ping = 2
pingimage = 3
PPCODE:
{
AV
*av;
char
# #
# P r e v i e w #
# #
# #
# #
###############################################################################
#
#
void
Preview(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
PreviewImage = 1
preview = 2
previewimage = 3
PPCODE:
{
AV
*av;
ExceptionInfo
# #
# Q u e r y C o l o r #
# #
# #
# #
###############################################################################
#
#
void
QueryColor(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
querycolor = 1
PPCODE:
{
char
*name;
ExceptionInfo
*exception;
# #
# Q u e r y C o l o r N a m e #
# #
# #
# #
###############################################################################
#
#
void
QueryColorname(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
querycolorname = 1
PPCODE:
{
AV
*av;
char
message[MagickPathExtent];
# #
# Q u e r y F o n t #
# #
# #
# #
###############################################################################
#
#
void
QueryFont(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
queryfont = 1
PPCODE:
{
char
*name,
message[MagickPathExtent];
ExceptionInfo
*exception;
# #
# Q u e r y F o n t M e t r i c s #
# #
# #
# #
###############################################################################
#
#
void
QueryFontMetrics(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
queryfontmetrics = 1
PPCODE:
{
AffineMatrix
affine,
current;
AV
*av;
# #
# Q u e r y M u l t i l i n e F o n t M e t r i c s #
# #
# #
# #
###############################################################################
#
#
void
QueryMultilineFontMetrics(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
querymultilinefontmetrics = 1
PPCODE:
{
AffineMatrix
affine,
current;
AV
*av;
# #
# Q u e r y F o r m a t #
# #
# #
# #
###############################################################################
#
#
void
QueryFormat(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
queryformat = 1
PPCODE:
{
char
*name;
ExceptionInfo
*exception;
# #
# Q u e r y O p t i o n #
# #
# #
# #
###############################################################################
#
#
void
QueryOption(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
queryoption = 1
PPCODE:
{
char
**options;
ExceptionInfo
*exception;
# #
# R e a d #
# #
# #
# #
###############################################################################
#
#
void
Read(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
ReadImage = 1
read = 2
readimage = 3
PPCODE:
{
AV
*av;
char
# #
# R e m o t e #
# #
# #
# #
###############################################################################
#
#
void
Remote(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
RemoteCommand = 1
remote = 2
remoteCommand = 3
PPCODE:
{
AV
*av;
ExceptionInfo
# #
# S e t #
# #
# #
# #
###############################################################################
#
#
void
Set(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
SetAttributes = 1
SetAttribute = 2
set = 3
setattributes = 4
setattribute = 5
PPCODE:
{
ExceptionInfo
*exception;
# #
# S e t P i x e l #
# #
# #
# #
###############################################################################
#
#
void
SetPixel(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
setpixel = 1
setPixel = 2
PPCODE:
{
AV
*av;
char
*attribute;
# #
# S e t P i x e l s #
# #
# #
# #
###############################################################################
#
#
void
SetPixels(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
setpixels = 1
setPixels = 2
PPCODE:
{
AV
*av;
char
*attribute;
# #
# S m u s h #
# #
# #
# #
###############################################################################
#
#
void
Smush(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
SmushImage = 1
smush = 2
smushimage = 3
PPCODE:
{
AV
*av;
char
# #
# S t a t i s t i c s #
# #
# #
# #
###############################################################################
#
#
void
Statistics(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
StatisticsImage = 1
statistics = 2
statisticsimage = 3
PPCODE:
{
#define ChannelStatistics(channel) \
{ \
(void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
(double) channel_statistics[channel].depth); \
# #
# S y n c A u t h e n t i c P i x e l s #
# #
# #
# #
###############################################################################
#
#
void
SyncAuthenticPixels(ref,...)
Image::Magick ref = NO_INIT
ALIAS:
Syncauthenticpixels = 1
SyncImagePixels = 2
syncimagepixels = 3
CODE:
{
ExceptionInfo
*exception;
Image
# #
# W r i t e #
# #
# #
# #
###############################################################################
#
#
void
Write(ref,...)
Image::Magick ref=NO_INIT
ALIAS:
WriteImage = 1
write = 2
writeimage = 3
PPCODE:
{
char
filename[MagickPathExtent];
ExceptionInfo
Makefile.PL view on Meta::CPAN
$LDDLFLAGS_magick = "$Config{'lddlflags'} $Lpaths ";
}
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile
(
# Module description
'ABSTRACT' => 'ImageMagick PERL Extension',
# Perl module name is Image::Magick
'NAME' => 'Image::Magick',
# Module author
'AUTHOR' => 'ImageMagick Studio LLC',
# Module version
'VERSION' => '7.0.10',
# Prerequisite version
'PREREQ_PM' => {'parent' => '0'},
Makefile.PL.in view on Meta::CPAN
$LDDLFLAGS_magick = "$Config{'lddlflags'} $Lpaths ";
}
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile
(
# Module description
'ABSTRACT' => 'ImageMagick PERL Extension',
# Perl module name is Image::Magick
'NAME' => 'Image::Magick',
# Module author
'AUTHOR' => 'ImageMagick Studio LLC',
# Module version
'VERSION' => '@PACKAGE_BASE_VERSION@',
# Prerequisite version
'PREREQ_PM' => {'parent' => '0'},
Makefile.nt view on Meta::CPAN
#
# Visual Studio 7.1 default install:
# libpth='"C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib" "C:\Perl\lib\CORE"'
#
# Visual Studio 9.0 default install (C:\Perl\lib\Config.pm):
# libpth='"C:\Program Files\Microsoft Visual Studio 9.0\VC\lib" "C:\Perl\lib\CORE"'
#
WriteMakefile(
'ABSTRACT' => 'ImageMagick PERL Extension',
'AUTHOR' => 'ImageMagick Studio',
'NAME' => 'Image::Magick',
'VERSION_FROM' => 'Magick.pm', # finds $VERSION
'LIBS' => ['-L..\..\VisualMagick\lib -L..\..\VisualMagick\bin -lCORE_RL_MagickCore_.lib -lCORE_DB_MagickCore_.lib'],
'DEFINE' => '-D_VISUALC_ -D_WINDOWS', # e.g., '-DHAVE_SOMETHING'
'INC' => '-I.. -I..\xlib\include',
'BINARY_LOCATION' => 'x86/Image-Magick.tar.gz',
'dist' => {ZIP => "zip.exe", ZIPFLAGS=>"-r"},
'clean' => {FILES => "Image-Magick.ppd Image-Magick.tar.gz PerlMagick.zip " },
($Config{'archname'} =~ /-object$/i ? ('CAPI' => 'TRUE') : ()),
);
3) During installation select that you want to install ImageMagick's
development files (libraries+headers)
4) You NEED TO have ImageMagick's directory in your PATH. Note: we are
checking the presence of convert.exe or identify.exe tools
5) You might need Visual C++ Redistributable Package installed on your
system. See instructions on ImageMagick's Binary Release webpage.
6) If you have all prerequisites 1)...5) you can simply install
ImageMagick by running: cpan -i Image::Magick
Testing PerlMagick
Before PerlMagick is installed, you may want to execute
make test
to verify that PERL can load the PerlMagick extension ok. Chances are
some of the tests will fail if you do not have the proper delegates
cd demo
make
Example Perl Magick Script
Here is an example script to get you started:
#!/usr/bin/perl
use Image::Magick;
$q = Image::Magick->new;
$x = $q->Read("model.gif", "logo.gif", "rose.gif");
warn "$x" if $x;
$x = $q->Crop(geom=>'100x100+100+100');
warn "$x" if $x;
$x = $q->Write("x.gif");
warn "$x" if $x;
The script reads three images, crops them, and writes a single image
demo/annotate.pl view on Meta::CPAN
#!/usr/bin/perl
use Image::Magick;
$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);
$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);
demo/annotate_words.pl view on Meta::CPAN
#
# 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){
demo/button.pl view on Meta::CPAN
#!/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',fill=>'black',gravity=>'Center',pointsize=>18);
$q->Write('button.gif');
$q->Write('win:');
demo/compose-specials.pl view on Meta::CPAN
#
# Essentially 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=>'80x80');
$circle->Read('xc:black');
$circle->Draw(fill=>'white',primitive=>'circle',points=>'39.5,39.5 10,39.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(
demo/composite.pl view on Meta::CPAN
#!/usr/bin/perl
use Image::Magick;
$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,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);
demo/demo.pl view on Meta::CPAN
#!/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');
demo/demo.pl view on Meta::CPAN
$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');
demo/demo.pl view on Meta::CPAN
$example->Normalize();
push(@$images,$example);
print "Oil Paint...\n";
$example=$model->Clone();
$example->Label('Oil Paint');
$example->OilPaint('2x0.5');
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');
demo/demo.pl view on Meta::CPAN
push(@$images,$example);
#
# Create image montage.
#
print "Montage...\n";
$montage=$images->Montage(geometry=>'140x160+8+4>',gravity=>'Center',
tile=>'5x+10+200',compose=>'over',background=>'#ffffff',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:');
demo/lsys.pl view on Meta::CPAN
#!/usr/bin/perl
# Written by jreed@itis.com, adapted by 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);
demo/lsys.pl view on Meta::CPAN
$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) = @_;
demo/piddle.pl view on Meta::CPAN
#!/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");
}
#
demo/pixel-fx.pl view on Meta::CPAN
# 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
demo/settings.pl view on Meta::CPAN
#!/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
# https://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;
demo/shadow-text.pl view on Meta::CPAN
#!/usr/bin/perl
#
# Make simple text with a shadow.
#
use Image::Magick;
$image=Image::Magick->new(size=>'525x125');
$image->Read('xc:white');
$image->Annotate(fill=>'rgba(100,100,100,0.8)',pointsize=>60,
text=>'Works like magick!',geometry=>'+8+90');
$image->Blur('0x1');
$image->Annotate(fill=>'red',stroke=>'blue',pointsize=>60,
text=>'Works like magick!',geometry=>'+4+86');
$image->Write('shadow.gif');
$image->Write('win:');
demo/shapes.pl view on Meta::CPAN
#!/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');
#
demo/single-pixels.pl view on Meta::CPAN
#!/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);
demo/steganography.pl view on Meta::CPAN
#!/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:');
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Test image blobs.
#
BEGIN { $| = 1; $test=1, print "1..1\n"; }
END {print "not ok 1\n" unless $loaded;}
use Image::Magick;
$loaded=1;
chdir 't' || die 'Cd failed';
$image = new Image::Magick;
$image->Read( 'input.miff' );
@blob = $image->ImageToBlob();
undef $image;
$image=Image::Magick->new( magick=>'MIFF' );
$image->BlobToImage( @blob );
if ($image->Get('signature') ne
'fb6fc68beb3b1001c5ebaa671c8ac8fddea06995027127765ff508f77723cc52')
{ print "not ok $test\n"; }
else
{ print "ok $test\n"; }
1;
t/bzlib/read.t view on Meta::CPAN
#!/usr/bin/perl
#
# Test reading an image which uses BZip compression
#
# Contributed by Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
#
BEGIN { $| = 1; $test=1; print "1..2\n"; }
END {print "not ok $test\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't/bzlib' || die 'Cd failed';
#
# Test reading BZip compressed MIFF
#
testRead( 'input.miff',
t/bzlib/write.t view on Meta::CPAN
#!/usr/bin/perl
#
# Test writing files using bzlib-based compression
#
# Contributed by Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
#
BEGIN { $| = 1; $test=1; print "1..1\n"; }
END {print "not ok $test\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't/bzlib' || die 'Cd failed';
#
# Test writing BZip-compressed MIFF
#
t/cgm/read.t view on Meta::CPAN
#
# Test reading CGM files
#
# Written by Bob Friesenhahn
#
# Whenever a new test is added/removed, be sure to update the
# 1..n ouput.
#
BEGIN { $| = 1; $test=1; print "1..1\n"; }
END {print "not ok $test\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't/cgm' || die 'Cd failed';
testReadCompare('CGM:input.cgm', '../reference/cgm/read.miff', q//, 0.0 0.0);
t/composite.t view on Meta::CPAN
# https://imagemagick.org/script/license.php
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
BEGIN { $| = 1; $test=1; print "1..18\n"; }
END {print "not ok $test\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't' || die 'Cd failed';
#
# Add
#
testCompositeCompare('gradient:white-black',q/size=>"100x80"/,
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Test image filters.
#
BEGIN { $| = 1; $test=1, print "1..58\n"; }
END {print "not ok 1\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't' || die 'Cd failed';
use FileHandle;
autoflush STDOUT 1;
autoflush STDERR 1;
$fuzz=int(0.05*(Image::Magick->new()->QuantumRange));
testFilterCompare('input.miff', q//, 'reference/filter/AdaptiveThreshold.miff', 'AdaptiveThreshold', q/'5x5+5%'/, 0.0, 0.0);
++$test;
testFilterCompare('input.miff', q//, 'reference/filter/Annotate.miff', 'Annotate', q/text=>'Magick',geometry=>'+0+20',font=>'Generic.ttf',fill=>'gold',gravity=>'North',pointsize=>14/, 0.05, 1.00);
++$test;
testFilterCompare('input.miff', q//, 'reference/filter/Blur.miff', 'Blur', q/'5x2'/, 0.007, 0.7);
++$test;
t/fpx/read.t view on Meta::CPAN
#!/usr/bin/perl
#
# Test reading FPX images
#
# Contributed by Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
#
BEGIN { $| = 1; $test=1; print "1..5\n"; }
END {print "not ok $test\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't/fpx' || die 'Cd failed';
#
# 1) Test Black-and-white, bit_depth=1 FPX
#
print( "1-bit grayscale FPX ...\n" );
t/fpx/write.t view on Meta::CPAN
#!/usr/bin/perl
#
# Test writing FPX images
#
# Contributed by Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
#
BEGIN { $| = 1; $test=1; print "1..4\n"; }
END {print "not ok $test\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't/fpx' || die 'Cd failed';
#
# 1) Test Black-and-white, bit_depth=1 FPX
#
print( "1-bit grayscale FPX ...\n" );
t/getattribute.t view on Meta::CPAN
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Test getting attributes.
#
BEGIN { $| = 1; $test=1, print "1..25\n"; }
END {print "not ok 1\n" unless $loaded;}
use Image::Magick;
$loaded=1;
require 't/subroutines.pl';
chdir 't' || die 'Cd failed';
testGetAttribute('input.miff','base-columns','70');
++$test;
testGetAttribute('input.miff','base-filename','input.miff');