]> git.pld-linux.org Git - packages/ImageMagick.git/blob - perlmagick.patch
- rebuild with perl 5.28.0
[packages/ImageMagick.git] / perlmagick.patch
1 diff -urN ImageMagick-6.9.7-0/PerlMagick/Magick.pm ImageMagick-6.9.6-6/PerlMagick/Magick.pm
2 --- ImageMagick-6.9.7-0/PerlMagick/Magick.pm    1970-01-01 01:00:00.000000000 +0100
3 +++ ImageMagick-6.9.6-6/PerlMagick/Magick.pm    2016-11-25 16:58:55.000000000 +0100
4 @@ -0,0 +1,144 @@
5 +package Image::Magick;
6 +
7 +#  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization
8 +#  dedicated to making software imaging solutions freely available.
9 +#
10 +#  You may not use this file except in compliance with the License.  You may
11 +#  obtain a copy of the License at
12 +#
13 +#    http://www.imagemagick.org/script/license.php
14 +#
15 +#  Unless required by applicable law or agreed to in writing, software
16 +#  distributed under the License is distributed on an "AS IS" BASIS,
17 +#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 +#  See the License for the specific language governing permissions and
19 +#  limitations under the License.
20 +#
21 +#  Initial version, written by Kyle Shorter.
22 +
23 +use strict;
24 +use Carp;
25 +use vars qw($VERSION @ISA @EXPORT $AUTOLOAD);
26 +
27 +require 5.002;
28 +require Exporter;
29 +require DynaLoader;
30 +require AutoLoader;
31 +
32 +@ISA = qw(Exporter DynaLoader);
33 +# Items to export into callers namespace by default. Note: do not export
34 +# names by default without a very good reason. Use EXPORT_OK instead.
35 +# Do not simply export all your public functions/methods/constants.
36 +@EXPORT =
37 +  qw(
38 +      Success Transparent Opaque QuantumDepth QuantumRange MaxRGB
39 +      WarningException ResourceLimitWarning TypeWarning OptionWarning
40 +      DelegateWarning MissingDelegateWarning CorruptImageWarning
41 +      FileOpenWarning BlobWarning StreamWarning CacheWarning CoderWarning
42 +      ModuleWarning DrawWarning ImageWarning XServerWarning RegistryWarning
43 +      ConfigureWarning ErrorException ResourceLimitError TypeError
44 +      OptionError DelegateError MissingDelegateError CorruptImageError
45 +      FileOpenError BlobError StreamError CacheError CoderError
46 +      ModuleError DrawError ImageError XServerError RegistryError
47 +      ConfigureError FatalErrorException
48 +    );
49 +
50 +$VERSION = '6.96';
51 +
52 +sub AUTOLOAD {
53 +    # This AUTOLOAD is used to 'autoload' constants from the constant()
54 +    # XS function.  If a constant is not found then control is passed
55 +    # to the AUTOLOAD in AutoLoader.
56 +
57 +    my $constname;
58 +    ($constname = $AUTOLOAD) =~ s/.*:://;
59 +    die "&${AUTOLOAD} not defined. The required ImageMagick libraries are not installed or not installed properly.\n" if $constname eq 'constant';
60 +    my $val = constant($constname, @_ ? $_[0] : 0);
61 +    if ($! != 0) {
62 +       if ($! =~ /Invalid/) {
63 +               $AutoLoader::AUTOLOAD = $AUTOLOAD;
64 +               goto &AutoLoader::AUTOLOAD;
65 +       }
66 +       else {
67 +               my($pack,$file,$line) = caller;
68 +               die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
69 +       }
70 +    }
71 +    eval "sub $AUTOLOAD { $val }";
72 +    goto &$AUTOLOAD;
73 +}
74 +
75 +bootstrap Image::Magick $VERSION;
76 +
77 +# Preloaded methods go here.
78 +
79 +sub new
80 +{
81 +    my $this = shift;
82 +    my $class = ref($this) || $this || "Image::Magick";
83 +    my $self = [ ];
84 +    bless $self, $class;
85 +    $self->set(@_) if @_;
86 +    return $self;
87 +}
88 +
89 +sub New
90 +{
91 +    my $this = shift;
92 +    my $class = ref($this) || $this || "Image::Magick";
93 +    my $self = [ ];
94 +    bless $self, $class;
95 +    $self->set(@_) if @_;
96 +    return $self;
97 +}
98 +
99 +# Autoload methods go after =cut, and are processed by the autosplit program.
100 +
101 +END { UNLOAD () };
102 +
103 +1;
104 +__END__
105 +
106 +=head1 NAME
107 +
108 +Image::Magick - objected-oriented Perl interface to ImageMagick. Use it to create, edit, compose, or convert bitmap images from within a Perl script.
109 +
110 +=head1 SYNOPSIS
111 +
112 +  use Image::Magick;
113 +  $p = new Image::Magick;
114 +  $p->Read("imagefile");
115 +  $p->Set(attribute => value, ...)
116 +  ($a, ...) = $p->Get("attribute", ...)
117 +  $p->routine(parameter => value, ...)
118 +  $p->Mogrify("Routine", parameter => value, ...)
119 +  $p->Write("filename");
120 +
121 +=head1 DESCRIPTION
122 +
123 +This Perl extension allows the reading, manipulation and writing of
124 +a large number of image file formats using the ImageMagick library.
125 +It was originally developed to be used by CGI scripts for Web pages.
126 +
127 +A web page has been set up for this extension. See:
128 +
129 +        file:///usr/share/doc/ImageMagick-6.8.0/www/perl-magick.html
130 +        http://www.imagemagick.org/script/perl-magick.php
131 +
132 +If you have problems, go to
133 +
134 +   http://www.imagemagick.org/discourse-server/viewforum.php?f=7
135 +
136 +=head1 AUTHOR
137 +
138 +Kyle Shorter   magick-users@imagemagick.org
139 +
140 +=head1 BUGS
141 +
142 +Has all the bugs of ImageMagick and much, much more!
143 +
144 +=head1 SEE ALSO
145 +
146 +perl(1).
147 +
148 +=cut
149 diff -urN ImageMagick-6.9.7-0/PerlMagick/Magick.xs ImageMagick-6.9.6-6/PerlMagick/Magick.xs
150 --- ImageMagick-6.9.7-0/PerlMagick/Magick.xs    1970-01-01 01:00:00.000000000 +0100
151 +++ ImageMagick-6.9.6-6/PerlMagick/Magick.xs    2016-11-25 16:58:55.000000000 +0100
152 @@ -0,0 +1,14450 @@
153 +/*
154 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 +%                                                                             %
156 +%                                                                             %
157 +%                         PPPP   EEEEE  RRRR   L                              %
158 +%                         P   P  E      R   R  L                              %
159 +%                         PPPP   EEE    RRRR   L                              %
160 +%                         P      E      R  R   L                              %
161 +%                         P      EEEEE  R   R  LLLLL                          %
162 +%                                                                             %
163 +%                  M   M   AAA    GGGG  IIIII   CCCC  K   K                   %
164 +%                  MM MM  A   A  G        I    C      K  K                    %
165 +%                  M M M  AAAAA  G GGG    I    C      KKK                     %
166 +%                  M   M  A   A  G   G    I    C      K  K                    %
167 +%                  M   M  A   A   GGGG  IIIII   CCCC  K   K                   %
168 +%                                                                             %
169 +%                                                                             %
170 +%                Object-oriented Perl interface to ImageMagick                %
171 +%                                                                             %
172 +%                            Software Design                                  %
173 +%                              Kyle Shorter                                   %
174 +%                                 Cristy                                      %
175 +%                             February 1997                                   %
176 +%                                                                             %
177 +%                                                                             %
178 +%  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization      %
179 +%  dedicated to making software imaging solutions freely available.           %
180 +%                                                                             %
181 +%  You may not use this file except in compliance with the License.  You may  %
182 +%  obtain a copy of the License at                                            %
183 +%                                                                             %
184 +%    http://www.imagemagick.org/script/license.php                            %
185 +%                                                                             %
186 +%  Unless required by applicable law or agreed to in writing, software        %
187 +%  distributed under the License is distributed on an "AS IS" BASIS,          %
188 +%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
189 +%  See the License for the specific language governing permissions and        %
190 +%  limitations under the License.                                             %
191 +%                                                                             %
192 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
193 +%
194 +%  PerlMagick is an objected-oriented Perl interface to ImageMagick.  Use
195 +%  the module to read, manipulate, or write an image or image sequence from
196 +%  within a Perl script.  This makes PerlMagick suitable for Web CGI scripts.
197 +%
198 +*/
199 +\f
200 +/*
201 +  Include declarations.
202 +*/
203 +#if defined(__cplusplus) || defined(c_plusplus)
204 +extern "C" {
205 +#endif
206 +
207 +#define PERL_NO_GET_CONTEXT
208 +#include "EXTERN.h"
209 +#include "perl.h"
210 +#include "XSUB.h"
211 +#include <math.h>
212 +#include <magick/MagickCore.h>
213 +#undef tainted
214 +
215 +#if defined(__cplusplus) || defined(c_plusplus)
216 +}
217 +#endif
218 +\f
219 +/*
220 +  Define declarations.
221 +*/
222 +#ifndef aTHX_
223 +#define aTHX_
224 +#define pTHX_
225 +#define dTHX
226 +#endif
227 +#define DegreesToRadians(x)  (MagickPI*(x)/180.0)
228 +#define EndOf(array)  (&array[NumberOf(array)])
229 +#define MagickPI  3.14159265358979323846264338327950288419716939937510
230 +#define MaxArguments  33
231 +#ifndef na
232 +#define na  PL_na
233 +#endif
234 +#define NumberOf(array)  (sizeof(array)/sizeof(*array))
235 +#define PackageName   "Image::Magick"
236 +#if PERL_VERSION <= 6
237 +#define PerlIO  FILE
238 +#define PerlIO_importFILE(f, fl)  (f)
239 +#define PerlIO_findFILE(f)  NULL
240 +#endif
241 +#ifndef sv_undef
242 +#define sv_undef  PL_sv_undef
243 +#endif
244 +
245 +#define AddImageToRegistry(sv,image) \
246 +{ \
247 +  if (magick_registry != (SplayTreeInfo *) NULL) \
248 +    { \
249 +      (void) AddValueToSplayTree(magick_registry,image,image); \
250 +      (sv)=newSViv(PTR2IV(image)); \
251 +    } \
252 +}
253 +
254 +#define DeleteImageFromRegistry(reference,image) \
255 +{ \
256 +  if (magick_registry != (SplayTreeInfo *) NULL) \
257 +    { \
258 +      if (GetImageReferenceCount(image) == 1) \
259 +       (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
260 +      image=DestroyImage(image); \
261 +      sv_setiv(reference,0); \
262 +    } \
263 +}
264 +
265 +#define InheritPerlException(exception,perl_exception) \
266 +{ \
267 +  char \
268 +    message[MaxTextExtent]; \
269 + \
270 +  if ((exception)->severity != UndefinedException) \
271 +    { \
272 +      (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
273 +        (exception)->severity, (exception)->reason ? \
274 +        GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
275 +        "Unknown", (exception)->description ? " (" : "", \
276 +        (exception)->description ? GetLocaleExceptionMessage( \
277 +        (exception)->severity,(exception)->description) : "", \
278 +        (exception)->description ? ")" : ""); \
279 +      if ((perl_exception) != (SV *) NULL) \
280 +        { \
281 +          if (SvCUR(perl_exception)) \
282 +            sv_catpv(perl_exception,"\n"); \
283 +          sv_catpv(perl_exception,message); \
284 +        } \
285 +    } \
286 +}
287 +
288 +#define ThrowPerlException(exception,severity,tag,reason) \
289 +  (void) ThrowMagickException(exception,GetMagickModule(),severity, \
290 +    tag,"`%s'",reason); \
291 +\f
292 +/*
293 +  Typedef and structure declarations.
294 +*/
295 +typedef enum
296 +{
297 +  ArrayReference = (~0),
298 +  RealReference = (~0)-1,
299 +  FileReference = (~0)-2,
300 +  ImageReference = (~0)-3,
301 +  IntegerReference = (~0)-4,
302 +  StringReference = (~0)-5
303 +} MagickReference;
304 +
305 +typedef struct _Arguments
306 +{
307 +  const char
308 +    *method;
309 +
310 +  ssize_t
311 +    type;
312 +} Arguments;
313 +
314 +struct ArgumentList
315 +{
316 +  ssize_t
317 +    integer_reference;
318 +
319 +  MagickRealType
320 +    real_reference;
321 +
322 +  const char
323 +    *string_reference;
324 +
325 +  Image
326 +    *image_reference;
327 +
328 +  SV
329 +    *array_reference;
330 +
331 +  FILE
332 +    *file_reference;
333 +
334 +  size_t
335 +    length;
336 +};
337 +
338 +struct PackageInfo
339 +{
340 +  ImageInfo
341 +    *image_info;
342 +};
343 +
344 +typedef void
345 +  *Image__Magick;  /* data type for the Image::Magick package */
346 +\f
347 +/*
348 +  Static declarations.
349 +*/
350 +static struct
351 +  Methods
352 +  {
353 +    const char
354 +      *name;
355 +
356 +    Arguments
357 +      arguments[MaxArguments];
358 +  } Methods[] =
359 +  {
360 +    { "Comment", { {"comment", StringReference} } },
361 +    { "Label", { {"label", StringReference} } },
362 +    { "AddNoise", { {"noise", MagickNoiseOptions},
363 +      {"channel", MagickChannelOptions} } },
364 +    { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
365 +    { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
366 +      {"height", IntegerReference}, {"fill", StringReference},
367 +      {"bordercolor", StringReference}, {"color", StringReference},
368 +      {"compose", MagickComposeOptions} } },
369 +    { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
370 +      {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
371 +    { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
372 +      {"height", IntegerReference}, {"x", IntegerReference},
373 +      {"y", IntegerReference}, {"gravity", MagickGravityOptions} } },
374 +    { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
375 +      {"height", IntegerReference}, {"x", IntegerReference},
376 +      {"y", IntegerReference}, {"fuzz", StringReference},
377 +      {"gravity", MagickGravityOptions} } },
378 +    { "Despeckle", },
379 +    { "Edge", { {"radius", RealReference} } },
380 +    { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
381 +      {"sigma", RealReference} } },
382 +    { "Enhance", },
383 +    { "Flip", },
384 +    { "Flop", },
385 +    { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
386 +      {"height", IntegerReference}, {"inner", IntegerReference},
387 +      {"outer", IntegerReference}, {"fill", StringReference},
388 +      {"color", StringReference}, {"compose", MagickComposeOptions} } },
389 +    { "Implode", { {"amount", RealReference},
390 +      {"interpolate", MagickInterpolateOptions} } },
391 +    { "Magnify", },
392 +    { "MedianFilter", { {"geometry", StringReference},
393 +      {"width", IntegerReference},{"height", IntegerReference},
394 +      {"channel", MagickChannelOptions} } },
395 +    { "Minify", },
396 +    { "OilPaint", { {"radius", RealReference} } },
397 +    { "ReduceNoise", { {"geometry", StringReference},
398 +      {"width", IntegerReference},{"height", IntegerReference},
399 +      {"channel", MagickChannelOptions} } },
400 +    { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
401 +      {"y", IntegerReference} } },
402 +    { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
403 +      {"color", StringReference}, {"background", StringReference} } },
404 +    { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
405 +      {"height", IntegerReference} } },
406 +    { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
407 +      {"height", IntegerReference} } },
408 +    { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
409 +      {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
410 +    { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
411 +      {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
412 +    { "Shear", { {"geometry", StringReference}, {"x", RealReference},
413 +      {"y", RealReference}, { "fill", StringReference},
414 +      {"color", StringReference} } },
415 +    { "Spread", { {"radius", RealReference},
416 +      {"interpolate", MagickInterpolateOptions} } },
417 +    { "Swirl", { {"degrees", RealReference},
418 +      {"interpolate", MagickInterpolateOptions} } },
419 +    { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
420 +      {"height", IntegerReference}, {"filter", MagickFilterOptions},
421 +      {"support", StringReference }, {"blur", RealReference } } },
422 +    { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
423 +      {"height", IntegerReference}, {"filter", MagickFilterOptions},
424 +      {"support", RealReference }, {"blur", RealReference } } },
425 +    { "Annotate", { {"text", StringReference}, {"font", StringReference},
426 +      {"pointsize", RealReference}, {"density", StringReference},
427 +      {"undercolor", StringReference}, {"stroke", StringReference},
428 +      {"fill", StringReference}, {"geometry", StringReference},
429 +      {"pen", StringReference}, {"x", RealReference},
430 +      {"y", RealReference}, {"gravity", MagickGravityOptions},
431 +      {"translate", StringReference}, {"scale", StringReference},
432 +      {"rotate", RealReference}, {"skewX", RealReference},
433 +      {"skewY", RealReference}, {"strokewidth", RealReference},
434 +      {"antialias", MagickBooleanOptions}, {"family", StringReference},
435 +      {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
436 +      {"weight", IntegerReference}, {"align", MagickAlignOptions},
437 +      {"encoding", StringReference}, {"affine", ArrayReference},
438 +      {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
439 +      {"tile", ImageReference}, {"kerning", RealReference},
440 +      {"interline-spacing", RealReference},
441 +      {"interword-spacing", RealReference},
442 +      {"direction", MagickDirectionOptions} } },
443 +    { "ColorFloodfill", { {"geometry", StringReference},
444 +      {"x", IntegerReference}, {"y", IntegerReference},
445 +      {"fill", StringReference}, {"bordercolor", StringReference},
446 +      {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
447 +    { "Composite", { {"image", ImageReference},
448 +      {"compose", MagickComposeOptions}, {"geometry", StringReference},
449 +      {"x", IntegerReference}, {"y", IntegerReference},
450 +      {"gravity", MagickGravityOptions}, {"opacity", StringReference},
451 +      {"tile", MagickBooleanOptions}, {"rotate", RealReference},
452 +      {"color", StringReference}, {"mask", ImageReference},
453 +      {"channel", MagickChannelOptions},
454 +      {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
455 +      {"blend", StringReference} } },
456 +    { "Contrast", { {"sharpen", MagickBooleanOptions} } },
457 +    { "CycleColormap", { {"display", IntegerReference} } },
458 +    { "Draw", { {"primitive", MagickPrimitiveOptions},
459 +      {"points", StringReference}, {"method", MagickMethodOptions},
460 +      {"stroke", StringReference}, {"fill", StringReference},
461 +      {"strokewidth", RealReference}, {"font", StringReference},
462 +      {"bordercolor", StringReference}, {"x", RealReference},
463 +      {"y", RealReference}, {"translate", StringReference},
464 +      {"scale", StringReference}, {"rotate", RealReference},
465 +      {"skewX", RealReference}, {"skewY", RealReference},
466 +      {"tile", ImageReference}, {"pointsize", RealReference},
467 +      {"antialias", MagickBooleanOptions}, {"density", StringReference},
468 +      {"linewidth", RealReference}, {"affine", ArrayReference},
469 +      {"stroke-dashoffset", RealReference},
470 +      {"stroke-dasharray", ArrayReference},
471 +      {"interpolate", MagickInterpolateOptions},
472 +      {"origin", StringReference}, {"text", StringReference},
473 +      {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
474 +      {"vector-graphics", StringReference}, {"kerning", RealReference},
475 +      {"interline-spacing", RealReference},
476 +      {"interword-spacing", RealReference},
477 +      {"direction", MagickDirectionOptions} } },
478 +    { "Equalize", { {"channel", MagickChannelOptions} } },
479 +    { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
480 +      {"red", RealReference}, {"green", RealReference},
481 +      {"blue", RealReference} } },
482 +    { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
483 +      {"dither-method", MagickDitherOptions} } },
484 +    { "MatteFloodfill", { {"geometry", StringReference},
485 +      {"x", IntegerReference}, {"y", IntegerReference},
486 +      {"opacity", StringReference}, {"bordercolor", StringReference},
487 +      {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
488 +    { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
489 +      {"saturation", RealReference}, {"whiteness", RealReference},
490 +      {"brightness", RealReference}, {"lightness", RealReference},
491 +      {"blackness", RealReference} } },
492 +    { "Negate", { {"gray", MagickBooleanOptions},
493 +      {"channel", MagickChannelOptions} } },
494 +    { "Normalize", { {"channel", MagickChannelOptions} } },
495 +    { "NumberColors", },
496 +    { "Opaque", { {"color", StringReference}, {"fill", StringReference},
497 +      {"fuzz", StringReference}, {"channel", MagickChannelOptions},
498 +      {"invert", MagickBooleanOptions} } },
499 +    { "Quantize", { {"colors", IntegerReference},
500 +      {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
501 +      {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
502 +      {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
503 +      {"dither-method", MagickDitherOptions} } },
504 +    { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
505 +      {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
506 +    { "Segment", { {"geometry", StringReference},
507 +      {"cluster-threshold", RealReference},
508 +      {"smoothing-threshold", RealReference},
509 +      {"colorspace", MagickColorspaceOptions},
510 +      {"verbose", MagickBooleanOptions} } },
511 +    { "Signature", },
512 +    { "Solarize", { {"geometry", StringReference},
513 +      {"threshold", StringReference}, {"channel", MagickChannelOptions} } },
514 +    { "Sync", },
515 +    { "Texture", { {"texture", ImageReference} } },
516 +    { "Evaluate", { {"value", RealReference},
517 +      {"operator", MagickEvaluateOptions},
518 +      {"channel", MagickChannelOptions} } },
519 +    { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
520 +      {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
521 +    { "Threshold", { {"threshold", StringReference},
522 +      {"channel", MagickChannelOptions} } },
523 +    { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
524 +      {"sigma", RealReference} } },
525 +    { "Trim", { {"fuzz", StringReference} } },
526 +    { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
527 +      {"wavelength", RealReference},
528 +      {"interpolate", MagickInterpolateOptions} } },
529 +    { "Separate", { {"channel", MagickChannelOptions} } },
530 +    { "Condense", },
531 +    { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
532 +      {"y", IntegerReference} } },
533 +    { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
534 +    { "Deconstruct", },
535 +    { "GaussianBlur", { {"geometry", StringReference},
536 +      {"radius", RealReference}, {"sigma", RealReference},
537 +      {"channel", MagickChannelOptions} } },
538 +    { "Convolve", { {"coefficients", ArrayReference},
539 +      {"channel", MagickChannelOptions}, {"bias", StringReference} } },
540 +    { "Profile", { {"name", StringReference}, {"profile", StringReference},
541 +      { "rendering-intent", MagickIntentOptions},
542 +      { "black-point-compensation", MagickBooleanOptions} } },
543 +    { "UnsharpMask", { {"geometry", StringReference},
544 +      {"radius", RealReference}, {"sigma", RealReference},
545 +      {"amount", RealReference}, {"threshold", RealReference},
546 +      {"channel", MagickChannelOptions} } },
547 +    { "MotionBlur", { {"geometry", StringReference},
548 +      {"radius", RealReference}, {"sigma", RealReference},
549 +      {"angle", RealReference}, {"channel", MagickChannelOptions} } },
550 +    { "OrderedDither", { {"threshold", StringReference},
551 +      {"channel", MagickChannelOptions} } },
552 +    { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
553 +      {"height", IntegerReference} } },
554 +    { "Level", { {"levels", StringReference}, {"black-point", RealReference},
555 +      {"white-point", RealReference}, {"gamma", RealReference},
556 +      {"channel", MagickChannelOptions}, {"level", StringReference} } },
557 +    { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
558 +    { "AffineTransform", { {"affine", ArrayReference},
559 +      {"translate", StringReference}, {"scale", StringReference},
560 +      {"rotate", RealReference}, {"skewX", RealReference},
561 +      {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
562 +      {"background", StringReference} } },
563 +    { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
564 +    { "AdaptiveThreshold", { {"geometry", StringReference},
565 +      {"width", IntegerReference}, {"height", IntegerReference},
566 +      {"offset", IntegerReference} } },
567 +    { "Resample", { {"density", StringReference}, {"x", RealReference},
568 +      {"y", RealReference}, {"filter", MagickFilterOptions},
569 +      {"support", RealReference }, {"blur", RealReference } } },
570 +    { "Describe", { {"file", FileReference} } },
571 +    { "BlackThreshold", { {"threshold", StringReference},
572 +      {"channel", MagickChannelOptions} } },
573 +    { "WhiteThreshold", { {"threshold", StringReference},
574 +      {"channel", MagickChannelOptions} } },
575 +    { "RotationalBlur", { {"geometry", StringReference},
576 +      {"angle", RealReference}, {"channel", MagickChannelOptions} } },
577 +    { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
578 +      {"height", IntegerReference} } },
579 +    { "Strip", },
580 +    { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
581 +    { "Channel", { {"channel", MagickChannelOptions} } },
582 +    { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
583 +      {"height", IntegerReference}, {"x", IntegerReference},
584 +      {"y", IntegerReference}, {"fuzz", StringReference},
585 +      {"background", StringReference}, {"gravity", MagickGravityOptions} } },
586 +    { "Posterize", { {"levels", IntegerReference},
587 +      {"dither", MagickBooleanOptions} } },
588 +    { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
589 +      {"sigma", RealReference}, {"x", IntegerReference},
590 +      {"y", IntegerReference} } },
591 +    { "Identify", { {"file", FileReference}, {"features", StringReference},
592 +      {"unique", MagickBooleanOptions} } },
593 +    { "SepiaTone", { {"threshold", RealReference} } },
594 +    { "SigmoidalContrast", { {"geometry", StringReference},
595 +      {"contrast", RealReference}, {"mid-point", RealReference},
596 +      {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
597 +    { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
598 +      {"height", IntegerReference}, {"x", IntegerReference},
599 +      {"y", IntegerReference}, {"fuzz", StringReference},
600 +      {"background", StringReference}, {"gravity", MagickGravityOptions} } },
601 +    { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
602 +      {"sigma", RealReference}, {"x", IntegerReference},
603 +      {"y", IntegerReference}, {"background", StringReference} } },
604 +    { "ContrastStretch", { {"levels", StringReference},
605 +      {"black-point", RealReference},{"white-point", RealReference},
606 +      {"channel", MagickChannelOptions} } },
607 +    { "Sans0", },
608 +    { "Sans1", },
609 +    { "AdaptiveSharpen", { {"geometry", StringReference},
610 +      {"radius", RealReference}, {"sigma", RealReference},
611 +      {"channel", MagickChannelOptions} } },
612 +    { "Transpose", },
613 +    { "Transverse", },
614 +    { "AutoOrient", },
615 +    { "AdaptiveBlur", { {"geometry", StringReference},
616 +      {"radius", RealReference}, {"sigma", RealReference},
617 +      {"channel", MagickChannelOptions} } },
618 +    { "Sketch", { {"geometry", StringReference},
619 +      {"radius", RealReference}, {"sigma", RealReference},
620 +      {"angle", RealReference} } },
621 +    { "UniqueColors", },
622 +    { "AdaptiveResize", { {"geometry", StringReference},
623 +      {"width", IntegerReference}, {"height", IntegerReference},
624 +      {"filter", MagickFilterOptions}, {"support", StringReference },
625 +      {"blur", RealReference } } },
626 +    { "ClipMask", { {"mask", ImageReference} } },
627 +    { "LinearStretch", { {"levels", StringReference},
628 +      {"black-point", RealReference},{"white-point", RealReference} } },
629 +    { "Recolor", { {"matrix", ArrayReference} } },
630 +    { "Mask", { {"mask", ImageReference} } },
631 +    { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
632 +      {"font", StringReference}, {"stroke", StringReference},
633 +      {"fill", StringReference}, {"strokewidth", RealReference},
634 +      {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
635 +      {"background", StringReference} } },
636 +    { "FloodfillPaint", { {"geometry", StringReference},
637 +      {"x", IntegerReference}, {"y", IntegerReference},
638 +      {"fill", StringReference}, {"bordercolor", StringReference},
639 +      {"fuzz", StringReference}, {"channel", MagickChannelOptions},
640 +      {"invert", MagickBooleanOptions} } },
641 +    { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
642 +      {"virtual-pixel", MagickVirtualPixelOptions},
643 +      {"best-fit", MagickBooleanOptions} } },
644 +    { "Clut", { {"image", ImageReference},
645 +      {"channel", MagickChannelOptions} } },
646 +    { "LiquidRescale", { {"geometry", StringReference},
647 +      {"width", IntegerReference}, {"height", IntegerReference},
648 +      {"delta-x", RealReference}, {"rigidity", RealReference } } },
649 +    { "Encipher", { {"passphrase", StringReference} } },
650 +    { "Decipher", { {"passphrase", StringReference} } },
651 +    { "Deskew", { {"geometry", StringReference},
652 +      {"threshold", StringReference} } },
653 +    { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
654 +      {"dither-method", MagickDitherOptions} } },
655 +    { "SparseColor", { {"points", ArrayReference},
656 +      {"method", MagickSparseColorOptions},
657 +      {"virtual-pixel", MagickVirtualPixelOptions},
658 +      {"channel", MagickChannelOptions} } },
659 +    { "Function", { {"parameters", ArrayReference},
660 +      {"function", MagickFunctionOptions},
661 +      {"virtual-pixel", MagickVirtualPixelOptions} } },
662 +    { "SelectiveBlur", { {"geometry", StringReference},
663 +      {"radius", RealReference}, {"sigma", RealReference},
664 +      {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
665 +    { "HaldClut", { {"image", ImageReference},
666 +      {"channel", MagickChannelOptions} } },
667 +    { "BlueShift", { {"factor", StringReference} } },
668 +    { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
669 +    { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
670 +    { "ColorDecisionList", {
671 +      {"color-correction-collection", StringReference} } },
672 +    { "AutoGamma", { {"channel", MagickChannelOptions} } },
673 +    { "AutoLevel", { {"channel", MagickChannelOptions} } },
674 +    { "LevelColors", { {"invert", MagickBooleanOptions},
675 +      {"black-point", StringReference}, {"white-point", StringReference},
676 +      {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
677 +    { "Clamp", { {"channel", MagickChannelOptions} } },
678 +    { "Filter", { {"kernel", StringReference},
679 +      {"channel", MagickChannelOptions}, {"bias", StringReference} } },
680 +    { "BrightnessContrast", { {"levels", StringReference},
681 +      {"brightness", RealReference},{"contrast", RealReference},
682 +      {"channel", MagickChannelOptions} } },
683 +    { "Morphology", { {"kernel", StringReference},
684 +      {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
685 +      {"iterations", IntegerReference} } },
686 +    { "ColorMatrix", { {"matrix", ArrayReference} } },
687 +    { "Color", { {"color", StringReference} } },
688 +    { "Mode", { {"geometry", StringReference},
689 +      {"width", IntegerReference},{"height", IntegerReference},
690 +      {"channel", MagickChannelOptions} } },
691 +    { "Statistic", { {"geometry", StringReference},
692 +      {"width", IntegerReference},{"height", IntegerReference},
693 +      {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
694 +    { "Perceptible", { {"epsilon", RealReference},
695 +      {"channel", MagickChannelOptions} } },
696 +    { "Poly", { {"terms", ArrayReference},
697 +      {"channel", MagickChannelOptions} } },
698 +    { "Grayscale", { {"method", MagickPixelIntensityOptions} } },
699 +    { "CannyEdge", { {"geometry", StringReference},
700 +      {"radius", RealReference}, {"sigma", RealReference},
701 +      {"lower-percent", RealReference}, {"upper-percent", RealReference} } },
702 +    { "HoughLine", { {"geometry", StringReference},
703 +      {"width", IntegerReference}, {"height", IntegerReference},
704 +      {"threshold", IntegerReference} } },
705 +    { "MeanShift", { {"geometry", StringReference},
706 +      {"width", IntegerReference}, {"height", IntegerReference},
707 +      {"distance", RealReference} } },
708 +    { "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference},
709 +      {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
710 +    { "ConnectedComponents", { {"connectivity", IntegerReference} } },
711 +    { "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference},
712 +      {"width", IntegerReference}, {"height", IntegerReference},
713 +      {"x", IntegerReference}, {"y", IntegerReference},
714 +      {"gravity", MagickGravityOptions}, {"offset", StringReference},
715 +      {"dx", IntegerReference}, {"dy", IntegerReference} } },
716 +    { "WaveletDenoise", {  {"geometry", StringReference},
717 +      {"threshold", RealReference}, {"softness", RealReference} } },
718 +  };
719 +
720 +static SplayTreeInfo
721 +  *magick_registry = (SplayTreeInfo *) NULL;
722 +\f
723 +/*
724 +  Forward declarations.
725 +*/
726 +static Image
727 +  *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
728 +
729 +static ssize_t
730 +  strEQcase(const char *,const char *);
731 +\f
732 +/*
733 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
734 +%                                                                             %
735 +%                                                                             %
736 +%                                                                             %
737 +%   C l o n e P a c k a g e I n f o                                           %
738 +%                                                                             %
739 +%                                                                             %
740 +%                                                                             %
741 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
742 +%
743 +%  ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
744 +%  a new one.
745 +%
746 +%  The format of the ClonePackageInfo routine is:
747 +%
748 +%      struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
749 +%        exception)
750 +%
751 +%  A description of each parameter follows:
752 +%
753 +%    o info: a structure of type info.
754 +%
755 +%    o exception: Return any errors or warnings in this structure.
756 +%
757 +*/
758 +static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
759 +  ExceptionInfo *exception)
760 +{
761 +  struct PackageInfo
762 +    *clone_info;
763 +
764 +  clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
765 +  if (clone_info == (struct PackageInfo *) NULL)
766 +    {
767 +      ThrowPerlException(exception,ResourceLimitError,
768 +        "UnableToClonePackageInfo",PackageName);
769 +      return((struct PackageInfo *) NULL);
770 +    }
771 +  if (info == (struct PackageInfo *) NULL)
772 +    {
773 +      clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
774 +      return(clone_info);
775 +    }
776 +  *clone_info=(*info);
777 +  clone_info->image_info=CloneImageInfo(info->image_info);
778 +  return(clone_info);
779 +}
780 +\f
781 +/*
782 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
783 +%                                                                             %
784 +%                                                                             %
785 +%                                                                             %
786 +%   c o n s t a n t                                                           %
787 +%                                                                             %
788 +%                                                                             %
789 +%                                                                             %
790 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
791 +%
792 +%  constant() returns a double value for the specified name.
793 +%
794 +%  The format of the constant routine is:
795 +%
796 +%      double constant(char *name,ssize_t sans)
797 +%
798 +%  A description of each parameter follows:
799 +%
800 +%    o value: Method constant returns a double value for the specified name.
801 +%
802 +%    o name: The name of the constant.
803 +%
804 +%    o sans: This integer value is not used.
805 +%
806 +*/
807 +static double constant(char *name,ssize_t sans)
808 +{
809 +  (void) sans;
810 +  errno=0;
811 +  switch (*name)
812 +  {
813 +    case 'B':
814 +    {
815 +      if (strEQ(name,"BlobError"))
816 +        return(BlobError);
817 +      if (strEQ(name,"BlobWarning"))
818 +        return(BlobWarning);
819 +      break;
820 +    }
821 +    case 'C':
822 +    {
823 +      if (strEQ(name,"CacheError"))
824 +        return(CacheError);
825 +      if (strEQ(name,"CacheWarning"))
826 +        return(CacheWarning);
827 +      if (strEQ(name,"CoderError"))
828 +        return(CoderError);
829 +      if (strEQ(name,"CoderWarning"))
830 +        return(CoderWarning);
831 +      if (strEQ(name,"ConfigureError"))
832 +        return(ConfigureError);
833 +      if (strEQ(name,"ConfigureWarning"))
834 +        return(ConfigureWarning);
835 +      if (strEQ(name,"CorruptImageError"))
836 +        return(CorruptImageError);
837 +      if (strEQ(name,"CorruptImageWarning"))
838 +        return(CorruptImageWarning);
839 +      break;
840 +    }
841 +    case 'D':
842 +    {
843 +      if (strEQ(name,"DelegateError"))
844 +        return(DelegateError);
845 +      if (strEQ(name,"DelegateWarning"))
846 +        return(DelegateWarning);
847 +      if (strEQ(name,"DrawError"))
848 +        return(DrawError);
849 +      if (strEQ(name,"DrawWarning"))
850 +        return(DrawWarning);
851 +      break;
852 +    }
853 +    case 'E':
854 +    {
855 +      if (strEQ(name,"ErrorException"))
856 +        return(ErrorException);
857 +      if (strEQ(name,"ExceptionError"))
858 +        return(CoderError);
859 +      if (strEQ(name,"ExceptionWarning"))
860 +        return(CoderWarning);
861 +      break;
862 +    }
863 +    case 'F':
864 +    {
865 +      if (strEQ(name,"FatalErrorException"))
866 +        return(FatalErrorException);
867 +      if (strEQ(name,"FileOpenError"))
868 +        return(FileOpenError);
869 +      if (strEQ(name,"FileOpenWarning"))
870 +        return(FileOpenWarning);
871 +      break;
872 +    }
873 +    case 'I':
874 +    {
875 +      if (strEQ(name,"ImageError"))
876 +        return(ImageError);
877 +      if (strEQ(name,"ImageWarning"))
878 +        return(ImageWarning);
879 +      break;
880 +    }
881 +    case 'M':
882 +    {
883 +      if (strEQ(name,"MaxRGB"))
884 +        return(QuantumRange);
885 +      if (strEQ(name,"MissingDelegateError"))
886 +        return(MissingDelegateError);
887 +      if (strEQ(name,"MissingDelegateWarning"))
888 +        return(MissingDelegateWarning);
889 +      if (strEQ(name,"ModuleError"))
890 +        return(ModuleError);
891 +      if (strEQ(name,"ModuleWarning"))
892 +        return(ModuleWarning);
893 +      break;
894 +    }
895 +    case 'O':
896 +    {
897 +      if (strEQ(name,"Opaque"))
898 +        return(OpaqueOpacity);
899 +      if (strEQ(name,"OptionError"))
900 +        return(OptionError);
901 +      if (strEQ(name,"OptionWarning"))
902 +        return(OptionWarning);
903 +      break;
904 +    }
905 +    case 'Q':
906 +    {
907 +      if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
908 +        return(MAGICKCORE_QUANTUM_DEPTH);
909 +      if (strEQ(name,"QuantumDepth"))
910 +        return(MAGICKCORE_QUANTUM_DEPTH);
911 +      if (strEQ(name,"QuantumRange"))
912 +        return(QuantumRange);
913 +      break;
914 +    }
915 +    case 'R':
916 +    {
917 +      if (strEQ(name,"ResourceLimitError"))
918 +        return(ResourceLimitError);
919 +      if (strEQ(name,"ResourceLimitWarning"))
920 +        return(ResourceLimitWarning);
921 +      if (strEQ(name,"RegistryError"))
922 +        return(RegistryError);
923 +      if (strEQ(name,"RegistryWarning"))
924 +        return(RegistryWarning);
925 +      break;
926 +    }
927 +    case 'S':
928 +    {
929 +      if (strEQ(name,"StreamError"))
930 +        return(StreamError);
931 +      if (strEQ(name,"StreamWarning"))
932 +        return(StreamWarning);
933 +      if (strEQ(name,"Success"))
934 +        return(0);
935 +      break;
936 +    }
937 +    case 'T':
938 +    {
939 +      if (strEQ(name,"Transparent"))
940 +        return(TransparentOpacity);
941 +      if (strEQ(name,"TypeError"))
942 +        return(TypeError);
943 +      if (strEQ(name,"TypeWarning"))
944 +        return(TypeWarning);
945 +      break;
946 +    }
947 +    case 'W':
948 +    {
949 +      if (strEQ(name,"WarningException"))
950 +        return(WarningException);
951 +      break;
952 +    }
953 +    case 'X':
954 +    {
955 +      if (strEQ(name,"XServerError"))
956 +        return(XServerError);
957 +      if (strEQ(name,"XServerWarning"))
958 +        return(XServerWarning);
959 +      break;
960 +    }
961 +  }
962 +  errno=EINVAL;
963 +  return(0);
964 +}
965 +\f
966 +/*
967 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 +%                                                                             %
969 +%                                                                             %
970 +%                                                                             %
971 +%   D e s t r o y P a c k a g e I n f o                                       %
972 +%                                                                             %
973 +%                                                                             %
974 +%                                                                             %
975 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
976 +%
977 +%  Method DestroyPackageInfo frees a previously created info structure.
978 +%
979 +%  The format of the DestroyPackageInfo routine is:
980 +%
981 +%      DestroyPackageInfo(struct PackageInfo *info)
982 +%
983 +%  A description of each parameter follows:
984 +%
985 +%    o info: a structure of type info.
986 +%
987 +*/
988 +static void DestroyPackageInfo(struct PackageInfo *info)
989 +{
990 +  info->image_info=DestroyImageInfo(info->image_info);
991 +  info=(struct PackageInfo *) RelinquishMagickMemory(info);
992 +}
993 +\f
994 +/*
995 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
996 +%                                                                             %
997 +%                                                                             %
998 +%                                                                             %
999 +%   G e t L i s t                                                             %
1000 +%                                                                             %
1001 +%                                                                             %
1002 +%                                                                             %
1003 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 +%
1005 +%  Method GetList is recursively called by SetupList to traverse the
1006 +%  Image__Magick reference.  If building an reference_vector (see SetupList),
1007 +%  *current is the current position in *reference_vector and *last is the final
1008 +%  entry in *reference_vector.
1009 +%
1010 +%  The format of the GetList routine is:
1011 +%
1012 +%      GetList(info)
1013 +%
1014 +%  A description of each parameter follows:
1015 +%
1016 +%    o info: a structure of type info.
1017 +%
1018 +*/
1019 +static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
1020 +  ssize_t *current,ssize_t *last,ExceptionInfo *exception)
1021 +{
1022 +  Image
1023 +    *image;
1024 +
1025 +  if (reference == (SV *) NULL)
1026 +    return(NULL);
1027 +  switch (SvTYPE(reference))
1028 +  {
1029 +    case SVt_PVAV:
1030 +    {
1031 +      AV
1032 +        *av;
1033 +
1034 +      Image
1035 +        *head,
1036 +        *previous;
1037 +
1038 +      register ssize_t
1039 +        i;
1040 +
1041 +      ssize_t
1042 +        n;
1043 +
1044 +      /*
1045 +        Array of images.
1046 +      */
1047 +      previous=(Image *) NULL;
1048 +      head=(Image *) NULL;
1049 +      av=(AV *) reference;
1050 +      n=av_len(av);
1051 +      for (i=0; i <= n; i++)
1052 +      {
1053 +        SV
1054 +          **rv;
1055 +
1056 +        rv=av_fetch(av,i,0);
1057 +        if (rv && *rv && sv_isobject(*rv))
1058 +          {
1059 +            image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
1060 +              exception);
1061 +            if (image == (Image *) NULL)
1062 +              continue;
1063 +            if (image == previous)
1064 +              {
1065 +                image=CloneImage(image,0,0,MagickTrue,exception);
1066 +                if (image == (Image *) NULL)
1067 +                  return(NULL);
1068 +              }
1069 +            image->previous=previous;
1070 +            *(previous ? &previous->next : &head)=image;
1071 +            for (previous=image; previous->next; previous=previous->next) ;
1072 +          }
1073 +      }
1074 +      return(head);
1075 +    }
1076 +    case SVt_PVMG:
1077 +    {
1078 +      /*
1079 +        Blessed scalar, one image.
1080 +      */
1081 +      image=INT2PTR(Image *,SvIV(reference));
1082 +      if (image == (Image *) NULL)
1083 +        return(NULL);
1084 +      image->previous=(Image *) NULL;
1085 +      image->next=(Image *) NULL;
1086 +      if (reference_vector)
1087 +        {
1088 +          if (*current == *last)
1089 +            {
1090 +              *last+=256;
1091 +              if (*reference_vector == (SV **) NULL)
1092 +                *reference_vector=(SV **) AcquireQuantumMemory(*last,
1093 +                  sizeof(*reference_vector));
1094 +              else
1095 +                *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
1096 +                  *last,sizeof(*reference_vector));
1097 +            }
1098 +          if (*reference_vector == (SV **) NULL)
1099 +            {
1100 +              ThrowPerlException(exception,ResourceLimitError,
1101 +                "MemoryAllocationFailed",PackageName);
1102 +              return((Image *) NULL);
1103 +            }
1104 +          (*reference_vector)[*current]=reference;
1105 +          (*reference_vector)[++(*current)]=NULL;
1106 +        }
1107 +      return(image);
1108 +    }
1109 +    default:
1110 +      break;
1111 +  }
1112 +  (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
1113 +    (double) SvTYPE(reference));
1114 +  return((Image *) NULL);
1115 +}
1116 +\f
1117 +/*
1118 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1119 +%                                                                             %
1120 +%                                                                             %
1121 +%                                                                             %
1122 +%   G e t P a c k a g e I n f o                                               %
1123 +%                                                                             %
1124 +%                                                                             %
1125 +%                                                                             %
1126 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1127 +%
1128 +%  Method GetPackageInfo looks up or creates an info structure for the given
1129 +%  Image__Magick reference.  If it does create a new one, the information in
1130 +%  package_info is used to initialize it.
1131 +%
1132 +%  The format of the GetPackageInfo routine is:
1133 +%
1134 +%      struct PackageInfo *GetPackageInfo(void *reference,
1135 +%        struct PackageInfo *package_info,ExceptionInfo *exception)
1136 +%
1137 +%  A description of each parameter follows:
1138 +%
1139 +%    o info: a structure of type info.
1140 +%
1141 +%    o exception: Return any errors or warnings in this structure.
1142 +%
1143 +*/
1144 +static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
1145 +  struct PackageInfo *package_info,ExceptionInfo *exception)
1146 +{
1147 +  char
1148 +    message[MaxTextExtent];
1149 +
1150 +  struct PackageInfo
1151 +    *clone_info;
1152 +
1153 +  SV
1154 +    *sv;
1155 +
1156 +  (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
1157 +    PackageName,XS_VERSION,reference);
1158 +  sv=perl_get_sv(message,(TRUE | 0x02));
1159 +  if (sv == (SV *) NULL)
1160 +    {
1161 +      ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1162 +        message);
1163 +      return(package_info);
1164 +    }
1165 +  if (SvREFCNT(sv) == 0)
1166 +    (void) SvREFCNT_inc(sv);
1167 +  if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1168 +    return(clone_info);
1169 +  clone_info=ClonePackageInfo(package_info,exception);
1170 +  sv_setiv(sv,PTR2IV(clone_info));
1171 +  return(clone_info);
1172 +}
1173 +\f
1174 +/*
1175 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1176 +%                                                                             %
1177 +%                                                                             %
1178 +%                                                                             %
1179 +%   S e t A t t r i b u t e                                                   %
1180 +%                                                                             %
1181 +%                                                                             %
1182 +%                                                                             %
1183 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1184 +%
1185 +%  SetAttribute() sets the attribute to the value in sval.  This can change
1186 +%  either or both of image or info.
1187 +%
1188 +%  The format of the SetAttribute routine is:
1189 +%
1190 +%      SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1191 +%        SV *sval,ExceptionInfo *exception)
1192 +%
1193 +%  A description of each parameter follows:
1194 +%
1195 +%    o list: a list of strings.
1196 +%
1197 +%    o string: a character string.
1198 +%
1199 +*/
1200 +
1201 +static double SiPrefixToDoubleInterval(const char *string,const double interval)
1202 +{
1203 +  char
1204 +    *q;
1205 +
1206 +  double
1207 +    value;
1208 +
1209 +  value=InterpretSiPrefixValue(string,&q);
1210 +  if (*q == '%')
1211 +    value*=interval/100.0;
1212 +  return(value);
1213 +}
1214 +
1215 +static inline double StringToDouble(const char *string,char **sentinal)
1216 +{
1217 +  return(InterpretLocaleValue(string,sentinal));
1218 +}
1219 +
1220 +static double StringToDoubleInterval(const char *string,const double interval)
1221 +{
1222 +  char
1223 +    *q;
1224 +
1225 +  double
1226 +    value;
1227 +
1228 +  value=InterpretLocaleValue(string,&q);
1229 +  if (*q == '%')
1230 +    value*=interval/100.0;
1231 +  return(value);
1232 +}
1233 +
1234 +static inline ssize_t StringToLong(const char *value)
1235 +{
1236 +  return(strtol(value,(char **) NULL,10));
1237 +}
1238 +
1239 +static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1240 +  const char *attribute,SV *sval,ExceptionInfo *exception)
1241 +{
1242 +  GeometryInfo
1243 +    geometry_info;
1244 +
1245 +  long
1246 +    x,
1247 +    y;
1248 +
1249 +  MagickPixelPacket
1250 +    pixel;
1251 +
1252 +  MagickStatusType
1253 +    flags;
1254 +
1255 +  PixelPacket
1256 +    *color,
1257 +    target_color;
1258 +
1259 +  ssize_t
1260 +    sp;
1261 +
1262 +  switch (*attribute)
1263 +  {
1264 +    case 'A':
1265 +    case 'a':
1266 +    {
1267 +      if (LocaleCompare(attribute,"adjoin") == 0)
1268 +        {
1269 +          sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1270 +            SvPV(sval,na)) : SvIV(sval);
1271 +          if (sp < 0)
1272 +            {
1273 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
1274 +                SvPV(sval,na));
1275 +              break;
1276 +            }
1277 +          if (info)
1278 +            info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1279 +          break;
1280 +        }
1281 +      if (LocaleCompare(attribute,"alpha") == 0)
1282 +        {
1283 +          sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1284 +            SvPV(sval,na)) : SvIV(sval);
1285 +          if (sp < 0)
1286 +            {
1287 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
1288 +                SvPV(sval,na));
1289 +              break;
1290 +            }
1291 +          for ( ; image; image=image->next)
1292 +            (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1293 +          break;
1294 +        }
1295 +      if (LocaleCompare(attribute,"antialias") == 0)
1296 +        {
1297 +          sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1298 +            SvPV(sval,na)) : SvIV(sval);
1299 +          if (sp < 0)
1300 +            {
1301 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
1302 +                SvPV(sval,na));
1303 +              break;
1304 +            }
1305 +          if (info)
1306 +            info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1307 +          break;
1308 +        }
1309 +      if (LocaleCompare(attribute,"area-limit") == 0)
1310 +        {
1311 +          MagickSizeType
1312 +            limit;
1313 +
1314 +          limit=MagickResourceInfinity;
1315 +          if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1316 +            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1317 +              100.0);
1318 +          (void) SetMagickResourceLimit(AreaResource,limit);
1319 +          break;
1320 +        }
1321 +      if (LocaleCompare(attribute,"attenuate") == 0)
1322 +        {
1323 +          if (info)
1324 +            (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1325 +          break;
1326 +        }
1327 +      if (LocaleCompare(attribute,"authenticate") == 0)
1328 +        {
1329 +          if (info)
1330 +            (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1331 +          break;
1332 +        }
1333 +      if (info)
1334 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1335 +      for ( ; image; image=image->next)
1336 +        SetImageProperty(image,attribute,SvPV(sval,na));
1337 +      break;
1338 +    }
1339 +    case 'B':
1340 +    case 'b':
1341 +    {
1342 +      if (LocaleCompare(attribute,"background") == 0)
1343 +        {
1344 +          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1345 +          if (info)
1346 +            info->image_info->background_color=target_color;
1347 +          for ( ; image; image=image->next)
1348 +            image->background_color=target_color;
1349 +          break;
1350 +        }
1351 +      if (LocaleCompare(attribute,"bias") == 0)
1352 +        {
1353 +          for ( ; image; image=image->next)
1354 +            image->bias=StringToDoubleInterval(SvPV(sval,na),(double)
1355 +              QuantumRange+1.0);
1356 +          break;
1357 +        }
1358 +      if (LocaleCompare(attribute,"blue-primary") == 0)
1359 +        {
1360 +          for ( ; image; image=image->next)
1361 +          {
1362 +            flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1363 +            image->chromaticity.blue_primary.x=geometry_info.rho;
1364 +            image->chromaticity.blue_primary.y=geometry_info.sigma;
1365 +            if ((flags & SigmaValue) == 0)
1366 +              image->chromaticity.blue_primary.y=
1367 +                image->chromaticity.blue_primary.x;
1368 +          }
1369 +          break;
1370 +        }
1371 +      if (LocaleCompare(attribute,"bordercolor") == 0)
1372 +        {
1373 +          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1374 +          if (info)
1375 +            info->image_info->border_color=target_color;
1376 +          for ( ; image; image=image->next)
1377 +            image->border_color=target_color;
1378 +          break;
1379 +        }
1380 +      if (info)
1381 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1382 +      for ( ; image; image=image->next)
1383 +        SetImageProperty(image,attribute,SvPV(sval,na));
1384 +      break;
1385 +    }
1386 +    case 'C':
1387 +    case 'c':
1388 +    {
1389 +      if (LocaleCompare(attribute,"cache-threshold") == 0)
1390 +        {
1391 +          (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1392 +            SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1393 +          (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1394 +            (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1395 +          break;
1396 +        }
1397 +      if (LocaleCompare(attribute,"clip-mask") == 0)
1398 +        {
1399 +          Image
1400 +            *clip_mask;
1401 +
1402 +          clip_mask=(Image *) NULL;
1403 +          if (SvPOK(sval))
1404 +            clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1405 +          for ( ; image; image=image->next)
1406 +            SetImageClipMask(image,clip_mask);
1407 +          break;
1408 +        }
1409 +      if (LocaleNCompare(attribute,"colormap",8) == 0)
1410 +        {
1411 +          for ( ; image; image=image->next)
1412 +          {
1413 +            int
1414 +              items;
1415 +
1416 +            long
1417 +              i;
1418 +
1419 +            if (image->storage_class == DirectClass)
1420 +              continue;
1421 +            i=0;
1422 +            items=sscanf(attribute,"%*[^[][%ld",&i);
1423 +            (void) items;
1424 +            if (i > (ssize_t) image->colors)
1425 +              i%=image->colors;
1426 +            if ((strchr(SvPV(sval,na),',') == 0) ||
1427 +                (strchr(SvPV(sval,na),')') != 0))
1428 +              QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1429 +            else
1430 +              {
1431 +                color=image->colormap+i;
1432 +                pixel.red=color->red;
1433 +                pixel.green=color->green;
1434 +                pixel.blue=color->blue;
1435 +                flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1436 +                pixel.red=geometry_info.rho;
1437 +                pixel.green=geometry_info.sigma;
1438 +                pixel.blue=geometry_info.xi;
1439 +                color->red=ClampToQuantum(pixel.red);
1440 +                color->green=ClampToQuantum(pixel.green);
1441 +                color->blue=ClampToQuantum(pixel.blue);
1442 +              }
1443 +          }
1444 +          break;
1445 +        }
1446 +      if (LocaleCompare(attribute,"colorspace") == 0)
1447 +        {
1448 +          sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1449 +            MagickFalse,SvPV(sval,na)) : SvIV(sval);
1450 +          if (sp < 0)
1451 +            {
1452 +              ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1453 +                SvPV(sval,na));
1454 +              break;
1455 +            }
1456 +          for ( ; image; image=image->next)
1457 +            (void) TransformImageColorspace(image,(ColorspaceType) sp);
1458 +          break;
1459 +        }
1460 +      if (LocaleCompare(attribute,"comment") == 0)
1461 +        {
1462 +          for ( ; image; image=image->next)
1463 +            (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1464 +              info ? info->image_info : (ImageInfo *) NULL,image,
1465 +              SvPV(sval,na)));
1466 +          break;
1467 +        }
1468 +      if (LocaleCompare(attribute,"compression") == 0)
1469 +        {
1470 +          sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1471 +            MagickFalse,SvPV(sval,na)) : SvIV(sval);
1472 +          if (sp < 0)
1473 +            {
1474 +              ThrowPerlException(exception,OptionError,
1475 +                "UnrecognizedImageCompression",SvPV(sval,na));
1476 +              break;
1477 +            }
1478 +          if (info)
1479 +            info->image_info->compression=(CompressionType) sp;
1480 +          for ( ; image; image=image->next)
1481 +            image->compression=(CompressionType) sp;
1482 +          break;
1483 +        }
1484 +      if (info)
1485 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1486 +      for ( ; image; image=image->next)
1487 +        SetImageProperty(image,attribute,SvPV(sval,na));
1488 +      break;
1489 +    }
1490 +    case 'D':
1491 +    case 'd':
1492 +    {
1493 +      if (LocaleCompare(attribute,"debug") == 0)
1494 +        {
1495 +          SetLogEventMask(SvPV(sval,na));
1496 +          break;
1497 +        }
1498 +      if (LocaleCompare(attribute,"delay") == 0)
1499 +        {
1500 +          flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1501 +          for ( ; image; image=image->next)
1502 +          {
1503 +            image->delay=(size_t) floor(geometry_info.rho+0.5);
1504 +            if ((flags & SigmaValue) != 0)
1505 +              image->ticks_per_second=(ssize_t)
1506 +                floor(geometry_info.sigma+0.5);
1507 +          }
1508 +          break;
1509 +        }
1510 +      if (LocaleCompare(attribute,"disk-limit") == 0)
1511 +        {
1512 +          MagickSizeType
1513 +            limit;
1514 +
1515 +          limit=MagickResourceInfinity;
1516 +          if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1517 +            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1518 +              100.0);
1519 +          (void) SetMagickResourceLimit(DiskResource,limit);
1520 +          break;
1521 +        }
1522 +      if (LocaleCompare(attribute,"density") == 0)
1523 +        {
1524 +          if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1525 +            {
1526 +              ThrowPerlException(exception,OptionError,"MissingGeometry",
1527 +                SvPV(sval,na));
1528 +              break;
1529 +            }
1530 +          if (info)
1531 +            (void) CloneString(&info->image_info->density,SvPV(sval,na));
1532 +          for ( ; image; image=image->next)
1533 +          {
1534 +            flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1535 +            image->x_resolution=geometry_info.rho;
1536 +            image->y_resolution=geometry_info.sigma;
1537 +            if ((flags & SigmaValue) == 0)
1538 +              image->y_resolution=image->x_resolution;
1539 +          }
1540 +          break;
1541 +        }
1542 +      if (LocaleCompare(attribute,"depth") == 0)
1543 +        {
1544 +          if (info)
1545 +            info->image_info->depth=SvIV(sval);
1546 +          for ( ; image; image=image->next)
1547 +            (void) SetImageDepth(image,SvIV(sval));
1548 +          break;
1549 +        }
1550 +      if (LocaleCompare(attribute,"dispose") == 0)
1551 +        {
1552 +          sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1553 +            SvPV(sval,na)) : SvIV(sval);
1554 +          if (sp < 0)
1555 +            {
1556 +              ThrowPerlException(exception,OptionError,
1557 +                "UnrecognizedDisposeMethod",SvPV(sval,na));
1558 +              break;
1559 +            }
1560 +          for ( ; image; image=image->next)
1561 +            image->dispose=(DisposeType) sp;
1562 +          break;
1563 +        }
1564 +      if (LocaleCompare(attribute,"dither") == 0)
1565 +        {
1566 +          if (info)
1567 +            {
1568 +              sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1569 +                MagickFalse,SvPV(sval,na)) : SvIV(sval);
1570 +              if (sp < 0)
1571 +                {
1572 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
1573 +                    SvPV(sval,na));
1574 +                  break;
1575 +                }
1576 +              info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1577 +            }
1578 +          break;
1579 +        }
1580 +      if (LocaleCompare(attribute,"display") == 0)
1581 +        {
1582 +          display:
1583 +          if (info)
1584 +            (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1585 +          break;
1586 +        }
1587 +      if (info)
1588 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1589 +      for ( ; image; image=image->next)
1590 +        SetImageProperty(image,attribute,SvPV(sval,na));
1591 +      break;
1592 +    }
1593 +    case 'E':
1594 +    case 'e':
1595 +    {
1596 +      if (LocaleCompare(attribute,"endian") == 0)
1597 +        {
1598 +          sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1599 +            SvPV(sval,na)) : SvIV(sval);
1600 +          if (sp < 0)
1601 +            {
1602 +              ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1603 +                SvPV(sval,na));
1604 +              break;
1605 +            }
1606 +          if (info)
1607 +            info->image_info->endian=(EndianType) sp;
1608 +          for ( ; image; image=image->next)
1609 +            image->endian=(EndianType) sp;
1610 +          break;
1611 +        }
1612 +      if (LocaleCompare(attribute,"extract") == 0)
1613 +        {
1614 +          /*
1615 +            Set image extract geometry.
1616 +          */
1617 +          (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1618 +          break;
1619 +        }
1620 +      if (info)
1621 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1622 +      for ( ; image; image=image->next)
1623 +        SetImageProperty(image,attribute,SvPV(sval,na));
1624 +      break;
1625 +    }
1626 +    case 'F':
1627 +    case 'f':
1628 +    {
1629 +      if (LocaleCompare(attribute,"filename") == 0)
1630 +        {
1631 +          if (info)
1632 +            (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1633 +              MaxTextExtent);
1634 +          for ( ; image; image=image->next)
1635 +            (void) CopyMagickString(image->filename,SvPV(sval,na),
1636 +              MaxTextExtent);
1637 +          break;
1638 +        }
1639 +      if (LocaleCompare(attribute,"file") == 0)
1640 +        {
1641 +          FILE
1642 +            *file;
1643 +
1644 +          PerlIO
1645 +            *io_info;
1646 +
1647 +          if (info == (struct PackageInfo *) NULL)
1648 +            break;
1649 +          io_info=IoIFP(sv_2io(sval));
1650 +          if (io_info == (PerlIO *) NULL)
1651 +            {
1652 +              ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1653 +                PackageName);
1654 +              break;
1655 +            }
1656 +          file=PerlIO_findFILE(io_info);
1657 +          if (file == (FILE *) NULL)
1658 +            {
1659 +              ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1660 +                PackageName);
1661 +              break;
1662 +            }
1663 +          SetImageInfoFile(info->image_info,file);
1664 +          break;
1665 +        }
1666 +      if (LocaleCompare(attribute,"fill") == 0)
1667 +        {
1668 +          if (info)
1669 +            (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1670 +          break;
1671 +        }
1672 +      if (LocaleCompare(attribute,"font") == 0)
1673 +        {
1674 +          if (info)
1675 +            (void) CloneString(&info->image_info->font,SvPV(sval,na));
1676 +          break;
1677 +        }
1678 +      if (LocaleCompare(attribute,"foreground") == 0)
1679 +        break;
1680 +      if (LocaleCompare(attribute,"fuzz") == 0)
1681 +        {
1682 +          if (info)
1683 +            info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1684 +              QuantumRange+1.0);
1685 +          for ( ; image; image=image->next)
1686 +            image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1687 +              QuantumRange+1.0);
1688 +          break;
1689 +        }
1690 +      if (info)
1691 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1692 +      for ( ; image; image=image->next)
1693 +        SetImageProperty(image,attribute,SvPV(sval,na));
1694 +      break;
1695 +    }
1696 +    case 'G':
1697 +    case 'g':
1698 +    {
1699 +      if (LocaleCompare(attribute,"gamma") == 0)
1700 +        {
1701 +          for ( ; image; image=image->next)
1702 +            image->gamma=SvNV(sval);
1703 +          break;
1704 +        }
1705 +      if (LocaleCompare(attribute,"gravity") == 0)
1706 +        {
1707 +          sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1708 +            SvPV(sval,na)) : SvIV(sval);
1709 +          if (sp < 0)
1710 +            {
1711 +              ThrowPerlException(exception,OptionError,
1712 +                "UnrecognizedGravityType",SvPV(sval,na));
1713 +              break;
1714 +            }
1715 +          if (info)
1716 +            SetImageOption(info->image_info,attribute,SvPV(sval,na));
1717 +          for ( ; image; image=image->next)
1718 +            image->gravity=(GravityType) sp;
1719 +          break;
1720 +        }
1721 +      if (LocaleCompare(attribute,"green-primary") == 0)
1722 +        {
1723 +          for ( ; image; image=image->next)
1724 +          {
1725 +            flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1726 +            image->chromaticity.green_primary.x=geometry_info.rho;
1727 +            image->chromaticity.green_primary.y=geometry_info.sigma;
1728 +            if ((flags & SigmaValue) == 0)
1729 +              image->chromaticity.green_primary.y=
1730 +                image->chromaticity.green_primary.x;
1731 +          }
1732 +          break;
1733 +        }
1734 +      if (info)
1735 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1736 +      for ( ; image; image=image->next)
1737 +        SetImageProperty(image,attribute,SvPV(sval,na));
1738 +      break;
1739 +    }
1740 +    case 'I':
1741 +    case 'i':
1742 +    {
1743 +      if (LocaleNCompare(attribute,"index",5) == 0)
1744 +        {
1745 +          IndexPacket
1746 +            *indexes;
1747 +
1748 +          int
1749 +            items;
1750 +
1751 +          long
1752 +            index;
1753 +
1754 +          register PixelPacket
1755 +            *p;
1756 +
1757 +          CacheView
1758 +            *image_view;
1759 +
1760 +          for ( ; image; image=image->next)
1761 +          {
1762 +            if (image->storage_class != PseudoClass)
1763 +              continue;
1764 +            x=0;
1765 +            y=0;
1766 +            items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1767 +            (void) items;
1768 +            image_view=AcquireAuthenticCacheView(image,exception);
1769 +            p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1770 +            if (p != (PixelPacket *) NULL)
1771 +              {
1772 +                indexes=GetCacheViewAuthenticIndexQueue(image_view);
1773 +                items=sscanf(SvPV(sval,na),"%ld",&index);
1774 +                if ((index >= 0) && (index < (ssize_t) image->colors))
1775 +                  SetPixelIndex(indexes,index);
1776 +                (void) SyncCacheViewAuthenticPixels(image_view,exception);
1777 +              }
1778 +            image_view=DestroyCacheView(image_view);
1779 +          }
1780 +          break;
1781 +        }
1782 +      if (LocaleCompare(attribute,"iterations") == 0)
1783 +        {
1784 +  iterations:
1785 +          for ( ; image; image=image->next)
1786 +            image->iterations=SvIV(sval);
1787 +          break;
1788 +        }
1789 +      if (LocaleCompare(attribute,"interlace") == 0)
1790 +        {
1791 +          sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1792 +            MagickFalse,SvPV(sval,na)) : SvIV(sval);
1793 +          if (sp < 0)
1794 +            {
1795 +              ThrowPerlException(exception,OptionError,
1796 +                "UnrecognizedInterlaceType",SvPV(sval,na));
1797 +              break;
1798 +            }
1799 +          if (info)
1800 +            info->image_info->interlace=(InterlaceType) sp;
1801 +          for ( ; image; image=image->next)
1802 +            image->interlace=(InterlaceType) sp;
1803 +          break;
1804 +        }
1805 +      if (info)
1806 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1807 +      for ( ; image; image=image->next)
1808 +        SetImageProperty(image,attribute,SvPV(sval,na));
1809 +      break;
1810 +    }
1811 +    case 'L':
1812 +    case 'l':
1813 +    {
1814 +      if (LocaleCompare(attribute,"label") == 0)
1815 +        {
1816 +          for ( ; image; image=image->next)
1817 +            (void) SetImageProperty(image,"label",InterpretImageProperties(
1818 +              info ? info->image_info : (ImageInfo *) NULL,image,
1819 +              SvPV(sval,na)));
1820 +          break;
1821 +        }
1822 +      if (LocaleCompare(attribute,"loop") == 0)
1823 +        goto iterations;
1824 +      if (info)
1825 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1826 +      for ( ; image; image=image->next)
1827 +        SetImageProperty(image,attribute,SvPV(sval,na));
1828 +      break;
1829 +    }
1830 +    case 'M':
1831 +    case 'm':
1832 +    {
1833 +      if (LocaleCompare(attribute,"magick") == 0)
1834 +        {
1835 +          if (info)
1836 +            (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1837 +              "%s:",SvPV(sval,na));
1838 +          for ( ; image; image=image->next)
1839 +            (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1840 +          break;
1841 +        }
1842 +      if (LocaleCompare(attribute,"map-limit") == 0)
1843 +        {
1844 +          MagickSizeType
1845 +            limit;
1846 +
1847 +          limit=MagickResourceInfinity;
1848 +          if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1849 +            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1850 +              100.0);
1851 +          (void) SetMagickResourceLimit(MapResource,limit);
1852 +          break;
1853 +        }
1854 +      if (LocaleCompare(attribute,"mask") == 0)
1855 +        {
1856 +          Image
1857 +            *mask;
1858 +
1859 +          mask=(Image *) NULL;
1860 +          if (SvPOK(sval))
1861 +            mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1862 +          for ( ; image; image=image->next)
1863 +            SetImageMask(image,mask);
1864 +          break;
1865 +        }
1866 +      if (LocaleCompare(attribute,"mattecolor") == 0)
1867 +        {
1868 +          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1869 +          if (info)
1870 +            info->image_info->matte_color=target_color;
1871 +          for ( ; image; image=image->next)
1872 +            image->matte_color=target_color;
1873 +          break;
1874 +        }
1875 +      if (LocaleCompare(attribute,"matte") == 0)
1876 +        {
1877 +          sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1878 +            SvPV(sval,na)) : SvIV(sval);
1879 +          if (sp < 0)
1880 +            {
1881 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
1882 +                SvPV(sval,na));
1883 +              break;
1884 +            }
1885 +          for ( ; image; image=image->next)
1886 +            image->matte=sp != 0 ? MagickTrue : MagickFalse;
1887 +          break;
1888 +        }
1889 +      if (LocaleCompare(attribute,"memory-limit") == 0)
1890 +        {
1891 +          MagickSizeType
1892 +            limit;
1893 +
1894 +          limit=MagickResourceInfinity;
1895 +          if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1896 +            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1897 +              100.0);
1898 +          (void) SetMagickResourceLimit(MemoryResource,limit);
1899 +          break;
1900 +        }
1901 +      if (LocaleCompare(attribute,"monochrome") == 0)
1902 +        {
1903 +          sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1904 +            SvPV(sval,na)) : SvIV(sval);
1905 +          if (sp < 0)
1906 +            {
1907 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
1908 +                SvPV(sval,na));
1909 +              break;
1910 +            }
1911 +          if (info)
1912 +            info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1913 +          for ( ; image; image=image->next)
1914 +            (void) SetImageType(image,BilevelType);
1915 +          break;
1916 +        }
1917 +      if (info)
1918 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1919 +      for ( ; image; image=image->next)
1920 +        SetImageProperty(image,attribute,SvPV(sval,na));
1921 +      break;
1922 +    }
1923 +    case 'O':
1924 +    case 'o':
1925 +    {
1926 +      if (LocaleCompare(attribute,"option") == 0)
1927 +        {
1928 +          if (info)
1929 +            DefineImageOption(info->image_info,SvPV(sval,na));
1930 +          break;
1931 +        }
1932 +      if (LocaleCompare(attribute,"orientation") == 0)
1933 +        {
1934 +          sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1935 +            MagickFalse,SvPV(sval,na)) : SvIV(sval);
1936 +          if (sp < 0)
1937 +            {
1938 +              ThrowPerlException(exception,OptionError,
1939 +                "UnrecognizedOrientationType",SvPV(sval,na));
1940 +              break;
1941 +            }
1942 +          if (info)
1943 +            info->image_info->orientation=(OrientationType) sp;
1944 +          for ( ; image; image=image->next)
1945 +            image->orientation=(OrientationType) sp;
1946 +          break;
1947 +        }
1948 +      if (info)
1949 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
1950 +      for ( ; image; image=image->next)
1951 +        SetImageProperty(image,attribute,SvPV(sval,na));
1952 +      break;
1953 +    }
1954 +    case 'P':
1955 +    case 'p':
1956 +    {
1957 +      if (LocaleCompare(attribute,"page") == 0)
1958 +        {
1959 +          char
1960 +            *geometry;
1961 +
1962 +          geometry=GetPageGeometry(SvPV(sval,na));
1963 +          if (info)
1964 +            (void) CloneString(&info->image_info->page,geometry);
1965 +          for ( ; image; image=image->next)
1966 +            (void) ParsePageGeometry(image,geometry,&image->page,exception);
1967 +          geometry=(char *) RelinquishMagickMemory(geometry);
1968 +          break;
1969 +        }
1970 +      if (LocaleCompare(attribute,"pen") == 0)
1971 +        {
1972 +          if (info)
1973 +            (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1974 +          break;
1975 +        }
1976 +      if (LocaleNCompare(attribute,"pixel",5) == 0)
1977 +        {
1978 +          int
1979 +            items;
1980 +
1981 +          MagickPixelPacket
1982 +            pixel;
1983 +
1984 +          register IndexPacket
1985 +            *indexes;
1986 +
1987 +          register PixelPacket
1988 +            *q;
1989 +
1990 +          CacheView
1991 +            *image_view;
1992 +
1993 +          for ( ; image; image=image->next)
1994 +          {
1995 +            if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1996 +              break;
1997 +            x=0;
1998 +            y=0;
1999 +            items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
2000 +            (void) items;
2001 +            image_view=AcquireAuthenticCacheView(image,exception);
2002 +            q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
2003 +            indexes=GetCacheViewAuthenticIndexQueue(image_view);
2004 +            if (q != (PixelPacket *) NULL)
2005 +              {
2006 +                if ((strchr(SvPV(sval,na),',') == 0) ||
2007 +                    (strchr(SvPV(sval,na),')') != 0))
2008 +                  QueryMagickColor(SvPV(sval,na),&pixel,exception);
2009 +                else
2010 +                  {
2011 +                    GetMagickPixelPacket(image,&pixel);
2012 +                    flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2013 +                    pixel.red=geometry_info.rho;
2014 +                    if ((flags & SigmaValue) != 0)
2015 +                      pixel.green=geometry_info.sigma;
2016 +                    if ((flags & XiValue) != 0)
2017 +                      pixel.blue=geometry_info.xi;
2018 +                    if ((flags & PsiValue) != 0)
2019 +                      pixel.opacity=geometry_info.psi;
2020 +                    if ((flags & ChiValue) != 0)
2021 +                      pixel.index=geometry_info.chi;
2022 +                  }
2023 +                SetPixelRed(q,ClampToQuantum(pixel.red));
2024 +                SetPixelGreen(q,ClampToQuantum(pixel.green));
2025 +                SetPixelBlue(q,ClampToQuantum(pixel.blue));
2026 +                SetPixelOpacity(q,ClampToQuantum(pixel.opacity));
2027 +                if (((image->colorspace == CMYKColorspace) ||
2028 +                     (image->storage_class == PseudoClass)) &&
2029 +                    (indexes != (IndexPacket *) NULL))
2030 +                  SetPixelIndex(indexes,ClampToQuantum(pixel.index));
2031 +                (void) SyncCacheViewAuthenticPixels(image_view,exception);
2032 +              }
2033 +            image_view=DestroyCacheView(image_view);
2034 +          }
2035 +          break;
2036 +        }
2037 +      if (LocaleCompare(attribute,"pointsize") == 0)
2038 +        {
2039 +          if (info)
2040 +            {
2041 +              (void) ParseGeometry(SvPV(sval,na),&geometry_info);
2042 +              info->image_info->pointsize=geometry_info.rho;
2043 +            }
2044 +          break;
2045 +        }
2046 +      if (LocaleCompare(attribute,"preview") == 0)
2047 +        {
2048 +          sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
2049 +            SvPV(sval,na)) : SvIV(sval);
2050 +          if (sp < 0)
2051 +            {
2052 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
2053 +                SvPV(sval,na));
2054 +              break;
2055 +            }
2056 +          if (info)
2057 +            info->image_info->preview_type=(PreviewType) sp;
2058 +          break;
2059 +        }
2060 +      if (info)
2061 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2062 +      for ( ; image; image=image->next)
2063 +        SetImageProperty(image,attribute,SvPV(sval,na));
2064 +      break;
2065 +    }
2066 +    case 'Q':
2067 +    case 'q':
2068 +    {
2069 +      if (LocaleCompare(attribute,"quality") == 0)
2070 +        {
2071 +          if (info)
2072 +            info->image_info->quality=SvIV(sval);
2073 +          for ( ; image; image=image->next)
2074 +            image->quality=SvIV(sval);
2075 +          break;
2076 +        }
2077 +      if (info)
2078 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2079 +      for ( ; image; image=image->next)
2080 +        SetImageProperty(image,attribute,SvPV(sval,na));
2081 +      break;
2082 +    }
2083 +    case 'R':
2084 +    case 'r':
2085 +    {
2086 +      if (LocaleCompare(attribute,"red-primary") == 0)
2087 +        {
2088 +          for ( ; image; image=image->next)
2089 +          {
2090 +            flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2091 +            image->chromaticity.red_primary.x=geometry_info.rho;
2092 +            image->chromaticity.red_primary.y=geometry_info.sigma;
2093 +            if ((flags & SigmaValue) == 0)
2094 +              image->chromaticity.red_primary.y=
2095 +                image->chromaticity.red_primary.x;
2096 +          }
2097 +          break;
2098 +        }
2099 +      if (LocaleCompare(attribute,"render") == 0)
2100 +        {
2101 +          sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
2102 +            SvPV(sval,na)) : SvIV(sval);
2103 +          if (sp < 0)
2104 +            {
2105 +              ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
2106 +                SvPV(sval,na));
2107 +              break;
2108 +            }
2109 +         for ( ; image; image=image->next)
2110 +           image->rendering_intent=(RenderingIntent) sp;
2111 +         break;
2112 +       }
2113 +      if (LocaleCompare(attribute,"repage") == 0)
2114 +        {
2115 +          RectangleInfo
2116 +            geometry;
2117 +
2118 +          for ( ; image; image=image->next)
2119 +          {
2120 +            flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
2121 +            if ((flags & WidthValue) != 0)
2122 +              {
2123 +                if ((flags & HeightValue) == 0)
2124 +                  geometry.height=geometry.width;
2125 +                image->page.width=geometry.width;
2126 +                image->page.height=geometry.height;
2127 +              }
2128 +            if ((flags & AspectValue) != 0)
2129 +              {
2130 +                if ((flags & XValue) != 0)
2131 +                  image->page.x+=geometry.x;
2132 +                if ((flags & YValue) != 0)
2133 +                  image->page.y+=geometry.y;
2134 +              }
2135 +            else
2136 +              {
2137 +                if ((flags & XValue) != 0)
2138 +                  {
2139 +                    image->page.x=geometry.x;
2140 +                    if (((flags & WidthValue) != 0) && (geometry.x > 0))
2141 +                      image->page.width=image->columns+geometry.x;
2142 +                  }
2143 +                if ((flags & YValue) != 0)
2144 +                  {
2145 +                    image->page.y=geometry.y;
2146 +                    if (((flags & HeightValue) != 0) && (geometry.y > 0))
2147 +                      image->page.height=image->rows+geometry.y;
2148 +                  }
2149 +              }
2150 +          }
2151 +          break;
2152 +        }
2153 +      if (info)
2154 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2155 +      for ( ; image; image=image->next)
2156 +        SetImageProperty(image,attribute,SvPV(sval,na));
2157 +      break;
2158 +    }
2159 +    case 'S':
2160 +    case 's':
2161 +    {
2162 +      if (LocaleCompare(attribute,"sampling-factor") == 0)
2163 +        {
2164 +          if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2165 +            {
2166 +              ThrowPerlException(exception,OptionError,"MissingGeometry",
2167 +                SvPV(sval,na));
2168 +              break;
2169 +            }
2170 +          if (info)
2171 +            (void) CloneString(&info->image_info->sampling_factor,
2172 +              SvPV(sval,na));
2173 +          break;
2174 +        }
2175 +      if (LocaleCompare(attribute,"scene") == 0)
2176 +        {
2177 +          for ( ; image; image=image->next)
2178 +            image->scene=SvIV(sval);
2179 +          break;
2180 +        }
2181 +      if (LocaleCompare(attribute,"subimage") == 0)
2182 +        {
2183 +          if (info)
2184 +            info->image_info->subimage=SvIV(sval);
2185 +          break;
2186 +        }
2187 +      if (LocaleCompare(attribute,"subrange") == 0)
2188 +        {
2189 +          if (info)
2190 +            info->image_info->subrange=SvIV(sval);
2191 +          break;
2192 +        }
2193 +      if (LocaleCompare(attribute,"server") == 0)
2194 +        goto display;
2195 +      if (LocaleCompare(attribute,"size") == 0)
2196 +        {
2197 +          if (info)
2198 +            {
2199 +              if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2200 +                {
2201 +                  ThrowPerlException(exception,OptionError,"MissingGeometry",
2202 +                    SvPV(sval,na));
2203 +                  break;
2204 +                }
2205 +              (void) CloneString(&info->image_info->size,SvPV(sval,na));
2206 +            }
2207 +          break;
2208 +        }
2209 +      if (LocaleCompare(attribute,"stroke") == 0)
2210 +        {
2211 +          if (info)
2212 +            (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2213 +          break;
2214 +        }
2215 +      if (info)
2216 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2217 +      for ( ; image; image=image->next)
2218 +        SetImageProperty(image,attribute,SvPV(sval,na));
2219 +      break;
2220 +    }
2221 +    case 'T':
2222 +    case 't':
2223 +    {
2224 +      if (LocaleCompare(attribute,"texture") == 0)
2225 +        {
2226 +          if (info)
2227 +            (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2228 +          break;
2229 +        }
2230 +      if (LocaleCompare(attribute,"thread-limit") == 0)
2231 +        {
2232 +          MagickSizeType
2233 +            limit;
2234 +
2235 +          limit=MagickResourceInfinity;
2236 +          if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2237 +            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2238 +              100.0);
2239 +          (void) SetMagickResourceLimit(ThreadResource,limit);
2240 +          break;
2241 +        }
2242 +      if (LocaleCompare(attribute,"tile") == 0)
2243 +        {
2244 +          if (info)
2245 +            (void) CloneString(&info->image_info->tile,SvPV(sval,na));
2246 +          break;
2247 +        }
2248 +      if (LocaleCompare(attribute,"tile-offset") == 0)
2249 +        {
2250 +          char
2251 +            *geometry;
2252 +
2253 +          geometry=GetPageGeometry(SvPV(sval,na));
2254 +          if (info)
2255 +            (void) CloneString(&info->image_info->page,geometry);
2256 +          for ( ; image; image=image->next)
2257 +            (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2258 +              exception);
2259 +          geometry=(char *) RelinquishMagickMemory(geometry);
2260 +          break;
2261 +        }
2262 +      if (LocaleCompare(attribute,"time-limit") == 0)
2263 +        {
2264 +          MagickSizeType
2265 +            limit;
2266 +
2267 +          limit=MagickResourceInfinity;
2268 +          if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2269 +            limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2270 +              100.0);
2271 +          (void) SetMagickResourceLimit(TimeResource,limit);
2272 +          break;
2273 +        }
2274 +      if (LocaleCompare(attribute,"transparent-color") == 0)
2275 +        {
2276 +          (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2277 +          if (info)
2278 +            info->image_info->transparent_color=target_color;
2279 +          for ( ; image; image=image->next)
2280 +            image->transparent_color=target_color;
2281 +          break;
2282 +        }
2283 +      if (LocaleCompare(attribute,"type") == 0)
2284 +        {
2285 +          sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2286 +            SvPV(sval,na)) : SvIV(sval);
2287 +          if (sp < 0)
2288 +            {
2289 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
2290 +                SvPV(sval,na));
2291 +              break;
2292 +            }
2293 +          if (info)
2294 +            info->image_info->type=(ImageType) sp;
2295 +          for ( ; image; image=image->next)
2296 +            SetImageType(image,(ImageType) sp);
2297 +          break;
2298 +        }
2299 +      if (info)
2300 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2301 +      for ( ; image; image=image->next)
2302 +        SetImageProperty(image,attribute,SvPV(sval,na));
2303 +      break;
2304 +    }
2305 +    case 'U':
2306 +    case 'u':
2307 +    {
2308 +      if (LocaleCompare(attribute,"units") == 0)
2309 +        {
2310 +          sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2311 +            MagickFalse,SvPV(sval,na)) : SvIV(sval);
2312 +          if (sp < 0)
2313 +            {
2314 +              ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2315 +                SvPV(sval,na));
2316 +              break;
2317 +            }
2318 +          if (info)
2319 +            info->image_info->units=(ResolutionType) sp;
2320 +          for ( ; image; image=image->next)
2321 +          {
2322 +            ResolutionType
2323 +              units;
2324 +
2325 +            units=(ResolutionType) sp;
2326 +            if (image->units != units)
2327 +              switch (image->units)
2328 +              {
2329 +                case UndefinedResolution:
2330 +                case PixelsPerInchResolution:
2331 +                {
2332 +                  if (units == PixelsPerCentimeterResolution)
2333 +                    {
2334 +                      image->x_resolution*=2.54;
2335 +                      image->y_resolution*=2.54;
2336 +                    }
2337 +                  break;
2338 +                }
2339 +                case PixelsPerCentimeterResolution:
2340 +                {
2341 +                  if (units == PixelsPerInchResolution)
2342 +                    {
2343 +                      image->x_resolution/=2.54;
2344 +                      image->y_resolution/=2.54;
2345 +                    }
2346 +                  break;
2347 +                }
2348 +              }
2349 +            image->units=units;
2350 +          }
2351 +          break;
2352 +        }
2353 +      if (info)
2354 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2355 +      for ( ; image; image=image->next)
2356 +        SetImageProperty(image,attribute,SvPV(sval,na));
2357 +      break;
2358 +    }
2359 +    case 'V':
2360 +    case 'v':
2361 +    {
2362 +      if (LocaleCompare(attribute,"verbose") == 0)
2363 +        {
2364 +          sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2365 +            SvPV(sval,na)) : SvIV(sval);
2366 +          if (sp < 0)
2367 +            {
2368 +              ThrowPerlException(exception,OptionError,"UnrecognizedType",
2369 +                SvPV(sval,na));
2370 +              break;
2371 +            }
2372 +          if (info)
2373 +            info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2374 +          break;
2375 +        }
2376 +      if (LocaleCompare(attribute,"view") == 0)
2377 +        {
2378 +          if (info)
2379 +            (void) CloneString(&info->image_info->view,SvPV(sval,na));
2380 +          break;
2381 +        }
2382 +      if (LocaleCompare(attribute,"virtual-pixel") == 0)
2383 +        {
2384 +          sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2385 +            MagickFalse,SvPV(sval,na)) : SvIV(sval);
2386 +          if (sp < 0)
2387 +            {
2388 +              ThrowPerlException(exception,OptionError,
2389 +                "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2390 +              break;
2391 +            }
2392 +          if (info)
2393 +            info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2394 +          for ( ; image; image=image->next)
2395 +            SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2396 +          break;
2397 +        }
2398 +      if (info)
2399 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2400 +      for ( ; image; image=image->next)
2401 +        SetImageProperty(image,attribute,SvPV(sval,na));
2402 +      break;
2403 +    }
2404 +    case 'W':
2405 +    case 'w':
2406 +    {
2407 +      if (LocaleCompare(attribute,"white-point") == 0)
2408 +        {
2409 +          for ( ; image; image=image->next)
2410 +          {
2411 +            flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2412 +            image->chromaticity.white_point.x=geometry_info.rho;
2413 +            image->chromaticity.white_point.y=geometry_info.sigma;
2414 +            if ((flags & SigmaValue) == 0)
2415 +              image->chromaticity.white_point.y=
2416 +                image->chromaticity.white_point.x;
2417 +          }
2418 +          break;
2419 +        }
2420 +      if (info)
2421 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2422 +      for ( ; image; image=image->next)
2423 +        SetImageProperty(image,attribute,SvPV(sval,na));
2424 +      break;
2425 +    }
2426 +    default:
2427 +    {
2428 +      if (info)
2429 +        SetImageOption(info->image_info,attribute,SvPV(sval,na));
2430 +      for ( ; image; image=image->next)
2431 +        SetImageProperty(image,attribute,SvPV(sval,na));
2432 +      break;
2433 +    }
2434 +  }
2435 +}
2436 +\f
2437 +/*
2438 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2439 +%                                                                             %
2440 +%                                                                             %
2441 +%                                                                             %
2442 +%   S e t u p L i s t                                                         %
2443 +%                                                                             %
2444 +%                                                                             %
2445 +%                                                                             %
2446 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2447 +%
2448 +%  Method SetupList returns the list of all the images linked by their
2449 +%  image->next and image->previous link lists for use with ImageMagick.  If
2450 +%  info is non-NULL, an info structure is returned in *info.  If
2451 +%  reference_vector is non-NULL,an array of SV* are returned in
2452 +%  *reference_vector.  Reference_vector is used when the images are going to be
2453 +%  replaced with new Image*'s.
2454 +%
2455 +%  The format of the SetupList routine is:
2456 +%
2457 +%      Image *SetupList(SV *reference,struct PackageInfo **info,
2458 +%        SV ***reference_vector,ExceptionInfo *exception)
2459 +%
2460 +%  A description of each parameter follows:
2461 +%
2462 +%    o list: a list of strings.
2463 +%
2464 +%    o string: a character string.
2465 +%
2466 +%    o exception: Return any errors or warnings in this structure.
2467 +%
2468 +*/
2469 +static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2470 +  SV ***reference_vector,ExceptionInfo *exception)
2471 +{
2472 +  Image
2473 +    *image;
2474 +
2475 +  ssize_t
2476 +    current,
2477 +    last;
2478 +
2479 +  if (reference_vector)
2480 +    *reference_vector=NULL;
2481 +  if (info)
2482 +    *info=NULL;
2483 +  current=0;
2484 +  last=0;
2485 +  image=GetList(aTHX_ reference,reference_vector,&current,&last,exception);
2486 +  if (info && (SvTYPE(reference) == SVt_PVAV))
2487 +    *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2488 +      exception);
2489 +  return(image);
2490 +}
2491 +\f
2492 +/*
2493 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2494 +%                                                                             %
2495 +%                                                                             %
2496 +%                                                                             %
2497 +%   s t r E Q c a s e                                                         %
2498 +%                                                                             %
2499 +%                                                                             %
2500 +%                                                                             %
2501 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2502 +%
2503 +%  strEQcase() compares two strings and returns 0 if they are the
2504 +%  same or if the second string runs out first.  The comparison is case
2505 +%  insensitive.
2506 +%
2507 +%  The format of the strEQcase routine is:
2508 +%
2509 +%      ssize_t strEQcase(const char *p,const char *q)
2510 +%
2511 +%  A description of each parameter follows:
2512 +%
2513 +%    o p: a character string.
2514 +%
2515 +%    o q: a character string.
2516 +%
2517 +%
2518 +*/
2519 +static ssize_t strEQcase(const char *p,const char *q)
2520 +{
2521 +  char
2522 +    c;
2523 +
2524 +  register ssize_t
2525 +    i;
2526 +
2527 +  for (i=0 ; (c=(*q)) != 0; i++)
2528 +  {
2529 +    if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2530 +        (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2531 +      return(0);
2532 +    p++;
2533 +    q++;
2534 +  }
2535 +  return(((*q == 0) && (*p == 0)) ? i : 0);
2536 +}
2537 +\f
2538 +/*
2539 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2540 +%                                                                             %
2541 +%                                                                             %
2542 +%                                                                             %
2543 +%   I m a g e : : M a g i c k                                                 %
2544 +%                                                                             %
2545 +%                                                                             %
2546 +%                                                                             %
2547 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2548 +%
2549 +%
2550 +*/
2551 +MODULE = Image::Magick PACKAGE = Image::Magick
2552 +
2553 +PROTOTYPES: ENABLE
2554 +
2555 +BOOT:
2556 +  MagickCoreGenesis("PerlMagick",MagickFalse);
2557 +  SetWarningHandler(NULL);
2558 +  SetErrorHandler(NULL);
2559 +  magick_registry=NewSplayTree((int (*)(const void *,const void *))
2560 +    NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2561 +
2562 +void
2563 +UNLOAD()
2564 +  PPCODE:
2565 +  {
2566 +    if (magick_registry != (SplayTreeInfo *) NULL)
2567 +      magick_registry=DestroySplayTree(magick_registry);
2568 +    MagickCoreTerminus();
2569 +  }
2570 +
2571 +double
2572 +constant(name,argument)
2573 +  char *name
2574 +  ssize_t argument
2575 +\f
2576 +#
2577 +###############################################################################
2578 +#                                                                             #
2579 +#                                                                             #
2580 +#                                                                             #
2581 +#   A n i m a t e                                                             #
2582 +#                                                                             #
2583 +#                                                                             #
2584 +#                                                                             #
2585 +###############################################################################
2586 +#
2587 +#
2588 +void
2589 +Animate(ref,...)
2590 +  Image::Magick ref = NO_INIT
2591 +  ALIAS:
2592 +    AnimateImage  = 1
2593 +    animate       = 2
2594 +    animateimage  = 3
2595 +  PPCODE:
2596 +  {
2597 +    ExceptionInfo
2598 +      *exception;
2599 +
2600 +    Image
2601 +      *image;
2602 +
2603 +    register ssize_t
2604 +      i;
2605 +
2606 +    struct PackageInfo
2607 +      *info,
2608 +      *package_info;
2609 +
2610 +    SV
2611 +      *perl_exception,
2612 +      *reference;
2613 +
2614 +    PERL_UNUSED_VAR(ref);
2615 +    PERL_UNUSED_VAR(ix);
2616 +    exception=AcquireExceptionInfo();
2617 +    perl_exception=newSVpv("",0);
2618 +    package_info=(struct PackageInfo *) NULL;
2619 +    if (sv_isobject(ST(0)) == 0)
2620 +      {
2621 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2622 +          PackageName);
2623 +        goto PerlException;
2624 +      }
2625 +    reference=SvRV(ST(0));
2626 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2627 +    if (image == (Image *) NULL)
2628 +      {
2629 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
2630 +          PackageName);
2631 +        goto PerlException;
2632 +      }
2633 +    package_info=ClonePackageInfo(info,exception);
2634 +    if (items == 2)
2635 +      SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2636 +    else
2637 +      if (items > 2)
2638 +        for (i=2; i < items; i+=2)
2639 +          SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2640 +            exception);
2641 +    (void) AnimateImages(package_info->image_info,image);
2642 +    (void) CatchImageException(image);
2643 +    InheritException(exception,&image->exception);
2644 +
2645 +  PerlException:
2646 +    if (package_info != (struct PackageInfo *) NULL)
2647 +      DestroyPackageInfo(package_info);
2648 +    InheritPerlException(exception,perl_exception);
2649 +    exception=DestroyExceptionInfo(exception);
2650 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2651 +    SvPOK_on(perl_exception);
2652 +    ST(0)=sv_2mortal(perl_exception);
2653 +    XSRETURN(1);
2654 +  }
2655 +\f
2656 +#
2657 +###############################################################################
2658 +#                                                                             #
2659 +#                                                                             #
2660 +#                                                                             #
2661 +#   A p p e n d                                                               #
2662 +#                                                                             #
2663 +#                                                                             #
2664 +#                                                                             #
2665 +###############################################################################
2666 +#
2667 +#
2668 +void
2669 +Append(ref,...)
2670 +  Image::Magick ref = NO_INIT
2671 +  ALIAS:
2672 +    AppendImage  = 1
2673 +    append       = 2
2674 +    appendimage  = 3
2675 +  PPCODE:
2676 +  {
2677 +    AV
2678 +      *av;
2679 +
2680 +    char
2681 +      *attribute;
2682 +
2683 +    ExceptionInfo
2684 +      *exception;
2685 +
2686 +    HV
2687 +      *hv;
2688 +
2689 +    Image
2690 +      *image;
2691 +
2692 +    register ssize_t
2693 +      i;
2694 +
2695 +    ssize_t
2696 +      stack;
2697 +
2698 +    struct PackageInfo
2699 +      *info;
2700 +
2701 +    SV
2702 +      *av_reference,
2703 +      *perl_exception,
2704 +      *reference,
2705 +      *rv,
2706 +      *sv;
2707 +
2708 +    PERL_UNUSED_VAR(ref);
2709 +    PERL_UNUSED_VAR(ix);
2710 +    exception=AcquireExceptionInfo();
2711 +    perl_exception=newSVpv("",0);
2712 +    sv=NULL;
2713 +    attribute=NULL;
2714 +    av=NULL;
2715 +    if (sv_isobject(ST(0)) == 0)
2716 +      {
2717 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2718 +          PackageName);
2719 +        goto PerlException;
2720 +      }
2721 +    reference=SvRV(ST(0));
2722 +    hv=SvSTASH(reference);
2723 +    av=newAV();
2724 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2725 +    SvREFCNT_dec(av);
2726 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2727 +    if (image == (Image *) NULL)
2728 +      {
2729 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
2730 +          PackageName);
2731 +        goto PerlException;
2732 +      }
2733 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2734 +    /*
2735 +      Get options.
2736 +    */
2737 +    stack=MagickTrue;
2738 +    for (i=2; i < items; i+=2)
2739 +    {
2740 +      attribute=(char *) SvPV(ST(i-1),na);
2741 +      switch (*attribute)
2742 +      {
2743 +        case 'S':
2744 +        case 's':
2745 +        {
2746 +          if (LocaleCompare(attribute,"stack") == 0)
2747 +            {
2748 +              stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2749 +                SvPV(ST(i),na));
2750 +              if (stack < 0)
2751 +                {
2752 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
2753 +                    SvPV(ST(i),na));
2754 +                  return;
2755 +                }
2756 +              break;
2757 +            }
2758 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2759 +            attribute);
2760 +          break;
2761 +        }
2762 +        default:
2763 +        {
2764 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2765 +            attribute);
2766 +          break;
2767 +        }
2768 +      }
2769 +    }
2770 +    image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2771 +    if (image == (Image *) NULL)
2772 +      goto PerlException;
2773 +    for ( ; image; image=image->next)
2774 +    {
2775 +      AddImageToRegistry(sv,image);
2776 +      rv=newRV(sv);
2777 +      av_push(av,sv_bless(rv,hv));
2778 +      SvREFCNT_dec(sv);
2779 +    }
2780 +    exception=DestroyExceptionInfo(exception);
2781 +    ST(0)=av_reference;
2782 +    SvREFCNT_dec(perl_exception);
2783 +    XSRETURN(1);
2784 +
2785 +  PerlException:
2786 +    InheritPerlException(exception,perl_exception);
2787 +    exception=DestroyExceptionInfo(exception);
2788 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2789 +    SvPOK_on(perl_exception);
2790 +    ST(0)=sv_2mortal(perl_exception);
2791 +    XSRETURN(1);
2792 +  }
2793 +\f
2794 +#
2795 +###############################################################################
2796 +#                                                                             #
2797 +#                                                                             #
2798 +#                                                                             #
2799 +#   A v e r a g e                                                             #
2800 +#                                                                             #
2801 +#                                                                             #
2802 +#                                                                             #
2803 +###############################################################################
2804 +#
2805 +#
2806 +void
2807 +Average(ref)
2808 +  Image::Magick ref = NO_INIT
2809 +  ALIAS:
2810 +    AverageImage   = 1
2811 +    average        = 2
2812 +    averageimage   = 3
2813 +  PPCODE:
2814 +  {
2815 +    AV
2816 +      *av;
2817 +
2818 +    char
2819 +      *p;
2820 +
2821 +    ExceptionInfo
2822 +      *exception;
2823 +
2824 +    HV
2825 +      *hv;
2826 +
2827 +    Image
2828 +      *image;
2829 +
2830 +    struct PackageInfo
2831 +      *info;
2832 +
2833 +    SV
2834 +      *perl_exception,
2835 +      *reference,
2836 +      *rv,
2837 +      *sv;
2838 +
2839 +    PERL_UNUSED_VAR(ref);
2840 +    PERL_UNUSED_VAR(ix);
2841 +    exception=AcquireExceptionInfo();
2842 +    perl_exception=newSVpv("",0);
2843 +    sv=NULL;
2844 +    if (sv_isobject(ST(0)) == 0)
2845 +      {
2846 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2847 +          PackageName);
2848 +        goto PerlException;
2849 +      }
2850 +    reference=SvRV(ST(0));
2851 +    hv=SvSTASH(reference);
2852 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2853 +    if (image == (Image *) NULL)
2854 +      {
2855 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
2856 +          PackageName);
2857 +        goto PerlException;
2858 +      }
2859 +    image=EvaluateImages(image,MeanEvaluateOperator,exception);
2860 +    if (image == (Image *) NULL)
2861 +      goto PerlException;
2862 +    /*
2863 +      Create blessed Perl array for the returned image.
2864 +    */
2865 +    av=newAV();
2866 +    ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2867 +    SvREFCNT_dec(av);
2868 +    AddImageToRegistry(sv,image);
2869 +    rv=newRV(sv);
2870 +    av_push(av,sv_bless(rv,hv));
2871 +    SvREFCNT_dec(sv);
2872 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2873 +    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2874 +      "average-%.*s",(int) (MaxTextExtent-9),
2875 +      ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2876 +    (void) CopyMagickString(image->filename,info->image_info->filename,
2877 +      MaxTextExtent);
2878 +    SetImageInfo(info->image_info,0,exception);
2879 +    exception=DestroyExceptionInfo(exception);
2880 +    SvREFCNT_dec(perl_exception);
2881 +    XSRETURN(1);
2882 +
2883 +  PerlException:
2884 +    InheritPerlException(exception,perl_exception);
2885 +    exception=DestroyExceptionInfo(exception);
2886 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2887 +    SvPOK_on(perl_exception);
2888 +    ST(0)=sv_2mortal(perl_exception);
2889 +    XSRETURN(1);
2890 +  }
2891 +\f
2892 +#
2893 +###############################################################################
2894 +#                                                                             #
2895 +#                                                                             #
2896 +#                                                                             #
2897 +#   B l o b T o I m a g e                                                     #
2898 +#                                                                             #
2899 +#                                                                             #
2900 +#                                                                             #
2901 +###############################################################################
2902 +#
2903 +#
2904 +void
2905 +BlobToImage(ref,...)
2906 +  Image::Magick ref = NO_INIT
2907 +  ALIAS:
2908 +    BlobToImage  = 1
2909 +    blobtoimage  = 2
2910 +    blobto       = 3
2911 +  PPCODE:
2912 +  {
2913 +    AV
2914 +      *av;
2915 +
2916 +    char
2917 +      **keep,
2918 +      **list;
2919 +
2920 +    ExceptionInfo
2921 +      *exception;
2922 +
2923 +    HV
2924 +      *hv;
2925 +
2926 +    Image
2927 +      *image;
2928 +
2929 +    register char
2930 +      **p;
2931 +
2932 +    register ssize_t
2933 +      i;
2934 +
2935 +    ssize_t
2936 +      ac,
2937 +      n,
2938 +      number_images;
2939 +
2940 +    STRLEN
2941 +      *length;
2942 +
2943 +    struct PackageInfo
2944 +      *info;
2945 +
2946 +    SV
2947 +      *perl_exception,
2948 +      *reference,
2949 +      *rv,
2950 +      *sv;
2951 +
2952 +    PERL_UNUSED_VAR(ref);
2953 +    PERL_UNUSED_VAR(ix);
2954 +    exception=AcquireExceptionInfo();
2955 +    perl_exception=newSVpv("",0);
2956 +    sv=NULL;
2957 +    number_images=0;
2958 +    ac=(items < 2) ? 1 : items-1;
2959 +    length=(STRLEN *) NULL;
2960 +    list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2961 +    if (list == (char **) NULL)
2962 +      {
2963 +        ThrowPerlException(exception,ResourceLimitError,
2964 +          "MemoryAllocationFailed",PackageName);
2965 +        goto PerlException;
2966 +      }
2967 +    length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2968 +    if (length == (STRLEN *) NULL)
2969 +      {
2970 +        ThrowPerlException(exception,ResourceLimitError,
2971 +          "MemoryAllocationFailed",PackageName);
2972 +        goto PerlException;
2973 +      }
2974 +    if (sv_isobject(ST(0)) == 0)
2975 +      {
2976 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2977 +          PackageName);
2978 +        goto PerlException;
2979 +      }
2980 +    reference=SvRV(ST(0));
2981 +    hv=SvSTASH(reference);
2982 +    if (SvTYPE(reference) != SVt_PVAV)
2983 +      {
2984 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2985 +          PackageName);
2986 +        goto PerlException;
2987 +      }
2988 +    av=(AV *) reference;
2989 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2990 +      exception);
2991 +    n=1;
2992 +    if (items <= 1)
2993 +      {
2994 +        ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2995 +        goto PerlException;
2996 +      }
2997 +    for (n=0, i=0; i < ac; i++)
2998 +    {
2999 +      list[n]=(char *) (SvPV(ST(i+1),length[n]));
3000 +      if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
3001 +        {
3002 +          list[n]=(char *) (SvPV(ST(i+2),length[n]));
3003 +          continue;
3004 +        }
3005 +      n++;
3006 +    }
3007 +    list[n]=(char *) NULL;
3008 +    keep=list;
3009 +    for (i=number_images=0; i < n; i++)
3010 +    {
3011 +      image=BlobToImage(info->image_info,list[i],length[i],exception);
3012 +      if (image == (Image *) NULL)
3013 +        break;
3014 +      for ( ; image; image=image->next)
3015 +      {
3016 +        AddImageToRegistry(sv,image);
3017 +        rv=newRV(sv);
3018 +        av_push(av,sv_bless(rv,hv));
3019 +        SvREFCNT_dec(sv);
3020 +        number_images++;
3021 +      }
3022 +    }
3023 +    /*
3024 +      Free resources.
3025 +    */
3026 +    for (i=0; i < n; i++)
3027 +      if (list[i] != (char *) NULL)
3028 +        for (p=keep; list[i] != *p++; )
3029 +          if (*p == (char *) NULL)
3030 +            {
3031 +              list[i]=(char *) RelinquishMagickMemory(list[i]);
3032 +              break;
3033 +            }
3034 +
3035 +  PerlException:
3036 +    if (list)
3037 +      list=(char **) RelinquishMagickMemory(list);
3038 +    if (length)
3039 +      length=(STRLEN *) RelinquishMagickMemory(length);
3040 +    InheritPerlException(exception,perl_exception);
3041 +    exception=DestroyExceptionInfo(exception);
3042 +    sv_setiv(perl_exception,(IV) number_images);
3043 +    SvPOK_on(perl_exception);
3044 +    ST(0)=sv_2mortal(perl_exception);
3045 +    XSRETURN(1);
3046 +  }
3047 +\f
3048 +#
3049 +###############################################################################
3050 +#                                                                             #
3051 +#                                                                             #
3052 +#                                                                             #
3053 +#   C l o n e                                                                 #
3054 +#                                                                             #
3055 +#                                                                             #
3056 +#                                                                             #
3057 +###############################################################################
3058 +#
3059 +#
3060 +void
3061 +Clone(ref)
3062 +  Image::Magick ref = NO_INIT
3063 +  ALIAS:
3064 +    CopyImage   = 1
3065 +    copy        = 2
3066 +    copyimage   = 3
3067 +    CloneImage  = 4
3068 +    clone       = 5
3069 +    cloneimage  = 6
3070 +    Clone       = 7
3071 +  PPCODE:
3072 +  {
3073 +    AV
3074 +      *av;
3075 +
3076 +    ExceptionInfo
3077 +      *exception;
3078 +
3079 +    HV
3080 +      *hv;
3081 +
3082 +    Image
3083 +      *clone,
3084 +      *image;
3085 +
3086 +    struct PackageInfo
3087 +      *info;
3088 +
3089 +    SV
3090 +      *perl_exception,
3091 +      *reference,
3092 +      *rv,
3093 +      *sv;
3094 +
3095 +    PERL_UNUSED_VAR(ref);
3096 +    PERL_UNUSED_VAR(ix);
3097 +    exception=AcquireExceptionInfo();
3098 +    perl_exception=newSVpv("",0);
3099 +    sv=NULL;
3100 +    if (sv_isobject(ST(0)) == 0)
3101 +      {
3102 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3103 +          PackageName);
3104 +        goto PerlException;
3105 +      }
3106 +    reference=SvRV(ST(0));
3107 +    hv=SvSTASH(reference);
3108 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3109 +    if (image == (Image *) NULL)
3110 +      {
3111 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3112 +          PackageName);
3113 +        goto PerlException;
3114 +      }
3115 +    /*
3116 +      Create blessed Perl array for the returned image.
3117 +    */
3118 +    av=newAV();
3119 +    ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3120 +    SvREFCNT_dec(av);
3121 +    for ( ; image; image=image->next)
3122 +    {
3123 +      clone=CloneImage(image,0,0,MagickTrue,exception);
3124 +      if (clone == (Image *) NULL)
3125 +        break;
3126 +      AddImageToRegistry(sv,clone);
3127 +      rv=newRV(sv);
3128 +      av_push(av,sv_bless(rv,hv));
3129 +      SvREFCNT_dec(sv);
3130 +    }
3131 +    exception=DestroyExceptionInfo(exception);
3132 +    SvREFCNT_dec(perl_exception);
3133 +    XSRETURN(1);
3134 +
3135 +  PerlException:
3136 +    InheritPerlException(exception,perl_exception);
3137 +    exception=DestroyExceptionInfo(exception);
3138 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3139 +    SvPOK_on(perl_exception);
3140 +    ST(0)=sv_2mortal(perl_exception);
3141 +    XSRETURN(1);
3142 +  }
3143 +\f
3144 +#
3145 +###############################################################################
3146 +#                                                                             #
3147 +#                                                                             #
3148 +#                                                                             #
3149 +#   C L O N E                                                                 #
3150 +#                                                                             #
3151 +#                                                                             #
3152 +#                                                                             #
3153 +###############################################################################
3154 +#
3155 +#
3156 +void
3157 +CLONE(ref,...)
3158 +  SV *ref;
3159 +  CODE:
3160 +  {
3161 +    PERL_UNUSED_VAR(ref);
3162 +    if (magick_registry != (SplayTreeInfo *) NULL)
3163 +      {
3164 +        register Image
3165 +          *p;
3166 +
3167 +        ResetSplayTreeIterator(magick_registry);
3168 +        p=(Image *) GetNextKeyInSplayTree(magick_registry);
3169 +        while (p != (Image *) NULL)
3170 +        {
3171 +          ReferenceImage(p);
3172 +          p=(Image *) GetNextKeyInSplayTree(magick_registry);
3173 +        }
3174 +      }
3175 +  }
3176 +\f
3177 +#
3178 +###############################################################################
3179 +#                                                                             #
3180 +#                                                                             #
3181 +#                                                                             #
3182 +#   C o a l e s c e                                                           #
3183 +#                                                                             #
3184 +#                                                                             #
3185 +#                                                                             #
3186 +###############################################################################
3187 +#
3188 +#
3189 +void
3190 +Coalesce(ref)
3191 +  Image::Magick ref = NO_INIT
3192 +  ALIAS:
3193 +    CoalesceImage   = 1
3194 +    coalesce        = 2
3195 +    coalesceimage   = 3
3196 +  PPCODE:
3197 +  {
3198 +    AV
3199 +      *av;
3200 +
3201 +    ExceptionInfo
3202 +      *exception;
3203 +
3204 +    HV
3205 +      *hv;
3206 +
3207 +    Image
3208 +      *image;
3209 +
3210 +    struct PackageInfo
3211 +      *info;
3212 +
3213 +    SV
3214 +      *av_reference,
3215 +      *perl_exception,
3216 +      *reference,
3217 +      *rv,
3218 +      *sv;
3219 +
3220 +    PERL_UNUSED_VAR(ref);
3221 +    PERL_UNUSED_VAR(ix);
3222 +    exception=AcquireExceptionInfo();
3223 +    perl_exception=newSVpv("",0);
3224 +    sv=NULL;
3225 +    if (sv_isobject(ST(0)) == 0)
3226 +      {
3227 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3228 +          PackageName);
3229 +        goto PerlException;
3230 +      }
3231 +    reference=SvRV(ST(0));
3232 +    hv=SvSTASH(reference);
3233 +    av=newAV();
3234 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3235 +    SvREFCNT_dec(av);
3236 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3237 +    if (image == (Image *) NULL)
3238 +      {
3239 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3240 +          PackageName);
3241 +        goto PerlException;
3242 +      }
3243 +    image=CoalesceImages(image,exception);
3244 +    if (image == (Image *) NULL)
3245 +      goto PerlException;
3246 +    for ( ; image; image=image->next)
3247 +    {
3248 +      AddImageToRegistry(sv,image);
3249 +      rv=newRV(sv);
3250 +      av_push(av,sv_bless(rv,hv));
3251 +      SvREFCNT_dec(sv);
3252 +    }
3253 +    exception=DestroyExceptionInfo(exception);
3254 +    ST(0)=av_reference;
3255 +    SvREFCNT_dec(perl_exception);
3256 +    XSRETURN(1);
3257 +
3258 +  PerlException:
3259 +    InheritPerlException(exception,perl_exception);
3260 +    exception=DestroyExceptionInfo(exception);
3261 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3262 +    SvPOK_on(perl_exception);
3263 +    ST(0)=sv_2mortal(perl_exception);
3264 +    XSRETURN(1);
3265 +  }
3266 +\f
3267 +#
3268 +###############################################################################
3269 +#                                                                             #
3270 +#                                                                             #
3271 +#                                                                             #
3272 +#   C o m p a r e                                                             #
3273 +#                                                                             #
3274 +#                                                                             #
3275 +#                                                                             #
3276 +###############################################################################
3277 +#
3278 +#
3279 +void
3280 +Compare(ref,...)
3281 +  Image::Magick ref = NO_INIT
3282 +  ALIAS:
3283 +    CompareImage = 1
3284 +    compare      = 2
3285 +    compareimage = 3
3286 +  PPCODE:
3287 +  {
3288 +    AV
3289 +      *av;
3290 +
3291 +    char
3292 +      *attribute;
3293 +
3294 +    ChannelType
3295 +      channel;
3296 +
3297 +    double
3298 +      distortion;
3299 +
3300 +    ExceptionInfo
3301 +      *exception;
3302 +
3303 +    HV
3304 +      *hv;
3305 +
3306 +    Image
3307 +      *difference_image,
3308 +      *image,
3309 +      *reconstruct_image;
3310 +
3311 +    MetricType
3312 +      metric;
3313 +
3314 +    register ssize_t
3315 +      i;
3316 +
3317 +    ssize_t
3318 +      option;
3319 +
3320 +    struct PackageInfo
3321 +      *info;
3322 +
3323 +    SV
3324 +      *av_reference,
3325 +      *perl_exception,
3326 +      *reference,
3327 +      *rv,
3328 +      *sv;
3329 +
3330 +    PERL_UNUSED_VAR(ref);
3331 +    PERL_UNUSED_VAR(ix);
3332 +    exception=AcquireExceptionInfo();
3333 +    perl_exception=newSVpv("",0);
3334 +    sv=NULL;
3335 +    av=NULL;
3336 +    attribute=NULL;
3337 +    if (sv_isobject(ST(0)) == 0)
3338 +      {
3339 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3340 +          PackageName);
3341 +        goto PerlException;
3342 +      }
3343 +    reference=SvRV(ST(0));
3344 +    hv=SvSTASH(reference);
3345 +    av=newAV();
3346 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3347 +    SvREFCNT_dec(av);
3348 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3349 +    if (image == (Image *) NULL)
3350 +      {
3351 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3352 +          PackageName);
3353 +        goto PerlException;
3354 +      }
3355 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3356 +    /*
3357 +      Get attribute.
3358 +    */
3359 +    channel=DefaultChannels;
3360 +    reconstruct_image=image;
3361 +    metric=RootMeanSquaredErrorMetric;
3362 +    for (i=2; i < items; i+=2)
3363 +    {
3364 +      attribute=(char *) SvPV(ST(i-1),na);
3365 +      switch (*attribute)
3366 +      {
3367 +        case 'C':
3368 +        case 'c':
3369 +        {
3370 +          if (LocaleCompare(attribute,"channel") == 0)
3371 +            {
3372 +              ssize_t
3373 +                option;
3374 +
3375 +              option=ParseChannelOption(SvPV(ST(i),na));
3376 +              if (option < 0)
3377 +                {
3378 +                  ThrowPerlException(exception,OptionError,
3379 +                    "UnrecognizedType",SvPV(ST(i),na));
3380 +                  return;
3381 +                }
3382 +              channel=(ChannelType) option;
3383 +              break;
3384 +            }
3385 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3386 +            attribute);
3387 +          break;
3388 +        }
3389 +        case 'F':
3390 +        case 'f':
3391 +        {
3392 +          if (LocaleCompare(attribute,"fuzz") == 0)
3393 +            {
3394 +              image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3395 +              break;
3396 +            }
3397 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3398 +            attribute);
3399 +          break;
3400 +        }
3401 +        case 'I':
3402 +        case 'i':
3403 +        {
3404 +          if (LocaleCompare(attribute,"image") == 0)
3405 +            {
3406 +              reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3407 +                (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3408 +              break;
3409 +            }
3410 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3411 +            attribute);
3412 +          break;
3413 +        }
3414 +        case 'M':
3415 +        case 'm':
3416 +        {
3417 +          if (LocaleCompare(attribute,"metric") == 0)
3418 +            {
3419 +              option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3420 +                SvPV(ST(i),na));
3421 +              if (option < 0)
3422 +                {
3423 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
3424 +                    SvPV(ST(i),na));
3425 +                  break;
3426 +                }
3427 +              metric=(MetricType) option;
3428 +              break;
3429 +            }
3430 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3431 +            attribute);
3432 +          break;
3433 +        }
3434 +        default:
3435 +        {
3436 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3437 +            attribute);
3438 +          break;
3439 +        }
3440 +      }
3441 +    }
3442 +    difference_image=CompareImageChannels(image,reconstruct_image,channel,
3443 +      metric,&distortion,exception);
3444 +    if (difference_image != (Image *) NULL)
3445 +      {
3446 +        difference_image->error.mean_error_per_pixel=distortion;
3447 +        AddImageToRegistry(sv,difference_image);
3448 +        rv=newRV(sv);
3449 +        av_push(av,sv_bless(rv,hv));
3450 +        SvREFCNT_dec(sv);
3451 +      }
3452 +    exception=DestroyExceptionInfo(exception);
3453 +    ST(0)=av_reference;
3454 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
3455 +    XSRETURN(1);
3456 +
3457 +  PerlException:
3458 +    InheritPerlException(exception,perl_exception);
3459 +    exception=DestroyExceptionInfo(exception);
3460 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3461 +    SvPOK_on(perl_exception);
3462 +    ST(0)=sv_2mortal(perl_exception);
3463 +    XSRETURN(1);
3464 +  }
3465 +\f
3466 +#
3467 +###############################################################################
3468 +#                                                                             #
3469 +#                                                                             #
3470 +#                                                                             #
3471 +#   C o m p a r e L a y e r s                                                 #
3472 +#                                                                             #
3473 +#                                                                             #
3474 +#                                                                             #
3475 +###############################################################################
3476 +#
3477 +#
3478 +void
3479 +CompareLayers(ref)
3480 +  Image::Magick ref = NO_INIT
3481 +  ALIAS:
3482 +    CompareImageLayers   = 1
3483 +    comparelayers        = 2
3484 +    compareimagelayers   = 3
3485 +  PPCODE:
3486 +  {
3487 +    AV
3488 +      *av;
3489 +
3490 +    char
3491 +      *attribute;
3492 +
3493 +    ExceptionInfo
3494 +      *exception;
3495 +
3496 +    HV
3497 +      *hv;
3498 +
3499 +    Image
3500 +      *image;
3501 +
3502 +    ImageLayerMethod
3503 +      method;
3504 +
3505 +    register ssize_t
3506 +      i;
3507 +
3508 +    ssize_t
3509 +      option;
3510 +
3511 +    struct PackageInfo
3512 +      *info;
3513 +
3514 +    SV
3515 +      *av_reference,
3516 +      *perl_exception,
3517 +      *reference,
3518 +      *rv,
3519 +      *sv;
3520 +
3521 +    PERL_UNUSED_VAR(ref);
3522 +    PERL_UNUSED_VAR(ix);
3523 +    exception=AcquireExceptionInfo();
3524 +    perl_exception=newSVpv("",0);
3525 +    sv=NULL;
3526 +    if (sv_isobject(ST(0)) == 0)
3527 +      {
3528 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3529 +          PackageName);
3530 +        goto PerlException;
3531 +      }
3532 +    reference=SvRV(ST(0));
3533 +    hv=SvSTASH(reference);
3534 +    av=newAV();
3535 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3536 +    SvREFCNT_dec(av);
3537 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3538 +    if (image == (Image *) NULL)
3539 +      {
3540 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3541 +          PackageName);
3542 +        goto PerlException;
3543 +      }
3544 +    method=CompareAnyLayer;
3545 +    for (i=2; i < items; i+=2)
3546 +    {
3547 +      attribute=(char *) SvPV(ST(i-1),na);
3548 +      switch (*attribute)
3549 +      {
3550 +        case 'M':
3551 +        case 'm':
3552 +        {
3553 +          if (LocaleCompare(attribute,"method") == 0)
3554 +            {
3555 +              option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3556 +                SvPV(ST(i),na));
3557 +              if (option < 0)
3558 +                {
3559 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
3560 +                    SvPV(ST(i),na));
3561 +                  break;
3562 +                }
3563 +               method=(ImageLayerMethod) option;
3564 +              break;
3565 +            }
3566 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3567 +            attribute);
3568 +          break;
3569 +        }
3570 +        default:
3571 +        {
3572 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3573 +            attribute);
3574 +          break;
3575 +        }
3576 +      }
3577 +    }
3578 +    image=CompareImageLayers(image,method,exception);
3579 +    if (image == (Image *) NULL)
3580 +      goto PerlException;
3581 +    for ( ; image; image=image->next)
3582 +    {
3583 +      AddImageToRegistry(sv,image);
3584 +      rv=newRV(sv);
3585 +      av_push(av,sv_bless(rv,hv));
3586 +      SvREFCNT_dec(sv);
3587 +    }
3588 +    exception=DestroyExceptionInfo(exception);
3589 +    ST(0)=av_reference;
3590 +    SvREFCNT_dec(perl_exception);
3591 +    XSRETURN(1);
3592 +
3593 +  PerlException:
3594 +    InheritPerlException(exception,perl_exception);
3595 +    exception=DestroyExceptionInfo(exception);
3596 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3597 +    SvPOK_on(perl_exception);
3598 +    ST(0)=sv_2mortal(perl_exception);
3599 +    XSRETURN(1);
3600 +  }
3601 +\f
3602 +#
3603 +###############################################################################
3604 +#                                                                             #
3605 +#                                                                             #
3606 +#                                                                             #
3607 +#   C o m p l e x I m a g e s                                                 #
3608 +#                                                                             #
3609 +#                                                                             #
3610 +#                                                                             #
3611 +###############################################################################
3612 +#
3613 +#
3614 +void
3615 +ComplexImages(ref)
3616 +  Image::Magick ref = NO_INIT
3617 +  ALIAS:
3618 +    ComplexImages   = 1
3619 +    compleximages   = 2
3620 +  PPCODE:
3621 +  {
3622 +    AV
3623 +      *av;
3624 +
3625 +    char
3626 +      *attribute,
3627 +      *p;
3628 +
3629 +    ExceptionInfo
3630 +      *exception;
3631 +
3632 +    HV
3633 +      *hv;
3634 +
3635 +    Image
3636 +      *image;
3637 +
3638 +    ComplexOperator
3639 +      op;
3640 +
3641 +    register ssize_t
3642 +      i;
3643 +
3644 +    struct PackageInfo
3645 +      *info;
3646 +
3647 +    SV
3648 +      *perl_exception,
3649 +      *reference,
3650 +      *rv,
3651 +      *sv;
3652 +
3653 +    PERL_UNUSED_VAR(ref);
3654 +    PERL_UNUSED_VAR(ix);
3655 +    exception=AcquireExceptionInfo();
3656 +    perl_exception=newSVpv("",0);
3657 +    sv=NULL;
3658 +    if (sv_isobject(ST(0)) == 0)
3659 +      {
3660 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3661 +          PackageName);
3662 +        goto PerlException;
3663 +      }
3664 +    reference=SvRV(ST(0));
3665 +    hv=SvSTASH(reference);
3666 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3667 +    if (image == (Image *) NULL)
3668 +      {
3669 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3670 +          PackageName);
3671 +        goto PerlException;
3672 +      }
3673 +    op=UndefinedComplexOperator;
3674 +    if (items == 2)
3675 +      {
3676 +        ssize_t
3677 +          in;
3678 +
3679 +        in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3680 +          SvPV(ST(1),na));
3681 +        if (in < 0)
3682 +          {
3683 +            ThrowPerlException(exception,OptionError,"UnrecognizedType",
3684 +              SvPV(ST(1),na));
3685 +            return;
3686 +          }
3687 +        op=(ComplexOperator) in;
3688 +      }
3689 +    else
3690 +      for (i=2; i < items; i+=2)
3691 +      {
3692 +        attribute=(char *) SvPV(ST(i-1),na);
3693 +        switch (*attribute)
3694 +        {
3695 +          case 'O':
3696 +          case 'o':
3697 +          {
3698 +            if (LocaleCompare(attribute,"operator") == 0)
3699 +              {
3700 +                ssize_t
3701 +                  in;
3702 +
3703 +                in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3704 +                  MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3705 +                if (in < 0)
3706 +                  {
3707 +                    ThrowPerlException(exception,OptionError,"UnrecognizedType",
3708 +                      SvPV(ST(i),na));
3709 +                    return;
3710 +                  }
3711 +                op=(ComplexOperator) in;
3712 +                break;
3713 +              }
3714 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3715 +              attribute);
3716 +            break;
3717 +          }
3718 +          default:
3719 +          {
3720 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3721 +              attribute);
3722 +            break;
3723 +          }
3724 +        }
3725 +      }
3726 +    image=ComplexImages(image,op,exception);
3727 +    if (image == (Image *) NULL)
3728 +      goto PerlException;
3729 +    /*
3730 +      Create blessed Perl array for the returned image.
3731 +    */
3732 +    av=newAV();
3733 +    ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3734 +    SvREFCNT_dec(av);
3735 +    AddImageToRegistry(sv,image);
3736 +    rv=newRV(sv);
3737 +    av_push(av,sv_bless(rv,hv));
3738 +    SvREFCNT_dec(sv);
3739 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3740 +    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3741 +      "complex-%.*s",(int) (MaxTextExtent-9),
3742 +      ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3743 +    (void) CopyMagickString(image->filename,info->image_info->filename,
3744 +      MaxTextExtent);
3745 +    SetImageInfo(info->image_info,0,exception);
3746 +    exception=DestroyExceptionInfo(exception);
3747 +    SvREFCNT_dec(perl_exception);
3748 +    XSRETURN(1);
3749 +
3750 +  PerlException:
3751 +    InheritPerlException(exception,perl_exception);
3752 +    exception=DestroyExceptionInfo(exception);
3753 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3754 +    SvPOK_on(perl_exception);
3755 +    ST(0)=sv_2mortal(perl_exception);
3756 +    XSRETURN(1);
3757 +  }
3758 +\f
3759 +#
3760 +###############################################################################
3761 +#                                                                             #
3762 +#                                                                             #
3763 +#                                                                             #
3764 +#   D e s t r o y                                                             #
3765 +#                                                                             #
3766 +#                                                                             #
3767 +#                                                                             #
3768 +###############################################################################
3769 +#
3770 +#
3771 +void
3772 +DESTROY(ref)
3773 +  Image::Magick ref = NO_INIT
3774 +  PPCODE:
3775 +  {
3776 +    SV
3777 +      *reference;
3778 +
3779 +    PERL_UNUSED_VAR(ref);
3780 +    if (sv_isobject(ST(0)) == 0)
3781 +      croak("ReferenceIsNotMyType");
3782 +    reference=SvRV(ST(0));
3783 +    switch (SvTYPE(reference))
3784 +    {
3785 +      case SVt_PVAV:
3786 +      {
3787 +        char
3788 +          message[MaxTextExtent];
3789 +
3790 +        const SV
3791 +          *key;
3792 +
3793 +        HV
3794 +          *hv;
3795 +
3796 +        GV
3797 +          **gvp;
3798 +
3799 +        struct PackageInfo
3800 +          *info;
3801 +
3802 +        SV
3803 +          *sv;
3804 +
3805 +        /*
3806 +          Array (AV *) reference
3807 +        */
3808 +        (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3809 +          XS_VERSION,reference);
3810 +        hv=gv_stashpv(PackageName, FALSE);
3811 +        if (!hv)
3812 +          break;
3813 +        gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3814 +        if (!gvp)
3815 +          break;
3816 +        sv=GvSV(*gvp);
3817 +        if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3818 +          {
3819 +            info=INT2PTR(struct PackageInfo *,SvIV(sv));
3820 +            DestroyPackageInfo(info);
3821 +          }
3822 +        key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3823 +        (void) key;
3824 +        break;
3825 +      }
3826 +      case SVt_PVMG:
3827 +      {
3828 +        Image
3829 +          *image;
3830 +
3831 +        /*
3832 +          Blessed scalar = (Image *) SvIV(reference)
3833 +        */
3834 +        image=INT2PTR(Image *,SvIV(reference));
3835 +        if (image != (Image *) NULL)
3836 +          DeleteImageFromRegistry(reference,image);
3837 +        break;
3838 +      }
3839 +      default:
3840 +        break;
3841 +    }
3842 +  }
3843 +\f
3844 +#
3845 +###############################################################################
3846 +#                                                                             #
3847 +#                                                                             #
3848 +#                                                                             #
3849 +#   D i s p l a y                                                             #
3850 +#                                                                             #
3851 +#                                                                             #
3852 +#                                                                             #
3853 +###############################################################################
3854 +#
3855 +#
3856 +void
3857 +Display(ref,...)
3858 +  Image::Magick ref = NO_INIT
3859 +  ALIAS:
3860 +    DisplayImage  = 1
3861 +    display       = 2
3862 +    displayimage  = 3
3863 +  PPCODE:
3864 +  {
3865 +    ExceptionInfo
3866 +      *exception;
3867 +
3868 +    Image
3869 +      *image;
3870 +
3871 +    register ssize_t
3872 +      i;
3873 +
3874 +    struct PackageInfo
3875 +      *info,
3876 +      *package_info;
3877 +
3878 +    SV
3879 +      *perl_exception,
3880 +      *reference;
3881 +
3882 +    PERL_UNUSED_VAR(ref);
3883 +    PERL_UNUSED_VAR(ix);
3884 +    exception=AcquireExceptionInfo();
3885 +    perl_exception=newSVpv("",0);
3886 +    package_info=(struct PackageInfo *) NULL;
3887 +    if (sv_isobject(ST(0)) == 0)
3888 +      {
3889 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3890 +          PackageName);
3891 +        goto PerlException;
3892 +      }
3893 +    reference=SvRV(ST(0));
3894 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3895 +    if (image == (Image *) NULL)
3896 +      {
3897 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3898 +          PackageName);
3899 +        goto PerlException;
3900 +      }
3901 +    package_info=ClonePackageInfo(info,exception);
3902 +    if (items == 2)
3903 +      SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3904 +    else
3905 +      if (items > 2)
3906 +        for (i=2; i < items; i+=2)
3907 +          SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3908 +            exception);
3909 +    (void) DisplayImages(package_info->image_info,image);
3910 +    (void) CatchImageException(image);
3911 +    InheritException(exception,&image->exception);
3912 +
3913 +  PerlException:
3914 +    if (package_info != (struct PackageInfo *) NULL)
3915 +      DestroyPackageInfo(package_info);
3916 +    InheritPerlException(exception,perl_exception);
3917 +    exception=DestroyExceptionInfo(exception);
3918 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3919 +    SvPOK_on(perl_exception);
3920 +    ST(0)=sv_2mortal(perl_exception);
3921 +    XSRETURN(1);
3922 +  }
3923 +\f
3924 +#
3925 +###############################################################################
3926 +#                                                                             #
3927 +#                                                                             #
3928 +#                                                                             #
3929 +#   E v a l u a t e I m a g e s                                               #
3930 +#                                                                             #
3931 +#                                                                             #
3932 +#                                                                             #
3933 +###############################################################################
3934 +#
3935 +#
3936 +void
3937 +EvaluateImages(ref)
3938 +  Image::Magick ref = NO_INIT
3939 +  ALIAS:
3940 +    EvaluateImages   = 1
3941 +    evaluateimages   = 2
3942 +  PPCODE:
3943 +  {
3944 +    AV
3945 +      *av;
3946 +
3947 +    char
3948 +      *attribute,
3949 +      *p;
3950 +
3951 +    ExceptionInfo
3952 +      *exception;
3953 +
3954 +    HV
3955 +      *hv;
3956 +
3957 +    Image
3958 +      *image;
3959 +
3960 +    MagickEvaluateOperator
3961 +      op;
3962 +
3963 +    register ssize_t
3964 +      i;
3965 +
3966 +    struct PackageInfo
3967 +      *info;
3968 +
3969 +    SV
3970 +      *perl_exception,
3971 +      *reference,
3972 +      *rv,
3973 +      *sv;
3974 +
3975 +    PERL_UNUSED_VAR(ref);
3976 +    PERL_UNUSED_VAR(ix);
3977 +    exception=AcquireExceptionInfo();
3978 +    perl_exception=newSVpv("",0);
3979 +    sv=NULL;
3980 +    if (sv_isobject(ST(0)) == 0)
3981 +      {
3982 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3983 +          PackageName);
3984 +        goto PerlException;
3985 +      }
3986 +    reference=SvRV(ST(0));
3987 +    hv=SvSTASH(reference);
3988 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3989 +    if (image == (Image *) NULL)
3990 +      {
3991 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
3992 +          PackageName);
3993 +        goto PerlException;
3994 +      }
3995 +    op=MeanEvaluateOperator;
3996 +    if (items == 2)
3997 +      {
3998 +        ssize_t
3999 +          in;
4000 +
4001 +        in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
4002 +          SvPV(ST(1),na));
4003 +        if (in < 0)
4004 +          {
4005 +            ThrowPerlException(exception,OptionError,"UnrecognizedType",
4006 +              SvPV(ST(1),na));
4007 +            return;
4008 +          }
4009 +        op=(MagickEvaluateOperator) in;
4010 +      }
4011 +    else
4012 +      for (i=2; i < items; i+=2)
4013 +      {
4014 +        attribute=(char *) SvPV(ST(i-1),na);
4015 +        switch (*attribute)
4016 +        {
4017 +          case 'O':
4018 +          case 'o':
4019 +          {
4020 +            if (LocaleCompare(attribute,"operator") == 0)
4021 +              {
4022 +                ssize_t
4023 +                  in;
4024 +
4025 +                in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4026 +                  MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4027 +                if (in < 0)
4028 +                  {
4029 +                    ThrowPerlException(exception,OptionError,"UnrecognizedType",
4030 +                      SvPV(ST(i),na));
4031 +                    return;
4032 +                  }
4033 +                op=(MagickEvaluateOperator) in;
4034 +                break;
4035 +              }
4036 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4037 +              attribute);
4038 +            break;
4039 +          }
4040 +          default:
4041 +          {
4042 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4043 +              attribute);
4044 +            break;
4045 +          }
4046 +        }
4047 +      }
4048 +    image=EvaluateImages(image,op,exception);
4049 +    if (image == (Image *) NULL)
4050 +      goto PerlException;
4051 +    /*
4052 +      Create blessed Perl array for the returned image.
4053 +    */
4054 +    av=newAV();
4055 +    ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4056 +    SvREFCNT_dec(av);
4057 +    AddImageToRegistry(sv,image);
4058 +    rv=newRV(sv);
4059 +    av_push(av,sv_bless(rv,hv));
4060 +    SvREFCNT_dec(sv);
4061 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4062 +    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4063 +      "evaluate-%.*s",(int) (MaxTextExtent-9),
4064 +      ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4065 +    (void) CopyMagickString(image->filename,info->image_info->filename,
4066 +      MaxTextExtent);
4067 +    SetImageInfo(info->image_info,0,exception);
4068 +    exception=DestroyExceptionInfo(exception);
4069 +    SvREFCNT_dec(perl_exception);
4070 +    XSRETURN(1);
4071 +
4072 +  PerlException:
4073 +    InheritPerlException(exception,perl_exception);
4074 +    exception=DestroyExceptionInfo(exception);
4075 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4076 +    SvPOK_on(perl_exception);
4077 +    ST(0)=sv_2mortal(perl_exception);
4078 +    XSRETURN(1);
4079 +  }
4080 +\f
4081 +#
4082 +###############################################################################
4083 +#                                                                             #
4084 +#                                                                             #
4085 +#                                                                             #
4086 +#   F e a t u r e s                                                           #
4087 +#                                                                             #
4088 +#                                                                             #
4089 +#                                                                             #
4090 +###############################################################################
4091 +#
4092 +#
4093 +void
4094 +Features(ref,...)
4095 +  Image::Magick ref = NO_INIT
4096 +  ALIAS:
4097 +    FeaturesImage = 1
4098 +    features      = 2
4099 +    featuresimage = 3
4100 +  PPCODE:
4101 +  {
4102 +#define ChannelFeatures(channel,direction) \
4103 +{ \
4104 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4105 +    channel_features[channel].angular_second_moment[direction]); \
4106 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4107 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4108 +    channel_features[channel].contrast[direction]); \
4109 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4110 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4111 +    channel_features[channel].contrast[direction]); \
4112 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4113 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4114 +    channel_features[channel].variance_sum_of_squares[direction]); \
4115 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4116 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4117 +    channel_features[channel].inverse_difference_moment[direction]); \
4118 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4119 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4120 +    channel_features[channel].sum_average[direction]); \
4121 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4122 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4123 +    channel_features[channel].sum_variance[direction]); \
4124 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4125 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4126 +    channel_features[channel].sum_entropy[direction]); \
4127 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4128 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4129 +    channel_features[channel].entropy[direction]); \
4130 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4131 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4132 +    channel_features[channel].difference_variance[direction]); \
4133 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4134 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4135 +    channel_features[channel].difference_entropy[direction]); \
4136 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4137 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4138 +    channel_features[channel].measure_of_correlation_1[direction]); \
4139 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4140 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4141 +    channel_features[channel].measure_of_correlation_2[direction]); \
4142 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4143 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4144 +    channel_features[channel].maximum_correlation_coefficient[direction]); \
4145 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
4146 +}
4147 +
4148 +    AV
4149 +      *av;
4150 +
4151 +    char
4152 +      *attribute,
4153 +      message[MaxTextExtent];
4154 +
4155 +    ChannelFeatures
4156 +      *channel_features;
4157 +
4158 +    double
4159 +      distance;
4160 +
4161 +    ExceptionInfo
4162 +      *exception;
4163 +
4164 +    Image
4165 +      *image;
4166 +
4167 +    register ssize_t
4168 +      i;
4169 +
4170 +    ssize_t
4171 +      count;
4172 +
4173 +    struct PackageInfo
4174 +      *info;
4175 +
4176 +    SV
4177 +      *perl_exception,
4178 +      *reference;
4179 +
4180 +    PERL_UNUSED_VAR(ref);
4181 +    PERL_UNUSED_VAR(ix);
4182 +    exception=AcquireExceptionInfo();
4183 +    perl_exception=newSVpv("",0);
4184 +    av=NULL;
4185 +    if (sv_isobject(ST(0)) == 0)
4186 +      {
4187 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4188 +          PackageName);
4189 +        goto PerlException;
4190 +      }
4191 +    reference=SvRV(ST(0));
4192 +    av=newAV();
4193 +    SvREFCNT_dec(av);
4194 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4195 +    if (image == (Image *) NULL)
4196 +      {
4197 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
4198 +          PackageName);
4199 +        goto PerlException;
4200 +      }
4201 +    distance=1.0;
4202 +    for (i=2; i < items; i+=2)
4203 +    {
4204 +      attribute=(char *) SvPV(ST(i-1),na);
4205 +      switch (*attribute)
4206 +      {
4207 +        case 'D':
4208 +        case 'd':
4209 +        {
4210 +          if (LocaleCompare(attribute,"distance") == 0)
4211 +            {
4212 +              distance=StringToLong((char *) SvPV(ST(1),na));
4213 +              break;
4214 +            }
4215 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4216 +            attribute);
4217 +          break;
4218 +        }
4219 +        default:
4220 +        {
4221 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4222 +            attribute);
4223 +          break;
4224 +        }
4225 +      }
4226 +    }
4227 +    count=0;
4228 +    for ( ; image; image=image->next)
4229 +    {
4230 +      channel_features=GetImageChannelFeatures(image,distance,
4231 +        &image->exception);
4232 +      if (channel_features == (ChannelFeatures *) NULL)
4233 +        continue;
4234 +      count++;
4235 +      EXTEND(sp,280*count);
4236 +      for (i=0; i < 4; i++)
4237 +      {
4238 +        ChannelFeatures(RedChannel,i);
4239 +        ChannelFeatures(GreenChannel,i);
4240 +        ChannelFeatures(BlueChannel,i);
4241 +        if (image->colorspace == CMYKColorspace)
4242 +          ChannelFeatures(IndexChannel,i);
4243 +        if (image->matte != MagickFalse)
4244 +          ChannelFeatures(OpacityChannel,i);
4245 +      }
4246 +      channel_features=(ChannelFeatures *)
4247 +        RelinquishMagickMemory(channel_features);
4248 +    }
4249 +
4250 +  PerlException:
4251 +    InheritPerlException(exception,perl_exception);
4252 +    exception=DestroyExceptionInfo(exception);
4253 +    SvREFCNT_dec(perl_exception);
4254 +  }
4255 +\f
4256 +#
4257 +###############################################################################
4258 +#                                                                             #
4259 +#                                                                             #
4260 +#                                                                             #
4261 +#   F l a t t e n                                                             #
4262 +#                                                                             #
4263 +#                                                                             #
4264 +#                                                                             #
4265 +###############################################################################
4266 +#
4267 +#
4268 +void
4269 +Flatten(ref)
4270 +  Image::Magick ref = NO_INIT
4271 +  ALIAS:
4272 +    FlattenImage   = 1
4273 +    flatten        = 2
4274 +    flattenimage   = 3
4275 +  PPCODE:
4276 +  {
4277 +    AV
4278 +      *av;
4279 +
4280 +    char
4281 +      *attribute,
4282 +      *p;
4283 +
4284 +    ExceptionInfo
4285 +      *exception;
4286 +
4287 +    HV
4288 +      *hv;
4289 +
4290 +    Image
4291 +      *image;
4292 +
4293 +    PixelPacket
4294 +      background_color;
4295 +
4296 +    register ssize_t
4297 +      i;
4298 +
4299 +    struct PackageInfo
4300 +      *info;
4301 +
4302 +    SV
4303 +      *perl_exception,
4304 +      *reference,
4305 +      *rv,
4306 +      *sv;
4307 +
4308 +    PERL_UNUSED_VAR(ref);
4309 +    PERL_UNUSED_VAR(ix);
4310 +    exception=AcquireExceptionInfo();
4311 +    perl_exception=newSVpv("",0);
4312 +    sv=NULL;
4313 +    if (sv_isobject(ST(0)) == 0)
4314 +      {
4315 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4316 +          PackageName);
4317 +        goto PerlException;
4318 +      }
4319 +    reference=SvRV(ST(0));
4320 +    hv=SvSTASH(reference);
4321 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4322 +    if (image == (Image *) NULL)
4323 +      {
4324 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
4325 +          PackageName);
4326 +        goto PerlException;
4327 +      }
4328 +    background_color=image->background_color;
4329 +    if (items == 2)
4330 +      (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
4331 +        exception);
4332 +    else
4333 +      for (i=2; i < items; i+=2)
4334 +      {
4335 +        attribute=(char *) SvPV(ST(i-1),na);
4336 +        switch (*attribute)
4337 +        {
4338 +          case 'B':
4339 +          case 'b':
4340 +          {
4341 +            if (LocaleCompare(attribute,"background") == 0)
4342 +              {
4343 +                (void) QueryColorDatabase((char *) SvPV(ST(1),na),
4344 +                  &background_color,exception);
4345 +                break;
4346 +              }
4347 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4348 +              attribute);
4349 +            break;
4350 +          }
4351 +          default:
4352 +          {
4353 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4354 +              attribute);
4355 +            break;
4356 +          }
4357 +        }
4358 +      }
4359 +    image->background_color=background_color;
4360 +    image=MergeImageLayers(image,FlattenLayer,exception);
4361 +    if (image == (Image *) NULL)
4362 +      goto PerlException;
4363 +    /*
4364 +      Create blessed Perl array for the returned image.
4365 +    */
4366 +    av=newAV();
4367 +    ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4368 +    SvREFCNT_dec(av);
4369 +    AddImageToRegistry(sv,image);
4370 +    rv=newRV(sv);
4371 +    av_push(av,sv_bless(rv,hv));
4372 +    SvREFCNT_dec(sv);
4373 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4374 +    (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4375 +      "flatten-%.*s",(int) (MaxTextExtent-9),
4376 +      ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4377 +    (void) CopyMagickString(image->filename,info->image_info->filename,
4378 +      MaxTextExtent);
4379 +    SetImageInfo(info->image_info,0,exception);
4380 +    exception=DestroyExceptionInfo(exception);
4381 +    SvREFCNT_dec(perl_exception);
4382 +    XSRETURN(1);
4383 +
4384 +  PerlException:
4385 +    InheritPerlException(exception,perl_exception);
4386 +    exception=DestroyExceptionInfo(exception);
4387 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4388 +    SvPOK_on(perl_exception);  /* return messages in string context */
4389 +    ST(0)=sv_2mortal(perl_exception);
4390 +    XSRETURN(1);
4391 +  }
4392 +\f
4393 +#
4394 +###############################################################################
4395 +#                                                                             #
4396 +#                                                                             #
4397 +#                                                                             #
4398 +#   F x                                                                       #
4399 +#                                                                             #
4400 +#                                                                             #
4401 +#                                                                             #
4402 +###############################################################################
4403 +#
4404 +#
4405 +void
4406 +Fx(ref,...)
4407 +  Image::Magick ref = NO_INIT
4408 +  ALIAS:
4409 +    FxImage  = 1
4410 +    fx       = 2
4411 +    fximage  = 3
4412 +  PPCODE:
4413 +  {
4414 +    AV
4415 +      *av;
4416 +
4417 +    char
4418 +      *attribute,
4419 +      expression[MaxTextExtent];
4420 +
4421 +    ChannelType
4422 +      channel;
4423 +
4424 +    ExceptionInfo
4425 +      *exception;
4426 +
4427 +    HV
4428 +      *hv;
4429 +
4430 +    Image
4431 +      *image;
4432 +
4433 +    register ssize_t
4434 +      i;
4435 +
4436 +    struct PackageInfo
4437 +      *info;
4438 +
4439 +    SV
4440 +      *av_reference,
4441 +      *perl_exception,
4442 +      *reference,
4443 +      *rv,
4444 +      *sv;
4445 +
4446 +    PERL_UNUSED_VAR(ref);
4447 +    PERL_UNUSED_VAR(ix);
4448 +    exception=AcquireExceptionInfo();
4449 +    perl_exception=newSVpv("",0);
4450 +    sv=NULL;
4451 +    attribute=NULL;
4452 +    av=NULL;
4453 +    if (sv_isobject(ST(0)) == 0)
4454 +      {
4455 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4456 +          PackageName);
4457 +        goto PerlException;
4458 +      }
4459 +    reference=SvRV(ST(0));
4460 +    hv=SvSTASH(reference);
4461 +    av=newAV();
4462 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4463 +    SvREFCNT_dec(av);
4464 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4465 +    if (image == (Image *) NULL)
4466 +      {
4467 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
4468 +          PackageName);
4469 +        goto PerlException;
4470 +      }
4471 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4472 +    /*
4473 +      Get options.
4474 +    */
4475 +    channel=DefaultChannels;
4476 +    (void) CopyMagickString(expression,"u",MaxTextExtent);
4477 +    if (items == 2)
4478 +      (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4479 +    else
4480 +      for (i=2; i < items; i+=2)
4481 +      {
4482 +        attribute=(char *) SvPV(ST(i-1),na);
4483 +        switch (*attribute)
4484 +        {
4485 +          case 'C':
4486 +          case 'c':
4487 +          {
4488 +            if (LocaleCompare(attribute,"channel") == 0)
4489 +              {
4490 +                ssize_t
4491 +                  option;
4492 +
4493 +                option=ParseChannelOption(SvPV(ST(i),na));
4494 +                if (option < 0)
4495 +                  {
4496 +                    ThrowPerlException(exception,OptionError,
4497 +                      "UnrecognizedType",SvPV(ST(i),na));
4498 +                    return;
4499 +                  }
4500 +                channel=(ChannelType) option;
4501 +                break;
4502 +              }
4503 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4504 +              attribute);
4505 +            break;
4506 +          }
4507 +          case 'E':
4508 +          case 'e':
4509 +          {
4510 +            if (LocaleCompare(attribute,"expression") == 0)
4511 +              {
4512 +                (void) CopyMagickString(expression,SvPV(ST(i),na),
4513 +                  MaxTextExtent);
4514 +                break;
4515 +              }
4516 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4517 +              attribute);
4518 +            break;
4519 +          }
4520 +          default:
4521 +          {
4522 +            ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4523 +              attribute);
4524 +            break;
4525 +          }
4526 +        }
4527 +      }
4528 +    image=FxImageChannel(image,channel,expression,exception);
4529 +    if (image == (Image *) NULL)
4530 +      goto PerlException;
4531 +    for ( ; image; image=image->next)
4532 +    {
4533 +      AddImageToRegistry(sv,image);
4534 +      rv=newRV(sv);
4535 +      av_push(av,sv_bless(rv,hv));
4536 +      SvREFCNT_dec(sv);
4537 +    }
4538 +    exception=DestroyExceptionInfo(exception);
4539 +    ST(0)=av_reference;
4540 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
4541 +    XSRETURN(1);
4542 +
4543 +  PerlException:
4544 +    InheritPerlException(exception,perl_exception);
4545 +    exception=DestroyExceptionInfo(exception);
4546 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4547 +    SvPOK_on(perl_exception);
4548 +    ST(0)=sv_2mortal(perl_exception);
4549 +    XSRETURN(1);
4550 +  }
4551 +\f
4552 +#
4553 +###############################################################################
4554 +#                                                                             #
4555 +#                                                                             #
4556 +#                                                                             #
4557 +#   G e t                                                                     #
4558 +#                                                                             #
4559 +#                                                                             #
4560 +#                                                                             #
4561 +###############################################################################
4562 +#
4563 +#
4564 +void
4565 +Get(ref,...)
4566 +  Image::Magick ref = NO_INIT
4567 +  ALIAS:
4568 +    GetAttributes = 1
4569 +    GetAttribute  = 2
4570 +    get           = 3
4571 +    getattributes = 4
4572 +    getattribute  = 5
4573 +  PPCODE:
4574 +  {
4575 +    char
4576 +      *attribute,
4577 +      color[MaxTextExtent];
4578 +
4579 +    const char
4580 +      *value;
4581 +
4582 +    ExceptionInfo
4583 +      *exception;
4584 +
4585 +    Image
4586 +      *image;
4587 +
4588 +    long
4589 +      j;
4590 +
4591 +    register ssize_t
4592 +      i;
4593 +
4594 +    struct PackageInfo
4595 +      *info;
4596 +
4597 +    SV
4598 +      *perl_exception,
4599 +      *reference,
4600 +      *s;
4601 +
4602 +    PERL_UNUSED_VAR(ref);
4603 +    PERL_UNUSED_VAR(ix);
4604 +    exception=AcquireExceptionInfo();
4605 +    perl_exception=newSVpv("",0);
4606 +    if (sv_isobject(ST(0)) == 0)
4607 +      {
4608 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4609 +          PackageName);
4610 +        XSRETURN_EMPTY;
4611 +      }
4612 +    reference=SvRV(ST(0));
4613 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4614 +    if (image == (Image *) NULL && !info)
4615 +      XSRETURN_EMPTY;
4616 +    EXTEND(sp,items);
4617 +    for (i=1; i < items; i++)
4618 +    {
4619 +      attribute=(char *) SvPV(ST(i),na);
4620 +      s=NULL;
4621 +      switch (*attribute)
4622 +      {
4623 +        case 'A':
4624 +        case 'a':
4625 +        {
4626 +          if (LocaleCompare(attribute,"adjoin") == 0)
4627 +            {
4628 +              if (info)
4629 +                s=newSViv((ssize_t) info->image_info->adjoin);
4630 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4631 +              continue;
4632 +            }
4633 +          if (LocaleCompare(attribute,"antialias") == 0)
4634 +            {
4635 +              if (info)
4636 +                s=newSViv((ssize_t) info->image_info->antialias);
4637 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4638 +              continue;
4639 +            }
4640 +          if (LocaleCompare(attribute,"area") == 0)
4641 +            {
4642 +              s=newSViv(GetMagickResource(AreaResource));
4643 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4644 +              continue;
4645 +            }
4646 +          if (LocaleCompare(attribute,"attenuate") == 0)
4647 +            {
4648 +              const char
4649 +                *value;
4650 +
4651 +              value=GetImageProperty(image,attribute);
4652 +              if (value != (const char *) NULL)
4653 +                s=newSVpv(value,0);
4654 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4655 +              continue;
4656 +            }
4657 +          if (LocaleCompare(attribute,"authenticate") == 0)
4658 +            {
4659 +              if (info)
4660 +                s=newSVpv(info->image_info->authenticate,0);
4661 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4662 +              continue;
4663 +            }
4664 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4665 +            attribute);
4666 +          break;
4667 +        }
4668 +        case 'B':
4669 +        case 'b':
4670 +        {
4671 +          if (LocaleCompare(attribute,"background") == 0)
4672 +            {
4673 +              if (image == (Image *) NULL)
4674 +                break;
4675 +              (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4676 +                QuantumFormat "," QuantumFormat "," QuantumFormat,
4677 +                image->background_color.red,image->background_color.green,
4678 +                image->background_color.blue,image->background_color.opacity);
4679 +              s=newSVpv(color,0);
4680 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4681 +              continue;
4682 +            }
4683 +          if (LocaleCompare(attribute,"base-columns") == 0)
4684 +            {
4685 +              if (image != (Image *) NULL)
4686 +                s=newSViv((ssize_t) image->magick_columns);
4687 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4688 +              continue;
4689 +            }
4690 +          if (LocaleCompare(attribute,"base-filename") == 0)
4691 +            {
4692 +              if (image != (Image *) NULL)
4693 +                s=newSVpv(image->magick_filename,0);
4694 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4695 +              continue;
4696 +            }
4697 +          if (LocaleCompare(attribute,"base-height") == 0)
4698 +            {
4699 +              if (image != (Image *) NULL)
4700 +                s=newSViv((ssize_t) image->magick_rows);
4701 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4702 +              continue;
4703 +            }
4704 +          if (LocaleCompare(attribute,"base-rows") == 0)
4705 +            {
4706 +              if (image != (Image *) NULL)
4707 +                s=newSViv((ssize_t) image->magick_rows);
4708 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4709 +              continue;
4710 +            }
4711 +          if (LocaleCompare(attribute,"base-width") == 0)
4712 +            {
4713 +              if (image != (Image *) NULL)
4714 +                s=newSViv((ssize_t) image->magick_columns);
4715 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4716 +              continue;
4717 +            }
4718 +          if (LocaleCompare(attribute,"bias") == 0)
4719 +            {
4720 +              if (image != (Image *) NULL)
4721 +                s=newSVnv(image->bias);
4722 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4723 +              continue;
4724 +            }
4725 +          if (LocaleCompare(attribute,"blue-primary") == 0)
4726 +            {
4727 +              if (image == (Image *) NULL)
4728 +                break;
4729 +              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4730 +                image->chromaticity.blue_primary.x,
4731 +                image->chromaticity.blue_primary.y);
4732 +              s=newSVpv(color,0);
4733 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4734 +              continue;
4735 +            }
4736 +          if (LocaleCompare(attribute,"bordercolor") == 0)
4737 +            {
4738 +              if (image == (Image *) NULL)
4739 +                break;
4740 +              (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4741 +                QuantumFormat "," QuantumFormat "," QuantumFormat,
4742 +                image->border_color.red,image->border_color.green,
4743 +                image->border_color.blue,image->border_color.opacity);
4744 +              s=newSVpv(color,0);
4745 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4746 +              continue;
4747 +            }
4748 +          if (LocaleCompare(attribute,"bounding-box") == 0)
4749 +            {
4750 +              char
4751 +                geometry[MaxTextExtent];
4752 +
4753 +              RectangleInfo
4754 +                page;
4755 +
4756 +              if (image == (Image *) NULL)
4757 +                break;
4758 +              page=GetImageBoundingBox(image,&image->exception);
4759 +              (void) FormatLocaleString(geometry,MaxTextExtent,
4760 +                "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4761 +                page.height,(double) page.x,(double) page.y);
4762 +              s=newSVpv(geometry,0);
4763 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4764 +              continue;
4765 +            }
4766 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4767 +            attribute);
4768 +          break;
4769 +        }
4770 +        case 'C':
4771 +        case 'c':
4772 +        {
4773 +          if (LocaleCompare(attribute,"class") == 0)
4774 +            {
4775 +              if (image == (Image *) NULL)
4776 +                break;
4777 +              s=newSViv(image->storage_class);
4778 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4779 +                image->storage_class));
4780 +              SvIOK_on(s);
4781 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4782 +              continue;
4783 +            }
4784 +          if (LocaleCompare(attribute,"clip-mask") == 0)
4785 +            {
4786 +              if (image != (Image *) NULL)
4787 +                {
4788 +                  SV
4789 +                    *sv;
4790 +
4791 +                  sv=NULL;
4792 +                  if (image->mask == (Image *) NULL)
4793 +                    ClipImage(image);
4794 +                  if (image->mask != (Image *) NULL)
4795 +                    {
4796 +                      AddImageToRegistry(sv,image->mask);
4797 +                      s=sv_bless(newRV(sv),SvSTASH(reference));
4798 +                    }
4799 +                }
4800 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4801 +              continue;
4802 +            }
4803 +          if (LocaleCompare(attribute,"clip-path") == 0)
4804 +            {
4805 +              if (image != (Image *) NULL)
4806 +                {
4807 +                  SV
4808 +                    *sv;
4809 +
4810 +                  sv=NULL;
4811 +                  if (image->clip_mask == (Image *) NULL)
4812 +                    ClipImage(image);
4813 +                  if (image->clip_mask != (Image *) NULL)
4814 +                    {
4815 +                      AddImageToRegistry(sv,image->clip_mask);
4816 +                      s=sv_bless(newRV(sv),SvSTASH(reference));
4817 +                    }
4818 +                }
4819 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4820 +              continue;
4821 +            }
4822 +          if (LocaleCompare(attribute,"compression") == 0)
4823 +            {
4824 +              j=info ? info->image_info->compression : image ?
4825 +                image->compression : UndefinedCompression;
4826 +              if (info)
4827 +                if (info->image_info->compression == UndefinedCompression)
4828 +                  j=image->compression;
4829 +              s=newSViv(j);
4830 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4831 +                j));
4832 +              SvIOK_on(s);
4833 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4834 +              continue;
4835 +            }
4836 +          if (LocaleCompare(attribute,"colorspace") == 0)
4837 +            {
4838 +              j=image ? image->colorspace : RGBColorspace;
4839 +              s=newSViv(j);
4840 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4841 +                j));
4842 +              SvIOK_on(s);
4843 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4844 +              continue;
4845 +            }
4846 +          if (LocaleCompare(attribute,"colors") == 0)
4847 +            {
4848 +              if (image != (Image *) NULL)
4849 +                s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4850 +                  &image->exception));
4851 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4852 +              continue;
4853 +            }
4854 +          if (LocaleNCompare(attribute,"colormap",8) == 0)
4855 +            {
4856 +              int
4857 +                items;
4858 +
4859 +              if (image == (Image *) NULL || !image->colormap)
4860 +                break;
4861 +              j=0;
4862 +              items=sscanf(attribute,"%*[^[][%ld",&j);
4863 +              (void) items;
4864 +              if (j > (ssize_t) image->colors)
4865 +                j%=image->colors;
4866 +              (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4867 +                QuantumFormat "," QuantumFormat "," QuantumFormat,
4868 +                image->colormap[j].red,image->colormap[j].green,
4869 +                image->colormap[j].blue,image->colormap[j].opacity);
4870 +              s=newSVpv(color,0);
4871 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4872 +              continue;
4873 +            }
4874 +          if (LocaleCompare(attribute,"columns") == 0)
4875 +            {
4876 +              if (image != (Image *) NULL)
4877 +                s=newSViv((ssize_t) image->columns);
4878 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4879 +              continue;
4880 +            }
4881 +          if (LocaleCompare(attribute,"comment") == 0)
4882 +            {
4883 +              const char
4884 +                *value;
4885 +
4886 +              value=GetImageProperty(image,attribute);
4887 +              if (value != (const char *) NULL)
4888 +                s=newSVpv(value,0);
4889 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4890 +              continue;
4891 +            }
4892 +          if (LocaleCompare(attribute,"copyright") == 0)
4893 +            {
4894 +              s=newSVpv(GetMagickCopyright(),0);
4895 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4896 +              continue;
4897 +            }
4898 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4899 +            attribute);
4900 +          break;
4901 +        }
4902 +        case 'D':
4903 +        case 'd':
4904 +        {
4905 +          if (LocaleCompare(attribute,"density") == 0)
4906 +            {
4907 +              char
4908 +                geometry[MaxTextExtent];
4909 +
4910 +              if (image == (Image *) NULL)
4911 +                break;
4912 +              (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4913 +                image->x_resolution,image->y_resolution);
4914 +              s=newSVpv(geometry,0);
4915 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4916 +              continue;
4917 +            }
4918 +          if (LocaleCompare(attribute,"delay") == 0)
4919 +            {
4920 +              if (image != (Image *) NULL)
4921 +                s=newSViv((ssize_t) image->delay);
4922 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4923 +              continue;
4924 +            }
4925 +          if (LocaleCompare(attribute,"depth") == 0)
4926 +            {
4927 +              s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4928 +              if (image != (Image *) NULL)
4929 +                s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4930 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4931 +              continue;
4932 +            }
4933 +          if (LocaleCompare(attribute,"directory") == 0)
4934 +            {
4935 +              if (image && image->directory)
4936 +                s=newSVpv(image->directory,0);
4937 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4938 +              continue;
4939 +            }
4940 +          if (LocaleCompare(attribute,"dispose") == 0)
4941 +            {
4942 +              if (image == (Image *) NULL)
4943 +                break;
4944 +
4945 +              s=newSViv(image->dispose);
4946 +              (void) sv_setpv(s,
4947 +                CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4948 +              SvIOK_on(s);
4949 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4950 +              continue;
4951 +            }
4952 +          if (LocaleCompare(attribute,"disk") == 0)
4953 +            {
4954 +              s=newSViv(GetMagickResource(DiskResource));
4955 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4956 +              continue;
4957 +            }
4958 +          if (LocaleCompare(attribute,"dither") == 0)
4959 +            {
4960 +              if (info)
4961 +                s=newSViv((ssize_t) info->image_info->dither);
4962 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4963 +              continue;
4964 +            }
4965 +          if (LocaleCompare(attribute,"display") == 0)  /* same as server */
4966 +            {
4967 +              if (info && info->image_info->server_name)
4968 +                s=newSVpv(info->image_info->server_name,0);
4969 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4970 +              continue;
4971 +            }
4972 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4973 +            attribute);
4974 +          break;
4975 +        }
4976 +        case 'E':
4977 +        case 'e':
4978 +        {
4979 +          if (LocaleCompare(attribute,"elapsed-time") == 0)
4980 +            {
4981 +              if (image != (Image *) NULL)
4982 +                s=newSVnv(GetElapsedTime(&image->timer));
4983 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4984 +              continue;
4985 +            }
4986 +          if (LocaleCompare(attribute,"endian") == 0)
4987 +            {
4988 +              j=info ? info->image_info->endian : image ? image->endian :
4989 +                UndefinedEndian;
4990 +              s=newSViv(j);
4991 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4992 +              SvIOK_on(s);
4993 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
4994 +              continue;
4995 +            }
4996 +          if (LocaleCompare(attribute,"error") == 0)
4997 +            {
4998 +              if (image != (Image *) NULL)
4999 +                s=newSVnv(image->error.mean_error_per_pixel);
5000 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5001 +              continue;
5002 +            }
5003 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5004 +            attribute);
5005 +          break;
5006 +        }
5007 +        case 'F':
5008 +        case 'f':
5009 +        {
5010 +          if (LocaleCompare(attribute,"filesize") == 0)
5011 +            {
5012 +              if (image != (Image *) NULL)
5013 +                s=newSViv((ssize_t) GetBlobSize(image));
5014 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5015 +              continue;
5016 +            }
5017 +          if (LocaleCompare(attribute,"filename") == 0)
5018 +            {
5019 +              if (info && info->image_info->filename &&
5020 +                  *info->image_info->filename)
5021 +                s=newSVpv(info->image_info->filename,0);
5022 +              if (image != (Image *) NULL)
5023 +                s=newSVpv(image->filename,0);
5024 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5025 +              continue;
5026 +            }
5027 +          if (LocaleCompare(attribute,"filter") == 0)
5028 +            {
5029 +              s=image ? newSViv(image->filter) : newSViv(0);
5030 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5031 +                image->filter));
5032 +              SvIOK_on(s);
5033 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5034 +              continue;
5035 +            }
5036 +          if (LocaleCompare(attribute,"font") == 0)
5037 +            {
5038 +              if (info && info->image_info->font)
5039 +                s=newSVpv(info->image_info->font,0);
5040 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5041 +              continue;
5042 +            }
5043 +          if (LocaleCompare(attribute,"foreground") == 0)
5044 +            continue;
5045 +          if (LocaleCompare(attribute,"format") == 0)
5046 +            {
5047 +              const MagickInfo
5048 +                *magick_info;
5049 +
5050 +              magick_info=(const MagickInfo *) NULL;
5051 +              if (info && (*info->image_info->magick != '\0'))
5052 +                magick_info=GetMagickInfo(info->image_info->magick,exception);
5053 +              if (image != (Image *) NULL)
5054 +                magick_info=GetMagickInfo(image->magick,&image->exception);
5055 +              if ((magick_info != (const MagickInfo *) NULL) &&
5056 +                  (*magick_info->description != '\0'))
5057 +                s=newSVpv((char *) magick_info->description,0);
5058 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5059 +              continue;
5060 +            }
5061 +          if (LocaleCompare(attribute,"fuzz") == 0)
5062 +            {
5063 +              if (info)
5064 +                s=newSVnv(info->image_info->fuzz);
5065 +              if (image != (Image *) NULL)
5066 +                s=newSVnv(image->fuzz);
5067 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5068 +              continue;
5069 +            }
5070 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5071 +            attribute);
5072 +          break;
5073 +        }
5074 +        case 'G':
5075 +        case 'g':
5076 +        {
5077 +          if (LocaleCompare(attribute,"gamma") == 0)
5078 +            {
5079 +              if (image != (Image *) NULL)
5080 +                s=newSVnv(image->gamma);
5081 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5082 +              continue;
5083 +            }
5084 +          if (LocaleCompare(attribute,"geometry") == 0)
5085 +            {
5086 +              if (image && image->geometry)
5087 +                s=newSVpv(image->geometry,0);
5088 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5089 +              continue;
5090 +            }
5091 +          if (LocaleCompare(attribute,"gravity") == 0)
5092 +            {
5093 +              s=image ? newSViv(image->gravity) : newSViv(0);
5094 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5095 +                image->gravity));
5096 +              SvIOK_on(s);
5097 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5098 +              continue;
5099 +            }
5100 +          if (LocaleCompare(attribute,"green-primary") == 0)
5101 +            {
5102 +              if (image == (Image *) NULL)
5103 +                break;
5104 +              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5105 +                image->chromaticity.green_primary.x,
5106 +                image->chromaticity.green_primary.y);
5107 +              s=newSVpv(color,0);
5108 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5109 +              continue;
5110 +            }
5111 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5112 +            attribute);
5113 +          break;
5114 +        }
5115 +        case 'H':
5116 +        case 'h':
5117 +        {
5118 +          if (LocaleCompare(attribute,"height") == 0)
5119 +            {
5120 +              if (image != (Image *) NULL)
5121 +                s=newSViv((ssize_t) image->rows);
5122 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5123 +              continue;
5124 +            }
5125 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5126 +            attribute);
5127 +          break;
5128 +        }
5129 +        case 'I':
5130 +        case 'i':
5131 +        {
5132 +          if (LocaleCompare(attribute,"icc") == 0)
5133 +            {
5134 +              if (image != (Image *) NULL)
5135 +                {
5136 +                  const StringInfo
5137 +                    *profile;
5138 +
5139 +                  profile=GetImageProfile(image,"icc");
5140 +                  if (profile != (StringInfo *) NULL)
5141 +                    s=newSVpv((const char *) GetStringInfoDatum(profile),
5142 +                      GetStringInfoLength(profile));
5143 +                }
5144 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5145 +              continue;
5146 +            }
5147 +          if (LocaleCompare(attribute,"icm") == 0)
5148 +            {
5149 +              if (image != (Image *) NULL)
5150 +                {
5151 +                  const StringInfo
5152 +                    *profile;
5153 +
5154 +                  profile=GetImageProfile(image,"icm");
5155 +                  if (profile != (const StringInfo *) NULL)
5156 +                    s=newSVpv((const char *) GetStringInfoDatum(profile),
5157 +                      GetStringInfoLength(profile));
5158 +                }
5159 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5160 +              continue;
5161 +            }
5162 +          if (LocaleCompare(attribute,"id") == 0)
5163 +            {
5164 +              if (image != (Image *) NULL)
5165 +                {
5166 +                  char
5167 +                    key[MaxTextExtent];
5168 +
5169 +                  MagickBooleanType
5170 +                    status;
5171 +
5172 +                  static ssize_t
5173 +                    id = 0;
5174 +
5175 +                  (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
5176 +                    id);
5177 +                  status=SetImageRegistry(ImageRegistryType,key,image,
5178 +                    &image->exception);
5179 +                  (void) status;
5180 +                  s=newSViv(id++);
5181 +                }
5182 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5183 +              continue;
5184 +            }
5185 +          if (LocaleNCompare(attribute,"index",5) == 0)
5186 +            {
5187 +              char
5188 +                name[MaxTextExtent];
5189 +
5190 +              int
5191 +                items;
5192 +
5193 +              long
5194 +                x,
5195 +                y;
5196 +
5197 +              register const IndexPacket
5198 +                *indexes;
5199 +
5200 +              register const PixelPacket
5201 +                *p;
5202 +
5203 +              CacheView
5204 +                *image_view;
5205 +
5206 +              if (image == (Image *) NULL)
5207 +                break;
5208 +              if (image->storage_class != PseudoClass)
5209 +                break;
5210 +              x=0;
5211 +              y=0;
5212 +              items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5213 +              (void) items;
5214 +              image_view=AcquireVirtualCacheView(image,exception);
5215 +              p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
5216 +              if (p != (const PixelPacket *) NULL)
5217 +                {
5218 +                  indexes=GetCacheViewVirtualIndexQueue(image_view);
5219 +                  (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5220 +                    GetPixelIndex(indexes));
5221 +                  s=newSVpv(name,0);
5222 +                  PUSHs(s ? sv_2mortal(s) : &sv_undef);
5223 +                }
5224 +              image_view=DestroyCacheView(image_view);
5225 +              continue;
5226 +            }
5227 +          if (LocaleCompare(attribute,"iptc") == 0)
5228 +            {
5229 +              if (image != (Image *) NULL)
5230 +                {
5231 +                  const StringInfo
5232 +                    *profile;
5233 +
5234 +                  profile=GetImageProfile(image,"iptc");
5235 +                  if (profile != (const StringInfo *) NULL)
5236 +                    s=newSVpv((const char *) GetStringInfoDatum(profile),
5237 +                      GetStringInfoLength(profile));
5238 +                }
5239 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5240 +              continue;
5241 +            }
5242 +          if (LocaleCompare(attribute,"iterations") == 0)  /* same as loop */
5243 +            {
5244 +              if (image != (Image *) NULL)
5245 +                s=newSViv((ssize_t) image->iterations);
5246 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5247 +              continue;
5248 +            }
5249 +          if (LocaleCompare(attribute,"interlace") == 0)
5250 +            {
5251 +              j=info ? info->image_info->interlace : image ? image->interlace :
5252 +                UndefinedInterlace;
5253 +              s=newSViv(j);
5254 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5255 +                j));
5256 +              SvIOK_on(s);
5257 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5258 +              continue;
5259 +            }
5260 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5261 +            attribute);
5262 +          break;
5263 +        }
5264 +        case 'L':
5265 +        case 'l':
5266 +        {
5267 +          if (LocaleCompare(attribute,"label") == 0)
5268 +            {
5269 +              const char
5270 +                *value;
5271 +
5272 +              if (image == (Image *) NULL)
5273 +                break;
5274 +              value=GetImageProperty(image,"Label");
5275 +              if (value != (const char *) NULL)
5276 +                s=newSVpv(value,0);
5277 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5278 +              continue;
5279 +            }
5280 +          if (LocaleCompare(attribute,"loop") == 0)  /* same as iterations */
5281 +            {
5282 +              if (image != (Image *) NULL)
5283 +                s=newSViv((ssize_t) image->iterations);
5284 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5285 +              continue;
5286 +            }
5287 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5288 +            attribute);
5289 +          break;
5290 +        }
5291 +        case 'M':
5292 +        case 'm':
5293 +        {
5294 +          if (LocaleCompare(attribute,"magick") == 0)
5295 +            {
5296 +              if (info && *info->image_info->magick)
5297 +                s=newSVpv(info->image_info->magick,0);
5298 +              if (image != (Image *) NULL)
5299 +                s=newSVpv(image->magick,0);
5300 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5301 +              continue;
5302 +            }
5303 +          if (LocaleCompare(attribute,"map") == 0)
5304 +            {
5305 +              s=newSViv(GetMagickResource(MapResource));
5306 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5307 +              continue;
5308 +            }
5309 +          if (LocaleCompare(attribute,"maximum-error") == 0)
5310 +            {
5311 +              if (image != (Image *) NULL)
5312 +                s=newSVnv(image->error.normalized_maximum_error);
5313 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5314 +              continue;
5315 +            }
5316 +          if (LocaleCompare(attribute,"memory") == 0)
5317 +            {
5318 +              s=newSViv(GetMagickResource(MemoryResource));
5319 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 +              continue;
5321 +            }
5322 +          if (LocaleCompare(attribute,"mean-error") == 0)
5323 +            {
5324 +              if (image != (Image *) NULL)
5325 +                s=newSVnv(image->error.normalized_mean_error);
5326 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5327 +              continue;
5328 +            }
5329 +          if (LocaleCompare(attribute,"mime") == 0)
5330 +            {
5331 +              if (info && *info->image_info->magick)
5332 +                s=newSVpv(MagickToMime(info->image_info->magick),0);
5333 +              if (image != (Image *) NULL)
5334 +                s=newSVpv(MagickToMime(image->magick),0);
5335 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5336 +              continue;
5337 +            }
5338 +          if (LocaleCompare(attribute,"mattecolor") == 0)
5339 +            {
5340 +              if (image == (Image *) NULL)
5341 +                break;
5342 +              (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5343 +                QuantumFormat "," QuantumFormat "," QuantumFormat,
5344 +                image->matte_color.red,image->matte_color.green,
5345 +                image->matte_color.blue,image->matte_color.opacity);
5346 +              s=newSVpv(color,0);
5347 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5348 +              continue;
5349 +            }
5350 +          if (LocaleCompare(attribute,"matte") == 0)
5351 +            {
5352 +              if (image != (Image *) NULL)
5353 +                s=newSViv((ssize_t) image->matte);
5354 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5355 +              continue;
5356 +            }
5357 +          if (LocaleCompare(attribute,"mime") == 0)
5358 +            {
5359 +              const char
5360 +                *magick;
5361 +
5362 +              magick=NULL;
5363 +              if (info && *info->image_info->magick)
5364 +                magick=info->image_info->magick;
5365 +              if (image != (Image *) NULL)
5366 +                magick=image->magick;
5367 +              if (magick)
5368 +                {
5369 +                  char
5370 +                    *mime;
5371 +
5372 +                  mime=MagickToMime(magick);
5373 +                  s=newSVpv(mime,0);
5374 +                  mime=(char *) RelinquishMagickMemory(mime);
5375 +                }
5376 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5377 +              continue;
5378 +            }
5379 +          if (LocaleCompare(attribute,"monochrome") == 0)
5380 +            {
5381 +              if (image == (Image *) NULL)
5382 +                continue;
5383 +              j=info ? info->image_info->monochrome :
5384 +                IsMonochromeImage(image,&image->exception);
5385 +              s=newSViv(j);
5386 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5387 +              continue;
5388 +            }
5389 +          if (LocaleCompare(attribute,"montage") == 0)
5390 +            {
5391 +              if (image && image->montage)
5392 +                s=newSVpv(image->montage,0);
5393 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5394 +              continue;
5395 +            }
5396 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5397 +            attribute);
5398 +          break;
5399 +        }
5400 +        case 'O':
5401 +        case 'o':
5402 +        {
5403 +          if (LocaleCompare(attribute,"orientation") == 0)
5404 +            {
5405 +              j=info ? info->image_info->orientation : image ?
5406 +                image->orientation : UndefinedOrientation;
5407 +              s=newSViv(j);
5408 +              (void) sv_setpv(s,CommandOptionToMnemonic(
5409 +                MagickOrientationOptions,j));
5410 +              SvIOK_on(s);
5411 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5412 +              continue;
5413 +            }
5414 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5415 +            attribute);
5416 +          break;
5417 +        }
5418 +        case 'P':
5419 +        case 'p':
5420 +        {
5421 +          if (LocaleCompare(attribute,"page") == 0)
5422 +            {
5423 +              if (info && info->image_info->page)
5424 +                s=newSVpv(info->image_info->page,0);
5425 +              if (image != (Image *) NULL)
5426 +                {
5427 +                  char
5428 +                    geometry[MaxTextExtent];
5429 +
5430 +                  (void) FormatLocaleString(geometry,MaxTextExtent,
5431 +                    "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5432 +                    (double) image->page.height,(double) image->page.x,(double)
5433 +                    image->page.y);
5434 +                  s=newSVpv(geometry,0);
5435 +                }
5436 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5437 +              continue;
5438 +            }
5439 +          if (LocaleCompare(attribute,"page.x") == 0)
5440 +            {
5441 +              if (image != (Image *) NULL)
5442 +                s=newSViv((ssize_t) image->page.x);
5443 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5444 +              continue;
5445 +            }
5446 +          if (LocaleCompare(attribute,"page.y") == 0)
5447 +            {
5448 +              if (image != (Image *) NULL)
5449 +                s=newSViv((ssize_t) image->page.y);
5450 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5451 +              continue;
5452 +            }
5453 +          if (LocaleNCompare(attribute,"pixel",5) == 0)
5454 +            {
5455 +              char
5456 +                tuple[MaxTextExtent];
5457 +
5458 +              int
5459 +                items;
5460 +
5461 +              long
5462 +                x,
5463 +                y;
5464 +
5465 +              register const PixelPacket
5466 +                *p;
5467 +
5468 +              register const IndexPacket
5469 +                *indexes;
5470 +
5471 +              if (image == (Image *) NULL)
5472 +                break;
5473 +              x=0;
5474 +              y=0;
5475 +              items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5476 +              (void) items;
5477 +              p=GetVirtualPixels(image,x,y,1,1,exception);
5478 +              indexes=GetVirtualIndexQueue(image);
5479 +              if (image->colorspace != CMYKColorspace)
5480 +                (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5481 +                  QuantumFormat "," QuantumFormat "," QuantumFormat,
5482 +                  GetPixelRed(p),GetPixelGreen(p),
5483 +                  GetPixelBlue(p),GetPixelOpacity(p));
5484 +              else
5485 +                (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5486 +                  QuantumFormat "," QuantumFormat "," QuantumFormat ","
5487 +                  QuantumFormat,GetPixelRed(p),
5488 +                  GetPixelGreen(p),GetPixelBlue(p),
5489 +                  GetPixelIndex(indexes),GetPixelOpacity(p));
5490 +              s=newSVpv(tuple,0);
5491 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5492 +              continue;
5493 +            }
5494 +          if (LocaleCompare(attribute,"pointsize") == 0)
5495 +            {
5496 +              if (info)
5497 +                s=newSViv((ssize_t) info->image_info->pointsize);
5498 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5499 +              continue;
5500 +            }
5501 +          if (LocaleCompare(attribute,"preview") == 0)
5502 +            {
5503 +              s=newSViv(info->image_info->preview_type);
5504 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5505 +                info->image_info->preview_type));
5506 +              SvIOK_on(s);
5507 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5508 +              continue;
5509 +            }
5510 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5511 +            attribute);
5512 +          break;
5513 +        }
5514 +        case 'Q':
5515 +        case 'q':
5516 +        {
5517 +          if (LocaleCompare(attribute,"quality") == 0)
5518 +            {
5519 +              if (info)
5520 +                s=newSViv((ssize_t) info->image_info->quality);
5521 +              if (image != (Image *) NULL)
5522 +                s=newSViv((ssize_t) image->quality);
5523 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5524 +              continue;
5525 +            }
5526 +          if (LocaleCompare(attribute,"quantum") == 0)
5527 +            {
5528 +              if (info)
5529 +                s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5530 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5531 +              continue;
5532 +            }
5533 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5534 +            attribute);
5535 +          break;
5536 +        }
5537 +        case 'R':
5538 +        case 'r':
5539 +        {
5540 +          if (LocaleCompare(attribute,"rendering-intent") == 0)
5541 +            {
5542 +              s=newSViv(image->rendering_intent);
5543 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5544 +                image->rendering_intent));
5545 +              SvIOK_on(s);
5546 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5547 +              continue;
5548 +            }
5549 +          if (LocaleCompare(attribute,"red-primary") == 0)
5550 +            {
5551 +              if (image == (Image *) NULL)
5552 +                break;
5553 +              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5554 +                image->chromaticity.red_primary.x,
5555 +                image->chromaticity.red_primary.y);
5556 +              s=newSVpv(color,0);
5557 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5558 +              continue;
5559 +            }
5560 +          if (LocaleCompare(attribute,"rows") == 0)
5561 +            {
5562 +              if (image != (Image *) NULL)
5563 +                s=newSViv((ssize_t) image->rows);
5564 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5565 +              continue;
5566 +            }
5567 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5568 +            attribute);
5569 +          break;
5570 +        }
5571 +        case 'S':
5572 +        case 's':
5573 +        {
5574 +          if (LocaleCompare(attribute,"sampling-factor") == 0)
5575 +            {
5576 +              if (info && info->image_info->sampling_factor)
5577 +                s=newSVpv(info->image_info->sampling_factor,0);
5578 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5579 +              continue;
5580 +            }
5581 +          if (LocaleCompare(attribute,"subimage") == 0)
5582 +            {
5583 +              if (info)
5584 +                s=newSViv((ssize_t) info->image_info->subimage);
5585 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5586 +              continue;
5587 +            }
5588 +          if (LocaleCompare(attribute,"subrange") == 0)
5589 +            {
5590 +              if (info)
5591 +                s=newSViv((ssize_t) info->image_info->subrange);
5592 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5593 +              continue;
5594 +            }
5595 +          if (LocaleCompare(attribute,"server") == 0)  /* same as display */
5596 +            {
5597 +              if (info && info->image_info->server_name)
5598 +                s=newSVpv(info->image_info->server_name,0);
5599 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5600 +              continue;
5601 +            }
5602 +          if (LocaleCompare(attribute,"size") == 0)
5603 +            {
5604 +              if (info && info->image_info->size)
5605 +                s=newSVpv(info->image_info->size,0);
5606 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5607 +              continue;
5608 +            }
5609 +          if (LocaleCompare(attribute,"scene") == 0)
5610 +            {
5611 +              if (image != (Image *) NULL)
5612 +                s=newSViv((ssize_t) image->scene);
5613 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5614 +              continue;
5615 +            }
5616 +          if (LocaleCompare(attribute,"scenes") == 0)
5617 +            {
5618 +              if (image != (Image *) NULL)
5619 +                s=newSViv((ssize_t) info->image_info->number_scenes);
5620 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5621 +              continue;
5622 +            }
5623 +          if (LocaleCompare(attribute,"signature") == 0)
5624 +            {
5625 +              const char
5626 +                *value;
5627 +
5628 +              if (image == (Image *) NULL)
5629 +                break;
5630 +              (void) SignatureImage(image);
5631 +              value=GetImageProperty(image,"Signature");
5632 +              if (value != (const char *) NULL)
5633 +                s=newSVpv(value,0);
5634 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5635 +              continue;
5636 +            }
5637 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5638 +            attribute);
5639 +          break;
5640 +        }
5641 +        case 'T':
5642 +        case 't':
5643 +        {
5644 +          if (LocaleCompare(attribute,"taint") == 0)
5645 +            {
5646 +              if (image != (Image *) NULL)
5647 +                s=newSViv((ssize_t) IsTaintImage(image));
5648 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5649 +              continue;
5650 +            }
5651 +          if (LocaleCompare(attribute,"tile") == 0)
5652 +            {
5653 +              if (info && info->image_info->tile)
5654 +                s=newSVpv(info->image_info->tile,0);
5655 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5656 +              continue;
5657 +            }
5658 +          if (LocaleCompare(attribute,"texture") == 0)
5659 +            {
5660 +              if (info && info->image_info->texture)
5661 +                s=newSVpv(info->image_info->texture,0);
5662 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5663 +              continue;
5664 +            }
5665 +          if (LocaleCompare(attribute,"total-ink-density") == 0)
5666 +            {
5667 +              s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5668 +              if (image != (Image *) NULL)
5669 +                s=newSVnv(GetImageTotalInkDensity(image));
5670 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5671 +              continue;
5672 +            }
5673 +          if (LocaleCompare(attribute,"transparent-color") == 0)
5674 +            {
5675 +              if (image == (Image *) NULL)
5676 +                break;
5677 +              (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5678 +                QuantumFormat "," QuantumFormat "," QuantumFormat,
5679 +                image->transparent_color.red,image->transparent_color.green,
5680 +                image->transparent_color.blue,image->transparent_color.opacity);
5681 +              s=newSVpv(color,0);
5682 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5683 +              continue;
5684 +            }
5685 +          if (LocaleCompare(attribute,"type") == 0)
5686 +            {
5687 +              if (image == (Image *) NULL)
5688 +                break;
5689 +              j=(ssize_t) GetImageType(image,&image->exception);
5690 +              s=newSViv(j);
5691 +              (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5692 +              SvIOK_on(s);
5693 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5694 +              continue;
5695 +            }
5696 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5697 +            attribute);
5698 +          break;
5699 +        }
5700 +        case 'U':
5701 +        case 'u':
5702 +        {
5703 +          if (LocaleCompare(attribute,"units") == 0)
5704 +            {
5705 +              j=info ? info->image_info->units : image ? image->units :
5706 +                UndefinedResolution;
5707 +              if (info && (info->image_info->units == UndefinedResolution))
5708 +                if (image)
5709 +                  j=image->units;
5710 +              if (j == UndefinedResolution)
5711 +                s=newSVpv("undefined units",0);
5712 +              else
5713 +                if (j == PixelsPerInchResolution)
5714 +                  s=newSVpv("pixels / inch",0);
5715 +                else
5716 +                  s=newSVpv("pixels / centimeter",0);
5717 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5718 +              continue;
5719 +            }
5720 +          if (LocaleCompare(attribute,"user-time") == 0)
5721 +            {
5722 +              if (image != (Image *) NULL)
5723 +                s=newSVnv(GetUserTime(&image->timer));
5724 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5725 +              continue;
5726 +            }
5727 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5728 +            attribute);
5729 +          break;
5730 +        }
5731 +        case 'V':
5732 +        case 'v':
5733 +        {
5734 +          if (LocaleCompare(attribute,"verbose") == 0)
5735 +            {
5736 +              if (info)
5737 +                s=newSViv((ssize_t) info->image_info->verbose);
5738 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5739 +              continue;
5740 +            }
5741 +          if (LocaleCompare(attribute,"version") == 0)
5742 +            {
5743 +              s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5744 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5745 +              continue;
5746 +            }
5747 +          if (LocaleCompare(attribute,"view") == 0)
5748 +            {
5749 +              if (info && info->image_info->view)
5750 +                s=newSVpv(info->image_info->view,0);
5751 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5752 +              continue;
5753 +            }
5754 +          if (LocaleCompare(attribute,"virtual-pixel") == 0)
5755 +            {
5756 +              if (image == (Image *) NULL)
5757 +                break;
5758 +              j=(ssize_t) GetImageVirtualPixelMethod(image);
5759 +              s=newSViv(j);
5760 +              (void) sv_setpv(s,CommandOptionToMnemonic(
5761 +                MagickVirtualPixelOptions,j));
5762 +              SvIOK_on(s);
5763 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5764 +              continue;
5765 +            }
5766 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5767 +            attribute);
5768 +          break;
5769 +        }
5770 +        case 'W':
5771 +        case 'w':
5772 +        {
5773 +          if (LocaleCompare(attribute,"white-point") == 0)
5774 +            {
5775 +              if (image == (Image *) NULL)
5776 +                break;
5777 +              (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5778 +                image->chromaticity.white_point.x,
5779 +                image->chromaticity.white_point.y);
5780 +              s=newSVpv(color,0);
5781 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5782 +              continue;
5783 +            }
5784 +          if (LocaleCompare(attribute,"width") == 0)
5785 +            {
5786 +              if (image != (Image *) NULL)
5787 +                s=newSViv((ssize_t) image->columns);
5788 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5789 +              continue;
5790 +            }
5791 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5792 +             attribute);
5793 +          break;
5794 +        }
5795 +        case 'X':
5796 +        case 'x':
5797 +        {
5798 +          if (LocaleCompare(attribute,"xmp") == 0)
5799 +            {
5800 +              if (image != (Image *) NULL)
5801 +                {
5802 +                  const StringInfo
5803 +                    *profile;
5804 +
5805 +                  profile=GetImageProfile(image,"xmp");
5806 +                  if (profile != (StringInfo *) NULL)
5807 +                    s=newSVpv((const char *) GetStringInfoDatum(profile),
5808 +                      GetStringInfoLength(profile));
5809 +                }
5810 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5811 +              continue;
5812 +            }
5813 +          if (LocaleCompare(attribute,"x-resolution") == 0)
5814 +            {
5815 +              if (image != (Image *) NULL)
5816 +                s=newSVnv(image->x_resolution);
5817 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5818 +              continue;
5819 +            }
5820 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5821 +            attribute);
5822 +          break;
5823 +        }
5824 +        case 'Y':
5825 +        case 'y':
5826 +        {
5827 +          if (LocaleCompare(attribute,"y-resolution") == 0)
5828 +            {
5829 +              if (image != (Image *) NULL)
5830 +                s=newSVnv(image->y_resolution);
5831 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5832 +              continue;
5833 +            }
5834 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5835 +            attribute);
5836 +          break;
5837 +        }
5838 +        default:
5839 +          break;
5840 +      }
5841 +      if (image == (Image *) NULL)
5842 +        ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5843 +          attribute)
5844 +      else
5845 +        {
5846 +          value=GetImageProperty(image,attribute);
5847 +          if (value != (const char *) NULL)
5848 +            {
5849 +              s=newSVpv(value,0);
5850 +              PUSHs(s ? sv_2mortal(s) : &sv_undef);
5851 +            }
5852 +          else
5853 +            if (*attribute != '%')
5854 +              ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5855 +                attribute)
5856 +            else
5857 +              {
5858 +                 char
5859 +                   *meta;
5860 +
5861 +                 meta=InterpretImageProperties(info ? info->image_info :
5862 +                   (ImageInfo *) NULL,image,attribute);
5863 +                 s=newSVpv(meta,0);
5864 +                 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5865 +                 meta=(char *) RelinquishMagickMemory(meta);
5866 +              }
5867 +        }
5868 +    }
5869 +    exception=DestroyExceptionInfo(exception);
5870 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
5871 +  }
5872 +\f
5873 +#
5874 +###############################################################################
5875 +#                                                                             #
5876 +#                                                                             #
5877 +#                                                                             #
5878 +#   G e t A u t h e n t i c P i x e l s                                       #
5879 +#                                                                             #
5880 +#                                                                             #
5881 +#                                                                             #
5882 +###############################################################################
5883 +#
5884 +#
5885 +void *
5886 +GetAuthenticPixels(ref,...)
5887 +  Image::Magick ref = NO_INIT
5888 +  ALIAS:
5889 +    getauthenticpixels = 1
5890 +    GetImagePixels = 2
5891 +    getimagepixels = 3
5892 +  CODE:
5893 +  {
5894 +    char
5895 +      *attribute;
5896 +
5897 +    ExceptionInfo
5898 +      *exception;
5899 +
5900 +    Image
5901 +      *image;
5902 +
5903 +    RectangleInfo
5904 +      region;
5905 +
5906 +    ssize_t
5907 +      i;
5908 +
5909 +    struct PackageInfo
5910 +      *info;
5911 +
5912 +    SV
5913 +      *perl_exception,
5914 +      *reference;
5915 +
5916 +    void
5917 +      *blob = NULL;
5918 +
5919 +    PERL_UNUSED_VAR(ref);
5920 +    PERL_UNUSED_VAR(ix);
5921 +    exception=AcquireExceptionInfo();
5922 +    perl_exception=newSVpv("",0);
5923 +    if (sv_isobject(ST(0)) == 0)
5924 +      {
5925 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5926 +          PackageName);
5927 +        goto PerlException;
5928 +      }
5929 +    reference=SvRV(ST(0));
5930 +
5931 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5932 +    if (image == (Image *) NULL)
5933 +      {
5934 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
5935 +          PackageName);
5936 +        goto PerlException;
5937 +      }
5938 +
5939 +    region.x=0;
5940 +    region.y=0;
5941 +    region.width=image->columns;
5942 +    region.height=1;
5943 +    if (items == 1)
5944 +      (void) ParseAbsoluteGeometry(SvPV(ST(1),na),&region);
5945 +    for (i=2; i < items; i+=2)
5946 +    {
5947 +      attribute=(char *) SvPV(ST(i-1),na);
5948 +      switch (*attribute)
5949 +      {
5950 +        case 'g':
5951 +        case 'G':
5952 +        {
5953 +          if (LocaleCompare(attribute,"geometry") == 0)
5954 +            {
5955 +              (void) ParseAbsoluteGeometry(SvPV(ST(i),na),&region);
5956 +              break;
5957 +            }
5958 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5959 +            attribute);
5960 +          break;
5961 +        }
5962 +        case 'H':
5963 +        case 'h':
5964 +        {
5965 +          if (LocaleCompare(attribute,"height") == 0)
5966 +            {
5967 +              region.height=SvIV(ST(i));
5968 +              continue;
5969 +            }
5970 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5971 +            attribute);
5972 +          break;
5973 +        }
5974 +        case 'X':
5975 +        case 'x':
5976 +        {
5977 +          if (LocaleCompare(attribute,"x") == 0)
5978 +            {
5979 +              region.x=SvIV(ST(i));
5980 +              continue;
5981 +            }
5982 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5983 +            attribute);
5984 +          break;
5985 +        }
5986 +        case 'Y':
5987 +        case 'y':
5988 +        {
5989 +          if (LocaleCompare(attribute,"y") == 0)
5990 +            {
5991 +              region.y=SvIV(ST(i));
5992 +              continue;
5993 +            }
5994 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5995 +            attribute);
5996 +          break;
5997 +        }
5998 +        case 'W':
5999 +        case 'w':
6000 +        {
6001 +          if (LocaleCompare(attribute,"width") == 0)
6002 +            {
6003 +              region.width=SvIV(ST(i));
6004 +              continue;
6005 +            }
6006 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6007 +            attribute);
6008 +          break;
6009 +        }
6010 +      }
6011 +    }
6012 +    blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
6013 +      region.height,exception);
6014 +    if (blob != (void *) NULL)
6015 +      goto PerlEnd;
6016 +
6017 +  PerlException:
6018 +    InheritPerlException(exception,perl_exception);
6019 +    exception=DestroyExceptionInfo(exception);
6020 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
6021 +
6022 +  PerlEnd:
6023 +    RETVAL = blob;
6024 +  }
6025 +  OUTPUT:
6026 +    RETVAL
6027 +\f
6028 +#
6029 +###############################################################################
6030 +#                                                                             #
6031 +#                                                                             #
6032 +#                                                                             #
6033 +#   G e t V i r t u a l P i x e l s                                           #
6034 +#                                                                             #
6035 +#                                                                             #
6036 +#                                                                             #
6037 +###############################################################################
6038 +#
6039 +#
6040 +void *
6041 +GetVirtualPixels(ref,...)
6042 +  Image::Magick ref = NO_INIT
6043 +  ALIAS:
6044 +    getvirtualpixels = 1
6045 +    AcquireImagePixels = 2
6046 +    acquireimagepixels = 3
6047 +  CODE:
6048 +  {
6049 +    char
6050 +      *attribute;
6051 +
6052 +    const void
6053 +      *blob = NULL;
6054 +
6055 +    ExceptionInfo
6056 +      *exception;
6057 +
6058 +    Image
6059 +      *image;
6060 +
6061 +    RectangleInfo
6062 +      region;
6063 +
6064 +    ssize_t
6065 +      i;
6066 +
6067 +    struct PackageInfo
6068 +      *info;
6069 +
6070 +    SV
6071 +      *perl_exception,
6072 +      *reference;
6073 +
6074 +    PERL_UNUSED_VAR(ref);
6075 +    PERL_UNUSED_VAR(ix);
6076 +    exception=AcquireExceptionInfo();
6077 +    perl_exception=newSVpv("",0);
6078 +    if (sv_isobject(ST(0)) == 0)
6079 +      {
6080 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6081 +          PackageName);
6082 +        goto PerlException;
6083 +      }
6084 +    reference=SvRV(ST(0));
6085 +
6086 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6087 +    if (image == (Image *) NULL)
6088 +      {
6089 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6090 +          PackageName);
6091 +        goto PerlException;
6092 +      }
6093 +
6094 +    region.x=0;
6095 +    region.y=0;
6096 +    region.width=image->columns;
6097 +    region.height=1;
6098 +    if (items == 1)
6099 +      (void) ParseAbsoluteGeometry(SvPV(ST(1),na),&region);
6100 +    for (i=2; i < items; i+=2)
6101 +    {
6102 +      attribute=(char *) SvPV(ST(i-1),na);
6103 +      switch (*attribute)
6104 +      {
6105 +        case 'g':
6106 +        case 'G':
6107 +        {
6108 +          if (LocaleCompare(attribute,"geometry") == 0)
6109 +            {
6110 +              (void) ParseAbsoluteGeometry(SvPV(ST(i),na),&region);
6111 +              break;
6112 +            }
6113 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6114 +            attribute);
6115 +          break;
6116 +        }
6117 +        case 'H':
6118 +        case 'h':
6119 +        {
6120 +          if (LocaleCompare(attribute,"height") == 0)
6121 +            {
6122 +              region.height=SvIV(ST(i));
6123 +              continue;
6124 +            }
6125 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6126 +            attribute);
6127 +          break;
6128 +        }
6129 +        case 'X':
6130 +        case 'x':
6131 +        {
6132 +          if (LocaleCompare(attribute,"x") == 0)
6133 +            {
6134 +              region.x=SvIV(ST(i));
6135 +              continue;
6136 +            }
6137 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6138 +            attribute);
6139 +          break;
6140 +        }
6141 +        case 'Y':
6142 +        case 'y':
6143 +        {
6144 +          if (LocaleCompare(attribute,"y") == 0)
6145 +            {
6146 +              region.y=SvIV(ST(i));
6147 +              continue;
6148 +            }
6149 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6150 +            attribute);
6151 +          break;
6152 +        }
6153 +        case 'W':
6154 +        case 'w':
6155 +        {
6156 +          if (LocaleCompare(attribute,"width") == 0)
6157 +            {
6158 +              region.width=SvIV(ST(i));
6159 +              continue;
6160 +            }
6161 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6162 +            attribute);
6163 +          break;
6164 +        }
6165 +      }
6166 +    }
6167 +    blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6168 +      region.height,exception);
6169 +    if (blob != (void *) NULL)
6170 +      goto PerlEnd;
6171 +
6172 +  PerlException:
6173 +    InheritPerlException(exception,perl_exception);
6174 +    exception=DestroyExceptionInfo(exception);
6175 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
6176 +
6177 +  PerlEnd:
6178 +    RETVAL = (void *) blob;
6179 +  }
6180 +  OUTPUT:
6181 +    RETVAL
6182 +\f
6183 +#
6184 +###############################################################################
6185 +#                                                                             #
6186 +#                                                                             #
6187 +#                                                                             #
6188 +#   G e t A u t h e n t i c I n d e x Q u e u e                               #
6189 +#                                                                             #
6190 +#                                                                             #
6191 +#                                                                             #
6192 +###############################################################################
6193 +#
6194 +#
6195 +void *
6196 +GetAuthenticIndexQueue(ref,...)
6197 +  Image::Magick ref = NO_INIT
6198 +  ALIAS:
6199 +    getauthenticindexqueue = 1
6200 +    GetIndexes = 2
6201 +    getindexes = 3
6202 +  CODE:
6203 +  {
6204 +    ExceptionInfo
6205 +      *exception;
6206 +
6207 +    Image
6208 +      *image;
6209 +
6210 +    struct PackageInfo
6211 +      *info;
6212 +
6213 +    SV
6214 +      *perl_exception,
6215 +      *reference;
6216 +
6217 +    void
6218 +      *blob = NULL;
6219 +
6220 +    PERL_UNUSED_VAR(ref);
6221 +    PERL_UNUSED_VAR(ix);
6222 +    exception=AcquireExceptionInfo();
6223 +    perl_exception=newSVpv("",0);
6224 +    if (sv_isobject(ST(0)) == 0)
6225 +      {
6226 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6227 +          PackageName);
6228 +        goto PerlException;
6229 +      }
6230 +    reference=SvRV(ST(0));
6231 +
6232 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6233 +    if (image == (Image *) NULL)
6234 +      {
6235 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6236 +          PackageName);
6237 +        goto PerlException;
6238 +      }
6239 +
6240 +    blob=(void *) GetAuthenticIndexQueue(image);
6241 +    if (blob != (void *) NULL)
6242 +      goto PerlEnd;
6243 +
6244 +  PerlException:
6245 +    InheritPerlException(exception,perl_exception);
6246 +    exception=DestroyExceptionInfo(exception);
6247 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
6248 +
6249 +  PerlEnd:
6250 +    RETVAL = blob;
6251 +  }
6252 +  OUTPUT:
6253 +    RETVAL
6254 +\f
6255 +#
6256 +###############################################################################
6257 +#                                                                             #
6258 +#                                                                             #
6259 +#                                                                             #
6260 +#   G e t V i r t u a l I n d e x Q u e u e                                   #
6261 +#                                                                             #
6262 +#                                                                             #
6263 +#                                                                             #
6264 +###############################################################################
6265 +#
6266 +#
6267 +void *
6268 +GetVirtualIndexQueue(ref,...)
6269 +  Image::Magick ref = NO_INIT
6270 +  ALIAS:
6271 +    getvirtualindexqueue = 1
6272 +  CODE:
6273 +  {
6274 +    ExceptionInfo
6275 +      *exception;
6276 +
6277 +    Image
6278 +      *image;
6279 +
6280 +    struct PackageInfo
6281 +      *info;
6282 +
6283 +    SV
6284 +      *perl_exception,
6285 +      *reference;
6286 +
6287 +    void
6288 +      *blob = NULL;
6289 +
6290 +    PERL_UNUSED_VAR(ref);
6291 +    PERL_UNUSED_VAR(ix);
6292 +    exception=AcquireExceptionInfo();
6293 +    perl_exception=newSVpv("",0);
6294 +    if (sv_isobject(ST(0)) == 0)
6295 +      {
6296 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6297 +          PackageName);
6298 +        goto PerlException;
6299 +      }
6300 +    reference=SvRV(ST(0));
6301 +
6302 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6303 +    if (image == (Image *) NULL)
6304 +      {
6305 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6306 +          PackageName);
6307 +        goto PerlException;
6308 +      }
6309 +
6310 +    blob=(void *) GetVirtualIndexQueue(image);
6311 +    if (blob != (void *) NULL)
6312 +      goto PerlEnd;
6313 +
6314 +  PerlException:
6315 +    InheritPerlException(exception,perl_exception);
6316 +    exception=DestroyExceptionInfo(exception);
6317 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
6318 +
6319 +  PerlEnd:
6320 +    RETVAL = blob;
6321 +  }
6322 +  OUTPUT:
6323 +    RETVAL
6324 +\f
6325 +#
6326 +###############################################################################
6327 +#                                                                             #
6328 +#                                                                             #
6329 +#                                                                             #
6330 +#   H i s t o g r a m                                                         #
6331 +#                                                                             #
6332 +#                                                                             #
6333 +#                                                                             #
6334 +###############################################################################
6335 +#
6336 +#
6337 +void
6338 +Histogram(ref,...)
6339 +  Image::Magick ref = NO_INIT
6340 +  ALIAS:
6341 +    HistogramImage = 1
6342 +    histogram      = 2
6343 +    histogramimage = 3
6344 +  PPCODE:
6345 +  {
6346 +    AV
6347 +      *av;
6348 +
6349 +    char
6350 +      message[MaxTextExtent];
6351 +
6352 +    ColorPacket
6353 +      *histogram;
6354 +
6355 +    ExceptionInfo
6356 +      *exception;
6357 +
6358 +    Image
6359 +      *image;
6360 +
6361 +    register ssize_t
6362 +      i;
6363 +
6364 +    ssize_t
6365 +      count;
6366 +
6367 +    struct PackageInfo
6368 +      *info;
6369 +
6370 +    SV
6371 +      *perl_exception,
6372 +      *reference;
6373 +
6374 +    size_t
6375 +      number_colors;
6376 +
6377 +    PERL_UNUSED_VAR(ref);
6378 +    PERL_UNUSED_VAR(ix);
6379 +    exception=AcquireExceptionInfo();
6380 +    perl_exception=newSVpv("",0);
6381 +    av=NULL;
6382 +    if (sv_isobject(ST(0)) == 0)
6383 +      {
6384 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6385 +          PackageName);
6386 +        goto PerlException;
6387 +      }
6388 +    reference=SvRV(ST(0));
6389 +    av=newAV();
6390 +    SvREFCNT_dec(av);
6391 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6392 +    if (image == (Image *) NULL)
6393 +      {
6394 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6395 +          PackageName);
6396 +        goto PerlException;
6397 +      }
6398 +    count=0;
6399 +    for ( ; image; image=image->next)
6400 +    {
6401 +      histogram=GetImageHistogram(image,&number_colors,&image->exception);
6402 +      if (histogram == (ColorPacket *) NULL)
6403 +        continue;
6404 +      count+=(ssize_t) number_colors;
6405 +      EXTEND(sp,6*count);
6406 +      for (i=0; i < (ssize_t) number_colors; i++)
6407 +      {
6408 +        (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6409 +          histogram[i].pixel.red);
6410 +        PUSHs(sv_2mortal(newSVpv(message,0)));
6411 +        (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6412 +          histogram[i].pixel.green);
6413 +        PUSHs(sv_2mortal(newSVpv(message,0)));
6414 +        (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6415 +          histogram[i].pixel.blue);
6416 +        PUSHs(sv_2mortal(newSVpv(message,0)));
6417 +        if (image->colorspace == CMYKColorspace)
6418 +          {
6419 +            (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6420 +              histogram[i].index);
6421 +            PUSHs(sv_2mortal(newSVpv(message,0)));
6422 +          }
6423 +        (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6424 +          histogram[i].pixel.opacity);
6425 +        PUSHs(sv_2mortal(newSVpv(message,0)));
6426 +        (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6427 +          histogram[i].count);
6428 +        PUSHs(sv_2mortal(newSVpv(message,0)));
6429 +      }
6430 +      histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
6431 +    }
6432 +
6433 +  PerlException:
6434 +    InheritPerlException(exception,perl_exception);
6435 +    exception=DestroyExceptionInfo(exception);
6436 +    SvREFCNT_dec(perl_exception);
6437 +  }
6438 +\f
6439 +#
6440 +###############################################################################
6441 +#                                                                             #
6442 +#                                                                             #
6443 +#                                                                             #
6444 +#   G e t P i x e l                                                           #
6445 +#                                                                             #
6446 +#                                                                             #
6447 +#                                                                             #
6448 +###############################################################################
6449 +#
6450 +#
6451 +void
6452 +GetPixel(ref,...)
6453 +  Image::Magick ref = NO_INIT
6454 +  ALIAS:
6455 +    getpixel = 1
6456 +    getPixel = 2
6457 +  PPCODE:
6458 +  {
6459 +    AV
6460 +      *av;
6461 +
6462 +    char
6463 +      *attribute;
6464 +
6465 +    ChannelType
6466 +      channel;
6467 +
6468 +    ExceptionInfo
6469 +      *exception;
6470 +
6471 +    Image
6472 +      *image;
6473 +
6474 +    MagickBooleanType
6475 +      normalize;
6476 +
6477 +    RectangleInfo
6478 +      region;
6479 +
6480 +    register const IndexPacket
6481 +      *indexes;
6482 +
6483 +    register const PixelPacket
6484 +      *p;
6485 +
6486 +    register ssize_t
6487 +      i;
6488 +
6489 +    ssize_t
6490 +      option;
6491 +
6492 +    struct PackageInfo
6493 +      *info;
6494 +
6495 +    SV
6496 +      *perl_exception,
6497 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
6498 +
6499 +    PERL_UNUSED_VAR(ref);
6500 +    PERL_UNUSED_VAR(ix);
6501 +    exception=AcquireExceptionInfo();
6502 +    perl_exception=newSVpv("",0);
6503 +    reference=SvRV(ST(0));
6504 +    av=(AV *) reference;
6505 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6506 +      exception);
6507 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6508 +    if (image == (Image *) NULL)
6509 +      {
6510 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6511 +          PackageName);
6512 +        goto PerlException;
6513 +      }
6514 +    channel=DefaultChannels;
6515 +    normalize=MagickTrue;
6516 +    region.x=0;
6517 +    region.y=0;
6518 +    region.width=image->columns;
6519 +    region.height=1;
6520 +    if (items == 1)
6521 +      (void) ParseAbsoluteGeometry(SvPV(ST(1),na),&region);
6522 +    for (i=2; i < items; i+=2)
6523 +    {
6524 +      attribute=(char *) SvPV(ST(i-1),na);
6525 +      switch (*attribute)
6526 +      {
6527 +        case 'C':
6528 +        case 'c':
6529 +        {
6530 +          if (LocaleCompare(attribute,"channel") == 0)
6531 +            {
6532 +              ssize_t
6533 +                option;
6534 +
6535 +              option=ParseChannelOption(SvPV(ST(i),na));
6536 +              if (option < 0)
6537 +                {
6538 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
6539 +                    SvPV(ST(i),na));
6540 +                  return;
6541 +                }
6542 +               channel=(ChannelType) option;
6543 +              break;
6544 +            }
6545 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6546 +            attribute);
6547 +          break;
6548 +        }
6549 +        case 'g':
6550 +        case 'G':
6551 +        {
6552 +          if (LocaleCompare(attribute,"geometry") == 0)
6553 +            {
6554 +              (void) ParseAbsoluteGeometry(SvPV(ST(i),na),&region);
6555 +              break;
6556 +            }
6557 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6558 +            attribute);
6559 +          break;
6560 +        }
6561 +        case 'N':
6562 +        case 'n':
6563 +        {
6564 +          if (LocaleCompare(attribute,"normalize") == 0)
6565 +            {
6566 +              option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6567 +                SvPV(ST(i),na));
6568 +              if (option < 0)
6569 +                {
6570 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
6571 +                    SvPV(ST(i),na));
6572 +                  break;
6573 +                }
6574 +             normalize=option != 0 ? MagickTrue : MagickFalse;
6575 +             break;
6576 +            }
6577 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6578 +            attribute);
6579 +          break;
6580 +        }
6581 +        case 'x':
6582 +        case 'X':
6583 +        {
6584 +          if (LocaleCompare(attribute,"x") == 0)
6585 +            {
6586 +              region.x=SvIV(ST(i));
6587 +              break;
6588 +            }
6589 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6590 +            attribute);
6591 +          break;
6592 +        }
6593 +        case 'y':
6594 +        case 'Y':
6595 +        {
6596 +          if (LocaleCompare(attribute,"y") == 0)
6597 +            {
6598 +              region.y=SvIV(ST(i));
6599 +              break;
6600 +            }
6601 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6602 +            attribute);
6603 +          break;
6604 +        }
6605 +        default:
6606 +        {
6607 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6608 +            attribute);
6609 +          break;
6610 +        }
6611 +      }
6612 +    }
6613 +    p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6614 +    if (p == (const PixelPacket *) NULL)
6615 +      PUSHs(&sv_undef);
6616 +    else
6617 +      {
6618 +        double
6619 +          scale;
6620 +
6621 +        indexes=GetVirtualIndexQueue(image);
6622 +        scale=1.0;
6623 +        if (normalize != MagickFalse)
6624 +          scale=1.0/QuantumRange;
6625 +        if ((channel & RedChannel) != 0)
6626 +          PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(p))));
6627 +        if ((channel & GreenChannel) != 0)
6628 +          PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(p))));
6629 +        if ((channel & BlueChannel) != 0)
6630 +          PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(p))));
6631 +        if (((channel & IndexChannel) != 0) &&
6632 +            (image->colorspace == CMYKColorspace))
6633 +          PUSHs(sv_2mortal(newSVnv(scale*GetPixelIndex(indexes))));
6634 +        if ((channel & OpacityChannel) != 0)
6635 +          PUSHs(sv_2mortal(newSVnv(scale*GetPixelOpacity(p))));
6636 +      }
6637 +
6638 +  PerlException:
6639 +    InheritPerlException(exception,perl_exception);
6640 +    exception=DestroyExceptionInfo(exception);
6641 +    SvREFCNT_dec(perl_exception);
6642 +  }
6643 +\f
6644 +#
6645 +###############################################################################
6646 +#                                                                             #
6647 +#                                                                             #
6648 +#                                                                             #
6649 +#   G e t P i x e l s                                                         #
6650 +#                                                                             #
6651 +#                                                                             #
6652 +#                                                                             #
6653 +###############################################################################
6654 +#
6655 +#
6656 +void
6657 +GetPixels(ref,...)
6658 +  Image::Magick ref = NO_INIT
6659 +  ALIAS:
6660 +    getpixels = 1
6661 +    getPixels = 2
6662 +  PPCODE:
6663 +  {
6664 +    AV
6665 +      *av;
6666 +
6667 +    char
6668 +      *attribute;
6669 +
6670 +    const char
6671 +      *map;
6672 +
6673 +    ExceptionInfo
6674 +      *exception;
6675 +
6676 +    Image
6677 +      *image;
6678 +
6679 +    MagickBooleanType
6680 +      normalize,
6681 +      status;
6682 +
6683 +    RectangleInfo
6684 +      region;
6685 +
6686 +    register ssize_t
6687 +      i;
6688 +
6689 +    ssize_t
6690 +      option;
6691 +
6692 +    struct PackageInfo
6693 +      *info;
6694 +
6695 +    SV
6696 +      *perl_exception,
6697 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
6698 +
6699 +    PERL_UNUSED_VAR(ref);
6700 +    PERL_UNUSED_VAR(ix);
6701 +    exception=AcquireExceptionInfo();
6702 +    perl_exception=newSVpv("",0);
6703 +    reference=SvRV(ST(0));
6704 +    av=(AV *) reference;
6705 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6706 +      exception);
6707 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6708 +    if (image == (Image *) NULL)
6709 +      {
6710 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6711 +          PackageName);
6712 +        goto PerlException;
6713 +      }
6714 +    map="RGB";
6715 +    if (image->matte != MagickFalse)
6716 +      map="RGBA";
6717 +    if (image->colorspace == CMYKColorspace)
6718 +      {
6719 +        map="CMYK";
6720 +        if (image->matte != MagickFalse)
6721 +          map="CMYKA";
6722 +      }
6723 +    normalize=MagickFalse;
6724 +    region.x=0;
6725 +    region.y=0;
6726 +    region.width=image->columns;
6727 +    region.height=1;
6728 +    if (items == 1)
6729 +      (void) ParseAbsoluteGeometry(SvPV(ST(1),na),&region);
6730 +    for (i=2; i < items; i+=2)
6731 +    {
6732 +      attribute=(char *) SvPV(ST(i-1),na);
6733 +      switch (*attribute)
6734 +      {
6735 +        case 'g':
6736 +        case 'G':
6737 +        {
6738 +          if (LocaleCompare(attribute,"geometry") == 0)
6739 +            {
6740 +              (void) ParseAbsoluteGeometry(SvPV(ST(i),na),&region);
6741 +              break;
6742 +            }
6743 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6744 +            attribute);
6745 +          break;
6746 +        }
6747 +        case 'H':
6748 +        case 'h':
6749 +        {
6750 +          if (LocaleCompare(attribute,"height") == 0)
6751 +            {
6752 +              region.height=SvIV(ST(i));
6753 +              break;
6754 +            }
6755 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6756 +            attribute);
6757 +          break;
6758 +        }
6759 +        case 'M':
6760 +        case 'm':
6761 +        {
6762 +          if (LocaleCompare(attribute,"map") == 0)
6763 +            {
6764 +              map=SvPV(ST(i),na);
6765 +              break;
6766 +            }
6767 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6768 +            attribute);
6769 +          break;
6770 +        }
6771 +        case 'N':
6772 +        case 'n':
6773 +        {
6774 +          if (LocaleCompare(attribute,"normalize") == 0)
6775 +            {
6776 +              option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6777 +                SvPV(ST(i),na));
6778 +              if (option < 0)
6779 +                {
6780 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
6781 +                    SvPV(ST(i),na));
6782 +                  break;
6783 +                }
6784 +             normalize=option != 0 ? MagickTrue : MagickFalse;
6785 +             break;
6786 +            }
6787 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6788 +            attribute);
6789 +          break;
6790 +        }
6791 +        case 'W':
6792 +        case 'w':
6793 +        {
6794 +          if (LocaleCompare(attribute,"width") == 0)
6795 +            {
6796 +              region.width=SvIV(ST(i));
6797 +              break;
6798 +            }
6799 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6800 +            attribute);
6801 +          break;
6802 +        }
6803 +        case 'x':
6804 +        case 'X':
6805 +        {
6806 +          if (LocaleCompare(attribute,"x") == 0)
6807 +            {
6808 +              region.x=SvIV(ST(i));
6809 +              break;
6810 +            }
6811 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6812 +            attribute);
6813 +          break;
6814 +        }
6815 +        case 'y':
6816 +        case 'Y':
6817 +        {
6818 +          if (LocaleCompare(attribute,"y") == 0)
6819 +            {
6820 +              region.y=SvIV(ST(i));
6821 +              break;
6822 +            }
6823 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6824 +            attribute);
6825 +          break;
6826 +        }
6827 +        default:
6828 +        {
6829 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6830 +            attribute);
6831 +          break;
6832 +        }
6833 +      }
6834 +    }
6835 +    if (normalize != MagickFalse)
6836 +      {
6837 +        float
6838 +          *pixels;
6839 +
6840 +        pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6841 +          region.height*sizeof(*pixels));
6842 +        if (pixels == (float *) NULL)
6843 +          {
6844 +            ThrowPerlException(exception,ResourceLimitError,
6845 +              "MemoryAllocationFailed",PackageName);
6846 +            goto PerlException;
6847 +          }
6848 +        status=ExportImagePixels(image,region.x,region.y,region.width,
6849 +          region.height,map,FloatPixel,pixels,exception);
6850 +        if (status == MagickFalse)
6851 +          PUSHs(&sv_undef);
6852 +        else
6853 +          {
6854 +            EXTEND(sp,strlen(map)*region.width*region.height);
6855 +            for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6856 +              PUSHs(sv_2mortal(newSVnv(pixels[i])));
6857 +          }
6858 +        pixels=(float *) RelinquishMagickMemory(pixels);
6859 +      }
6860 +    else
6861 +      {
6862 +        Quantum
6863 +          *pixels;
6864 +
6865 +        pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6866 +          region.height*sizeof(*pixels));
6867 +        if (pixels == (Quantum *) NULL)
6868 +          {
6869 +            ThrowPerlException(exception,ResourceLimitError,
6870 +              "MemoryAllocationFailed",PackageName);
6871 +            goto PerlException;
6872 +          }
6873 +        status=ExportImagePixels(image,region.x,region.y,region.width,
6874 +          region.height,map,QuantumPixel,pixels,exception);
6875 +        if (status == MagickFalse)
6876 +          PUSHs(&sv_undef);
6877 +        else
6878 +          {
6879 +            EXTEND(sp,strlen(map)*region.width*region.height);
6880 +            for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6881 +              PUSHs(sv_2mortal(newSViv(pixels[i])));
6882 +          }
6883 +        pixels=(Quantum *) RelinquishMagickMemory(pixels);
6884 +      }
6885 +
6886 +  PerlException:
6887 +    InheritPerlException(exception,perl_exception);
6888 +    exception=DestroyExceptionInfo(exception);
6889 +    SvREFCNT_dec(perl_exception);
6890 +  }
6891 +\f
6892 +#
6893 +###############################################################################
6894 +#                                                                             #
6895 +#                                                                             #
6896 +#                                                                             #
6897 +#   I m a g e T o B l o b                                                     #
6898 +#                                                                             #
6899 +#                                                                             #
6900 +#                                                                             #
6901 +###############################################################################
6902 +#
6903 +#
6904 +void
6905 +ImageToBlob(ref,...)
6906 +  Image::Magick ref = NO_INIT
6907 +  ALIAS:
6908 +    ImageToBlob  = 1
6909 +    imagetoblob  = 2
6910 +    toblob       = 3
6911 +    blob         = 4
6912 +  PPCODE:
6913 +  {
6914 +    char
6915 +      filename[MaxTextExtent];
6916 +
6917 +    ExceptionInfo
6918 +      *exception;
6919 +
6920 +    Image
6921 +      *image,
6922 +      *next;
6923 +
6924 +    register ssize_t
6925 +      i;
6926 +
6927 +    struct PackageInfo
6928 +      *info,
6929 +      *package_info;
6930 +
6931 +    size_t
6932 +      length;
6933 +
6934 +    ssize_t
6935 +      scene;
6936 +
6937 +    SV
6938 +      *perl_exception,
6939 +      *reference;
6940 +
6941 +    void
6942 +      *blob;
6943 +
6944 +    PERL_UNUSED_VAR(ref);
6945 +    PERL_UNUSED_VAR(ix);
6946 +    exception=AcquireExceptionInfo();
6947 +    perl_exception=newSVpv("",0);
6948 +    package_info=(struct PackageInfo *) NULL;
6949 +    if (sv_isobject(ST(0)) == 0)
6950 +      {
6951 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6952 +          PackageName);
6953 +        goto PerlException;
6954 +      }
6955 +    reference=SvRV(ST(0));
6956 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6957 +    if (image == (Image *) NULL)
6958 +      {
6959 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
6960 +          PackageName);
6961 +        goto PerlException;
6962 +      }
6963 +    package_info=ClonePackageInfo(info,exception);
6964 +    for (i=2; i < items; i+=2)
6965 +      SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6966 +    (void) CopyMagickString(filename,package_info->image_info->filename,
6967 +      MaxTextExtent);
6968 +    scene=0;
6969 +    for (next=image; next; next=next->next)
6970 +    {
6971 +      (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6972 +      next->scene=scene++;
6973 +    }
6974 +    SetImageInfo(package_info->image_info,(unsigned int)
6975 +      GetImageListLength(image),&image->exception);
6976 +    EXTEND(sp,(ssize_t) GetImageListLength(image));
6977 +    for ( ; image; image=image->next)
6978 +    {
6979 +      length=0;
6980 +      blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6981 +      if (blob != (char *) NULL)
6982 +        {
6983 +          PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6984 +          blob=(unsigned char *) RelinquishMagickMemory(blob);
6985 +        }
6986 +      if (package_info->image_info->adjoin)
6987 +        break;
6988 +    }
6989 +
6990 +  PerlException:
6991 +    if (package_info != (struct PackageInfo *) NULL)
6992 +      DestroyPackageInfo(package_info);
6993 +    InheritPerlException(exception,perl_exception);
6994 +    exception=DestroyExceptionInfo(exception);
6995 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
6996 +  }
6997 +\f
6998 +#
6999 +###############################################################################
7000 +#                                                                             #
7001 +#                                                                             #
7002 +#                                                                             #
7003 +#   L a y e r s                                                               #
7004 +#                                                                             #
7005 +#                                                                             #
7006 +#                                                                             #
7007 +###############################################################################
7008 +#
7009 +#
7010 +void
7011 +Layers(ref,...)
7012 +  Image::Magick ref = NO_INIT
7013 +  ALIAS:
7014 +    Layers                = 1
7015 +    layers           = 2
7016 +    OptimizeImageLayers   = 3
7017 +    optimizelayers        = 4
7018 +    optimizeimagelayers   = 5
7019 +  PPCODE:
7020 +  {
7021 +    AV
7022 +      *av;
7023 +
7024 +    char
7025 +      *attribute;
7026 +
7027 +    CompositeOperator
7028 +      compose;
7029 +
7030 +    ExceptionInfo
7031 +      *exception;
7032 +
7033 +    HV
7034 +      *hv;
7035 +
7036 +    Image
7037 +      *image,
7038 +      *layers;
7039 +
7040 +    ImageLayerMethod
7041 +      method;
7042 +
7043 +    register ssize_t
7044 +      i;
7045 +
7046 +    ssize_t
7047 +      option,
7048 +      sp;
7049 +
7050 +    struct PackageInfo
7051 +      *info;
7052 +
7053 +    SV
7054 +      *av_reference,
7055 +      *perl_exception,
7056 +      *reference,
7057 +      *rv,
7058 +      *sv;
7059 +
7060 +    PERL_UNUSED_VAR(ref);
7061 +    PERL_UNUSED_VAR(ix);
7062 +    exception=AcquireExceptionInfo();
7063 +    perl_exception=newSVpv("",0);
7064 +    sv=NULL;
7065 +    if (sv_isobject(ST(0)) == 0)
7066 +      {
7067 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7068 +          PackageName);
7069 +        goto PerlException;
7070 +      }
7071 +    reference=SvRV(ST(0));
7072 +    hv=SvSTASH(reference);
7073 +    av=newAV();
7074 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7075 +    SvREFCNT_dec(av);
7076 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7077 +    if (image == (Image *) NULL)
7078 +      {
7079 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
7080 +          PackageName);
7081 +        goto PerlException;
7082 +      }
7083 +    compose=image->compose;
7084 +    method=OptimizeLayer;
7085 +    for (i=2; i < items; i+=2)
7086 +    {
7087 +      attribute=(char *) SvPV(ST(i-1),na);
7088 +      switch (*attribute)
7089 +      {
7090 +        case 'C':
7091 +        case 'c':
7092 +        {
7093 +          if (LocaleCompare(attribute,"compose") == 0)
7094 +            {
7095 +              sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7096 +                MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7097 +              if (sp < 0)
7098 +                {
7099 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
7100 +                    SvPV(ST(i),na));
7101 +                  break;
7102 +                }
7103 +              compose=(CompositeOperator) sp;
7104 +              break;
7105 +            }
7106 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7107 +            attribute);
7108 +          break;
7109 +        }
7110 +        case 'M':
7111 +        case 'm':
7112 +        {
7113 +          if (LocaleCompare(attribute,"method") == 0)
7114 +            {
7115 +              option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7116 +                SvPV(ST(i),na));
7117 +              if (option < 0)
7118 +                {
7119 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
7120 +                    SvPV(ST(i),na));
7121 +                  break;
7122 +                }
7123 +              method=(ImageLayerMethod) option;
7124 +              break;
7125 +            }
7126 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7127 +            attribute);
7128 +          break;
7129 +        }
7130 +        default:
7131 +        {
7132 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7133 +            attribute);
7134 +          break;
7135 +        }
7136 +      }
7137 +    }
7138 +    layers=(Image *) NULL;
7139 +    switch (method)
7140 +    {
7141 +      case CompareAnyLayer:
7142 +      case CompareClearLayer:
7143 +      case CompareOverlayLayer:
7144 +      default:
7145 +      {
7146 +        layers=CompareImageLayers(image,method,exception);
7147 +        break;
7148 +      }
7149 +      case MergeLayer:
7150 +      case FlattenLayer:
7151 +      case MosaicLayer:
7152 +      {
7153 +        layers=MergeImageLayers(image,method,exception);
7154 +        break;
7155 +      }
7156 +      case DisposeLayer:
7157 +      {
7158 +        layers=DisposeImages(image,exception);
7159 +        break;
7160 +      }
7161 +      case OptimizeImageLayer:
7162 +      {
7163 +        layers=OptimizeImageLayers(image,exception);
7164 +        break;
7165 +      }
7166 +      case OptimizePlusLayer:
7167 +      {
7168 +        layers=OptimizePlusImageLayers(image,exception);
7169 +        break;
7170 +      }
7171 +      case OptimizeTransLayer:
7172 +      {
7173 +        OptimizeImageTransparency(image,exception);
7174 +        InheritException(&(image->exception),exception);
7175 +        break;
7176 +      }
7177 +      case RemoveDupsLayer:
7178 +      {
7179 +        RemoveDuplicateLayers(&image,exception);
7180 +        InheritException(&(image->exception),exception);
7181 +        break;
7182 +      }
7183 +      case RemoveZeroLayer:
7184 +      {
7185 +        RemoveZeroDelayLayers(&image,exception);
7186 +        InheritException(&(image->exception),exception);
7187 +        break;
7188 +      }
7189 +      case OptimizeLayer:
7190 +      {
7191 +        QuantizeInfo
7192 +          *quantize_info;
7193 +
7194 +        /*
7195 +          General Purpose, GIF Animation Optimizer.
7196 +        */
7197 +        layers=CoalesceImages(image,exception);
7198 +        if (layers == (Image *) NULL)
7199 +          break;
7200 +        InheritException(&(layers->exception),exception);
7201 +        image=layers;
7202 +        layers=OptimizeImageLayers(image,exception);
7203 +        if (layers == (Image *) NULL)
7204 +          break;
7205 +        InheritException(&(layers->exception),exception);
7206 +        image=DestroyImageList(image);
7207 +        image=layers;
7208 +        layers=(Image *) NULL;
7209 +        OptimizeImageTransparency(image,exception);
7210 +        InheritException(&(image->exception),exception);
7211 +        quantize_info=AcquireQuantizeInfo(info->image_info);
7212 +        (void) RemapImages(quantize_info,image,(Image *) NULL);
7213 +        quantize_info=DestroyQuantizeInfo(quantize_info);
7214 +        break;
7215 +      }
7216 +      case CompositeLayer:
7217 +      {
7218 +        Image
7219 +          *source;
7220 +
7221 +        RectangleInfo
7222 +          geometry;
7223 +
7224 +        /*
7225 +          Split image sequence at the first 'NULL:' image.
7226 +        */
7227 +        source=image;
7228 +        while (source != (Image *) NULL)
7229 +        {
7230 +          source=GetNextImageInList(source);
7231 +          if ((source != (Image *) NULL) &&
7232 +              (LocaleCompare(source->magick,"NULL") == 0))
7233 +            break;
7234 +        }
7235 +        if (source != (Image *) NULL)
7236 +          {
7237 +            if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7238 +                (GetNextImageInList(source) == (Image *) NULL))
7239 +              source=(Image *) NULL;
7240 +            else
7241 +              {
7242 +                /*
7243 +                  Separate the two lists, junk the null: image.
7244 +                */
7245 +                source=SplitImageList(source->previous);
7246 +                DeleteImageFromList(&source);
7247 +              }
7248 +          }
7249 +        if (source == (Image *) NULL)
7250 +          {
7251 +            (void) ThrowMagickException(exception,GetMagickModule(),
7252 +              OptionError,"MissingNullSeparator","layers Composite");
7253 +            break;
7254 +          }
7255 +        /*
7256 +          Adjust offset with gravity and virtual canvas.
7257 +        */
7258 +        SetGeometry(image,&geometry);
7259 +        (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7260 +        geometry.width=source->page.width != 0 ? source->page.width :
7261 +          source->columns;
7262 +        geometry.height=source->page.height != 0 ? source->page.height :
7263 +          source->rows;
7264 +        GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7265 +          image->columns,image->page.height != 0 ? image->page.height :
7266 +          image->rows,image->gravity,&geometry);
7267 +        CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7268 +        source=DestroyImageList(source);
7269 +        InheritException(&(image->exception),exception);
7270 +        break;
7271 +      }
7272 +    }
7273 +    if (layers == (Image *) NULL)
7274 +      image=CloneImage(image,0,0,MagickTrue,exception);
7275 +    else
7276 +      {
7277 +        InheritException(&(layers->exception),exception);
7278 +        image=layers;
7279 +      }
7280 +    if (image == (Image *) NULL)
7281 +      goto PerlException;
7282 +    for ( ; image; image=image->next)
7283 +    {
7284 +      AddImageToRegistry(sv,image);
7285 +      rv=newRV(sv);
7286 +      av_push(av,sv_bless(rv,hv));
7287 +      SvREFCNT_dec(sv);
7288 +    }
7289 +    exception=DestroyExceptionInfo(exception);
7290 +    ST(0)=av_reference;
7291 +    SvREFCNT_dec(perl_exception);
7292 +    XSRETURN(1);
7293 +
7294 +  PerlException:
7295 +    InheritPerlException(exception,perl_exception);
7296 +    exception=DestroyExceptionInfo(exception);
7297 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7298 +    SvPOK_on(perl_exception);
7299 +    ST(0)=sv_2mortal(perl_exception);
7300 +    XSRETURN(1);
7301 +  }
7302 +\f
7303 +#
7304 +###############################################################################
7305 +#                                                                             #
7306 +#                                                                             #
7307 +#                                                                             #
7308 +#   M a g i c k T o M i m e                                                   #
7309 +#                                                                             #
7310 +#                                                                             #
7311 +#                                                                             #
7312 +###############################################################################
7313 +#
7314 +#
7315 +SV *
7316 +MagickToMime(ref,name)
7317 +  Image::Magick ref = NO_INIT
7318 +  char *name
7319 +  ALIAS:
7320 +    magicktomime = 1
7321 +  CODE:
7322 +  {
7323 +    char
7324 +      *mime;
7325 +
7326 +    PERL_UNUSED_VAR(ref);
7327 +    PERL_UNUSED_VAR(ix);
7328 +    mime=MagickToMime(name);
7329 +    RETVAL=newSVpv(mime,0);
7330 +    mime=(char *) RelinquishMagickMemory(mime);
7331 +  }
7332 +  OUTPUT:
7333 +    RETVAL
7334 +\f
7335 +#
7336 +###############################################################################
7337 +#                                                                             #
7338 +#                                                                             #
7339 +#                                                                             #
7340 +#   M o g r i f y                                                             #
7341 +#                                                                             #
7342 +#                                                                             #
7343 +#                                                                             #
7344 +###############################################################################
7345 +#
7346 +#
7347 +void
7348 +Mogrify(ref,...)
7349 +  Image::Magick ref = NO_INIT
7350 +  ALIAS:
7351 +    Comment            =   1
7352 +    CommentImage       =   2
7353 +    Label              =   3
7354 +    LabelImage         =   4
7355 +    AddNoise           =   5
7356 +    AddNoiseImage      =   6
7357 +    Colorize           =   7
7358 +    ColorizeImage      =   8
7359 +    Border             =   9
7360 +    BorderImage        =  10
7361 +    Blur               =  11
7362 +    BlurImage          =  12
7363 +    Chop               =  13
7364 +    ChopImage          =  14
7365 +    Crop               =  15
7366 +    CropImage          =  16
7367 +    Despeckle          =  17
7368 +    DespeckleImage     =  18
7369 +    Edge               =  19
7370 +    EdgeImage          =  20
7371 +    Emboss             =  21
7372 +    EmbossImage        =  22
7373 +    Enhance            =  23
7374 +    EnhanceImage       =  24
7375 +    Flip               =  25
7376 +    FlipImage          =  26
7377 +    Flop               =  27
7378 +    FlopImage          =  28
7379 +    Frame              =  29
7380 +    FrameImage         =  30
7381 +    Implode            =  31
7382 +    ImplodeImage       =  32
7383 +    Magnify            =  33
7384 +    MagnifyImage       =  34
7385 +    MedianFilter       =  35
7386 +    MedianFilterImage  =  36
7387 +    Minify             =  37
7388 +    MinifyImage        =  38
7389 +    OilPaint           =  39
7390 +    OilPaintImage      =  40
7391 +    ReduceNoise        =  41
7392 +    ReduceNoiseImage   =  42
7393 +    Roll               =  43
7394 +    RollImage          =  44
7395 +    Rotate             =  45
7396 +    RotateImage        =  46
7397 +    Sample             =  47
7398 +    SampleImage        =  48
7399 +    Scale              =  49
7400 +    ScaleImage         =  50
7401 +    Shade              =  51
7402 +    ShadeImage         =  52
7403 +    Sharpen            =  53
7404 +    SharpenImage       =  54
7405 +    Shear              =  55
7406 +    ShearImage         =  56
7407 +    Spread             =  57
7408 +    SpreadImage        =  58
7409 +    Swirl              =  59
7410 +    SwirlImage         =  60
7411 +    Resize             =  61
7412 +    ResizeImage        =  62
7413 +    Zoom               =  63
7414 +    ZoomImage          =  64
7415 +    Annotate           =  65
7416 +    AnnotateImage      =  66
7417 +    ColorFloodfill     =  67
7418 +    ColorFloodfillImage=  68
7419 +    Composite          =  69
7420 +    CompositeImage     =  70
7421 +    Contrast           =  71
7422 +    ContrastImage      =  72
7423 +    CycleColormap      =  73
7424 +    CycleColormapImage =  74
7425 +    Draw               =  75
7426 +    DrawImage          =  76
7427 +    Equalize           =  77
7428 +    EqualizeImage      =  78
7429 +    Gamma              =  79
7430 +    GammaImage         =  80
7431 +    Map                =  81
7432 +    MapImage           =  82
7433 +    MatteFloodfill     =  83
7434 +    MatteFloodfillImage=  84
7435 +    Modulate           =  85
7436 +    ModulateImage      =  86
7437 +    Negate             =  87
7438 +    NegateImage        =  88
7439 +    Normalize          =  89
7440 +    NormalizeImage     =  90
7441 +    NumberColors       =  91
7442 +    NumberColorsImage  =  92
7443 +    Opaque             =  93
7444 +    OpaqueImage        =  94
7445 +    Quantize           =  95
7446 +    QuantizeImage      =  96
7447 +    Raise              =  97
7448 +    RaiseImage         =  98
7449 +    Segment            =  99
7450 +    SegmentImage       = 100
7451 +    Signature          = 101
7452 +    SignatureImage     = 102
7453 +    Solarize           = 103
7454 +    SolarizeImage      = 104
7455 +    Sync               = 105
7456 +    SyncImage          = 106
7457 +    Texture            = 107
7458 +    TextureImage       = 108
7459 +    Evaluate           = 109
7460 +    EvaluateImage      = 110
7461 +    Transparent        = 111
7462 +    TransparentImage   = 112
7463 +    Threshold          = 113
7464 +    ThresholdImage     = 114
7465 +    Charcoal           = 115
7466 +    CharcoalImage      = 116
7467 +    Trim               = 117
7468 +    TrimImage          = 118
7469 +    Wave               = 119
7470 +    WaveImage          = 120
7471 +    Separate           = 121
7472 +    SeparateImage      = 122
7473 +    Stereo             = 125
7474 +    StereoImage        = 126
7475 +    Stegano            = 127
7476 +    SteganoImage       = 128
7477 +    Deconstruct        = 129
7478 +    DeconstructImage   = 130
7479 +    GaussianBlur       = 131
7480 +    GaussianBlurImage  = 132
7481 +    Convolve           = 133
7482 +    ConvolveImage      = 134
7483 +    Profile            = 135
7484 +    ProfileImage       = 136
7485 +    UnsharpMask        = 137
7486 +    UnsharpMaskImage   = 138
7487 +    MotionBlur         = 139
7488 +    MotionBlurImage    = 140
7489 +    OrderedDither      = 141
7490 +    OrderedDitherImage = 142
7491 +    Shave              = 143
7492 +    ShaveImage         = 144
7493 +    Level              = 145
7494 +    LevelImage         = 146
7495 +    Clip               = 147
7496 +    ClipImage          = 148
7497 +    AffineTransform    = 149
7498 +    AffineTransformImage = 150
7499 +    Difference         = 151
7500 +    DifferenceImage    = 152
7501 +    AdaptiveThreshold  = 153
7502 +    AdaptiveThresholdImage = 154
7503 +    Resample           = 155
7504 +    ResampleImage      = 156
7505 +    Describe           = 157
7506 +    DescribeImage      = 158
7507 +    BlackThreshold     = 159
7508 +    BlackThresholdImage= 160
7509 +    WhiteThreshold     = 161
7510 +    WhiteThresholdImage= 162
7511 +    RotationalBlur     = 163
7512 +    RotationalBlurImage= 164
7513 +    Thumbnail          = 165
7514 +    ThumbnailImage     = 166
7515 +    Strip              = 167
7516 +    StripImage         = 168
7517 +    Tint               = 169
7518 +    TintImage          = 170
7519 +    Channel            = 171
7520 +    ChannelImage       = 172
7521 +    Splice             = 173
7522 +    SpliceImage        = 174
7523 +    Posterize          = 175
7524 +    PosterizeImage     = 176
7525 +    Shadow             = 177
7526 +    ShadowImage        = 178
7527 +    Identify           = 179
7528 +    IdentifyImage      = 180
7529 +    SepiaTone          = 181
7530 +    SepiaToneImage     = 182
7531 +    SigmoidalContrast  = 183
7532 +    SigmoidalContrastImage = 184
7533 +    Extent             = 185
7534 +    ExtentImage        = 186
7535 +    Vignette           = 187
7536 +    VignetteImage      = 188
7537 +    ContrastStretch    = 189
7538 +    ContrastStretchImage = 190
7539 +    Sans0              = 191
7540 +    Sans0Image         = 192
7541 +    Sans1              = 193
7542 +    Sans1Image         = 194
7543 +    AdaptiveSharpen    = 195
7544 +    AdaptiveSharpenImage = 196
7545 +    Transpose          = 197
7546 +    TransposeImage     = 198
7547 +    Transverse         = 199
7548 +    TransverseImage    = 200
7549 +    AutoOrient         = 201
7550 +    AutoOrientImage    = 202
7551 +    AdaptiveBlur       = 203
7552 +    AdaptiveBlurImage  = 204
7553 +    Sketch             = 205
7554 +    SketchImage        = 206
7555 +    UniqueColors       = 207
7556 +    UniqueColorsImage  = 208
7557 +    AdaptiveResize     = 209
7558 +    AdaptiveResizeImage= 210
7559 +    ClipMask           = 211
7560 +    ClipMaskImage      = 212
7561 +    LinearStretch      = 213
7562 +    LinearStretchImage = 214
7563 +    RecolorImage       = 215
7564 +    Recolor            = 216
7565 +    Mask               = 217
7566 +    MaskImage          = 218
7567 +    Polaroid           = 219
7568 +    PolaroidImage      = 220
7569 +    FloodfillPaint     = 221
7570 +    FloodfillPaintImage= 222
7571 +    Distort            = 223
7572 +    DistortImage       = 224
7573 +    Clut               = 225
7574 +    ClutImage          = 226
7575 +    LiquidRescale      = 227
7576 +    LiquidRescaleImage = 228
7577 +    Encipher           = 229
7578 +    EncipherImage      = 230
7579 +    Decipher           = 231
7580 +    DecipherImage      = 232
7581 +    Deskew             = 233
7582 +    DeskewImage        = 234
7583 +    Remap              = 235
7584 +    RemapImage         = 236
7585 +    SparseColor        = 237
7586 +    SparseColorImage   = 238
7587 +    Function           = 239
7588 +    FunctionImage      = 240
7589 +    SelectiveBlur      = 241
7590 +    SelectiveBlurImage = 242
7591 +    HaldClut           = 243
7592 +    HaldClutImage      = 244
7593 +    BlueShift          = 245
7594 +    BlueShiftImage     = 246
7595 +    ForwardFourierTransform  = 247
7596 +    ForwardFourierTransformImage = 248
7597 +    InverseFourierTransform = 249
7598 +    InverseFourierTransformImage = 250
7599 +    ColorDecisionList  = 251
7600 +    ColorDecisionListImage = 252
7601 +    AutoGamma          = 253
7602 +    AutoGammaImage     = 254
7603 +    AutoLevel          = 255
7604 +    AutoLevelImage     = 256
7605 +    LevelColors        = 257
7606 +    LevelColorsImage   = 258
7607 +    Clamp              = 259
7608 +    ClampImage         = 260
7609 +    Filter             = 261
7610 +    FilterImage        = 262
7611 +    BrightnessContrast = 263
7612 +    BrightnessContrastImage = 264
7613 +    Morphology         = 265
7614 +    MorphologyImage    = 266
7615 +    ColorMatrix        = 267
7616 +    ColorMatrixImage   = 268
7617 +    Color              = 269
7618 +    ColorImage         = 270
7619 +    Mode               = 271
7620 +    ModeImage          = 272
7621 +    Statistic          = 273
7622 +    StatisticImage     = 274
7623 +    Perceptible        = 275
7624 +    PerceptibleImage   = 276
7625 +    Poly               = 277
7626 +    PolyImage          = 278
7627 +    Grayscale          = 279
7628 +    GrayscaleImage     = 280
7629 +    CannyEdge          = 281
7630 +    CannyEdgeImage     = 282
7631 +    HoughLine          = 283
7632 +    HoughLineImage     = 284
7633 +    MeanShift          = 285
7634 +    MeanShiftImage     = 286
7635 +    Kuwahara           = 287
7636 +    KuwaharaImage      = 288
7637 +    ConnectedComponent = 289
7638 +    ConnectedComponentImage = 290
7639 +    CopyPixels         = 291
7640 +    CopyPixelsImage    = 292
7641 +    WaveletDenoise     = 293
7642 +    WaveletDenoiseImage= 294
7643 +    MogrifyRegion      = 666
7644 +  PPCODE:
7645 +  {
7646 +    AffineMatrix
7647 +      affine,
7648 +      current;
7649 +
7650 +    char
7651 +      attribute_flag[MaxArguments],
7652 +      message[MaxTextExtent];
7653 +
7654 +    ChannelType
7655 +      channel;
7656 +
7657 +    CompositeOperator
7658 +      compose;
7659 +
7660 +    const char
7661 +      *attribute,
7662 +      *value;
7663 +
7664 +    double
7665 +      angle;
7666 +
7667 +    ExceptionInfo
7668 +      *exception;
7669 +
7670 +    GeometryInfo
7671 +      geometry_info;
7672 +
7673 +    Image
7674 +      *image,
7675 +      *next,
7676 +      *region_image;
7677 +
7678 +    MagickBooleanType
7679 +      status;
7680 +
7681 +    MagickStatusType
7682 +      flags;
7683 +
7684 +    PixelPacket
7685 +      fill_color;
7686 +
7687 +    RectangleInfo
7688 +      geometry,
7689 +      region_info;
7690 +
7691 +    register ssize_t
7692 +      i;
7693 +
7694 +    ssize_t
7695 +      base,
7696 +      j,
7697 +      number_images;
7698 +
7699 +    struct Methods
7700 +      *rp;
7701 +
7702 +    struct PackageInfo
7703 +      *info;
7704 +
7705 +    SV
7706 +      *perl_exception,
7707 +      **pv,
7708 +      *reference,
7709 +      **reference_vector;
7710 +
7711 +    struct ArgumentList
7712 +      argument_list[MaxArguments];
7713 +
7714 +    PERL_UNUSED_VAR(ref);
7715 +    PERL_UNUSED_VAR(ix);
7716 +    exception=AcquireExceptionInfo();
7717 +    perl_exception=newSVpv("",0);
7718 +    reference_vector=NULL;
7719 +    region_image=NULL;
7720 +    number_images=0;
7721 +    base=2;
7722 +    if (sv_isobject(ST(0)) == 0)
7723 +      {
7724 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7725 +          PackageName);
7726 +        goto PerlException;
7727 +      }
7728 +    reference=SvRV(ST(0));
7729 +    region_info.width=0;
7730 +    region_info.height=0;
7731 +    region_info.x=0;
7732 +    region_info.y=0;
7733 +    region_image=(Image *) NULL;
7734 +    image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7735 +    if (ix && (ix != 666))
7736 +      {
7737 +        /*
7738 +          Called as Method(...)
7739 +        */
7740 +        ix=(ix+1)/2;
7741 +        rp=(&Methods[ix-1]);
7742 +        attribute=rp->name;
7743 +      }
7744 +    else
7745 +      {
7746 +        /*
7747 +          Called as Mogrify("Method",...)
7748 +        */
7749 +        attribute=(char *) SvPV(ST(1),na);
7750 +        if (ix)
7751 +          {
7752 +            flags=ParseGravityGeometry(image,attribute,&region_info,exception);
7753 +            attribute=(char *) SvPV(ST(2),na);
7754 +            base++;
7755 +          }
7756 +        for (rp=Methods; ; rp++)
7757 +        {
7758 +          if (rp >= EndOf(Methods))
7759 +            {
7760 +              ThrowPerlException(exception,OptionError,
7761 +                "UnrecognizedPerlMagickMethod",attribute);
7762 +              goto PerlException;
7763 +            }
7764 +          if (strEQcase(attribute,rp->name))
7765 +            break;
7766 +        }
7767 +        ix=rp-Methods+1;
7768 +        base++;
7769 +      }
7770 +    if (image == (Image *) NULL)
7771 +      {
7772 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7773 +        goto PerlException;
7774 +      }
7775 +    Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7776 +    Zero(&attribute_flag,NumberOf(attribute_flag),char);
7777 +    for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7778 +    {
7779 +      Arguments
7780 +        *pp,
7781 +        *qq;
7782 +
7783 +      ssize_t
7784 +        ssize_test;
7785 +
7786 +      struct ArgumentList
7787 +        *al;
7788 +
7789 +      SV
7790 +        *sv;
7791 +
7792 +      sv=NULL;
7793 +      ssize_test=0;
7794 +      pp=(Arguments *) NULL;
7795 +      qq=rp->arguments;
7796 +      if (i == items)
7797 +        {
7798 +          pp=rp->arguments,
7799 +          sv=ST(i-1);
7800 +        }
7801 +      else
7802 +        for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7803 +        {
7804 +          if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7805 +            break;
7806 +          if (strEQcase(attribute,qq->method) > ssize_test)
7807 +            {
7808 +              pp=qq;
7809 +              ssize_test=strEQcase(attribute,qq->method);
7810 +            }
7811 +        }
7812 +      if (pp == (Arguments *) NULL)
7813 +        {
7814 +          ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7815 +            attribute);
7816 +          goto continue_outer_loop;
7817 +        }
7818 +      al=(&argument_list[pp-rp->arguments]);
7819 +      switch (pp->type)
7820 +      {
7821 +        case ArrayReference:
7822 +        {
7823 +          if (SvTYPE(sv) != SVt_RV)
7824 +            {
7825 +              (void) FormatLocaleString(message,MaxTextExtent,
7826 +                "invalid %.60s value",pp->method);
7827 +              ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7828 +              goto continue_outer_loop;
7829 +            }
7830 +          al->array_reference=SvRV(sv);
7831 +          break;
7832 +        }
7833 +        case RealReference:
7834 +        {
7835 +          al->real_reference=SvNV(sv);
7836 +          break;
7837 +        }
7838 +        case FileReference:
7839 +        {
7840 +          al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7841 +          break;
7842 +        }
7843 +        case ImageReference:
7844 +        {
7845 +          if (!sv_isobject(sv) ||
7846 +              !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7847 +                (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7848 +            {
7849 +              ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7850 +                PackageName);
7851 +              goto PerlException;
7852 +            }
7853 +          break;
7854 +        }
7855 +        case IntegerReference:
7856 +        {
7857 +          al->integer_reference=SvIV(sv);
7858 +          break;
7859 +        }
7860 +        case StringReference:
7861 +        {
7862 +          al->string_reference=(char *) SvPV(sv,al->length);
7863 +          if (sv_isobject(sv))
7864 +            al->image_reference=SetupList(aTHX_ SvRV(sv),
7865 +              (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7866 +          break;
7867 +        }
7868 +        default:
7869 +        {
7870 +          /*
7871 +            Is a string; look up name.
7872 +          */
7873 +          if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7874 +            {
7875 +              al->string_reference=(char *) SvPV(sv,al->length);
7876 +              al->integer_reference=(-1);
7877 +              break;
7878 +            }
7879 +          al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7880 +            MagickFalse,SvPV(sv,na));
7881 +          if (pp->type == MagickChannelOptions)
7882 +            al->integer_reference=ParseChannelOption(SvPV(sv,na));
7883 +          if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7884 +            {
7885 +              (void) FormatLocaleString(message,MaxTextExtent,
7886 +                "invalid %.60s value",pp->method);
7887 +              ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7888 +              goto continue_outer_loop;
7889 +            }
7890 +          break;
7891 +        }
7892 +      }
7893 +      attribute_flag[pp-rp->arguments]++;
7894 +      continue_outer_loop: ;
7895 +    }
7896 +    (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7897 +    pv=reference_vector;
7898 +    SetGeometryInfo(&geometry_info);
7899 +    channel=DefaultChannels;
7900 +    for (next=image; next; next=next->next)
7901 +    {
7902 +      image=next;
7903 +      SetGeometry(image,&geometry);
7904 +      if ((region_info.width*region_info.height) != 0)
7905 +        {
7906 +          region_image=image;
7907 +          image=CropImage(image,&region_info,exception);
7908 +        }
7909 +      switch (ix)
7910 +      {
7911 +        default:
7912 +        {
7913 +          (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7914 +          ThrowPerlException(exception,OptionError,
7915 +            "UnrecognizedPerlMagickMethod",message);
7916 +          goto PerlException;
7917 +        }
7918 +        case 1:  /* Comment */
7919 +        {
7920 +          if (attribute_flag[0] == 0)
7921 +            argument_list[0].string_reference=(char *) NULL;
7922 +          (void) SetImageProperty(image,"comment",InterpretImageProperties(
7923 +            info ? info->image_info : (ImageInfo *) NULL,image,
7924 +            argument_list[0].string_reference));
7925 +          break;
7926 +        }
7927 +        case 2:  /* Label */
7928 +        {
7929 +          if (attribute_flag[0] == 0)
7930 +            argument_list[0].string_reference=(char *) NULL;
7931 +          (void) SetImageProperty(image,"label",InterpretImageProperties(
7932 +            info ? info->image_info : (ImageInfo *) NULL,image,
7933 +            argument_list[0].string_reference));
7934 +          break;
7935 +        }
7936 +        case 3:  /* AddNoise */
7937 +        {
7938 +          if (attribute_flag[0] == 0)
7939 +            argument_list[0].integer_reference=UniformNoise;
7940 +          if (attribute_flag[1] != 0)
7941 +            channel=(ChannelType) argument_list[1].integer_reference;
7942 +          image=AddNoiseImageChannel(image,channel,(NoiseType)
7943 +            argument_list[0].integer_reference,exception);
7944 +          break;
7945 +        }
7946 +        case 4:  /* Colorize */
7947 +        {
7948 +          PixelPacket
7949 +            target;
7950 +
7951 +          (void) GetOneVirtualPixel(image,0,0,&target,exception);
7952 +          if (attribute_flag[0] != 0)
7953 +            (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7954 +              exception);
7955 +          if (attribute_flag[1] == 0)
7956 +            argument_list[1].string_reference="100%";
7957 +          image=ColorizeImage(image,argument_list[1].string_reference,target,
7958 +            exception);
7959 +          break;
7960 +        }
7961 +        case 5:  /* Border */
7962 +        {
7963 +          geometry.width=0;
7964 +          geometry.height=0;
7965 +          if (attribute_flag[0] != 0)
7966 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
7967 +              &geometry,exception);
7968 +          if (attribute_flag[1] != 0)
7969 +            geometry.width=argument_list[1].integer_reference;
7970 +          if (attribute_flag[2] != 0)
7971 +            geometry.height=argument_list[2].integer_reference;
7972 +          if (attribute_flag[3] != 0)
7973 +            QueryColorDatabase(argument_list[3].string_reference,
7974 +              &image->border_color,exception);
7975 +          if (attribute_flag[4] != 0)
7976 +            QueryColorDatabase(argument_list[4].string_reference,
7977 +              &image->border_color,exception);
7978 +          if (attribute_flag[5] != 0)
7979 +            QueryColorDatabase(argument_list[5].string_reference,
7980 +              &image->border_color,exception);
7981 +          if (attribute_flag[6] != 0)
7982 +            image->compose=(CompositeOperator)
7983 +              argument_list[6].integer_reference;
7984 +          image=BorderImage(image,&geometry,exception);
7985 +          break;
7986 +        }
7987 +        case 6:  /* Blur */
7988 +        {
7989 +          if (attribute_flag[0] != 0)
7990 +            {
7991 +              flags=ParseGeometry(argument_list[0].string_reference,
7992 +                &geometry_info);
7993 +              if ((flags & SigmaValue) == 0)
7994 +                geometry_info.sigma=1.0;
7995 +            }
7996 +          if (attribute_flag[1] != 0)
7997 +            geometry_info.rho=argument_list[1].real_reference;
7998 +          if (attribute_flag[2] != 0)
7999 +            geometry_info.sigma=argument_list[2].real_reference;
8000 +          if (attribute_flag[3] != 0)
8001 +            channel=(ChannelType) argument_list[3].integer_reference;
8002 +          image=BlurImageChannel(image,channel,geometry_info.rho,
8003 +            geometry_info.sigma,exception);
8004 +          break;
8005 +        }
8006 +        case 7:  /* Chop */
8007 +        {
8008 +          if (attribute_flag[5] != 0)
8009 +            image->gravity=(GravityType) argument_list[5].integer_reference;
8010 +          if (attribute_flag[0] != 0)
8011 +            flags=ParseGravityGeometry(image,argument_list[0].string_reference,
8012 +              &geometry,exception);
8013 +          if (attribute_flag[1] != 0)
8014 +            geometry.width=argument_list[1].integer_reference;
8015 +          if (attribute_flag[2] != 0)
8016 +            geometry.height=argument_list[2].integer_reference;
8017 +          if (attribute_flag[3] != 0)
8018 +            geometry.x=argument_list[3].integer_reference;
8019 +          if (attribute_flag[4] != 0)
8020 +            geometry.y=argument_list[4].integer_reference;
8021 +          image=ChopImage(image,&geometry,exception);
8022 +          break;
8023 +        }
8024 +        case 8:  /* Crop */
8025 +        {
8026 +          if (attribute_flag[6] != 0)
8027 +            image->gravity=(GravityType) argument_list[6].integer_reference;
8028 +          if (attribute_flag[0] != 0)
8029 +            flags=ParseGravityGeometry(image,argument_list[0].string_reference,
8030 +              &geometry,exception);
8031 +          if (attribute_flag[1] != 0)
8032 +            geometry.width=argument_list[1].integer_reference;
8033 +          if (attribute_flag[2] != 0)
8034 +            geometry.height=argument_list[2].integer_reference;
8035 +          if (attribute_flag[3] != 0)
8036 +            geometry.x=argument_list[3].integer_reference;
8037 +          if (attribute_flag[4] != 0)
8038 +            geometry.y=argument_list[4].integer_reference;
8039 +          if (attribute_flag[5] != 0)
8040 +            image->fuzz=StringToDoubleInterval(
8041 +              argument_list[5].string_reference,(double) QuantumRange+1.0);
8042 +          image=CropImage(image,&geometry,exception);
8043 +          break;
8044 +        }
8045 +        case 9:  /* Despeckle */
8046 +        {
8047 +          image=DespeckleImage(image,exception);
8048 +          break;
8049 +        }
8050 +        case 10:  /* Edge */
8051 +        {
8052 +          if (attribute_flag[0] != 0)
8053 +            geometry_info.rho=argument_list[0].real_reference;
8054 +          image=EdgeImage(image,geometry_info.rho,exception);
8055 +          break;
8056 +        }
8057 +        case 11:  /* Emboss */
8058 +        {
8059 +          if (attribute_flag[0] != 0)
8060 +            {
8061 +              flags=ParseGeometry(argument_list[0].string_reference,
8062 +                &geometry_info);
8063 +              if ((flags & SigmaValue) == 0)
8064 +                geometry_info.sigma=1.0;
8065 +            }
8066 +          if (attribute_flag[1] != 0)
8067 +            geometry_info.rho=argument_list[1].real_reference;
8068 +          if (attribute_flag[2] != 0)
8069 +            geometry_info.sigma=argument_list[2].real_reference;
8070 +          image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8071 +            exception);
8072 +          break;
8073 +        }
8074 +        case 12:  /* Enhance */
8075 +        {
8076 +          image=EnhanceImage(image,exception);
8077 +          break;
8078 +        }
8079 +        case 13:  /* Flip */
8080 +        {
8081 +          image=FlipImage(image,exception);
8082 +          break;
8083 +        }
8084 +        case 14:  /* Flop */
8085 +        {
8086 +          image=FlopImage(image,exception);
8087 +          break;
8088 +        }
8089 +        case 15:  /* Frame */
8090 +        {
8091 +          FrameInfo
8092 +            frame_info;
8093 +
8094 +          if (attribute_flag[0] != 0)
8095 +            {
8096 +              flags=ParsePageGeometry(image,argument_list[0].string_reference,
8097 +                &geometry,exception);
8098 +              frame_info.width=geometry.width;
8099 +              frame_info.height=geometry.height;
8100 +              frame_info.outer_bevel=geometry.x;
8101 +              frame_info.inner_bevel=geometry.y;
8102 +            }
8103 +          if (attribute_flag[1] != 0)
8104 +            frame_info.width=argument_list[1].integer_reference;
8105 +          if (attribute_flag[2] != 0)
8106 +            frame_info.height=argument_list[2].integer_reference;
8107 +          if (attribute_flag[3] != 0)
8108 +            frame_info.inner_bevel=argument_list[3].integer_reference;
8109 +          if (attribute_flag[4] != 0)
8110 +            frame_info.outer_bevel=argument_list[4].integer_reference;
8111 +          if (attribute_flag[5] != 0)
8112 +            QueryColorDatabase(argument_list[5].string_reference,&fill_color,
8113 +              exception);
8114 +          if (attribute_flag[6] != 0)
8115 +            QueryColorDatabase(argument_list[6].string_reference,&fill_color,
8116 +              exception);
8117 +          frame_info.x=(ssize_t) frame_info.width;
8118 +          frame_info.y=(ssize_t) frame_info.height;
8119 +          frame_info.width=image->columns+2*frame_info.x;
8120 +          frame_info.height=image->rows+2*frame_info.y;
8121 +          if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8122 +            image->matte_color=fill_color;
8123 +          if (attribute_flag[7] != 0)
8124 +            image->compose=(CompositeOperator)
8125 +              argument_list[7].integer_reference;
8126 +          image=FrameImage(image,&frame_info,exception);
8127 +          break;
8128 +        }
8129 +        case 16:  /* Implode */
8130 +        {
8131 +          if (attribute_flag[0] == 0)
8132 +            argument_list[0].real_reference=0.5;
8133 +          if (attribute_flag[1] != 0)
8134 +            image->interpolate=(InterpolatePixelMethod)
8135 +              argument_list[1].integer_reference;
8136 +          image=ImplodeImage(image,argument_list[0].real_reference,
8137 +            exception);
8138 +          break;
8139 +        }
8140 +        case 17:  /* Magnify */
8141 +        {
8142 +          image=MagnifyImage(image,exception);
8143 +          break;
8144 +        }
8145 +        case 18:  /* MedianFilter */
8146 +        {
8147 +          if (attribute_flag[0] != 0)
8148 +            {
8149 +              flags=ParseGeometry(argument_list[0].string_reference,
8150 +                &geometry_info);
8151 +              if ((flags & SigmaValue) == 0)
8152 +                geometry_info.sigma=1.0;
8153 +            }
8154 +          if (attribute_flag[1] != 0)
8155 +            geometry_info.rho=argument_list[1].real_reference;
8156 +          if (attribute_flag[2] != 0)
8157 +            geometry_info.sigma=argument_list[2].real_reference;
8158 +          if (attribute_flag[3] != 0)
8159 +            channel=(ChannelType) argument_list[3].integer_reference;
8160 +          image=StatisticImageChannel(image,channel,MedianStatistic,
8161 +            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
8162 +          break;
8163 +        }
8164 +        case 19:  /* Minify */
8165 +        {
8166 +          image=MinifyImage(image,exception);
8167 +          break;
8168 +        }
8169 +        case 20:  /* OilPaint */
8170 +        {
8171 +          if (attribute_flag[0] == 0)
8172 +            argument_list[0].real_reference=0.0;
8173 +          image=OilPaintImage(image,argument_list[0].real_reference,
8174 +            exception);
8175 +          break;
8176 +        }
8177 +        case 21:  /* ReduceNoise */
8178 +        {
8179 +          if (attribute_flag[0] != 0)
8180 +            {
8181 +              flags=ParseGeometry(argument_list[0].string_reference,
8182 +                &geometry_info);
8183 +              if ((flags & SigmaValue) == 0)
8184 +                geometry_info.sigma=1.0;
8185 +            }
8186 +          if (attribute_flag[1] != 0)
8187 +            geometry_info.rho=argument_list[1].real_reference;
8188 +          if (attribute_flag[2] != 0)
8189 +            geometry_info.sigma=argument_list[2].real_reference;
8190 +          if (attribute_flag[3] != 0)
8191 +            channel=(ChannelType) argument_list[3].integer_reference;
8192 +          image=StatisticImageChannel(image,channel,NonpeakStatistic,
8193 +            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
8194 +          break;
8195 +        }
8196 +        case 22:  /* Roll */
8197 +        {
8198 +          if (attribute_flag[0] != 0)
8199 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
8200 +              &geometry,exception);
8201 +          if (attribute_flag[1] != 0)
8202 +            geometry.x=argument_list[1].integer_reference;
8203 +          if (attribute_flag[2] != 0)
8204 +            geometry.y=argument_list[2].integer_reference;
8205 +          image=RollImage(image,geometry.x,geometry.y,exception);
8206 +          break;
8207 +        }
8208 +        case 23:  /* Rotate */
8209 +        {
8210 +          if (attribute_flag[0] == 0)
8211 +            argument_list[0].real_reference=90.0;
8212 +          if (attribute_flag[1] != 0)
8213 +            QueryColorDatabase(argument_list[1].string_reference,
8214 +              &image->background_color,exception);
8215 +          if (attribute_flag[2] != 0)
8216 +            QueryColorDatabase(argument_list[2].string_reference,
8217 +              &image->background_color,exception);
8218 +          if (attribute_flag[3] != 0)
8219 +            QueryColorDatabase(argument_list[3].string_reference,
8220 +              &image->background_color,exception);
8221 +          image=RotateImage(image,argument_list[0].real_reference,exception);
8222 +          break;
8223 +        }
8224 +        case 24:  /* Sample */
8225 +        {
8226 +          if (attribute_flag[0] != 0)
8227 +            flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8228 +              &geometry,exception);
8229 +          if (attribute_flag[1] != 0)
8230 +            geometry.width=argument_list[1].integer_reference;
8231 +          if (attribute_flag[2] != 0)
8232 +            geometry.height=argument_list[2].integer_reference;
8233 +          image=SampleImage(image,geometry.width,geometry.height,exception);
8234 +          break;
8235 +        }
8236 +        case 25:  /* Scale */
8237 +        {
8238 +          if (attribute_flag[0] != 0)
8239 +            flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8240 +              &geometry,exception);
8241 +          if (attribute_flag[1] != 0)
8242 +            geometry.width=argument_list[1].integer_reference;
8243 +          if (attribute_flag[2] != 0)
8244 +            geometry.height=argument_list[2].integer_reference;
8245 +          image=ScaleImage(image,geometry.width,geometry.height,exception);
8246 +          break;
8247 +        }
8248 +        case 26:  /* Shade */
8249 +        {
8250 +          if (attribute_flag[0] != 0)
8251 +            {
8252 +              flags=ParseGeometry(argument_list[0].string_reference,
8253 +                &geometry_info);
8254 +              if ((flags & SigmaValue) == 0)
8255 +                geometry_info.sigma=0.0;
8256 +            }
8257 +          if (attribute_flag[1] != 0)
8258 +            geometry_info.rho=argument_list[1].real_reference;
8259 +          if (attribute_flag[2] != 0)
8260 +            geometry_info.sigma=argument_list[2].real_reference;
8261 +          image=ShadeImage(image,
8262 +            argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8263 +            geometry_info.rho,geometry_info.sigma,exception);
8264 +          break;
8265 +        }
8266 +        case 27:  /* Sharpen */
8267 +        {
8268 +          if (attribute_flag[0] != 0)
8269 +            {
8270 +              flags=ParseGeometry(argument_list[0].string_reference,
8271 +                &geometry_info);
8272 +              if ((flags & SigmaValue) == 0)
8273 +                geometry_info.sigma=1.0;
8274 +            }
8275 +          if (attribute_flag[1] != 0)
8276 +            geometry_info.rho=argument_list[1].real_reference;
8277 +          if (attribute_flag[2] != 0)
8278 +            geometry_info.sigma=argument_list[2].real_reference;
8279 +          if (attribute_flag[3] != 0)
8280 +            channel=(ChannelType) argument_list[3].integer_reference;
8281 +          image=SharpenImageChannel(image,channel,geometry_info.rho,
8282 +            geometry_info.sigma,exception);
8283 +          break;
8284 +        }
8285 +        case 28:  /* Shear */
8286 +        {
8287 +          if (attribute_flag[0] != 0)
8288 +            {
8289 +              flags=ParseGeometry(argument_list[0].string_reference,
8290 +                &geometry_info);
8291 +              if ((flags & SigmaValue) == 0)
8292 +                geometry_info.sigma=geometry_info.rho;
8293 +            }
8294 +          if (attribute_flag[1] != 0)
8295 +            geometry_info.rho=argument_list[1].real_reference;
8296 +          if (attribute_flag[2] != 0)
8297 +            geometry_info.sigma=argument_list[2].real_reference;
8298 +          if (attribute_flag[3] != 0)
8299 +            QueryColorDatabase(argument_list[3].string_reference,
8300 +              &image->background_color,exception);
8301 +          if (attribute_flag[4] != 0)
8302 +            QueryColorDatabase(argument_list[4].string_reference,
8303 +              &image->background_color,exception);
8304 +          image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8305 +            exception);
8306 +          break;
8307 +        }
8308 +        case 29:  /* Spread */
8309 +        {
8310 +          if (attribute_flag[0] == 0)
8311 +            argument_list[0].real_reference=1.0;
8312 +          image=SpreadImage(image,argument_list[0].real_reference,exception);
8313 +          break;
8314 +        }
8315 +        case 30:  /* Swirl */
8316 +        {
8317 +          if (attribute_flag[0] == 0)
8318 +            argument_list[0].real_reference=50.0;
8319 +          if (attribute_flag[1] != 0)
8320 +            image->interpolate=(InterpolatePixelMethod)
8321 +              argument_list[1].integer_reference;
8322 +          image=SwirlImage(image,argument_list[0].real_reference,exception);
8323 +          break;
8324 +        }
8325 +        case 31:  /* Resize */
8326 +        case 32:  /* Zoom */
8327 +        {
8328 +          if (attribute_flag[0] != 0)
8329 +            flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8330 +              &geometry,exception);
8331 +          if (attribute_flag[1] != 0)
8332 +            geometry.width=argument_list[1].integer_reference;
8333 +          if (attribute_flag[2] != 0)
8334 +            geometry.height=argument_list[2].integer_reference;
8335 +          if (attribute_flag[3] == 0)
8336 +            argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8337 +          if (attribute_flag[4] != 0)
8338 +            SetImageArtifact(image,"filter:support",
8339 +              argument_list[4].string_reference);
8340 +          if (attribute_flag[5] == 0)
8341 +            argument_list[5].real_reference=1.0;
8342 +          image=ResizeImage(image,geometry.width,geometry.height,
8343 +            (FilterTypes) argument_list[3].integer_reference,
8344 +            argument_list[5].real_reference,exception);
8345 +          break;
8346 +        }
8347 +        case 33:  /* Annotate */
8348 +        {
8349 +          DrawInfo
8350 +            *draw_info;
8351 +
8352 +          draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8353 +            (DrawInfo *) NULL);
8354 +          if (attribute_flag[0] != 0)
8355 +            {
8356 +              char
8357 +                *text;
8358 +
8359 +              text=InterpretImageProperties(info ? info->image_info :
8360 +                (ImageInfo *) NULL,image,argument_list[0].string_reference);
8361 +              (void) CloneString(&draw_info->text,text);
8362 +              text=DestroyString(text);
8363 +            }
8364 +          if (attribute_flag[1] != 0)
8365 +            (void) CloneString(&draw_info->font,
8366 +              argument_list[1].string_reference);
8367 +          if (attribute_flag[2] != 0)
8368 +            draw_info->pointsize=argument_list[2].real_reference;
8369 +          if (attribute_flag[3] != 0)
8370 +            (void) CloneString(&draw_info->density,
8371 +              argument_list[3].string_reference);
8372 +          if (attribute_flag[4] != 0)
8373 +            (void) QueryColorDatabase(argument_list[4].string_reference,
8374 +              &draw_info->undercolor,exception);
8375 +          if (attribute_flag[5] != 0)
8376 +            {
8377 +              (void) QueryColorDatabase(argument_list[5].string_reference,
8378 +                &draw_info->stroke,exception);
8379 +              if (argument_list[5].image_reference != (Image *) NULL)
8380 +                draw_info->stroke_pattern=CloneImage(
8381 +                  argument_list[5].image_reference,0,0,MagickTrue,exception);
8382 +            }
8383 +          if (attribute_flag[6] != 0)
8384 +            {
8385 +              (void) QueryColorDatabase(argument_list[6].string_reference,
8386 +                &draw_info->fill,exception);
8387 +              if (argument_list[6].image_reference != (Image *) NULL)
8388 +                draw_info->fill_pattern=CloneImage(
8389 +                  argument_list[6].image_reference,0,0,MagickTrue,exception);
8390 +            }
8391 +          if (attribute_flag[7] != 0)
8392 +            {
8393 +              (void) CloneString(&draw_info->geometry,
8394 +                argument_list[7].string_reference);
8395 +              flags=ParsePageGeometry(image,argument_list[7].string_reference,
8396 +                &geometry,exception);
8397 +              if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8398 +                geometry_info.sigma=geometry_info.xi;
8399 +            }
8400 +          if (attribute_flag[8] != 0)
8401 +            (void) QueryColorDatabase(argument_list[8].string_reference,
8402 +              &draw_info->fill,exception);
8403 +          if (attribute_flag[11] != 0)
8404 +            draw_info->gravity=(GravityType) argument_list[11].integer_reference;
8405 +          if (attribute_flag[25] != 0)
8406 +            {
8407 +              AV
8408 +                *av;
8409 +
8410 +              av=(AV *) argument_list[25].array_reference;
8411 +              if ((av_len(av) != 3) && (av_len(av) != 5))
8412 +                {
8413 +                  ThrowPerlException(exception,OptionError,
8414 +                    "affine matrix must have 4 or 6 elements",PackageName);
8415 +                  goto PerlException;
8416 +                }
8417 +              draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8418 +              draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8419 +              draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8420 +              draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8421 +              if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8422 +                  draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8423 +                {
8424 +                  ThrowPerlException(exception,OptionError,
8425 +                    "affine matrix is singular",PackageName);
8426 +                   goto PerlException;
8427 +                }
8428 +              if (av_len(av) == 5)
8429 +                {
8430 +                  draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8431 +                  draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8432 +                }
8433 +            }
8434 +          for (j=12; j < 17; j++)
8435 +          {
8436 +            if (attribute_flag[j] == 0)
8437 +              continue;
8438 +            value=argument_list[j].string_reference;
8439 +            angle=argument_list[j].real_reference;
8440 +            current=draw_info->affine;
8441 +            GetAffineMatrix(&affine);
8442 +            switch (j)
8443 +            {
8444 +              case 12:
8445 +              {
8446 +                /*
8447 +                  Translate.
8448 +                */
8449 +                flags=ParseGeometry(value,&geometry_info);
8450 +                affine.tx=geometry_info.xi;
8451 +                affine.ty=geometry_info.psi;
8452 +                if ((flags & PsiValue) == 0)
8453 +                  affine.ty=affine.tx;
8454 +                break;
8455 +              }
8456 +              case 13:
8457 +              {
8458 +                /*
8459 +                  Scale.
8460 +                */
8461 +                flags=ParseGeometry(value,&geometry_info);
8462 +                affine.sx=geometry_info.rho;
8463 +                affine.sy=geometry_info.sigma;
8464 +                if ((flags & SigmaValue) == 0)
8465 +                  affine.sy=affine.sx;
8466 +                break;
8467 +              }
8468 +              case 14:
8469 +              {
8470 +                /*
8471 +                  Rotate.
8472 +                */
8473 +                if (angle == 0.0)
8474 +                  break;
8475 +                affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8476 +                affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8477 +                affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8478 +                affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8479 +                break;
8480 +              }
8481 +              case 15:
8482 +              {
8483 +                /*
8484 +                  SkewX.
8485 +                */
8486 +                affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8487 +                break;
8488 +              }
8489 +              case 16:
8490 +              {
8491 +                /*
8492 +                  SkewY.
8493 +                */
8494 +                affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8495 +                break;
8496 +              }
8497 +            }
8498 +            draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8499 +            draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8500 +            draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8501 +            draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8502 +            draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8503 +              current.tx;
8504 +            draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8505 +              current.ty;
8506 +          }
8507 +          if (attribute_flag[9] == 0)
8508 +            argument_list[9].real_reference=0.0;
8509 +          if (attribute_flag[10] == 0)
8510 +            argument_list[10].real_reference=0.0;
8511 +          if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8512 +            {
8513 +              char
8514 +                geometry[MaxTextExtent];
8515 +
8516 +              (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8517 +                (double) argument_list[9].real_reference+draw_info->affine.tx,
8518 +                (double) argument_list[10].real_reference+draw_info->affine.ty);
8519 +              (void) CloneString(&draw_info->geometry,geometry);
8520 +            }
8521 +          if (attribute_flag[17] != 0)
8522 +            draw_info->stroke_width=argument_list[17].real_reference;
8523 +          if (attribute_flag[18] != 0)
8524 +            {
8525 +              draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8526 +                MagickTrue : MagickFalse;
8527 +              draw_info->stroke_antialias=draw_info->text_antialias;
8528 +            }
8529 +          if (attribute_flag[19] != 0)
8530 +            (void) CloneString(&draw_info->family,
8531 +              argument_list[19].string_reference);
8532 +          if (attribute_flag[20] != 0)
8533 +            draw_info->style=(StyleType) argument_list[20].integer_reference;
8534 +          if (attribute_flag[21] != 0)
8535 +            draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8536 +          if (attribute_flag[22] != 0)
8537 +            draw_info->weight=argument_list[22].integer_reference;
8538 +          if (attribute_flag[23] != 0)
8539 +            draw_info->align=(AlignType) argument_list[23].integer_reference;
8540 +          if (attribute_flag[24] != 0)
8541 +            (void) CloneString(&draw_info->encoding,
8542 +              argument_list[24].string_reference);
8543 +          if (attribute_flag[25] != 0)
8544 +            draw_info->fill_pattern=CloneImage(
8545 +              argument_list[25].image_reference,0,0,MagickTrue,exception);
8546 +          if (attribute_flag[26] != 0)
8547 +            draw_info->fill_pattern=CloneImage(
8548 +              argument_list[26].image_reference,0,0,MagickTrue,exception);
8549 +          if (attribute_flag[27] != 0)
8550 +            draw_info->stroke_pattern=CloneImage(
8551 +              argument_list[27].image_reference,0,0,MagickTrue,exception);
8552 +          if (attribute_flag[29] != 0)
8553 +            draw_info->kerning=argument_list[29].real_reference;
8554 +          if (attribute_flag[30] != 0)
8555 +            draw_info->interline_spacing=argument_list[30].real_reference;
8556 +          if (attribute_flag[31] != 0)
8557 +            draw_info->interword_spacing=argument_list[31].real_reference;
8558 +          if (attribute_flag[32] != 0)
8559 +            draw_info->direction=(DirectionType)
8560 +              argument_list[32].integer_reference;
8561 +          (void) AnnotateImage(image,draw_info);
8562 +          draw_info=DestroyDrawInfo(draw_info);
8563 +          break;
8564 +        }
8565 +        case 34:  /* ColorFloodfill */
8566 +        {
8567 +          DrawInfo
8568 +            *draw_info;
8569 +
8570 +          MagickBooleanType
8571 +            invert;
8572 +
8573 +          MagickPixelPacket
8574 +            target;
8575 +
8576 +          draw_info=CloneDrawInfo(info ? info->image_info :
8577 +            (ImageInfo *) NULL,(DrawInfo *) NULL);
8578 +          if (attribute_flag[0] != 0)
8579 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
8580 +              &geometry,exception);
8581 +          if (attribute_flag[1] != 0)
8582 +            geometry.x=argument_list[1].integer_reference;
8583 +          if (attribute_flag[2] != 0)
8584 +            geometry.y=argument_list[2].integer_reference;
8585 +          if (attribute_flag[3] != 0)
8586 +            (void) QueryColorDatabase(argument_list[3].string_reference,
8587 +              &draw_info->fill,exception);
8588 +          (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8589 +            exception);
8590 +          invert=MagickFalse;
8591 +          if (attribute_flag[4] != 0)
8592 +            {
8593 +              QueryMagickColor(argument_list[4].string_reference,&target,
8594 +                exception);
8595 +              invert=MagickTrue;
8596 +            }
8597 +          if (attribute_flag[5] != 0)
8598 +            image->fuzz=StringToDoubleInterval(
8599 +              argument_list[5].string_reference,(double) QuantumRange+1.0);
8600 +          if (attribute_flag[6] != 0)
8601 +            invert=(MagickBooleanType) argument_list[6].integer_reference;
8602 +          (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8603 +            geometry.x,geometry.y,invert);
8604 +          draw_info=DestroyDrawInfo(draw_info);
8605 +          break;
8606 +        }
8607 +        case 35:  /* Composite */
8608 +        {
8609 +          char
8610 +            composite_geometry[MaxTextExtent];
8611 +
8612 +          Image
8613 +            *composite_image,
8614 +            *rotate_image;
8615 +
8616 +          compose=OverCompositeOp;
8617 +          if (attribute_flag[0] != 0)
8618 +            composite_image=argument_list[0].image_reference;
8619 +          else
8620 +            {
8621 +              ThrowPerlException(exception,OptionError,
8622 +                "CompositeImageRequired",PackageName);
8623 +              goto PerlException;
8624 +            }
8625 +          /*
8626 +            Parameter Handling used for BOTH normal and tiled composition.
8627 +          */
8628 +          if (attribute_flag[1] != 0) /* compose */
8629 +            compose=(CompositeOperator) argument_list[1].integer_reference;
8630 +          if (attribute_flag[6] != 0) /* opacity  */
8631 +            {
8632 +              if (compose != DissolveCompositeOp)
8633 +                (void) SetImageOpacity(composite_image,(Quantum) (QuantumRange-
8634 +                  StringToDoubleInterval(argument_list[6].string_reference,
8635 +                  (double) QuantumRange+1.0)));
8636 +              else
8637 +                {
8638 +                  CacheView
8639 +                    *composite_view;
8640 +
8641 +                  double
8642 +                    opacity;
8643 +
8644 +                  MagickBooleanType
8645 +                    sync;
8646 +
8647 +                  register ssize_t
8648 +                    x;
8649 +
8650 +                  register PixelPacket
8651 +                    *q;
8652 +
8653 +                  ssize_t
8654 +                    y;
8655 +
8656 +                  /*
8657 +                    Handle dissolve composite operator.
8658 +                  */
8659 +                  (void) CloneString(&image->geometry,
8660 +                    argument_list[6].string_reference);
8661 +                  opacity=(Quantum) (QuantumRange-StringToDoubleInterval(
8662 +                    argument_list[6].string_reference,(double) QuantumRange+
8663 +                    1.0));
8664 +                  if (composite_image->matte != MagickTrue)
8665 +                    (void) SetImageOpacity(composite_image,OpaqueOpacity);
8666 +                  composite_view=AcquireAuthenticCacheView(composite_image,
8667 +                    exception);
8668 +                  for (y=0; y < (ssize_t) composite_image->rows ; y++)
8669 +                  {
8670 +                    q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8671 +                      composite_image->columns,1,exception);
8672 +                    for (x=0; x < (ssize_t) composite_image->columns; x++)
8673 +                    {
8674 +                      if (q->opacity == OpaqueOpacity)
8675 +                        q->opacity=ClampToQuantum(opacity);
8676 +                      q++;
8677 +                    }
8678 +                    sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8679 +                    if (sync == MagickFalse)
8680 +                      break;
8681 +                  }
8682 +                  composite_view=DestroyCacheView(composite_view);
8683 +                }
8684 +            }
8685 +          if (attribute_flag[9] != 0)    /* "color=>" */
8686 +            QueryColorDatabase(argument_list[9].string_reference,
8687 +              &composite_image->background_color,exception);
8688 +          if (attribute_flag[12] != 0) /* "interpolate=>" */
8689 +            image->interpolate=(InterpolatePixelMethod)
8690 +              argument_list[12].integer_reference;
8691 +          if (attribute_flag[13] != 0)   /* "args=>" */
8692 +            (void) SetImageArtifact(composite_image,"compose:args",
8693 +              argument_list[13].string_reference);
8694 +          if (attribute_flag[14] != 0)   /* "blend=>"  depreciated */
8695 +            (void) SetImageArtifact(composite_image,"compose:args",
8696 +              argument_list[14].string_reference);
8697 +          /*
8698 +            Tiling Composition (with orthogonal rotate).
8699 +          */
8700 +          rotate_image=(Image *) NULL;
8701 +          if (attribute_flag[8] != 0)   /* "rotate=>" */
8702 +            {
8703 +               /*
8704 +                 Rotate image.
8705 +               */
8706 +               rotate_image=RotateImage(composite_image,
8707 +                 argument_list[8].real_reference,exception);
8708 +               if (rotate_image == (Image *) NULL)
8709 +                 break;
8710 +            }
8711 +          if ((attribute_flag[7] != 0) &&
8712 +              (argument_list[7].integer_reference != 0)) /* tile */
8713 +            {
8714 +              ssize_t
8715 +                x,
8716 +                y;
8717 +
8718 +              /*
8719 +                Tile the composite image.
8720 +              */
8721 +             if (attribute_flag[8] != 0)   /* "tile=>" */
8722 +               (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8723 +                 "false");
8724 +             else
8725 +               (void) SetImageArtifact(composite_image,
8726 +                 "compose:outside-overlay","false");
8727 +             for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8728 +                for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8729 +                {
8730 +                  if (attribute_flag[8] != 0) /* rotate */
8731 +                    (void) CompositeImage(image,compose,rotate_image,x,y);
8732 +                  else
8733 +                    (void) CompositeImage(image,compose,composite_image,x,y);
8734 +                }
8735 +              if (attribute_flag[8] != 0) /* rotate */
8736 +                rotate_image=DestroyImage(rotate_image);
8737 +              break;
8738 +            }
8739 +          /*
8740 +            Parameter Handling used used ONLY for normal composition.
8741 +          */
8742 +          if (attribute_flag[5] != 0) /* gravity */
8743 +            image->gravity=(GravityType) argument_list[5].integer_reference;
8744 +          if (attribute_flag[2] != 0) /* geometry offset */
8745 +            {
8746 +              SetGeometry(image,&geometry);
8747 +              (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8748 +                &geometry);
8749 +              GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8750 +                &geometry);
8751 +            }
8752 +          if (attribute_flag[3] != 0) /* x offset */
8753 +            geometry.x=argument_list[3].integer_reference;
8754 +          if (attribute_flag[4] != 0) /* y offset */
8755 +            geometry.y=argument_list[4].integer_reference;
8756 +          if (attribute_flag[10] != 0) /* mask */
8757 +            {
8758 +              if ((image->compose == DisplaceCompositeOp) ||
8759 +                  (image->compose == DistortCompositeOp))
8760 +                {
8761 +                  /*
8762 +                    Merge Y displacement into X displacement image.
8763 +                  */
8764 +                  composite_image=CloneImage(composite_image,0,0,MagickTrue,
8765 +                    &image->exception);
8766 +                  (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8767 +                    argument_list[10].image_reference,0,0);
8768 +                }
8769 +              else
8770 +                {
8771 +                  /*
8772 +                    Set a blending mask for the composition.
8773 +                  */
8774 +                  image->mask=CloneImage(argument_list[10].image_reference,0,0,
8775 +                    MagickTrue,&image->exception);
8776 +                  (void) NegateImage(image->mask,MagickFalse);
8777 +                }
8778 +            }
8779 +          if (attribute_flag[11] != 0) /* channel */
8780 +            channel=(ChannelType) argument_list[11].integer_reference;
8781 +          /*
8782 +            Composite two images (normal composition).
8783 +          */
8784 +          (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8785 +            "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8786 +            (double) composite_image->rows,(double) geometry.x,(double)
8787 +            geometry.y);
8788 +          flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8789 +            exception);
8790 +          if (attribute_flag[8] == 0) /* no rotate */
8791 +            CompositeImageChannel(image,channel,compose,composite_image,
8792 +              geometry.x,geometry.y);
8793 +          else
8794 +            {
8795 +              /*
8796 +                Position adjust rotated image then composite.
8797 +              */
8798 +              geometry.x-=(ssize_t) (rotate_image->columns-
8799 +                composite_image->columns)/2;
8800 +              geometry.y-=(ssize_t) (rotate_image->rows-
8801 +                composite_image->rows)/2;
8802 +              CompositeImageChannel(image,channel,compose,rotate_image,
8803 +                geometry.x,geometry.y);
8804 +              rotate_image=DestroyImage(rotate_image);
8805 +            }
8806 +          if (attribute_flag[10] != 0) /* mask */
8807 +            {
8808 +              if ((image->compose == DisplaceCompositeOp) ||
8809 +                  (image->compose == DistortCompositeOp))
8810 +                composite_image=DestroyImage(composite_image);
8811 +              else
8812 +                image->mask=DestroyImage(image->mask);
8813 +            }
8814 +          break;
8815 +        }
8816 +        case 36:  /* Contrast */
8817 +        {
8818 +          if (attribute_flag[0] == 0)
8819 +            argument_list[0].integer_reference=0;
8820 +          (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8821 +            MagickTrue : MagickFalse);
8822 +          break;
8823 +        }
8824 +        case 37:  /* CycleColormap */
8825 +        {
8826 +          if (attribute_flag[0] == 0)
8827 +            argument_list[0].integer_reference=6;
8828 +          (void) CycleColormapImage(image,argument_list[0].integer_reference);
8829 +          break;
8830 +        }
8831 +        case 38:  /* Draw */
8832 +        {
8833 +          DrawInfo
8834 +            *draw_info;
8835 +
8836 +          draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8837 +            (DrawInfo *) NULL);
8838 +          (void) CloneString(&draw_info->primitive,"point");
8839 +          if (attribute_flag[0] != 0)
8840 +            {
8841 +              if (argument_list[0].integer_reference < 0)
8842 +                (void) CloneString(&draw_info->primitive,
8843 +                  argument_list[0].string_reference);
8844 +              else
8845 +                (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8846 +                  MagickPrimitiveOptions,argument_list[0].integer_reference));
8847 +            }
8848 +          if (attribute_flag[1] != 0)
8849 +            {
8850 +              if (LocaleCompare(draw_info->primitive,"path") == 0)
8851 +                {
8852 +                  (void) ConcatenateString(&draw_info->primitive," '");
8853 +                  ConcatenateString(&draw_info->primitive,
8854 +                    argument_list[1].string_reference);
8855 +                  (void) ConcatenateString(&draw_info->primitive,"'");
8856 +                }
8857 +              else
8858 +                {
8859 +                  (void) ConcatenateString(&draw_info->primitive," ");
8860 +                  ConcatenateString(&draw_info->primitive,
8861 +                    argument_list[1].string_reference);
8862 +                }
8863 +            }
8864 +          if (attribute_flag[2] != 0)
8865 +            {
8866 +              (void) ConcatenateString(&draw_info->primitive," ");
8867 +              (void) ConcatenateString(&draw_info->primitive,
8868 +                CommandOptionToMnemonic(MagickMethodOptions,
8869 +                argument_list[2].integer_reference));
8870 +            }
8871 +          if (attribute_flag[3] != 0)
8872 +            {
8873 +              (void) QueryColorDatabase(argument_list[3].string_reference,
8874 +                &draw_info->stroke,exception);
8875 +              if (argument_list[3].image_reference != (Image *) NULL)
8876 +                draw_info->stroke_pattern=CloneImage(
8877 +                  argument_list[3].image_reference,0,0,MagickTrue,exception);
8878 +            }
8879 +          if (attribute_flag[4] != 0)
8880 +            {
8881 +              (void) QueryColorDatabase(argument_list[4].string_reference,
8882 +                &draw_info->fill,exception);
8883 +              if (argument_list[4].image_reference != (Image *) NULL)
8884 +                draw_info->fill_pattern=CloneImage(
8885 +                  argument_list[4].image_reference,0,0,MagickTrue,exception);
8886 +            }
8887 +          if (attribute_flag[5] != 0)
8888 +            draw_info->stroke_width=argument_list[5].real_reference;
8889 +          if (attribute_flag[6] != 0)
8890 +            (void) CloneString(&draw_info->font,
8891 +              argument_list[6].string_reference);
8892 +          if (attribute_flag[7] != 0)
8893 +            (void) QueryColorDatabase(argument_list[7].string_reference,
8894 +              &draw_info->border_color,exception);
8895 +          if (attribute_flag[8] != 0)
8896 +            draw_info->affine.tx=argument_list[8].real_reference;
8897 +          if (attribute_flag[9] != 0)
8898 +            draw_info->affine.ty=argument_list[9].real_reference;
8899 +          if (attribute_flag[20] != 0)
8900 +            {
8901 +              AV
8902 +                *av;
8903 +
8904 +              av=(AV *) argument_list[20].array_reference;
8905 +              if ((av_len(av) != 3) && (av_len(av) != 5))
8906 +                {
8907 +                  ThrowPerlException(exception,OptionError,
8908 +                    "affine matrix must have 4 or 6 elements",PackageName);
8909 +                  goto PerlException;
8910 +                }
8911 +              draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8912 +              draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8913 +              draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8914 +              draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8915 +              if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8916 +                  draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8917 +                {
8918 +                  ThrowPerlException(exception,OptionError,
8919 +                    "affine matrix is singular",PackageName);
8920 +                   goto PerlException;
8921 +                }
8922 +              if (av_len(av) == 5)
8923 +                {
8924 +                  draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8925 +                  draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8926 +                }
8927 +            }
8928 +          for (j=10; j < 15; j++)
8929 +          {
8930 +            if (attribute_flag[j] == 0)
8931 +              continue;
8932 +            value=argument_list[j].string_reference;
8933 +            angle=argument_list[j].real_reference;
8934 +            current=draw_info->affine;
8935 +            GetAffineMatrix(&affine);
8936 +            switch (j)
8937 +            {
8938 +              case 10:
8939 +              {
8940 +                /*
8941 +                  Translate.
8942 +                */
8943 +                flags=ParseGeometry(value,&geometry_info);
8944 +                affine.tx=geometry_info.xi;
8945 +                affine.ty=geometry_info.psi;
8946 +                if ((flags & PsiValue) == 0)
8947 +                  affine.ty=affine.tx;
8948 +                break;
8949 +              }
8950 +              case 11:
8951 +              {
8952 +                /*
8953 +                  Scale.
8954 +                */
8955 +                flags=ParseGeometry(value,&geometry_info);
8956 +                affine.sx=geometry_info.rho;
8957 +                affine.sy=geometry_info.sigma;
8958 +                if ((flags & SigmaValue) == 0)
8959 +                  affine.sy=affine.sx;
8960 +                break;
8961 +              }
8962 +              case 12:
8963 +              {
8964 +                /*
8965 +                  Rotate.
8966 +                */
8967 +                if (angle == 0.0)
8968 +                  break;
8969 +                affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8970 +                affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8971 +                affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8972 +                affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8973 +                break;
8974 +              }
8975 +              case 13:
8976 +              {
8977 +                /*
8978 +                  SkewX.
8979 +                */
8980 +                affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8981 +                break;
8982 +              }
8983 +              case 14:
8984 +              {
8985 +                /*
8986 +                  SkewY.
8987 +                */
8988 +                affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8989 +                break;
8990 +              }
8991 +            }
8992 +            draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8993 +            draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8994 +            draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8995 +            draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8996 +            draw_info->affine.tx=
8997 +              current.sx*affine.tx+current.ry*affine.ty+current.tx;
8998 +            draw_info->affine.ty=
8999 +              current.rx*affine.tx+current.sy*affine.ty+current.ty;
9000 +          }
9001 +          if (attribute_flag[15] != 0)
9002 +            draw_info->fill_pattern=CloneImage(
9003 +              argument_list[15].image_reference,0,0,MagickTrue,exception);
9004 +          if (attribute_flag[16] != 0)
9005 +            draw_info->pointsize=argument_list[16].real_reference;
9006 +          if (attribute_flag[17] != 0)
9007 +            {
9008 +              draw_info->stroke_antialias=argument_list[17].integer_reference != 0
9009 +                ? MagickTrue : MagickFalse;
9010 +              draw_info->text_antialias=draw_info->stroke_antialias;
9011 +            }
9012 +          if (attribute_flag[18] != 0)
9013 +            (void) CloneString(&draw_info->density,
9014 +              argument_list[18].string_reference);
9015 +          if (attribute_flag[19] != 0)
9016 +            draw_info->stroke_width=argument_list[19].real_reference;
9017 +          if (attribute_flag[21] != 0)
9018 +            draw_info->dash_offset=argument_list[21].real_reference;
9019 +          if (attribute_flag[22] != 0)
9020 +            {
9021 +              AV
9022 +                *av;
9023 +
9024 +              av=(AV *) argument_list[22].array_reference;
9025 +              draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9026 +                av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9027 +              if (draw_info->dash_pattern != (double *) NULL)
9028 +                {
9029 +                  for (i=0; i <= av_len(av); i++)
9030 +                    draw_info->dash_pattern[i]=(double)
9031 +                      SvNV(*(av_fetch(av,i,0)));
9032 +                  draw_info->dash_pattern[i]=0.0;
9033 +                }
9034 +            }
9035 +          if (attribute_flag[23] != 0)
9036 +            image->interpolate=(InterpolatePixelMethod)
9037 +              argument_list[23].integer_reference;
9038 +          if ((attribute_flag[24] != 0) &&
9039 +              (draw_info->fill_pattern != (Image *) NULL))
9040 +            flags=ParsePageGeometry(draw_info->fill_pattern,
9041 +              argument_list[24].string_reference,
9042 +              &draw_info->fill_pattern->tile_offset,exception);
9043 +          if (attribute_flag[25] != 0)
9044 +            {
9045 +              (void) ConcatenateString(&draw_info->primitive," '");
9046 +              (void) ConcatenateString(&draw_info->primitive,
9047 +                argument_list[25].string_reference);
9048 +              (void) ConcatenateString(&draw_info->primitive,"'");
9049 +            }
9050 +          if (attribute_flag[26] != 0)
9051 +            draw_info->fill_pattern=CloneImage(
9052 +              argument_list[26].image_reference,0,0,MagickTrue,exception);
9053 +          if (attribute_flag[27] != 0)
9054 +            draw_info->stroke_pattern=CloneImage(
9055 +              argument_list[27].image_reference,0,0,MagickTrue,exception);
9056 +          if (attribute_flag[28] != 0)
9057 +            (void) CloneString(&draw_info->primitive,
9058 +              argument_list[28].string_reference);
9059 +          if (attribute_flag[29] != 0)
9060 +            draw_info->kerning=argument_list[29].real_reference;
9061 +          if (attribute_flag[30] != 0)
9062 +            draw_info->interline_spacing=argument_list[30].real_reference;
9063 +          if (attribute_flag[31] != 0)
9064 +            draw_info->interword_spacing=argument_list[31].real_reference;
9065 +          if (attribute_flag[32] != 0)
9066 +            draw_info->direction=(DirectionType)
9067 +              argument_list[32].integer_reference;
9068 +          DrawImage(image,draw_info);
9069 +          draw_info=DestroyDrawInfo(draw_info);
9070 +          break;
9071 +        }
9072 +        case 39:  /* Equalize */
9073 +        {
9074 +          if (attribute_flag[0] != 0)
9075 +            channel=(ChannelType) argument_list[0].integer_reference;
9076 +          EqualizeImageChannel(image,channel);
9077 +          break;
9078 +        }
9079 +        case 40:  /* Gamma */
9080 +        {
9081 +          if (attribute_flag[1] != 0)
9082 +            channel=(ChannelType) argument_list[1].integer_reference;
9083 +          if (attribute_flag[2] == 0)
9084 +            argument_list[2].real_reference=1.0;
9085 +          if (attribute_flag[3] == 0)
9086 +            argument_list[3].real_reference=1.0;
9087 +          if (attribute_flag[4] == 0)
9088 +            argument_list[4].real_reference=1.0;
9089 +          if (attribute_flag[0] == 0)
9090 +            {
9091 +              (void) FormatLocaleString(message,MaxTextExtent,
9092 +                "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9093 +                (double) argument_list[3].real_reference,
9094 +                (double) argument_list[4].real_reference);
9095 +              argument_list[0].string_reference=message;
9096 +            }
9097 +          if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
9098 +            (void) GammaImage(image,argument_list[0].string_reference);
9099 +          else
9100 +            (void) GammaImageChannel(image,channel,StringToDouble(
9101 +              argument_list[0].string_reference,(char **) NULL));
9102 +          break;
9103 +        }
9104 +        case 41:  /* Map */
9105 +        {
9106 +          QuantizeInfo
9107 +            *quantize_info;
9108 +
9109 +          if (attribute_flag[0] == 0)
9110 +            {
9111 +              ThrowPerlException(exception,OptionError,"MapImageRequired",
9112 +                PackageName);
9113 +              goto PerlException;
9114 +            }
9115 +          quantize_info=AcquireQuantizeInfo(info->image_info);
9116 +          if (attribute_flag[1] != 0)
9117 +            quantize_info->dither=(MagickBooleanType)
9118 +              argument_list[1].integer_reference;
9119 +          if (attribute_flag[2] != 0)
9120 +            quantize_info->dither_method=(DitherMethod)
9121 +              argument_list[2].integer_reference;
9122 +          (void) RemapImages(quantize_info,image,
9123 +            argument_list[0].image_reference);
9124 +          quantize_info=DestroyQuantizeInfo(quantize_info);
9125 +          break;
9126 +        }
9127 +        case 42:  /* MatteFloodfill */
9128 +        {
9129 +          DrawInfo
9130 +            *draw_info;
9131 +
9132 +          MagickBooleanType
9133 +            invert;
9134 +
9135 +          MagickPixelPacket
9136 +            target;
9137 +
9138 +          draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9139 +            (DrawInfo *) NULL);
9140 +          if (attribute_flag[0] != 0)
9141 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
9142 +              &geometry,exception);
9143 +          if (attribute_flag[1] != 0)
9144 +            geometry.x=argument_list[1].integer_reference;
9145 +          if (attribute_flag[2] != 0)
9146 +            geometry.y=argument_list[2].integer_reference;
9147 +          if (image->matte == MagickFalse)
9148 +            (void) SetImageOpacity(image,OpaqueOpacity);
9149 +          (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
9150 +            exception);
9151 +          if (attribute_flag[4] != 0)
9152 +            QueryMagickColor(argument_list[4].string_reference,&target,
9153 +              exception);
9154 +          if (attribute_flag[3] != 0)
9155 +            target.opacity=StringToDoubleInterval(
9156 +              argument_list[3].string_reference,(double) QuantumRange+1.0);
9157 +          if (attribute_flag[5] != 0)
9158 +            image->fuzz=StringToDoubleInterval(
9159 +              argument_list[5].string_reference,(double) QuantumRange+1.0);
9160 +          invert=MagickFalse;
9161 +          if (attribute_flag[6] != 0)
9162 +            invert=(MagickBooleanType) argument_list[6].integer_reference;
9163 +          (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
9164 +            geometry.x,geometry.y,invert);
9165 +          draw_info=DestroyDrawInfo(draw_info);
9166 +          break;
9167 +        }
9168 +        case 43:  /* Modulate */
9169 +        {
9170 +          char
9171 +            modulate[MaxTextExtent];
9172 +
9173 +          geometry_info.rho=100.0;
9174 +          geometry_info.sigma=100.0;
9175 +          geometry_info.xi=100.0;
9176 +          if (attribute_flag[0] != 0)
9177 +            (void)ParseGeometry(argument_list[0].string_reference,
9178 +              &geometry_info);
9179 +          if (attribute_flag[1] != 0)
9180 +            geometry_info.xi=argument_list[1].real_reference;
9181 +          if (attribute_flag[2] != 0)
9182 +            geometry_info.sigma=argument_list[2].real_reference;
9183 +          if (attribute_flag[3] != 0)
9184 +            {
9185 +              geometry_info.sigma=argument_list[3].real_reference;
9186 +              SetImageArtifact(image,"modulate:colorspace","HWB");
9187 +            }
9188 +          if (attribute_flag[4] != 0)
9189 +            {
9190 +              geometry_info.rho=argument_list[4].real_reference;
9191 +              SetImageArtifact(image,"modulate:colorspace","HSB");
9192 +            }
9193 +          if (attribute_flag[5] != 0)
9194 +            {
9195 +              geometry_info.sigma=argument_list[5].real_reference;
9196 +              SetImageArtifact(image,"modulate:colorspace","HSL");
9197 +            }
9198 +          if (attribute_flag[6] != 0)
9199 +            {
9200 +              geometry_info.rho=argument_list[6].real_reference;
9201 +              SetImageArtifact(image,"modulate:colorspace","HWB");
9202 +            }
9203 +          (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
9204 +            geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9205 +          (void) ModulateImage(image,modulate);
9206 +          break;
9207 +        }
9208 +        case 44:  /* Negate */
9209 +        {
9210 +          if (attribute_flag[0] == 0)
9211 +            argument_list[0].integer_reference=0;
9212 +          if (attribute_flag[1] != 0)
9213 +            channel=(ChannelType) argument_list[1].integer_reference;
9214 +          (void) NegateImageChannel(image,channel,
9215 +            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
9216 +          break;
9217 +        }
9218 +        case 45:  /* Normalize */
9219 +        {
9220 +          if (attribute_flag[0] != 0)
9221 +            channel=(ChannelType) argument_list[0].integer_reference;
9222 +          NormalizeImageChannel(image,channel);
9223 +          break;
9224 +        }
9225 +        case 46:  /* NumberColors */
9226 +          break;
9227 +        case 47:  /* Opaque */
9228 +        {
9229 +          MagickBooleanType
9230 +            invert;
9231 +
9232 +          MagickPixelPacket
9233 +            fill_color,
9234 +            target;
9235 +
9236 +          (void) QueryMagickColor("none",&target,exception);
9237 +          (void) QueryMagickColor("none",&fill_color,exception);
9238 +          if (attribute_flag[0] != 0)
9239 +            (void) QueryMagickColor(argument_list[0].string_reference,
9240 +              &target,exception);
9241 +          if (attribute_flag[1] != 0)
9242 +            (void) QueryMagickColor(argument_list[1].string_reference,
9243 +              &fill_color,exception);
9244 +          if (attribute_flag[2] != 0)
9245 +            image->fuzz=StringToDoubleInterval(
9246 +              argument_list[2].string_reference,(double) QuantumRange+1.0);
9247 +          if (attribute_flag[3] != 0)
9248 +            channel=(ChannelType) argument_list[3].integer_reference;
9249 +          invert=MagickFalse;
9250 +          if (attribute_flag[4] != 0)
9251 +            invert=(MagickBooleanType) argument_list[4].integer_reference;
9252 +          (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
9253 +            invert);
9254 +          break;
9255 +        }
9256 +        case 48:  /* Quantize */
9257 +        {
9258 +          QuantizeInfo
9259 +            *quantize_info;
9260 +
9261 +          quantize_info=AcquireQuantizeInfo(info->image_info);
9262 +          if (attribute_flag[0] != 0)
9263 +            quantize_info->number_colors=(size_t)
9264 +              argument_list[0].integer_reference;
9265 +          if (attribute_flag[1] != 0)
9266 +            quantize_info->tree_depth=(size_t)
9267 +              argument_list[1].integer_reference;
9268 +          if (attribute_flag[2] != 0)
9269 +            quantize_info->colorspace=(ColorspaceType)
9270 +              argument_list[2].integer_reference;
9271 +          if (attribute_flag[3] != 0)
9272 +            quantize_info->dither=argument_list[3].integer_reference != 0 ?
9273 +              MagickTrue : MagickFalse;
9274 +          if (attribute_flag[4] != 0)
9275 +            quantize_info->measure_error=
9276 +              argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9277 +          if (attribute_flag[6] != 0)
9278 +            (void) QueryColorDatabase(argument_list[6].string_reference,
9279 +              &image->transparent_color,exception);
9280 +          if (attribute_flag[7] != 0)
9281 +            quantize_info->dither_method=(DitherMethod)
9282 +              argument_list[7].integer_reference;
9283 +          if (attribute_flag[5] && argument_list[5].integer_reference)
9284 +              (void) QuantizeImages(quantize_info,image);
9285 +          else if ((image->storage_class == DirectClass) ||
9286 +              (image->colors > quantize_info->number_colors) ||
9287 +              (quantize_info->colorspace == GRAYColorspace))
9288 +            (void) QuantizeImage(quantize_info,image);
9289 +          else
9290 +            CompressImageColormap(image);
9291 +          quantize_info=DestroyQuantizeInfo(quantize_info);
9292 +          break;
9293 +        }
9294 +        case 49:  /* Raise */
9295 +        {
9296 +          if (attribute_flag[0] != 0)
9297 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
9298 +              &geometry,exception);
9299 +          if (attribute_flag[1] != 0)
9300 +            geometry.width=argument_list[1].integer_reference;
9301 +          if (attribute_flag[2] != 0)
9302 +            geometry.height=argument_list[2].integer_reference;
9303 +          if (attribute_flag[3] == 0)
9304 +            argument_list[3].integer_reference=1;
9305 +          (void) RaiseImage(image,&geometry,argument_list[3].integer_reference
9306 +            != 0 ? MagickTrue : MagickFalse);
9307 +          break;
9308 +        }
9309 +        case 50:  /* Segment */
9310 +        {
9311 +          ColorspaceType
9312 +            colorspace;
9313 +
9314 +          double
9315 +            cluster_threshold,
9316 +            smoothing_threshold;
9317 +
9318 +          MagickBooleanType
9319 +            verbose;
9320 +
9321 +          cluster_threshold=1.0;
9322 +          smoothing_threshold=1.5;
9323 +          colorspace=sRGBColorspace;
9324 +          verbose=MagickFalse;
9325 +          if (attribute_flag[0] != 0)
9326 +            {
9327 +              flags=ParseGeometry(argument_list[0].string_reference,
9328 +                &geometry_info);
9329 +              cluster_threshold=geometry_info.rho;
9330 +              if (flags & SigmaValue)
9331 +                smoothing_threshold=geometry_info.sigma;
9332 +            }
9333 +          if (attribute_flag[1] != 0)
9334 +            cluster_threshold=argument_list[1].real_reference;
9335 +          if (attribute_flag[2] != 0)
9336 +            smoothing_threshold=argument_list[2].real_reference;
9337 +          if (attribute_flag[3] != 0)
9338 +            colorspace=(ColorspaceType) argument_list[3].integer_reference;
9339 +          if (attribute_flag[4] != 0)
9340 +            verbose=argument_list[4].integer_reference != 0 ?
9341 +              MagickTrue : MagickFalse;
9342 +          (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9343 +            smoothing_threshold);
9344 +          break;
9345 +        }
9346 +        case 51:  /* Signature */
9347 +        {
9348 +          (void) SignatureImage(image);
9349 +          break;
9350 +        }
9351 +        case 52:  /* Solarize */
9352 +        {
9353 +          geometry_info.rho=QuantumRange/2.0;
9354 +          if (attribute_flag[0] != 0)
9355 +            flags=ParseGeometry(argument_list[0].string_reference,
9356 +              &geometry_info);
9357 +          if (attribute_flag[1] != 0)
9358 +            geometry_info.rho=StringToDoubleInterval(
9359 +             argument_list[1].string_reference,(double) QuantumRange+1.0);
9360 +          if (attribute_flag[2] != 0)
9361 +            channel=(ChannelType) argument_list[2].integer_reference;
9362 +          (void) SolarizeImageChannel(image,channel,geometry_info.rho,
9363 +            exception);
9364 +          break;
9365 +        }
9366 +        case 53:  /* Sync */
9367 +        {
9368 +          (void) SyncImage(image);
9369 +          break;
9370 +        }
9371 +        case 54:  /* Texture */
9372 +        {
9373 +          if (attribute_flag[0] == 0)
9374 +            break;
9375 +          TextureImage(image,argument_list[0].image_reference);
9376 +          break;
9377 +        }
9378 +        case 55:  /* Evalute */
9379 +        {
9380 +          MagickEvaluateOperator
9381 +            op;
9382 +
9383 +          op=SetEvaluateOperator;
9384 +          if (attribute_flag[0] == MagickFalse)
9385 +            argument_list[0].real_reference=0.0;
9386 +          if (attribute_flag[1] != MagickFalse)
9387 +            op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9388 +          if (attribute_flag[2] != MagickFalse)
9389 +            channel=(ChannelType) argument_list[2].integer_reference;
9390 +          (void) EvaluateImageChannel(image,channel,op,
9391 +            argument_list[0].real_reference,exception);
9392 +          break;
9393 +        }
9394 +        case 56:  /* Transparent */
9395 +        {
9396 +          double
9397 +            opacity;
9398 +
9399 +          MagickBooleanType
9400 +            invert;
9401 +
9402 +          MagickPixelPacket
9403 +            target;
9404 +
9405 +          (void) QueryMagickColor("none",&target,exception);
9406 +          if (attribute_flag[0] != 0)
9407 +            (void) QueryMagickColor(argument_list[0].string_reference,&target,
9408 +              exception);
9409 +          opacity=TransparentOpacity;
9410 +          if (attribute_flag[1] != 0)
9411 +            opacity=StringToDoubleInterval(argument_list[1].string_reference,
9412 +              (double) QuantumRange+1.0);
9413 +          if (attribute_flag[2] != 0)
9414 +            image->fuzz=StringToDoubleInterval(
9415 +              argument_list[2].string_reference,(double) QuantumRange+1.0);
9416 +          if (attribute_flag[3] == 0)
9417 +            argument_list[3].integer_reference=0;
9418 +          invert=MagickFalse;
9419 +          if (attribute_flag[3] != 0)
9420 +            invert=(MagickBooleanType) argument_list[3].integer_reference;
9421 +          (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9422 +            invert);
9423 +          break;
9424 +        }
9425 +        case 57:  /* Threshold */
9426 +        {
9427 +          double
9428 +            threshold;
9429 +
9430 +          if (attribute_flag[0] == 0)
9431 +            argument_list[0].string_reference="50%";
9432 +          if (attribute_flag[1] != 0)
9433 +            channel=(ChannelType) argument_list[1].integer_reference;
9434 +          threshold=StringToDoubleInterval(argument_list[0].string_reference,
9435 +            (double) QuantumRange+1.0);
9436 +          (void) BilevelImageChannel(image,channel,threshold);
9437 +          break;
9438 +        }
9439 +        case 58:  /* Charcoal */
9440 +        {
9441 +          if (attribute_flag[0] != 0)
9442 +            {
9443 +              flags=ParseGeometry(argument_list[0].string_reference,
9444 +                &geometry_info);
9445 +              if ((flags & SigmaValue) == 0)
9446 +                geometry_info.sigma=1.0;
9447 +            }
9448 +          if (attribute_flag[1] != 0)
9449 +            geometry_info.rho=argument_list[1].real_reference;
9450 +          if (attribute_flag[2] != 0)
9451 +            geometry_info.sigma=argument_list[2].real_reference;
9452 +          image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9453 +            exception);
9454 +          break;
9455 +        }
9456 +        case 59:  /* Trim */
9457 +        {
9458 +          if (attribute_flag[0] != 0)
9459 +            image->fuzz=StringToDoubleInterval(
9460 +              argument_list[0].string_reference,(double) QuantumRange+1.0);
9461 +          image=TrimImage(image,exception);
9462 +          break;
9463 +        }
9464 +        case 60:  /* Wave */
9465 +        {
9466 +          if (attribute_flag[0] != 0)
9467 +            {
9468 +              flags=ParseGeometry(argument_list[0].string_reference,
9469 +                &geometry_info);
9470 +              if ((flags & SigmaValue) == 0)
9471 +                geometry_info.sigma=1.0;
9472 +            }
9473 +          if (attribute_flag[1] != 0)
9474 +            geometry_info.rho=argument_list[1].real_reference;
9475 +          if (attribute_flag[2] != 0)
9476 +            geometry_info.sigma=argument_list[2].real_reference;
9477 +          if (attribute_flag[3] != 0)
9478 +            image->interpolate=(InterpolatePixelMethod)
9479 +              argument_list[3].integer_reference;
9480 +          image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9481 +            exception);
9482 +          break;
9483 +        }
9484 +        case 61:  /* Separate */
9485 +        {
9486 +          if (attribute_flag[0] != 0)
9487 +            channel=(ChannelType) argument_list[0].integer_reference;
9488 +          (void) SeparateImageChannel(image,channel);
9489 +          break;
9490 +        }
9491 +        case 63:  /* Stereo */
9492 +        {
9493 +          if (attribute_flag[0] == 0)
9494 +            {
9495 +              ThrowPerlException(exception,OptionError,"StereoImageRequired",
9496 +                PackageName);
9497 +              goto PerlException;
9498 +            }
9499 +          if (attribute_flag[1] != 0)
9500 +            geometry.x=argument_list[1].integer_reference;
9501 +          if (attribute_flag[2] != 0)
9502 +            geometry.y=argument_list[2].integer_reference;
9503 +          image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9504 +            geometry.x,geometry.y,exception);
9505 +          break;
9506 +        }
9507 +        case 64:  /* Stegano */
9508 +        {
9509 +          if (attribute_flag[0] == 0)
9510 +            {
9511 +              ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9512 +                PackageName);
9513 +              goto PerlException;
9514 +            }
9515 +          if (attribute_flag[1] == 0)
9516 +            argument_list[1].integer_reference=0;
9517 +          image->offset=argument_list[1].integer_reference;
9518 +          image=SteganoImage(image,argument_list[0].image_reference,exception);
9519 +          break;
9520 +        }
9521 +        case 65:  /* Deconstruct */
9522 +        {
9523 +          image=DeconstructImages(image,exception);
9524 +          break;
9525 +        }
9526 +        case 66:  /* GaussianBlur */
9527 +        {
9528 +          if (attribute_flag[0] != 0)
9529 +            {
9530 +              flags=ParseGeometry(argument_list[0].string_reference,
9531 +                &geometry_info);
9532 +              if ((flags & SigmaValue) == 0)
9533 +                geometry_info.sigma=1.0;
9534 +            }
9535 +          if (attribute_flag[1] != 0)
9536 +            geometry_info.rho=argument_list[1].real_reference;
9537 +          if (attribute_flag[2] != 0)
9538 +            geometry_info.sigma=argument_list[2].real_reference;
9539 +          if (attribute_flag[3] != 0)
9540 +            channel=(ChannelType) argument_list[3].integer_reference;
9541 +          image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9542 +            geometry_info.sigma,exception);
9543 +          break;
9544 +        }
9545 +        case 67:  /* Convolve */
9546 +        {
9547 +          AV
9548 +            *av;
9549 +
9550 +          double
9551 +            *kernel;
9552 +
9553 +          size_t
9554 +            order;
9555 +
9556 +          if (attribute_flag[0] == 0)
9557 +            break;
9558 +          if (attribute_flag[1] != 0)
9559 +            channel=(ChannelType) argument_list[1].integer_reference;
9560 +          if (attribute_flag[2] != 0)
9561 +            image->bias=StringToDoubleInterval(
9562 +              argument_list[2].string_reference,(double) QuantumRange+1.0);
9563 +          av=(AV *) argument_list[0].array_reference;
9564 +          order=(size_t) sqrt(av_len(av)+1);
9565 +          kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9566 +          if (kernel == (double *) NULL)
9567 +            {
9568 +              ThrowPerlException(exception,ResourceLimitFatalError,
9569 +                "MemoryAllocationFailed",PackageName);
9570 +              goto PerlException;
9571 +            }
9572 +          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9573 +            kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9574 +          for ( ; j < (ssize_t) (order*order); j++)
9575 +            kernel[j]=0.0;
9576 +          image=ConvolveImageChannel(image,channel,order,kernel,exception);
9577 +          kernel=(double *) RelinquishMagickMemory(kernel);
9578 +          break;
9579 +        }
9580 +        case 68:  /* Profile */
9581 +        {
9582 +          const char
9583 +            *name;
9584 +
9585 +          Image
9586 +            *profile_image;
9587 +
9588 +          ImageInfo
9589 +            *profile_info;
9590 +
9591 +          StringInfo
9592 +            *profile;
9593 +
9594 +          name="*";
9595 +          if (attribute_flag[0] != 0)
9596 +            name=argument_list[0].string_reference;
9597 +          if (attribute_flag[2] != 0)
9598 +            image->rendering_intent=(RenderingIntent)
9599 +              argument_list[2].integer_reference;
9600 +          if (attribute_flag[3] != 0)
9601 +            image->black_point_compensation=
9602 +              argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9603 +          if (attribute_flag[1] != 0)
9604 +            {
9605 +              if (argument_list[1].length == 0)
9606 +                {
9607 +                  /*
9608 +                    Remove a profile from the image.
9609 +                  */
9610 +                  (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9611 +                    MagickTrue);
9612 +                  break;
9613 +                }
9614 +              /*
9615 +                Associate user supplied profile with the image.
9616 +              */
9617 +              profile=AcquireStringInfo(argument_list[1].length);
9618 +              SetStringInfoDatum(profile,(const unsigned char *)
9619 +                argument_list[1].string_reference);
9620 +              (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9621 +                (size_t) GetStringInfoLength(profile),MagickFalse);
9622 +              profile=DestroyStringInfo(profile);
9623 +              break;
9624 +            }
9625 +          /*
9626 +            Associate a profile with the image.
9627 +          */
9628 +          profile_info=
9629 +            CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9630 +          (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9631 +          profile_image=ReadImages(profile_info,&image->exception);
9632 +          if (profile_image == (Image *) NULL)
9633 +            break;
9634 +          ResetImageProfileIterator(profile_image);
9635 +          name=GetNextImageProfile(profile_image);
9636 +          while (name != (const char *) NULL)
9637 +          {
9638 +            const StringInfo
9639 +              *profile;
9640 +
9641 +            profile=GetImageProfile(profile_image,name);
9642 +            if (profile != (const StringInfo *) NULL)
9643 +              (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9644 +                (size_t) GetStringInfoLength(profile),MagickFalse);
9645 +            name=GetNextImageProfile(profile_image);
9646 +          }
9647 +          profile_image=DestroyImage(profile_image);
9648 +          profile_info=DestroyImageInfo(profile_info);
9649 +          break;
9650 +        }
9651 +        case 69:  /* UnsharpMask */
9652 +        {
9653 +          if (attribute_flag[0] != 0)
9654 +            {
9655 +              flags=ParseGeometry(argument_list[0].string_reference,
9656 +                &geometry_info);
9657 +              if ((flags & SigmaValue) == 0)
9658 +                geometry_info.sigma=1.0;
9659 +              if ((flags & XiValue) == 0)
9660 +                geometry_info.xi=1.0;
9661 +              if ((flags & PsiValue) == 0)
9662 +                geometry_info.psi=0.5;
9663 +            }
9664 +          if (attribute_flag[1] != 0)
9665 +            geometry_info.rho=argument_list[1].real_reference;
9666 +          if (attribute_flag[2] != 0)
9667 +            geometry_info.sigma=argument_list[2].real_reference;
9668 +          if (attribute_flag[3] != 0)
9669 +            geometry_info.xi=argument_list[3].real_reference;
9670 +          if (attribute_flag[4] != 0)
9671 +            geometry_info.psi=argument_list[4].real_reference;
9672 +          if (attribute_flag[5] != 0)
9673 +            channel=(ChannelType) argument_list[5].integer_reference;
9674 +          image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9675 +            geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9676 +          break;
9677 +        }
9678 +        case 70:  /* MotionBlur */
9679 +        {
9680 +          if (attribute_flag[0] != 0)
9681 +            {
9682 +              flags=ParseGeometry(argument_list[0].string_reference,
9683 +                &geometry_info);
9684 +              if ((flags & SigmaValue) == 0)
9685 +                geometry_info.sigma=1.0;
9686 +              if ((flags & XiValue) == 0)
9687 +                geometry_info.xi=1.0;
9688 +            }
9689 +          if (attribute_flag[1] != 0)
9690 +            geometry_info.rho=argument_list[1].real_reference;
9691 +          if (attribute_flag[2] != 0)
9692 +            geometry_info.sigma=argument_list[2].real_reference;
9693 +          if (attribute_flag[3] != 0)
9694 +            geometry_info.xi=argument_list[3].real_reference;
9695 +          if (attribute_flag[4] != 0)
9696 +            channel=(ChannelType) argument_list[4].integer_reference;
9697 +          image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9698 +            geometry_info.sigma,geometry_info.xi,exception);
9699 +          break;
9700 +        }
9701 +        case 71:  /* OrderedDither */
9702 +        {
9703 +          if (attribute_flag[0] == 0)
9704 +            argument_list[0].string_reference="o8x8";
9705 +          if (attribute_flag[1] != 0)
9706 +            channel=(ChannelType) argument_list[1].integer_reference;
9707 +          (void) OrderedPosterizeImageChannel(image,channel,
9708 +            argument_list[0].string_reference,exception);
9709 +          break;
9710 +        }
9711 +        case 72:  /* Shave */
9712 +        {
9713 +          if (attribute_flag[0] != 0)
9714 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
9715 +              &geometry,exception);
9716 +          if (attribute_flag[1] != 0)
9717 +            geometry.width=argument_list[1].integer_reference;
9718 +          if (attribute_flag[2] != 0)
9719 +            geometry.height=argument_list[2].integer_reference;
9720 +          image=ShaveImage(image,&geometry,exception);
9721 +          break;
9722 +        }
9723 +        case 73:  /* Level */
9724 +        {
9725 +          double
9726 +            black_point,
9727 +            gamma,
9728 +            white_point;
9729 +
9730 +          black_point=0.0;
9731 +          white_point=(MagickRealType) image->columns*image->rows;
9732 +          gamma=1.0;
9733 +          if (attribute_flag[0] != 0)
9734 +            {
9735 +              flags=ParseGeometry(argument_list[0].string_reference,
9736 +                &geometry_info);
9737 +              black_point=geometry_info.rho;
9738 +              if ((flags & SigmaValue) != 0)
9739 +                white_point=geometry_info.sigma;
9740 +              if ((flags & XiValue) != 0)
9741 +                gamma=geometry_info.xi;
9742 +              if ((flags & PercentValue) != 0)
9743 +                {
9744 +                  black_point*=(double) (QuantumRange/100.0);
9745 +                  white_point*=(double) (QuantumRange/100.0);
9746 +                }
9747 +              if ((flags & SigmaValue) == 0)
9748 +                white_point=(double) QuantumRange-black_point;
9749 +            }
9750 +          if (attribute_flag[1] != 0)
9751 +            black_point=argument_list[1].real_reference;
9752 +          if (attribute_flag[2] != 0)
9753 +            white_point=argument_list[2].real_reference;
9754 +          if (attribute_flag[3] != 0)
9755 +            gamma=argument_list[3].real_reference;
9756 +          if (attribute_flag[4] != 0)
9757 +            channel=(ChannelType) argument_list[4].integer_reference;
9758 +          if (attribute_flag[5] != 0)
9759 +            {
9760 +              argument_list[0].real_reference=argument_list[5].real_reference;
9761 +              attribute_flag[0]=attribute_flag[5];
9762 +            }
9763 +          (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
9764 +          break;
9765 +        }
9766 +        case 74:  /* Clip */
9767 +        {
9768 +          if (attribute_flag[0] == 0)
9769 +            argument_list[0].string_reference="#1";
9770 +          if (attribute_flag[1] == 0)
9771 +            argument_list[1].integer_reference=MagickTrue;
9772 +          (void) ClipImagePath(image,argument_list[0].string_reference,
9773 +            argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9774 +          break;
9775 +        }
9776 +        case 75:  /* AffineTransform */
9777 +        {
9778 +          DrawInfo
9779 +            *draw_info;
9780 +
9781 +          draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9782 +            (DrawInfo *) NULL);
9783 +          if (attribute_flag[0] != 0)
9784 +            {
9785 +              AV
9786 +                *av;
9787 +
9788 +              av=(AV *) argument_list[0].array_reference;
9789 +              if ((av_len(av) != 3) && (av_len(av) != 5))
9790 +                {
9791 +                  ThrowPerlException(exception,OptionError,
9792 +                    "affine matrix must have 4 or 6 elements",PackageName);
9793 +                  goto PerlException;
9794 +                }
9795 +              draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9796 +              draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9797 +              draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9798 +              draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9799 +              if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9800 +                  draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9801 +                {
9802 +                  ThrowPerlException(exception,OptionError,
9803 +                    "affine matrix is singular",PackageName);
9804 +                   goto PerlException;
9805 +                }
9806 +              if (av_len(av) == 5)
9807 +                {
9808 +                  draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9809 +                  draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9810 +                }
9811 +            }
9812 +          for (j=1; j < 6; j++)
9813 +          {
9814 +            if (attribute_flag[j] == 0)
9815 +              continue;
9816 +            value=argument_list[j].string_reference;
9817 +            angle=argument_list[j].real_reference;
9818 +            current=draw_info->affine;
9819 +            GetAffineMatrix(&affine);
9820 +            switch (j)
9821 +            {
9822 +              case 1:
9823 +              {
9824 +                /*
9825 +                  Translate.
9826 +                */
9827 +                flags=ParseGeometry(value,&geometry_info);
9828 +                affine.tx=geometry_info.xi;
9829 +                affine.ty=geometry_info.psi;
9830 +                if ((flags & PsiValue) == 0)
9831 +                  affine.ty=affine.tx;
9832 +                break;
9833 +              }
9834 +              case 2:
9835 +              {
9836 +                /*
9837 +                  Scale.
9838 +                */
9839 +                flags=ParseGeometry(value,&geometry_info);
9840 +                affine.sx=geometry_info.rho;
9841 +                affine.sy=geometry_info.sigma;
9842 +                if ((flags & SigmaValue) == 0)
9843 +                  affine.sy=affine.sx;
9844 +                break;
9845 +              }
9846 +              case 3:
9847 +              {
9848 +                /*
9849 +                  Rotate.
9850 +                */
9851 +                if (angle == 0.0)
9852 +                  break;
9853 +                affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9854 +                affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9855 +                affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9856 +                affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9857 +                break;
9858 +              }
9859 +              case 4:
9860 +              {
9861 +                /*
9862 +                  SkewX.
9863 +                */
9864 +                affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9865 +                break;
9866 +              }
9867 +              case 5:
9868 +              {
9869 +                /*
9870 +                  SkewY.
9871 +                */
9872 +                affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9873 +                break;
9874 +              }
9875 +            }
9876 +            draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9877 +            draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9878 +            draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9879 +            draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9880 +            draw_info->affine.tx=
9881 +              current.sx*affine.tx+current.ry*affine.ty+current.tx;
9882 +            draw_info->affine.ty=
9883 +              current.rx*affine.tx+current.sy*affine.ty+current.ty;
9884 +          }
9885 +          if (attribute_flag[6] != 0)
9886 +            image->interpolate=(InterpolatePixelMethod)
9887 +              argument_list[6].integer_reference;
9888 +          if (attribute_flag[7] != 0)
9889 +            QueryColorDatabase(argument_list[7].string_reference,
9890 +              &image->background_color,exception);
9891 +          image=AffineTransformImage(image,&draw_info->affine,exception);
9892 +          draw_info=DestroyDrawInfo(draw_info);
9893 +          break;
9894 +        }
9895 +        case 76:  /* Difference */
9896 +        {
9897 +          if (attribute_flag[0] == 0)
9898 +            {
9899 +              ThrowPerlException(exception,OptionError,
9900 +                "ReferenceImageRequired",PackageName);
9901 +              goto PerlException;
9902 +            }
9903 +          if (attribute_flag[1] != 0)
9904 +            image->fuzz=StringToDoubleInterval(
9905 +              argument_list[1].string_reference,(double) QuantumRange+1.0);
9906 +          (void) IsImagesEqual(image,argument_list[0].image_reference);
9907 +          break;
9908 +        }
9909 +        case 77:  /* AdaptiveThreshold */
9910 +        {
9911 +          if (attribute_flag[0] != 0)
9912 +            {
9913 +              flags=ParseGeometry(argument_list[0].string_reference,
9914 +                &geometry_info);
9915 +              if ((flags & PercentValue) != 0)
9916 +                geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9917 +            }
9918 +          if (attribute_flag[1] != 0)
9919 +            geometry_info.rho=argument_list[1].integer_reference;
9920 +          if (attribute_flag[2] != 0)
9921 +            geometry_info.sigma=argument_list[2].integer_reference;
9922 +          if (attribute_flag[3] != 0)
9923 +            geometry_info.xi=argument_list[3].integer_reference;;
9924 +          image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9925 +            (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9926 +            exception);
9927 +          break;
9928 +        }
9929 +        case 78:  /* Resample */
9930 +        {
9931 +          size_t
9932 +            height,
9933 +            width;
9934 +
9935 +          if (attribute_flag[0] != 0)
9936 +            {
9937 +              flags=ParseGeometry(argument_list[0].string_reference,
9938 +                &geometry_info);
9939 +              if ((flags & SigmaValue) == 0)
9940 +                geometry_info.sigma=geometry_info.rho;
9941 +            }
9942 +          if (attribute_flag[1] != 0)
9943 +            geometry_info.rho=argument_list[1].real_reference;
9944 +          if (attribute_flag[2] != 0)
9945 +            geometry_info.sigma=argument_list[2].real_reference;
9946 +          if (attribute_flag[3] == 0)
9947 +            argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9948 +          if (attribute_flag[4] == 0)
9949 +            SetImageArtifact(image,"filter:support",
9950 +              argument_list[4].string_reference);
9951 +          if (attribute_flag[5] != 0)
9952 +            argument_list[5].real_reference=1.0;
9953 +          width=(size_t) (geometry_info.rho*image->columns/
9954 +            (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9955 +          height=(size_t) (geometry_info.sigma*image->rows/
9956 +            (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9957 +          image=ResizeImage(image,width,height,(FilterTypes)
9958 +            argument_list[3].integer_reference,argument_list[5].real_reference,
9959 +            exception);
9960 +          if (image != (Image *) NULL)
9961 +            {
9962 +              image->x_resolution=geometry_info.rho;
9963 +              image->y_resolution=geometry_info.sigma;
9964 +            }
9965 +          break;
9966 +        }
9967 +        case 79:  /* Describe */
9968 +        {
9969 +          if (attribute_flag[0] == 0)
9970 +            argument_list[0].file_reference=(FILE *) NULL;
9971 +          if (attribute_flag[1] != 0)
9972 +            (void) SetImageArtifact(image,"identify:features",
9973 +              argument_list[1].string_reference);
9974 +          (void) IdentifyImage(image,argument_list[0].file_reference,
9975 +            MagickTrue);
9976 +          break;
9977 +        }
9978 +        case 80:  /* BlackThreshold */
9979 +        {
9980 +          if (attribute_flag[0] == 0)
9981 +            argument_list[0].string_reference="50%";
9982 +          if (attribute_flag[2] != 0)
9983 +            channel=(ChannelType) argument_list[2].integer_reference;
9984 +          BlackThresholdImageChannel(image,channel,
9985 +            argument_list[0].string_reference,exception);
9986 +          break;
9987 +        }
9988 +        case 81:  /* WhiteThreshold */
9989 +        {
9990 +          if (attribute_flag[0] == 0)
9991 +            argument_list[0].string_reference="50%";
9992 +          if (attribute_flag[2] != 0)
9993 +            channel=(ChannelType) argument_list[2].integer_reference;
9994 +          WhiteThresholdImageChannel(image,channel,
9995 +            argument_list[0].string_reference,exception);
9996 +          break;
9997 +        }
9998 +        case 82:  /* RotationalBlur */
9999 +        {
10000 +          if (attribute_flag[0] != 0)
10001 +            {
10002 +              flags=ParseGeometry(argument_list[0].string_reference,
10003 +                &geometry_info);
10004 +              if ((flags & SigmaValue) == 0)
10005 +                geometry_info.sigma=1.0;
10006 +            }
10007 +          if (attribute_flag[1] != 0)
10008 +            geometry_info.rho=argument_list[1].real_reference;
10009 +          if (attribute_flag[2] != 0)
10010 +            channel=(ChannelType) argument_list[2].integer_reference;
10011 +          image=RotationalBlurImageChannel(image,channel,geometry_info.rho,
10012 +            exception);
10013 +          break;
10014 +        }
10015 +        case 83:  /* Thumbnail */
10016 +        {
10017 +          if (attribute_flag[0] != 0)
10018 +            flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10019 +              &geometry,exception);
10020 +          if (attribute_flag[1] != 0)
10021 +            geometry.width=argument_list[1].integer_reference;
10022 +          if (attribute_flag[2] != 0)
10023 +            geometry.height=argument_list[2].integer_reference;
10024 +          image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10025 +          break;
10026 +        }
10027 +        case 84:  /* Strip */
10028 +        {
10029 +          (void) StripImage(image);
10030 +          break;
10031 +        }
10032 +        case 85:  /* Tint */
10033 +        {
10034 +          PixelPacket
10035 +            target;
10036 +
10037 +          (void) GetOneVirtualPixel(image,0,0,&target,exception);
10038 +          if (attribute_flag[0] != 0)
10039 +            (void) QueryColorDatabase(argument_list[0].string_reference,&target,
10040 +              exception);
10041 +          if (attribute_flag[1] == 0)
10042 +            argument_list[1].string_reference="100";
10043 +          image=TintImage(image,argument_list[1].string_reference,target,
10044 +            exception);
10045 +          break;
10046 +        }
10047 +        case 86:  /* Channel */
10048 +        {
10049 +          if (attribute_flag[0] != 0)
10050 +            channel=(ChannelType) argument_list[0].integer_reference;
10051 +          (void) SeparateImageChannel(image,channel);
10052 +          break;
10053 +        }
10054 +        case 87:  /* Splice */
10055 +        {
10056 +          if (attribute_flag[7] != 0)
10057 +            image->gravity=(GravityType) argument_list[7].integer_reference;
10058 +          if (attribute_flag[0] != 0)
10059 +            flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10060 +              &geometry,exception);
10061 +          if (attribute_flag[1] != 0)
10062 +            geometry.width=argument_list[1].integer_reference;
10063 +          if (attribute_flag[2] != 0)
10064 +            geometry.height=argument_list[2].integer_reference;
10065 +          if (attribute_flag[3] != 0)
10066 +            geometry.x=argument_list[3].integer_reference;
10067 +          if (attribute_flag[4] != 0)
10068 +            geometry.y=argument_list[4].integer_reference;
10069 +          if (attribute_flag[5] != 0)
10070 +            image->fuzz=StringToDoubleInterval(
10071 +              argument_list[5].string_reference,(double) QuantumRange+1.0);
10072 +          if (attribute_flag[6] != 0)
10073 +            (void) QueryColorDatabase(argument_list[6].string_reference,
10074 +              &image->background_color,exception);
10075 +          image=SpliceImage(image,&geometry,exception);
10076 +          break;
10077 +        }
10078 +        case 88:  /* Posterize */
10079 +        {
10080 +          if (attribute_flag[0] == 0)
10081 +            argument_list[0].integer_reference=3;
10082 +          if (attribute_flag[1] == 0)
10083 +            argument_list[1].integer_reference=0;
10084 +          (void) PosterizeImage(image,argument_list[0].integer_reference,
10085 +            argument_list[1].integer_reference ? MagickTrue : MagickFalse);
10086 +          break;
10087 +        }
10088 +        case 89:  /* Shadow */
10089 +        {
10090 +          if (attribute_flag[0] != 0)
10091 +            {
10092 +              flags=ParseGeometry(argument_list[0].string_reference,
10093 +                &geometry_info);
10094 +              if ((flags & SigmaValue) == 0)
10095 +                geometry_info.sigma=1.0;
10096 +              if ((flags & XiValue) == 0)
10097 +                geometry_info.xi=4.0;
10098 +              if ((flags & PsiValue) == 0)
10099 +                geometry_info.psi=4.0;
10100 +            }
10101 +          if (attribute_flag[1] != 0)
10102 +            geometry_info.rho=argument_list[1].real_reference;
10103 +          if (attribute_flag[2] != 0)
10104 +            geometry_info.sigma=argument_list[2].real_reference;
10105 +          if (attribute_flag[3] != 0)
10106 +            geometry_info.xi=argument_list[3].integer_reference;
10107 +          if (attribute_flag[4] != 0)
10108 +            geometry_info.psi=argument_list[4].integer_reference;
10109 +          image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10110 +            (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
10111 +            0.5),exception);
10112 +          break;
10113 +        }
10114 +        case 90:  /* Identify */
10115 +        {
10116 +          if (attribute_flag[0] == 0)
10117 +            argument_list[0].file_reference=(FILE *) NULL;
10118 +          if (attribute_flag[1] != 0)
10119 +            (void) SetImageArtifact(image,"identify:features",
10120 +              argument_list[1].string_reference);
10121 +          if ((attribute_flag[2] != 0) &&
10122 +              (argument_list[2].integer_reference != 0))
10123 +            (void) SetImageArtifact(image,"identify:unique","true");
10124 +          (void) IdentifyImage(image,argument_list[0].file_reference,
10125 +            MagickTrue);
10126 +          break;
10127 +        }
10128 +        case 91:  /* SepiaTone */
10129 +        {
10130 +          if (attribute_flag[0] == 0)
10131 +            argument_list[0].real_reference=80.0*QuantumRange/100.0;
10132 +          image=SepiaToneImage(image,argument_list[0].real_reference,
10133 +            exception);
10134 +          break;
10135 +        }
10136 +        case 92:  /* SigmoidalContrast */
10137 +        {
10138 +          MagickBooleanType
10139 +            sharpen;
10140 +
10141 +          if (attribute_flag[0] != 0)
10142 +            {
10143 +              flags=ParseGeometry(argument_list[0].string_reference,
10144 +                &geometry_info);
10145 +              if ((flags & SigmaValue) == 0)
10146 +                geometry_info.sigma=QuantumRange/2.0;
10147 +              if ((flags & PercentValue) != 0)
10148 +                geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10149 +            }
10150 +          if (attribute_flag[1] != 0)
10151 +            geometry_info.rho=argument_list[1].real_reference;
10152 +          if (attribute_flag[2] != 0)
10153 +            geometry_info.sigma=argument_list[2].real_reference;
10154 +          if (attribute_flag[3] != 0)
10155 +            channel=(ChannelType) argument_list[3].integer_reference;
10156 +          sharpen=MagickTrue;
10157 +          if (attribute_flag[4] != 0)
10158 +            sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10159 +              MagickFalse;
10160 +          (void) SigmoidalContrastImageChannel(image,channel,sharpen,
10161 +            geometry_info.rho,geometry_info.sigma);
10162 +          break;
10163 +        }
10164 +        case 93:  /* Extent */
10165 +        {
10166 +          if (attribute_flag[7] != 0)
10167 +            image->gravity=(GravityType) argument_list[7].integer_reference;
10168 +          if (attribute_flag[0] != 0)
10169 +            {
10170 +              int
10171 +                flags;
10172 +
10173 +              flags=ParseGravityGeometry(image,
10174 +                argument_list[0].string_reference,&geometry,exception);
10175 +              (void) flags;
10176 +              if (geometry.width == 0)
10177 +                geometry.width=image->columns;
10178 +              if (geometry.height == 0)
10179 +                geometry.height=image->rows;
10180 +            }
10181 +          if (attribute_flag[1] != 0)
10182 +            geometry.width=argument_list[1].integer_reference;
10183 +          if (attribute_flag[2] != 0)
10184 +            geometry.height=argument_list[2].integer_reference;
10185 +          if (attribute_flag[3] != 0)
10186 +            geometry.x=argument_list[3].integer_reference;
10187 +          if (attribute_flag[4] != 0)
10188 +            geometry.y=argument_list[4].integer_reference;
10189 +          if (attribute_flag[5] != 0)
10190 +            image->fuzz=StringToDoubleInterval(
10191 +              argument_list[5].string_reference,(double) QuantumRange+1.0);
10192 +          if (attribute_flag[6] != 0)
10193 +            (void) QueryColorDatabase(argument_list[6].string_reference,
10194 +              &image->background_color,exception);
10195 +          image=ExtentImage(image,&geometry,exception);
10196 +          break;
10197 +        }
10198 +        case 94:  /* Vignette */
10199 +        {
10200 +          if (attribute_flag[0] != 0)
10201 +            {
10202 +              flags=ParseGeometry(argument_list[0].string_reference,
10203 +                &geometry_info);
10204 +              if ((flags & SigmaValue) == 0)
10205 +                geometry_info.sigma=1.0;
10206 +              if ((flags & XiValue) == 0)
10207 +                geometry_info.xi=0.1*image->columns;
10208 +              if ((flags & PsiValue) == 0)
10209 +                geometry_info.psi=0.1*image->rows;
10210 +            }
10211 +          if (attribute_flag[1] != 0)
10212 +            geometry_info.rho=argument_list[1].real_reference;
10213 +          if (attribute_flag[2] != 0)
10214 +            geometry_info.sigma=argument_list[2].real_reference;
10215 +          if (attribute_flag[3] != 0)
10216 +            geometry_info.xi=argument_list[3].integer_reference;
10217 +          if (attribute_flag[4] != 0)
10218 +            geometry_info.psi=argument_list[4].integer_reference;
10219 +          if (attribute_flag[5] != 0)
10220 +            (void) QueryColorDatabase(argument_list[5].string_reference,
10221 +              &image->background_color,exception);
10222 +          image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10223 +            (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
10224 +            0.5),exception);
10225 +          break;
10226 +        }
10227 +        case 95:  /* ContrastStretch */
10228 +        {
10229 +          double
10230 +            black_point,
10231 +            white_point;
10232 +
10233 +          black_point=0.0;
10234 +          white_point=(MagickRealType) image->columns*image->rows;
10235 +          if (attribute_flag[0] != 0)
10236 +            {
10237 +              flags=ParseGeometry(argument_list[0].string_reference,
10238 +                &geometry_info);
10239 +              black_point=geometry_info.rho;
10240 +              white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10241 +                black_point;
10242 +              if ((flags & PercentValue) != 0)
10243 +                {
10244 +                  black_point*=(double) image->columns*image->rows/100.0;
10245 +                  white_point*=(double) image->columns*image->rows/100.0;
10246 +                }
10247 +              white_point=(MagickRealType) image->columns*image->rows-
10248 +                white_point;
10249 +            }
10250 +          if (attribute_flag[1] != 0)
10251 +            black_point=argument_list[1].real_reference;
10252 +          if (attribute_flag[2] != 0)
10253 +            white_point=argument_list[2].real_reference;
10254 +          if (attribute_flag[4] != 0)
10255 +            channel=(ChannelType) argument_list[4].integer_reference;
10256 +          (void) ContrastStretchImageChannel(image,channel,black_point,
10257 +            white_point);
10258 +          break;
10259 +        }
10260 +        case 96:  /* Sans0 */
10261 +        {
10262 +          break;
10263 +        }
10264 +        case 97:  /* Sans1 */
10265 +        {
10266 +          break;
10267 +        }
10268 +        case 98:  /* AdaptiveSharpen */
10269 +        {
10270 +          if (attribute_flag[0] != 0)
10271 +            {
10272 +              flags=ParseGeometry(argument_list[0].string_reference,
10273 +                &geometry_info);
10274 +              if ((flags & SigmaValue) == 0)
10275 +                geometry_info.sigma=1.0;
10276 +            }
10277 +          if (attribute_flag[1] != 0)
10278 +            geometry_info.rho=argument_list[1].real_reference;
10279 +          if (attribute_flag[2] != 0)
10280 +            geometry_info.sigma=argument_list[2].real_reference;
10281 +          if (attribute_flag[3] != 0)
10282 +            channel=(ChannelType) argument_list[3].integer_reference;
10283 +          image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
10284 +            geometry_info.sigma,exception);
10285 +          break;
10286 +        }
10287 +        case 99:  /* Transpose */
10288 +        {
10289 +          image=TransposeImage(image,exception);
10290 +          break;
10291 +        }
10292 +        case 100:  /* Tranverse */
10293 +        {
10294 +          image=TransverseImage(image,exception);
10295 +          break;
10296 +        }
10297 +        case 101:  /* AutoOrient */
10298 +        {
10299 +          image=AutoOrientImage(image,image->orientation,exception);
10300 +          break;
10301 +        }
10302 +        case 102:  /* AdaptiveBlur */
10303 +        {
10304 +          if (attribute_flag[0] != 0)
10305 +            {
10306 +              flags=ParseGeometry(argument_list[0].string_reference,
10307 +                &geometry_info);
10308 +              if ((flags & SigmaValue) == 0)
10309 +                geometry_info.sigma=1.0;
10310 +            }
10311 +          if (attribute_flag[1] != 0)
10312 +            geometry_info.rho=argument_list[1].real_reference;
10313 +          if (attribute_flag[2] != 0)
10314 +            geometry_info.sigma=argument_list[2].real_reference;
10315 +          if (attribute_flag[3] != 0)
10316 +            channel=(ChannelType) argument_list[3].integer_reference;
10317 +          image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
10318 +            geometry_info.sigma,exception);
10319 +          break;
10320 +        }
10321 +        case 103:  /* Sketch */
10322 +        {
10323 +          if (attribute_flag[0] != 0)
10324 +            {
10325 +              flags=ParseGeometry(argument_list[0].string_reference,
10326 +                &geometry_info);
10327 +              if ((flags & SigmaValue) == 0)
10328 +                geometry_info.sigma=1.0;
10329 +              if ((flags & XiValue) == 0)
10330 +                geometry_info.xi=1.0;
10331 +            }
10332 +          if (attribute_flag[1] != 0)
10333 +            geometry_info.rho=argument_list[1].real_reference;
10334 +          if (attribute_flag[2] != 0)
10335 +            geometry_info.sigma=argument_list[2].real_reference;
10336 +          if (attribute_flag[3] != 0)
10337 +            geometry_info.xi=argument_list[3].real_reference;
10338 +          image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10339 +            geometry_info.xi,exception);
10340 +          break;
10341 +        }
10342 +        case 104:  /* UniqueColors */
10343 +        {
10344 +          image=UniqueImageColors(image,exception);
10345 +          break;
10346 +        }
10347 +        case 105:  /* AdaptiveResize */
10348 +        {
10349 +          if (attribute_flag[0] != 0)
10350 +            flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10351 +              &geometry,exception);
10352 +          if (attribute_flag[1] != 0)
10353 +            geometry.width=argument_list[1].integer_reference;
10354 +          if (attribute_flag[2] != 0)
10355 +            geometry.height=argument_list[2].integer_reference;
10356 +          if (attribute_flag[3] != 0)
10357 +            image->filter=(FilterTypes) argument_list[4].integer_reference;
10358 +          if (attribute_flag[4] != 0)
10359 +            SetImageArtifact(image,"filter:support",
10360 +              argument_list[4].string_reference);
10361 +          if (attribute_flag[5] != 0)
10362 +            image->blur=argument_list[5].real_reference;
10363 +          image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10364 +            exception);
10365 +          break;
10366 +        }
10367 +        case 106:  /* ClipMask */
10368 +        {
10369 +          if (attribute_flag[0] == 0)
10370 +            {
10371 +              ThrowPerlException(exception,OptionError,"MaskImageRequired",
10372 +                PackageName);
10373 +              goto PerlException;
10374 +            }
10375 +          image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10376 +            MagickTrue,exception);
10377 +          (void) NegateImage(image->clip_mask,MagickFalse);
10378 +          break;
10379 +        }
10380 +        case 107:  /* LinearStretch */
10381 +        {
10382 +           double
10383 +             black_point,
10384 +             white_point;
10385 +
10386 +           black_point=0.0;
10387 +           white_point=(MagickRealType) image->columns*image->rows;
10388 +           if (attribute_flag[0] != 0)
10389 +             {
10390 +               flags=ParseGeometry(argument_list[0].string_reference,
10391 +                 &geometry_info);
10392 +               if ((flags & SigmaValue) != 0)
10393 +                  white_point=geometry_info.sigma;
10394 +               if ((flags & PercentValue) != 0)
10395 +                 {
10396 +                   black_point*=(double) image->columns*image->rows/100.0;
10397 +                   white_point*=(double) image->columns*image->rows/100.0;
10398 +                 }
10399 +               if ((flags & SigmaValue) == 0)
10400 +                 white_point=(double) image->columns*image->rows-black_point;
10401 +             }
10402 +          if (attribute_flag[1] != 0)
10403 +            black_point=argument_list[1].real_reference;
10404 +          if (attribute_flag[2] != 0)
10405 +            white_point=argument_list[2].real_reference;
10406 +          (void) LinearStretchImage(image,black_point,white_point);
10407 +          break;
10408 +        }
10409 +        case 109:  /* Mask */
10410 +        {
10411 +          if (attribute_flag[0] == 0)
10412 +            {
10413 +              ThrowPerlException(exception,OptionError,"MaskImageRequired",
10414 +                PackageName);
10415 +              goto PerlException;
10416 +            }
10417 +          image->mask=CloneImage(argument_list[0].image_reference,0,0,
10418 +            MagickTrue,exception);
10419 +          (void) NegateImage(image->mask,MagickFalse);
10420 +          break;
10421 +        }
10422 +        case 110:  /* Polaroid */
10423 +        {
10424 +          DrawInfo
10425 +            *draw_info;
10426 +
10427 +          double
10428 +            angle;
10429 +
10430 +          draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10431 +            (DrawInfo *) NULL);
10432 +          if (attribute_flag[0] != 0)
10433 +            (void) SetImageProperty(image,"caption",InterpretImageProperties(
10434 +              info ? info->image_info : (ImageInfo *) NULL,image,
10435 +              argument_list[0].string_reference));
10436 +          angle=0.0;
10437 +          if (attribute_flag[1] != 0)
10438 +            angle=argument_list[1].real_reference;
10439 +          if (attribute_flag[2] != 0)
10440 +            (void) CloneString(&draw_info->font,
10441 +              argument_list[2].string_reference);
10442 +          if (attribute_flag[3] != 0)
10443 +            (void) QueryColorDatabase(argument_list[3].string_reference,
10444 +              &draw_info->stroke,exception);
10445 +          if (attribute_flag[4] != 0)
10446 +            (void) QueryColorDatabase(argument_list[4].string_reference,
10447 +              &draw_info->fill,exception);
10448 +          if (attribute_flag[5] != 0)
10449 +            draw_info->stroke_width=argument_list[5].real_reference;
10450 +          if (attribute_flag[6] != 0)
10451 +            draw_info->pointsize=argument_list[6].real_reference;
10452 +          if (attribute_flag[7] != 0)
10453 +            draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10454 +          if (attribute_flag[8] != 0)
10455 +            (void) QueryColorDatabase(argument_list[8].string_reference,
10456 +              &image->background_color,exception);
10457 +          image=PolaroidImage(image,draw_info,angle,exception);
10458 +          draw_info=DestroyDrawInfo(draw_info);
10459 +          break;
10460 +        }
10461 +        case 111:  /* FloodfillPaint */
10462 +        {
10463 +          DrawInfo
10464 +            *draw_info;
10465 +
10466 +          MagickBooleanType
10467 +            invert;
10468 +
10469 +          MagickPixelPacket
10470 +            target;
10471 +
10472 +          draw_info=CloneDrawInfo(info ? info->image_info :
10473 +            (ImageInfo *) NULL,(DrawInfo *) NULL);
10474 +          if (attribute_flag[0] != 0)
10475 +            flags=ParsePageGeometry(image,argument_list[0].string_reference,
10476 +              &geometry,exception);
10477 +          if (attribute_flag[1] != 0)
10478 +            geometry.x=argument_list[1].integer_reference;
10479 +          if (attribute_flag[2] != 0)
10480 +            geometry.y=argument_list[2].integer_reference;
10481 +          if (attribute_flag[3] != 0)
10482 +            (void) QueryColorDatabase(argument_list[3].string_reference,
10483 +              &draw_info->fill,exception);
10484 +          (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10485 +            exception);
10486 +          if (attribute_flag[4] != 0)
10487 +            QueryMagickColor(argument_list[4].string_reference,&target,
10488 +              exception);
10489 +          if (attribute_flag[5] != 0)
10490 +            image->fuzz=StringToDoubleInterval(
10491 +              argument_list[5].string_reference,(double) QuantumRange+1.0);
10492 +          if (attribute_flag[6] != 0)
10493 +            channel=(ChannelType) argument_list[6].integer_reference;
10494 +          invert=MagickFalse;
10495 +          if (attribute_flag[7] != 0)
10496 +            invert=(MagickBooleanType) argument_list[7].integer_reference;
10497 +          (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10498 +            geometry.y,invert);
10499 +          draw_info=DestroyDrawInfo(draw_info);
10500 +          break;
10501 +        }
10502 +        case 112:  /* Distort */
10503 +        {
10504 +          AV
10505 +            *av;
10506 +
10507 +          double
10508 +            *coordinates;
10509 +
10510 +          DistortImageMethod
10511 +            method;
10512 +
10513 +          size_t
10514 +            number_coordinates;
10515 +
10516 +          VirtualPixelMethod
10517 +            virtual_pixel;
10518 +
10519 +          if (attribute_flag[0] == 0)
10520 +            break;
10521 +          method=UndefinedDistortion;
10522 +          if (attribute_flag[1] != 0)
10523 +            method=(DistortImageMethod) argument_list[1].integer_reference;
10524 +          av=(AV *) argument_list[0].array_reference;
10525 +          number_coordinates=(size_t) av_len(av)+1;
10526 +          coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10527 +            sizeof(*coordinates));
10528 +          if (coordinates == (double *) NULL)
10529 +            {
10530 +              ThrowPerlException(exception,ResourceLimitFatalError,
10531 +                "MemoryAllocationFailed",PackageName);
10532 +              goto PerlException;
10533 +            }
10534 +          for (j=0; j < (ssize_t) number_coordinates; j++)
10535 +            coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10536 +          virtual_pixel=UndefinedVirtualPixelMethod;
10537 +          if (attribute_flag[2] != 0)
10538 +            virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10539 +              argument_list[2].integer_reference);
10540 +          image=DistortImage(image,method,number_coordinates,coordinates,
10541 +            argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10542 +            exception);
10543 +          if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10544 +            virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10545 +          coordinates=(double *) RelinquishMagickMemory(coordinates);
10546 +          break;
10547 +        }
10548 +        case 113:  /* Clut */
10549 +        {
10550 +          if (attribute_flag[0] == 0)
10551 +            {
10552 +              ThrowPerlException(exception,OptionError,"ClutImageRequired",
10553 +                PackageName);
10554 +              goto PerlException;
10555 +            }
10556 +          if (attribute_flag[1] != 0)
10557 +            channel=(ChannelType) argument_list[1].integer_reference;
10558 +          (void) ClutImageChannel(image,channel,
10559 +            argument_list[0].image_reference);
10560 +          break;
10561 +        }
10562 +        case 114:  /* LiquidRescale */
10563 +        {
10564 +          if (attribute_flag[0] != 0)
10565 +            flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10566 +              &geometry,exception);
10567 +          if (attribute_flag[1] != 0)
10568 +            geometry.width=argument_list[1].integer_reference;
10569 +          if (attribute_flag[2] != 0)
10570 +            geometry.height=argument_list[2].integer_reference;
10571 +          if (attribute_flag[3] == 0)
10572 +            argument_list[3].real_reference=1.0;
10573 +          if (attribute_flag[4] == 0)
10574 +            argument_list[4].real_reference=0.0;
10575 +          image=LiquidRescaleImage(image,geometry.width,geometry.height,
10576 +            argument_list[3].real_reference,argument_list[4].real_reference,
10577 +            exception);
10578 +          break;
10579 +        }
10580 +        case 115:  /* EncipherImage */
10581 +        {
10582 +          (void) EncipherImage(image,argument_list[0].string_reference,
10583 +            exception);
10584 +          break;
10585 +        }
10586 +        case 116:  /* DecipherImage */
10587 +        {
10588 +          (void) DecipherImage(image,argument_list[0].string_reference,
10589 +            exception);
10590 +          break;
10591 +        }
10592 +        case 117:  /* Deskew */
10593 +        {
10594 +          geometry_info.rho=QuantumRange/2.0;
10595 +          if (attribute_flag[0] != 0)
10596 +            flags=ParseGeometry(argument_list[0].string_reference,
10597 +              &geometry_info);
10598 +          if (attribute_flag[1] != 0)
10599 +            geometry_info.rho=StringToDoubleInterval(
10600 +              argument_list[1].string_reference,(double) QuantumRange+1.0);
10601 +          image=DeskewImage(image,geometry_info.rho,exception);
10602 +          break;
10603 +        }
10604 +        case 118:  /* Remap */
10605 +        {
10606 +          QuantizeInfo
10607 +            *quantize_info;
10608 +
10609 +          if (attribute_flag[0] == 0)
10610 +            {
10611 +              ThrowPerlException(exception,OptionError,"RemapImageRequired",
10612 +                PackageName);
10613 +              goto PerlException;
10614 +            }
10615 +          quantize_info=AcquireQuantizeInfo(info->image_info);
10616 +          if (attribute_flag[1] != 0)
10617 +            quantize_info->dither=(MagickBooleanType)
10618 +              argument_list[1].integer_reference;
10619 +          if (attribute_flag[2] != 0)
10620 +            quantize_info->dither_method=(DitherMethod)
10621 +              argument_list[2].integer_reference;
10622 +          (void) RemapImages(quantize_info,image,
10623 +            argument_list[0].image_reference);
10624 +          quantize_info=DestroyQuantizeInfo(quantize_info);
10625 +          break;
10626 +        }
10627 +        case 119:  /* SparseColor */
10628 +        {
10629 +          AV
10630 +            *av;
10631 +
10632 +          double
10633 +            *coordinates;
10634 +
10635 +          SparseColorMethod
10636 +            method;
10637 +
10638 +          size_t
10639 +            number_coordinates;
10640 +
10641 +          VirtualPixelMethod
10642 +            virtual_pixel;
10643 +
10644 +          if (attribute_flag[0] == 0)
10645 +            break;
10646 +          method=UndefinedColorInterpolate;
10647 +          if (attribute_flag[1] != 0)
10648 +            method=(SparseColorMethod) argument_list[1].integer_reference;
10649 +          av=(AV *) argument_list[0].array_reference;
10650 +          number_coordinates=(size_t) av_len(av)+1;
10651 +          coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10652 +            sizeof(*coordinates));
10653 +          if (coordinates == (double *) NULL)
10654 +            {
10655 +              ThrowPerlException(exception,ResourceLimitFatalError,
10656 +                "MemoryAllocationFailed",PackageName);
10657 +              goto PerlException;
10658 +            }
10659 +          for (j=0; j < (ssize_t) number_coordinates; j++)
10660 +            coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10661 +          virtual_pixel=UndefinedVirtualPixelMethod;
10662 +          if (attribute_flag[2] != 0)
10663 +            virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10664 +              argument_list[2].integer_reference);
10665 +          if (attribute_flag[3] != 0)
10666 +            channel=(ChannelType) argument_list[3].integer_reference;
10667 +          image=SparseColorImage(image,channel,method,number_coordinates,
10668 +            coordinates,exception);
10669 +          if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10670 +            virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10671 +          coordinates=(double *) RelinquishMagickMemory(coordinates);
10672 +          break;
10673 +        }
10674 +        case 120:  /* Function */
10675 +        {
10676 +          AV
10677 +            *av;
10678 +
10679 +          double
10680 +            *parameters;
10681 +
10682 +          MagickFunction
10683 +            function;
10684 +
10685 +          size_t
10686 +            number_parameters;
10687 +
10688 +          VirtualPixelMethod
10689 +            virtual_pixel;
10690 +
10691 +          if (attribute_flag[0] == 0)
10692 +            break;
10693 +          function=UndefinedFunction;
10694 +          if (attribute_flag[1] != 0)
10695 +            function=(MagickFunction) argument_list[1].integer_reference;
10696 +          av=(AV *) argument_list[0].array_reference;
10697 +          number_parameters=(size_t) av_len(av)+1;
10698 +          parameters=(double *) AcquireQuantumMemory(number_parameters,
10699 +            sizeof(*parameters));
10700 +          if (parameters == (double *) NULL)
10701 +            {
10702 +              ThrowPerlException(exception,ResourceLimitFatalError,
10703 +                "MemoryAllocationFailed",PackageName);
10704 +              goto PerlException;
10705 +            }
10706 +          for (j=0; j < (ssize_t) number_parameters; j++)
10707 +            parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10708 +          virtual_pixel=UndefinedVirtualPixelMethod;
10709 +          if (attribute_flag[2] != 0)
10710 +            virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10711 +              argument_list[2].integer_reference);
10712 +          (void) FunctionImage(image,function,number_parameters,parameters,
10713 +            exception);
10714 +          if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10715 +            virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10716 +          parameters=(double *) RelinquishMagickMemory(parameters);
10717 +          break;
10718 +        }
10719 +        case 121:  /* SelectiveBlur */
10720 +        {
10721 +          if (attribute_flag[0] != 0)
10722 +            {
10723 +              flags=ParseGeometry(argument_list[0].string_reference,
10724 +                &geometry_info);
10725 +              if ((flags & SigmaValue) == 0)
10726 +                geometry_info.sigma=1.0;
10727 +              if ((flags & PercentValue) != 0)
10728 +                geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10729 +            }
10730 +          if (attribute_flag[1] != 0)
10731 +            geometry_info.rho=argument_list[1].real_reference;
10732 +          if (attribute_flag[2] != 0)
10733 +            geometry_info.sigma=argument_list[2].real_reference;
10734 +          if (attribute_flag[3] != 0)
10735 +            geometry_info.xi=argument_list[3].integer_reference;;
10736 +          if (attribute_flag[4] != 0)
10737 +            channel=(ChannelType) argument_list[4].integer_reference;
10738 +          image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10739 +            geometry_info.sigma,geometry_info.xi,exception);
10740 +          break;
10741 +        }
10742 +        case 122:  /* HaldClut */
10743 +        {
10744 +          if (attribute_flag[0] == 0)
10745 +            {
10746 +              ThrowPerlException(exception,OptionError,"ClutImageRequired",
10747 +                PackageName);
10748 +              goto PerlException;
10749 +            }
10750 +          if (attribute_flag[1] != 0)
10751 +            channel=(ChannelType) argument_list[1].integer_reference;
10752 +          (void) HaldClutImageChannel(image,channel,
10753 +            argument_list[0].image_reference);
10754 +          break;
10755 +        }
10756 +        case 123:  /* BlueShift */
10757 +        {
10758 +          if (attribute_flag[0] != 0)
10759 +            (void) ParseGeometry(argument_list[0].string_reference,
10760 +              &geometry_info);
10761 +          image=BlueShiftImage(image,geometry_info.rho,exception);
10762 +          break;
10763 +        }
10764 +        case 124:  /* ForwardFourierTransformImage */
10765 +        {
10766 +          image=ForwardFourierTransformImage(image,
10767 +            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10768 +            exception);
10769 +          break;
10770 +        }
10771 +        case 125:  /* InverseFourierTransformImage */
10772 +        {
10773 +          image=InverseFourierTransformImage(image,image->next,
10774 +            argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10775 +            exception);
10776 +          break;
10777 +        }
10778 +        case 126:  /* ColorDecisionList */
10779 +        {
10780 +          if (attribute_flag[0] == 0)
10781 +            argument_list[0].string_reference=(char *) NULL;
10782 +          (void) ColorDecisionListImage(image,
10783 +            argument_list[0].string_reference);
10784 +          break;
10785 +        }
10786 +        case 127:  /* AutoGamma */
10787 +        {
10788 +          if (attribute_flag[0] != 0)
10789 +            channel=(ChannelType) argument_list[0].integer_reference;
10790 +          (void) AutoGammaImageChannel(image,channel);
10791 +          break;
10792 +        }
10793 +        case 128:  /* AutoLevel */
10794 +        {
10795 +          if (attribute_flag[0] != 0)
10796 +            channel=(ChannelType) argument_list[0].integer_reference;
10797 +          (void) AutoLevelImageChannel(image,channel);
10798 +          break;
10799 +        }
10800 +        case 129:  /* LevelColors */
10801 +        {
10802 +          MagickPixelPacket
10803 +            black_point,
10804 +            white_point;
10805 +
10806 +          (void) QueryMagickColor("#000000",&black_point,exception);
10807 +          (void) QueryMagickColor("#ffffff",&white_point,exception);
10808 +          if (attribute_flag[1] != 0)
10809 +             (void) QueryMagickColor(argument_list[1].string_reference,
10810 +               &black_point,exception);
10811 +          if (attribute_flag[2] != 0)
10812 +             (void) QueryMagickColor(argument_list[2].string_reference,
10813 +               &white_point,exception);
10814 +          if (attribute_flag[3] != 0)
10815 +            channel=(ChannelType) argument_list[3].integer_reference;
10816 +          (void) LevelColorsImageChannel(image,channel,&black_point,
10817 +            &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
10818 +            MagickFalse);
10819 +          break;
10820 +        }
10821 +        case 130:  /* Clamp */
10822 +        {
10823 +          if (attribute_flag[0] != 0)
10824 +            channel=(ChannelType) argument_list[0].integer_reference;
10825 +          (void) ClampImageChannel(image,channel);
10826 +          break;
10827 +        }
10828 +        case 131:  /* Filter */
10829 +        {
10830 +          KernelInfo
10831 +            *kernel;
10832 +
10833 +          if (attribute_flag[0] == 0)
10834 +            break;
10835 +          kernel=AcquireKernelInfo(argument_list[0].string_reference);
10836 +          if (kernel == (KernelInfo *) NULL)
10837 +            break;
10838 +          if (attribute_flag[1] != 0)
10839 +            channel=(ChannelType) argument_list[1].integer_reference;
10840 +          if (attribute_flag[2] != 0)
10841 +            image->bias=StringToDoubleInterval(
10842 +              argument_list[2].string_reference,(double) QuantumRange+1.0);
10843 +          image=FilterImageChannel(image,channel,kernel,exception);
10844 +          kernel=DestroyKernelInfo(kernel);
10845 +          break;
10846 +        }
10847 +        case 132:  /* BrightnessContrast */
10848 +        {
10849 +          double
10850 +            brightness,
10851 +            contrast;
10852 +
10853 +          brightness=0.0;
10854 +          contrast=0.0;
10855 +          if (attribute_flag[0] != 0)
10856 +            {
10857 +              flags=ParseGeometry(argument_list[0].string_reference,
10858 +                &geometry_info);
10859 +              brightness=geometry_info.rho;
10860 +              if ((flags & SigmaValue) == 0)
10861 +                contrast=geometry_info.sigma;
10862 +            }
10863 +          if (attribute_flag[1] != 0)
10864 +            brightness=argument_list[1].real_reference;
10865 +          if (attribute_flag[2] != 0)
10866 +            contrast=argument_list[2].real_reference;
10867 +          if (attribute_flag[4] != 0)
10868 +            channel=(ChannelType) argument_list[4].integer_reference;
10869 +          (void) BrightnessContrastImageChannel(image,channel,brightness,
10870 +            contrast);
10871 +          break;
10872 +        }
10873 +        case 133:  /* Morphology */
10874 +        {
10875 +          KernelInfo
10876 +            *kernel;
10877 +
10878 +          MorphologyMethod
10879 +            method;
10880 +
10881 +          ssize_t
10882 +            iterations;
10883 +
10884 +          if (attribute_flag[0] == 0)
10885 +            break;
10886 +          kernel=AcquireKernelInfo(argument_list[0].string_reference);
10887 +          if (kernel == (KernelInfo *) NULL)
10888 +            break;
10889 +          if (attribute_flag[1] != 0)
10890 +            channel=(ChannelType) argument_list[1].integer_reference;
10891 +          method=UndefinedMorphology;
10892 +          if (attribute_flag[2] != 0)
10893 +            method=argument_list[2].integer_reference;
10894 +          iterations=1;
10895 +          if (attribute_flag[3] != 0)
10896 +            iterations=argument_list[3].integer_reference;
10897 +          image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10898 +            exception);
10899 +          kernel=DestroyKernelInfo(kernel);
10900 +          break;
10901 +        }
10902 +        case 108:  /* Recolor */
10903 +        case 134:  /* ColorMatrix */
10904 +        {
10905 +          AV
10906 +            *av;
10907 +
10908 +          double
10909 +            *color_matrix;
10910 +
10911 +          KernelInfo
10912 +            *kernel_info;
10913 +
10914 +          size_t
10915 +            order;
10916 +
10917 +          if (attribute_flag[0] == 0)
10918 +            break;
10919 +          av=(AV *) argument_list[0].array_reference;
10920 +          order=(size_t) sqrt(av_len(av)+1);
10921 +          color_matrix=(double *) AcquireQuantumMemory(order,order*
10922 +            sizeof(*color_matrix));
10923 +          if (color_matrix == (double *) NULL)
10924 +            {
10925 +              ThrowPerlException(exception,ResourceLimitFatalError,
10926 +                "MemoryAllocationFailed",PackageName);
10927 +              goto PerlException;
10928 +           }
10929 +          for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10930 +            color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10931 +          for ( ; j < (ssize_t) (order*order); j++)
10932 +            color_matrix[j]=0.0;
10933 +          kernel_info=AcquireKernelInfo("1");
10934 +          if (kernel_info == (KernelInfo *) NULL)
10935 +            break;
10936 +          kernel_info->width=order;
10937 +          kernel_info->height=order;
10938 +          kernel_info->values=color_matrix;
10939 +          image=ColorMatrixImage(image,kernel_info,exception);
10940 +          kernel_info->values=(double *) NULL;
10941 +          kernel_info=DestroyKernelInfo(kernel_info);
10942 +          color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10943 +          break;
10944 +        }
10945 +        case 135:  /* Color */
10946 +        {
10947 +          MagickPixelPacket
10948 +            color;
10949 +
10950 +          (void) QueryMagickColor("none",&color,exception);
10951 +          if (attribute_flag[0] != 0)
10952 +            (void) QueryMagickColor(argument_list[0].string_reference,
10953 +              &color,exception);
10954 +          (void) SetImageColor(image,&color);
10955 +          break;
10956 +        }
10957 +        case 136:  /* Mode */
10958 +        {
10959 +          if (attribute_flag[0] != 0)
10960 +            {
10961 +              flags=ParseGeometry(argument_list[0].string_reference,
10962 +                &geometry_info);
10963 +              if ((flags & SigmaValue) == 0)
10964 +                geometry_info.sigma=1.0;
10965 +            }
10966 +          if (attribute_flag[1] != 0)
10967 +            geometry_info.rho=argument_list[1].real_reference;
10968 +          if (attribute_flag[2] != 0)
10969 +            geometry_info.sigma=argument_list[2].real_reference;
10970 +          if (attribute_flag[3] != 0)
10971 +            channel=(ChannelType) argument_list[3].integer_reference;
10972 +          image=StatisticImageChannel(image,channel,ModeStatistic,
10973 +            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10974 +          break;
10975 +        }
10976 +        case 137:  /* Statistic */
10977 +        {
10978 +          StatisticType
10979 +            statistic;
10980 +
10981 +          statistic=UndefinedStatistic;
10982 +          if (attribute_flag[0] != 0)
10983 +            {
10984 +              flags=ParseGeometry(argument_list[0].string_reference,
10985 +                &geometry_info);
10986 +              if ((flags & SigmaValue) == 0)
10987 +                geometry_info.sigma=1.0;
10988 +            }
10989 +          if (attribute_flag[1] != 0)
10990 +            geometry_info.rho=argument_list[1].real_reference;
10991 +          if (attribute_flag[2] != 0)
10992 +            geometry_info.sigma=argument_list[2].real_reference;
10993 +          if (attribute_flag[3] != 0)
10994 +            channel=(ChannelType) argument_list[3].integer_reference;
10995 +          if (attribute_flag[4] != 0)
10996 +            statistic=(StatisticType) argument_list[4].integer_reference;
10997 +          image=StatisticImageChannel(image,channel,statistic,
10998 +            (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10999 +          break;
11000 +        }
11001 +        case 138:  /* Perceptible */
11002 +        {
11003 +          double
11004 +            epsilon;
11005 +
11006 +          epsilon=MagickEpsilon;
11007 +          if (attribute_flag[0] != 0)
11008 +            epsilon=argument_list[0].real_reference;
11009 +          if (attribute_flag[1] != 0)
11010 +            channel=(ChannelType) argument_list[1].integer_reference;
11011 +          (void) PerceptibleImageChannel(image,channel,epsilon);
11012 +          break;
11013 +        }
11014 +        case 139:  /* Poly */
11015 +        {
11016 +          AV
11017 +            *av;
11018 +
11019 +          double
11020 +            *terms;
11021 +
11022 +          size_t
11023 +            number_terms;
11024 +
11025 +          if (attribute_flag[0] == 0)
11026 +            break;
11027 +          if (attribute_flag[1] != 0)
11028 +            channel=(ChannelType) argument_list[1].integer_reference;
11029 +          av=(AV *) argument_list[0].array_reference;
11030 +          number_terms=(size_t) av_len(av);
11031 +          terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11032 +          if (terms == (double *) NULL)
11033 +            {
11034 +              ThrowPerlException(exception,ResourceLimitFatalError,
11035 +                "MemoryAllocationFailed",PackageName);
11036 +              goto PerlException;
11037 +            }
11038 +          for (j=0; j < av_len(av); j++)
11039 +            terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11040 +          image=PolynomialImageChannel(image,channel,number_terms >> 1,terms,
11041 +            exception);
11042 +          terms=(double *) RelinquishMagickMemory(terms);
11043 +          break;
11044 +        }
11045 +        case 140:  /* Grayscale */
11046 +        {
11047 +          PixelIntensityMethod
11048 +            method;
11049 +
11050 +          method=UndefinedPixelIntensityMethod;
11051 +          if (attribute_flag[0] != 0)
11052 +            method=(PixelIntensityMethod) argument_list[0].integer_reference;
11053 +          (void) GrayscaleImage(image,method);
11054 +          break;
11055 +        }
11056 +        case 141:  /* CannyEdge */
11057 +        {
11058 +          if (attribute_flag[0] != 0)
11059 +            {
11060 +              flags=ParseGeometry(argument_list[0].string_reference,
11061 +                &geometry_info);
11062 +              if ((flags & SigmaValue) == 0)
11063 +                geometry_info.sigma=1.0;
11064 +              if ((flags & XiValue) == 0)
11065 +                geometry_info.xi=0.10;
11066 +              if ((flags & PsiValue) == 0)
11067 +                geometry_info.psi=0.30;
11068 +              if ((flags & PercentValue) != 0)
11069 +                {
11070 +                  geometry_info.xi/=100.0;
11071 +                  geometry_info.psi/=100.0;
11072 +                }
11073 +            }
11074 +          if (attribute_flag[1] != 0)
11075 +            geometry_info.rho=argument_list[1].real_reference;
11076 +          if (attribute_flag[2] != 0)
11077 +            geometry_info.sigma=argument_list[2].real_reference;
11078 +          if (attribute_flag[3] != 0)
11079 +            geometry_info.xi=argument_list[3].real_reference;
11080 +          if (attribute_flag[4] != 0)
11081 +            geometry_info.psi=argument_list[4].real_reference;
11082 +          image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11083 +            geometry_info.xi,geometry_info.psi,exception);
11084 +          break;
11085 +        }
11086 +        case 142:  /* HoughLine */
11087 +        {
11088 +          if (attribute_flag[0] != 0)
11089 +            {
11090 +              flags=ParseGeometry(argument_list[0].string_reference,
11091 +                &geometry_info);
11092 +              if ((flags & SigmaValue) == 0)
11093 +                geometry_info.sigma=geometry_info.rho;
11094 +              if ((flags & XiValue) == 0)
11095 +                geometry_info.xi=40;
11096 +            }
11097 +          if (attribute_flag[1] != 0)
11098 +            geometry_info.rho=(double) argument_list[1].integer_reference;
11099 +          if (attribute_flag[2] != 0)
11100 +            geometry_info.sigma=(double) argument_list[2].integer_reference;
11101 +          if (attribute_flag[3] != 0)
11102 +            geometry_info.xi=(double) argument_list[3].integer_reference;
11103 +          image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11104 +            geometry_info.sigma,(size_t) geometry_info.xi,exception);
11105 +          break;
11106 +        }
11107 +        case 143:  /* MeanShift */
11108 +        {
11109 +          if (attribute_flag[0] != 0)
11110 +            {
11111 +              flags=ParseGeometry(argument_list[0].string_reference,
11112 +                &geometry_info);
11113 +              if ((flags & SigmaValue) == 0)
11114 +                geometry_info.sigma=geometry_info.rho;
11115 +              if ((flags & XiValue) == 0)
11116 +                geometry_info.xi=0.10*QuantumRange;
11117 +              if ((flags & PercentValue) != 0)
11118 +                geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11119 +            }
11120 +          if (attribute_flag[1] != 0)
11121 +            geometry_info.rho=(double) argument_list[1].integer_reference;
11122 +          if (attribute_flag[2] != 0)
11123 +            geometry_info.sigma=(double) argument_list[2].integer_reference;
11124 +          if (attribute_flag[3] != 0)
11125 +            geometry_info.xi=(double) argument_list[3].real_reference;
11126 +          image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11127 +            geometry_info.sigma,geometry_info.xi,exception);
11128 +          break;
11129 +        }
11130 +        case 144:  /* Kuwahara */
11131 +        {
11132 +          if (attribute_flag[0] != 0)
11133 +            {
11134 +              flags=ParseGeometry(argument_list[0].string_reference,
11135 +                &geometry_info);
11136 +              if ((flags & SigmaValue) == 0)
11137 +                geometry_info.sigma=geometry_info.rho-0.5;
11138 +            }
11139 +          if (attribute_flag[1] != 0)
11140 +            geometry_info.rho=argument_list[1].real_reference;
11141 +          if (attribute_flag[2] != 0)
11142 +            geometry_info.sigma=argument_list[2].real_reference;
11143 +          if (attribute_flag[3] != 0)
11144 +            channel=(ChannelType) argument_list[3].integer_reference;
11145 +          image=KuwaharaImageChannel(image,channel,geometry_info.rho,
11146 +            geometry_info.sigma,exception);
11147 +          break;
11148 +        }
11149 +        case 145:  /* ConnectedComponent */
11150 +        {
11151 +          size_t
11152 +            connectivity;
11153 +
11154 +          connectivity=4;
11155 +          if (attribute_flag[0] != 0)
11156 +            connectivity=argument_list[0].integer_reference;
11157 +          image=ConnectedComponentsImage(image,connectivity,exception);
11158 +          break;
11159 +        }
11160 +        case 146:  /* Copy */
11161 +        {
11162 +          Image
11163 +            *source_image;
11164 +
11165 +          OffsetInfo
11166 +            offset;
11167 +
11168 +          RectangleInfo
11169 +            offset_geometry;
11170 +
11171 +          source_image=image;
11172 +          if (attribute_flag[0] != 0)
11173 +            source_image=argument_list[0].image_reference;
11174 +          SetGeometry(source_image,&geometry);
11175 +          if (attribute_flag[1] != 0)
11176 +            flags=ParseGravityGeometry(source_image,
11177 +              argument_list[1].string_reference,&geometry,exception);
11178 +          if (attribute_flag[2] != 0)
11179 +            geometry.width=argument_list[2].integer_reference;
11180 +          if (attribute_flag[3] != 0)
11181 +            geometry.height=argument_list[3].integer_reference;
11182 +          if (attribute_flag[4] != 0)
11183 +            geometry.x=argument_list[4].integer_reference;
11184 +          if (attribute_flag[5] != 0)
11185 +            geometry.y=argument_list[5].integer_reference;
11186 +          if (attribute_flag[6] != 0)
11187 +            image->gravity=(GravityType) argument_list[6].integer_reference;
11188 +          SetGeometry(image,&offset_geometry);
11189 +          if (attribute_flag[7] != 0)
11190 +            flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11191 +              &offset_geometry,exception);
11192 +          offset.x=offset_geometry.x;
11193 +          offset.y=offset_geometry.y;
11194 +          if (attribute_flag[8] != 0)
11195 +            offset.x=argument_list[8].integer_reference;
11196 +          if (attribute_flag[9] != 0)
11197 +            offset.y=argument_list[9].integer_reference;
11198 +          (void) CopyImagePixels(image,source_image,&geometry,&offset,
11199 +            exception);
11200 +          break;
11201 +        }
11202 +        case 147:  /* WaveletDenoise */
11203 +        {
11204 +          if (attribute_flag[0] != 0)
11205 +            {
11206 +              flags=ParseGeometry(argument_list[0].string_reference,
11207 +                &geometry_info);
11208 +              if ((flags & PercentValue) != 0)
11209 +                {
11210 +                  geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
11211 +                  geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
11212 +                }
11213 +              if ((flags & SigmaValue) == 0)
11214 +                geometry_info.sigma=0.0;
11215 +            }
11216 +          if (attribute_flag[1] != 0)
11217 +            geometry_info.rho=argument_list[1].real_reference;
11218 +          if (attribute_flag[2] != 0)
11219 +            geometry_info.sigma=argument_list[2].real_reference;
11220 +          image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma,
11221 +            exception);
11222 +          break;
11223 +        }
11224 +      }
11225 +      if (next != (Image *) NULL)
11226 +        (void) CatchImageException(next);
11227 +      if (region_image != (Image *) NULL)
11228 +        {
11229 +          /*
11230 +            Composite region.
11231 +          */
11232 +          status=CompositeImage(region_image,CopyCompositeOp,image,
11233 +            region_info.x,region_info.y);
11234 +          (void) status;
11235 +          (void) CatchImageException(region_image);
11236 +          image=DestroyImage(image);
11237 +          image=region_image;
11238 +        }
11239 +      if (image != (Image *) NULL)
11240 +        {
11241 +          number_images++;
11242 +          if (next && (next != image))
11243 +            {
11244 +              image->next=next->next;
11245 +              if (image->next != (Image *) NULL)
11246 +                image->next->previous=image;
11247 +              DeleteImageFromRegistry(*pv,next);
11248 +            }
11249 +          sv_setiv(*pv,PTR2IV(image));
11250 +          next=image;
11251 +        }
11252 +      if (*pv)
11253 +        pv++;
11254 +    }
11255 +
11256 +  PerlException:
11257 +    if (reference_vector)
11258 +      reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11259 +    InheritPerlException(exception,perl_exception);
11260 +    exception=DestroyExceptionInfo(exception);
11261 +    sv_setiv(perl_exception,(IV) number_images);
11262 +    SvPOK_on(perl_exception);
11263 +    ST(0)=sv_2mortal(perl_exception);
11264 +    XSRETURN(1);
11265 +  }
11266 +\f
11267 +#
11268 +###############################################################################
11269 +#                                                                             #
11270 +#                                                                             #
11271 +#                                                                             #
11272 +#   M o n t a g e                                                             #
11273 +#                                                                             #
11274 +#                                                                             #
11275 +#                                                                             #
11276 +###############################################################################
11277 +#
11278 +#
11279 +void
11280 +Montage(ref,...)
11281 +  Image::Magick ref = NO_INIT
11282 +  ALIAS:
11283 +    MontageImage  = 1
11284 +    montage       = 2
11285 +    montageimage  = 3
11286 +  PPCODE:
11287 +  {
11288 +    AV
11289 +      *av;
11290 +
11291 +    char
11292 +      *attribute;
11293 +
11294 +    ExceptionInfo
11295 +      *exception;
11296 +
11297 +    HV
11298 +      *hv;
11299 +
11300 +    Image
11301 +      *image,
11302 +      *next;
11303 +
11304 +    MagickPixelPacket
11305 +      transparent_color;
11306 +
11307 +    MontageInfo
11308 +      *montage_info;
11309 +
11310 +    register ssize_t
11311 +      i;
11312 +
11313 +    ssize_t
11314 +      sp;
11315 +
11316 +    struct PackageInfo
11317 +      *info;
11318 +
11319 +    SV
11320 +      *av_reference,
11321 +      *perl_exception,
11322 +      *reference,
11323 +      *rv,
11324 +      *sv;
11325 +
11326 +    PERL_UNUSED_VAR(ref);
11327 +    PERL_UNUSED_VAR(ix);
11328 +    exception=AcquireExceptionInfo();
11329 +    perl_exception=newSVpv("",0);
11330 +    sv=NULL;
11331 +    attribute=NULL;
11332 +    if (sv_isobject(ST(0)) == 0)
11333 +      {
11334 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11335 +          PackageName);
11336 +        goto PerlException;
11337 +      }
11338 +    reference=SvRV(ST(0));
11339 +    hv=SvSTASH(reference);
11340 +    av=newAV();
11341 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11342 +    SvREFCNT_dec(av);
11343 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11344 +    if (image == (Image *) NULL)
11345 +      {
11346 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
11347 +          PackageName);
11348 +        goto PerlException;
11349 +      }
11350 +    /*
11351 +      Get options.
11352 +    */
11353 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11354 +    montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11355 +    (void) QueryMagickColor("none",&transparent_color,exception);
11356 +    for (i=2; i < items; i+=2)
11357 +    {
11358 +      attribute=(char *) SvPV(ST(i-1),na);
11359 +      switch (*attribute)
11360 +      {
11361 +        case 'B':
11362 +        case 'b':
11363 +        {
11364 +          if (LocaleCompare(attribute,"background") == 0)
11365 +            {
11366 +              (void) QueryColorDatabase(SvPV(ST(i),na),
11367 +                &montage_info->background_color,exception);
11368 +              for (next=image; next; next=next->next)
11369 +                next->background_color=montage_info->background_color;
11370 +              break;
11371 +            }
11372 +          if (LocaleCompare(attribute,"border") == 0)
11373 +            {
11374 +              montage_info->border_width=SvIV(ST(i));
11375 +              break;
11376 +            }
11377 +          if (LocaleCompare(attribute,"bordercolor") == 0)
11378 +            {
11379 +              (void) QueryColorDatabase(SvPV(ST(i),na),
11380 +                &montage_info->border_color,exception);
11381 +              for (next=image; next; next=next->next)
11382 +                next->border_color=montage_info->border_color;
11383 +              break;
11384 +            }
11385 +          if (LocaleCompare(attribute,"borderwidth") == 0)
11386 +            {
11387 +              montage_info->border_width=SvIV(ST(i));
11388 +              break;
11389 +            }
11390 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11391 +            attribute);
11392 +          break;
11393 +        }
11394 +        case 'C':
11395 +        case 'c':
11396 +        {
11397 +          if (LocaleCompare(attribute,"compose") == 0)
11398 +            {
11399 +              sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11400 +                MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11401 +              if (sp < 0)
11402 +                {
11403 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
11404 +                    SvPV(ST(i),na));
11405 +                  break;
11406 +                }
11407 +              for (next=image; next; next=next->next)
11408 +                next->compose=(CompositeOperator) sp;
11409 +              break;
11410 +            }
11411 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11412 +            attribute);
11413 +          break;
11414 +        }
11415 +        case 'F':
11416 +        case 'f':
11417 +        {
11418 +          if (LocaleCompare(attribute,"fill") == 0)
11419 +            {
11420 +              (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
11421 +                exception);
11422 +              break;
11423 +            }
11424 +          if (LocaleCompare(attribute,"font") == 0)
11425 +            {
11426 +              (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11427 +              break;
11428 +            }
11429 +          if (LocaleCompare(attribute,"frame") == 0)
11430 +            {
11431 +              char
11432 +                *p;
11433 +
11434 +              p=SvPV(ST(i),na);
11435 +              if (IsGeometry(p) == MagickFalse)
11436 +                {
11437 +                  ThrowPerlException(exception,OptionError,"MissingGeometry",
11438 +                    p);
11439 +                  break;
11440 +                }
11441 +              (void) CloneString(&montage_info->frame,p);
11442 +              if (*p == '\0')
11443 +                montage_info->frame=(char *) NULL;
11444 +              break;
11445 +            }
11446 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11447 +            attribute);
11448 +          break;
11449 +        }
11450 +        case 'G':
11451 +        case 'g':
11452 +        {
11453 +          if (LocaleCompare(attribute,"geometry") == 0)
11454 +            {
11455 +              char
11456 +                *p;
11457 +
11458 +              p=SvPV(ST(i),na);
11459 +              if (IsGeometry(p) == MagickFalse)
11460 +                {
11461 +                  ThrowPerlException(exception,OptionError,"MissingGeometry",
11462 +                    p);
11463 +                  break;
11464 +                }
11465 +             (void) CloneString(&montage_info->geometry,p);
11466 +             if (*p == '\0')
11467 +               montage_info->geometry=(char *) NULL;
11468 +             break;
11469 +           }
11470 +         if (LocaleCompare(attribute,"gravity") == 0)
11471 +           {
11472 +             ssize_t
11473 +               in;
11474 +
11475 +             in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11476 +               MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11477 +             if (in < 0)
11478 +               {
11479 +                 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11480 +                   SvPV(ST(i),na));
11481 +                 return;
11482 +               }
11483 +             montage_info->gravity=(GravityType) in;
11484 +             for (next=image; next; next=next->next)
11485 +               next->gravity=(GravityType) in;
11486 +             break;
11487 +           }
11488 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11489 +            attribute);
11490 +          break;
11491 +        }
11492 +        case 'L':
11493 +        case 'l':
11494 +        {
11495 +          if (LocaleCompare(attribute,"label") == 0)
11496 +            {
11497 +              for (next=image; next; next=next->next)
11498 +                (void) SetImageProperty(next,"label",InterpretImageProperties(
11499 +                  info ? info->image_info : (ImageInfo *) NULL,next,
11500 +                  SvPV(ST(i),na)));
11501 +              break;
11502 +            }
11503 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11504 +            attribute);
11505 +          break;
11506 +        }
11507 +        case 'M':
11508 +        case 'm':
11509 +        {
11510 +          if (LocaleCompare(attribute,"mattecolor") == 0)
11511 +            {
11512 +              (void) QueryColorDatabase(SvPV(ST(i),na),
11513 +                &montage_info->matte_color,exception);
11514 +              for (next=image; next; next=next->next)
11515 +                next->matte_color=montage_info->matte_color;
11516 +              break;
11517 +            }
11518 +          if (LocaleCompare(attribute,"mode") == 0)
11519 +            {
11520 +              ssize_t
11521 +                in;
11522 +
11523 +              in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
11524 +                ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11525 +              switch (in)
11526 +              {
11527 +                default:
11528 +                {
11529 +                  ThrowPerlException(exception,OptionError,
11530 +                    "UnrecognizedModeType",SvPV(ST(i),na));
11531 +                  break;
11532 +                }
11533 +                case FrameMode:
11534 +                {
11535 +                  (void) CloneString(&montage_info->frame,"15x15+3+3");
11536 +                  montage_info->shadow=MagickTrue;
11537 +                  break;
11538 +                }
11539 +                case UnframeMode:
11540 +                {
11541 +                  montage_info->frame=(char *) NULL;
11542 +                  montage_info->shadow=MagickFalse;
11543 +                  montage_info->border_width=0;
11544 +                  break;
11545 +                }
11546 +                case ConcatenateMode:
11547 +                {
11548 +                  montage_info->frame=(char *) NULL;
11549 +                  montage_info->shadow=MagickFalse;
11550 +                  (void) CloneString(&montage_info->geometry,"+0+0");
11551 +                  montage_info->border_width=0;
11552 +                }
11553 +              }
11554 +              break;
11555 +            }
11556 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11557 +            attribute);
11558 +          break;
11559 +        }
11560 +        case 'P':
11561 +        case 'p':
11562 +        {
11563 +          if (LocaleCompare(attribute,"pointsize") == 0)
11564 +            {
11565 +              montage_info->pointsize=SvIV(ST(i));
11566 +              break;
11567 +            }
11568 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11569 +            attribute);
11570 +          break;
11571 +        }
11572 +        case 'S':
11573 +        case 's':
11574 +        {
11575 +          if (LocaleCompare(attribute,"shadow") == 0)
11576 +            {
11577 +              sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11578 +                MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11579 +              if (sp < 0)
11580 +                {
11581 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
11582 +                    SvPV(ST(i),na));
11583 +                  break;
11584 +                }
11585 +             montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11586 +             break;
11587 +            }
11588 +          if (LocaleCompare(attribute,"stroke") == 0)
11589 +            {
11590 +              (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11591 +                exception);
11592 +              break;
11593 +            }
11594 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11595 +            attribute);
11596 +          break;
11597 +        }
11598 +        case 'T':
11599 +        case 't':
11600 +        {
11601 +          if (LocaleCompare(attribute,"texture") == 0)
11602 +            {
11603 +              (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11604 +              break;
11605 +            }
11606 +          if (LocaleCompare(attribute,"tile") == 0)
11607 +            {
11608 +              char *p=SvPV(ST(i),na);
11609 +              if (IsGeometry(p) == MagickFalse)
11610 +                {
11611 +                  ThrowPerlException(exception,OptionError,"MissingGeometry",
11612 +                    p);
11613 +                  break;
11614 +                }
11615 +              (void) CloneString(&montage_info->tile,p);
11616 +              if (*p == '\0')
11617 +                montage_info->tile=(char *) NULL;
11618 +              break;
11619 +            }
11620 +          if (LocaleCompare(attribute,"title") == 0)
11621 +            {
11622 +              (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11623 +              break;
11624 +            }
11625 +          if (LocaleCompare(attribute,"transparent") == 0)
11626 +            {
11627 +              MagickPixelPacket
11628 +                transparent_color;
11629 +
11630 +              QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11631 +              for (next=image; next; next=next->next)
11632 +                (void) TransparentPaintImage(next,&transparent_color,
11633 +                  TransparentOpacity,MagickFalse);
11634 +              break;
11635 +            }
11636 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11637 +            attribute);
11638 +          break;
11639 +        }
11640 +        default:
11641 +        {
11642 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11643 +            attribute);
11644 +          break;
11645 +        }
11646 +      }
11647 +    }
11648 +    image=MontageImageList(info->image_info,montage_info,image,exception);
11649 +    montage_info=DestroyMontageInfo(montage_info);
11650 +    if (image == (Image *) NULL)
11651 +      goto PerlException;
11652 +    if (transparent_color.opacity != TransparentOpacity)
11653 +      for (next=image; next; next=next->next)
11654 +        (void) TransparentPaintImage(next,&transparent_color,
11655 +          TransparentOpacity,MagickFalse);
11656 +    for (  ; image; image=image->next)
11657 +    {
11658 +      AddImageToRegistry(sv,image);
11659 +      rv=newRV(sv);
11660 +      av_push(av,sv_bless(rv,hv));
11661 +      SvREFCNT_dec(sv);
11662 +    }
11663 +    exception=DestroyExceptionInfo(exception);
11664 +    ST(0)=av_reference;
11665 +    SvREFCNT_dec(perl_exception);
11666 +    XSRETURN(1);
11667 +
11668 +  PerlException:
11669 +    InheritPerlException(exception,perl_exception);
11670 +    exception=DestroyExceptionInfo(exception);
11671 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11672 +    SvPOK_on(perl_exception);
11673 +    ST(0)=sv_2mortal(perl_exception);
11674 +    XSRETURN(1);
11675 +  }
11676 +\f
11677 +#
11678 +###############################################################################
11679 +#                                                                             #
11680 +#                                                                             #
11681 +#                                                                             #
11682 +#   M o r p h                                                                 #
11683 +#                                                                             #
11684 +#                                                                             #
11685 +#                                                                             #
11686 +###############################################################################
11687 +#
11688 +#
11689 +void
11690 +Morph(ref,...)
11691 +  Image::Magick ref = NO_INIT
11692 +  ALIAS:
11693 +    MorphImage  = 1
11694 +    morph       = 2
11695 +    morphimage  = 3
11696 +  PPCODE:
11697 +  {
11698 +    AV
11699 +      *av;
11700 +
11701 +    char
11702 +      *attribute;
11703 +
11704 +    ExceptionInfo
11705 +      *exception;
11706 +
11707 +    HV
11708 +      *hv;
11709 +
11710 +    Image
11711 +      *image;
11712 +
11713 +    register ssize_t
11714 +      i;
11715 +
11716 +    ssize_t
11717 +      number_frames;
11718 +
11719 +    struct PackageInfo
11720 +      *info;
11721 +
11722 +    SV
11723 +      *av_reference,
11724 +      *perl_exception,
11725 +      *reference,
11726 +      *rv,
11727 +      *sv;
11728 +
11729 +    PERL_UNUSED_VAR(ref);
11730 +    PERL_UNUSED_VAR(ix);
11731 +    exception=AcquireExceptionInfo();
11732 +    perl_exception=newSVpv("",0);
11733 +    sv=NULL;
11734 +    av=NULL;
11735 +    attribute=NULL;
11736 +    if (sv_isobject(ST(0)) == 0)
11737 +      {
11738 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11739 +          PackageName);
11740 +        goto PerlException;
11741 +      }
11742 +    reference=SvRV(ST(0));
11743 +    hv=SvSTASH(reference);
11744 +    av=newAV();
11745 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11746 +    SvREFCNT_dec(av);
11747 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11748 +    if (image == (Image *) NULL)
11749 +      {
11750 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
11751 +          PackageName);
11752 +        goto PerlException;
11753 +      }
11754 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11755 +    /*
11756 +      Get attribute.
11757 +    */
11758 +    number_frames=30;
11759 +    for (i=2; i < items; i+=2)
11760 +    {
11761 +      attribute=(char *) SvPV(ST(i-1),na);
11762 +      switch (*attribute)
11763 +      {
11764 +        case 'F':
11765 +        case 'f':
11766 +        {
11767 +          if (LocaleCompare(attribute,"frames") == 0)
11768 +            {
11769 +              number_frames=SvIV(ST(i));
11770 +              break;
11771 +            }
11772 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11773 +            attribute);
11774 +          break;
11775 +        }
11776 +        default:
11777 +        {
11778 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11779 +            attribute);
11780 +          break;
11781 +        }
11782 +      }
11783 +    }
11784 +    image=MorphImages(image,number_frames,exception);
11785 +    if (image == (Image *) NULL)
11786 +      goto PerlException;
11787 +    for ( ; image; image=image->next)
11788 +    {
11789 +      AddImageToRegistry(sv,image);
11790 +      rv=newRV(sv);
11791 +      av_push(av,sv_bless(rv,hv));
11792 +      SvREFCNT_dec(sv);
11793 +    }
11794 +    exception=DestroyExceptionInfo(exception);
11795 +    ST(0)=av_reference;
11796 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
11797 +    XSRETURN(1);
11798 +
11799 +  PerlException:
11800 +    InheritPerlException(exception,perl_exception);
11801 +    exception=DestroyExceptionInfo(exception);
11802 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11803 +    SvPOK_on(perl_exception);
11804 +    ST(0)=sv_2mortal(perl_exception);
11805 +    XSRETURN(1);
11806 +  }
11807 +\f
11808 +#
11809 +###############################################################################
11810 +#                                                                             #
11811 +#                                                                             #
11812 +#                                                                             #
11813 +#   M o s a i c                                                               #
11814 +#                                                                             #
11815 +#                                                                             #
11816 +#                                                                             #
11817 +###############################################################################
11818 +#
11819 +#
11820 +void
11821 +Mosaic(ref)
11822 +  Image::Magick ref = NO_INIT
11823 +  ALIAS:
11824 +    MosaicImage   = 1
11825 +    mosaic        = 2
11826 +    mosaicimage   = 3
11827 +  PPCODE:
11828 +  {
11829 +    AV
11830 +      *av;
11831 +
11832 +    ExceptionInfo
11833 +      *exception;
11834 +
11835 +    HV
11836 +      *hv;
11837 +
11838 +    Image
11839 +      *image;
11840 +
11841 +    struct PackageInfo
11842 +      *info;
11843 +
11844 +    SV
11845 +      *perl_exception,
11846 +      *reference,
11847 +      *rv,
11848 +      *sv;
11849 +
11850 +    PERL_UNUSED_VAR(ref);
11851 +    PERL_UNUSED_VAR(ix);
11852 +    exception=AcquireExceptionInfo();
11853 +    perl_exception=newSVpv("",0);
11854 +    sv=NULL;
11855 +    if (sv_isobject(ST(0)) == 0)
11856 +      {
11857 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11858 +          PackageName);
11859 +        goto PerlException;
11860 +      }
11861 +    reference=SvRV(ST(0));
11862 +    hv=SvSTASH(reference);
11863 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11864 +    if (image == (Image *) NULL)
11865 +      {
11866 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
11867 +          PackageName);
11868 +        goto PerlException;
11869 +      }
11870 +    image=MergeImageLayers(image,MosaicLayer,exception);
11871 +    /*
11872 +      Create blessed Perl array for the returned image.
11873 +    */
11874 +    av=newAV();
11875 +    ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11876 +    SvREFCNT_dec(av);
11877 +    AddImageToRegistry(sv,image);
11878 +    rv=newRV(sv);
11879 +    av_push(av,sv_bless(rv,hv));
11880 +    SvREFCNT_dec(sv);
11881 +    (void) CopyMagickString(info->image_info->filename,image->filename,
11882 +      MaxTextExtent);
11883 +    SetImageInfo(info->image_info,0,&image->exception);
11884 +    exception=DestroyExceptionInfo(exception);
11885 +    SvREFCNT_dec(perl_exception);
11886 +    XSRETURN(1);
11887 +
11888 +  PerlException:
11889 +    InheritPerlException(exception,perl_exception);
11890 +    exception=DestroyExceptionInfo(exception);
11891 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11892 +    SvPOK_on(perl_exception);  /* return messages in string context */
11893 +    ST(0)=sv_2mortal(perl_exception);
11894 +    XSRETURN(1);
11895 +  }
11896 +\f
11897 +#
11898 +###############################################################################
11899 +#                                                                             #
11900 +#                                                                             #
11901 +#                                                                             #
11902 +#   P i n g                                                                   #
11903 +#                                                                             #
11904 +#                                                                             #
11905 +#                                                                             #
11906 +###############################################################################
11907 +#
11908 +#
11909 +void
11910 +Ping(ref,...)
11911 +  Image::Magick ref = NO_INIT
11912 +  ALIAS:
11913 +    PingImage  = 1
11914 +    ping       = 2
11915 +    pingimage  = 3
11916 +  PPCODE:
11917 +  {
11918 +    AV
11919 +      *av;
11920 +
11921 +    char
11922 +      **keep,
11923 +      **list;
11924 +
11925 +    ExceptionInfo
11926 +      *exception;
11927 +
11928 +    Image
11929 +      *image,
11930 +      *next;
11931 +
11932 +    int
11933 +      n;
11934 +
11935 +    MagickBooleanType
11936 +      status;
11937 +
11938 +    register char
11939 +      **p;
11940 +
11941 +    register ssize_t
11942 +      i;
11943 +
11944 +    ssize_t
11945 +      ac;
11946 +
11947 +    STRLEN
11948 +      *length;
11949 +
11950 +    struct PackageInfo
11951 +      *info,
11952 +      *package_info;
11953 +
11954 +    SV
11955 +      *perl_exception,
11956 +      *reference;
11957 +
11958 +    size_t
11959 +      count;
11960 +
11961 +    PERL_UNUSED_VAR(ref);
11962 +    PERL_UNUSED_VAR(ix);
11963 +    exception=AcquireExceptionInfo();
11964 +    perl_exception=newSVpv("",0);
11965 +    package_info=(struct PackageInfo *) NULL;
11966 +    ac=(items < 2) ? 1 : items-1;
11967 +    list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11968 +    keep=list;
11969 +    length=(STRLEN *) NULL;
11970 +    if (list == (char **) NULL)
11971 +      {
11972 +        ThrowPerlException(exception,ResourceLimitError,
11973 +          "MemoryAllocationFailed",PackageName);
11974 +        goto PerlException;
11975 +      }
11976 +    keep=list;
11977 +    length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11978 +    if (length == (STRLEN *) NULL)
11979 +      {
11980 +        ThrowPerlException(exception,ResourceLimitError,
11981 +          "MemoryAllocationFailed",PackageName);
11982 +        goto PerlException;
11983 +      }
11984 +    if (sv_isobject(ST(0)) == 0)
11985 +      {
11986 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11987 +          PackageName);
11988 +        goto PerlException;
11989 +      }
11990 +    reference=SvRV(ST(0));
11991 +    if (SvTYPE(reference) != SVt_PVAV)
11992 +      {
11993 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11994 +          PackageName);
11995 +        goto PerlException;
11996 +      }
11997 +    av=(AV *) reference;
11998 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11999 +      exception);
12000 +    package_info=ClonePackageInfo(info,exception);
12001 +    n=1;
12002 +    if (items <= 1)
12003 +      *list=(char *) (*package_info->image_info->filename ?
12004 +        package_info->image_info->filename : "XC:black");
12005 +    else
12006 +      for (n=0, i=0; i < ac; i++)
12007 +      {
12008 +        list[n]=(char *) SvPV(ST(i+1),length[n]);
12009 +        if ((items >= 3) && strEQcase(list[n],"blob"))
12010 +          {
12011 +            void
12012 +              *blob;
12013 +
12014 +            i++;
12015 +            blob=(void *) (SvPV(ST(i+1),length[n]));
12016 +            SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12017 +          }
12018 +        if ((items >= 3) && strEQcase(list[n],"filename"))
12019 +          continue;
12020 +        if ((items >= 3) && strEQcase(list[n],"file"))
12021 +          {
12022 +            FILE
12023 +              *file;
12024 +
12025 +            PerlIO
12026 +              *io_info;
12027 +
12028 +            i++;
12029 +            io_info=IoIFP(sv_2io(ST(i+1)));
12030 +            if (io_info == (PerlIO *) NULL)
12031 +              {
12032 +                ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12033 +                  PackageName);
12034 +                continue;
12035 +              }
12036 +            file=PerlIO_findFILE(io_info);
12037 +            if (file == (FILE *) NULL)
12038 +              {
12039 +                ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12040 +                  PackageName);
12041 +                continue;
12042 +              }
12043 +            SetImageInfoFile(package_info->image_info,file);
12044 +          }
12045 +        if ((items >= 3) && strEQcase(list[n],"magick"))
12046 +          continue;
12047 +        n++;
12048 +      }
12049 +    list[n]=(char *) NULL;
12050 +    keep=list;
12051 +    status=ExpandFilenames(&n,&list);
12052 +    if (status == MagickFalse)
12053 +      {
12054 +        ThrowPerlException(exception,ResourceLimitError,
12055 +          "MemoryAllocationFailed",PackageName);
12056 +        goto PerlException;
12057 +      }
12058 +    count=0;
12059 +    for (i=0; i < n; i++)
12060 +    {
12061 +      (void) CopyMagickString(package_info->image_info->filename,list[i],
12062 +        MaxTextExtent);
12063 +      image=PingImage(package_info->image_info,exception);
12064 +      if (image == (Image *) NULL)
12065 +        break;
12066 +      if ((package_info->image_info->file != (FILE *) NULL) ||
12067 +          (package_info->image_info->blob != (void *) NULL))
12068 +        DisassociateImageStream(image);
12069 +      count+=GetImageListLength(image);
12070 +      EXTEND(sp,4*count);
12071 +      for (next=image; next; next=next->next)
12072 +      {
12073 +        PUSHs(sv_2mortal(newSViv(next->columns)));
12074 +        PUSHs(sv_2mortal(newSViv(next->rows)));
12075 +        PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12076 +        PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12077 +      }
12078 +      image=DestroyImageList(image);
12079 +    }
12080 +    /*
12081 +      Free resources.
12082 +    */
12083 +    for (i=0; i < n; i++)
12084 +      if (list[i] != (char *) NULL)
12085 +        for (p=keep; list[i] != *p++; )
12086 +          if (*p == NULL)
12087 +            {
12088 +              list[i]=(char *) RelinquishMagickMemory(list[i]);
12089 +              break;
12090 +            }
12091 +
12092 +  PerlException:
12093 +    if (package_info != (struct PackageInfo *) NULL)
12094 +      DestroyPackageInfo(package_info);
12095 +    if (list && (list != keep))
12096 +      list=(char **) RelinquishMagickMemory(list);
12097 +    if (keep)
12098 +      keep=(char **) RelinquishMagickMemory(keep);
12099 +    if (length)
12100 +      length=(STRLEN *) RelinquishMagickMemory(length);
12101 +    InheritPerlException(exception,perl_exception);
12102 +    exception=DestroyExceptionInfo(exception);
12103 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
12104 +  }
12105 +\f
12106 +#
12107 +###############################################################################
12108 +#                                                                             #
12109 +#                                                                             #
12110 +#                                                                             #
12111 +#   P r e v i e w                                                             #
12112 +#                                                                             #
12113 +#                                                                             #
12114 +#                                                                             #
12115 +###############################################################################
12116 +#
12117 +#
12118 +void
12119 +Preview(ref,...)
12120 +  Image::Magick ref = NO_INIT
12121 +  ALIAS:
12122 +    PreviewImage = 1
12123 +    preview      = 2
12124 +    previewimage = 3
12125 +  PPCODE:
12126 +  {
12127 +    AV
12128 +      *av;
12129 +
12130 +    ExceptionInfo
12131 +      *exception;
12132 +
12133 +    HV
12134 +      *hv;
12135 +
12136 +    Image
12137 +      *image,
12138 +      *preview_image;
12139 +
12140 +    PreviewType
12141 +      preview_type;
12142 +
12143 +    struct PackageInfo
12144 +      *info;
12145 +
12146 +    SV
12147 +      *av_reference,
12148 +      *perl_exception,
12149 +      *reference,
12150 +      *rv,
12151 +      *sv;
12152 +
12153 +    PERL_UNUSED_VAR(ref);
12154 +    PERL_UNUSED_VAR(ix);
12155 +    exception=AcquireExceptionInfo();
12156 +    perl_exception=newSVpv("",0);
12157 +    sv=NULL;
12158 +    av=NULL;
12159 +    if (sv_isobject(ST(0)) == 0)
12160 +      {
12161 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12162 +          PackageName);
12163 +        goto PerlException;
12164 +      }
12165 +    reference=SvRV(ST(0));
12166 +    hv=SvSTASH(reference);
12167 +    av=newAV();
12168 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12169 +    SvREFCNT_dec(av);
12170 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12171 +    if (image == (Image *) NULL)
12172 +      {
12173 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
12174 +          PackageName);
12175 +        goto PerlException;
12176 +      }
12177 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12178 +    preview_type=GammaPreview;
12179 +    if (items > 1)
12180 +      preview_type=(PreviewType)
12181 +        ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12182 +    for ( ; image; image=image->next)
12183 +    {
12184 +      preview_image=PreviewImage(image,preview_type,exception);
12185 +      if (preview_image == (Image *) NULL)
12186 +        goto PerlException;
12187 +      AddImageToRegistry(sv,preview_image);
12188 +      rv=newRV(sv);
12189 +      av_push(av,sv_bless(rv,hv));
12190 +      SvREFCNT_dec(sv);
12191 +    }
12192 +    exception=DestroyExceptionInfo(exception);
12193 +    ST(0)=av_reference;
12194 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
12195 +    XSRETURN(1);
12196 +
12197 +  PerlException:
12198 +    InheritPerlException(exception,perl_exception);
12199 +    exception=DestroyExceptionInfo(exception);
12200 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12201 +    SvPOK_on(perl_exception);
12202 +    ST(0)=sv_2mortal(perl_exception);
12203 +    XSRETURN(1);
12204 +  }
12205 +\f
12206 +#
12207 +###############################################################################
12208 +#                                                                             #
12209 +#                                                                             #
12210 +#                                                                             #
12211 +#   Q u e r y C o l o r                                                       #
12212 +#                                                                             #
12213 +#                                                                             #
12214 +#                                                                             #
12215 +###############################################################################
12216 +#
12217 +#
12218 +void
12219 +QueryColor(ref,...)
12220 +  Image::Magick ref = NO_INIT
12221 +  ALIAS:
12222 +    querycolor = 1
12223 +  PPCODE:
12224 +  {
12225 +    char
12226 +      *name;
12227 +
12228 +    ExceptionInfo
12229 +      *exception;
12230 +
12231 +    MagickPixelPacket
12232 +      color;
12233 +
12234 +    register ssize_t
12235 +      i;
12236 +
12237 +    SV
12238 +      *perl_exception;
12239 +
12240 +    PERL_UNUSED_VAR(ref);
12241 +    PERL_UNUSED_VAR(ix);
12242 +    exception=AcquireExceptionInfo();
12243 +    perl_exception=newSVpv("",0);
12244 +    if (items == 1)
12245 +      {
12246 +        const ColorInfo
12247 +          **colorlist;
12248 +
12249 +        size_t
12250 +          colors;
12251 +
12252 +        colorlist=GetColorInfoList("*",&colors,exception);
12253 +        EXTEND(sp,colors);
12254 +        for (i=0; i < (ssize_t) colors; i++)
12255 +        {
12256 +          PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12257 +        }
12258 +        colorlist=(const ColorInfo **)
12259 +          RelinquishMagickMemory((ColorInfo **) colorlist);
12260 +        goto PerlException;
12261 +      }
12262 +    EXTEND(sp,5*items);
12263 +    for (i=1; i < items; i++)
12264 +    {
12265 +      name=(char *) SvPV(ST(i),na);
12266 +      if (QueryMagickColor(name,&color,exception) == MagickFalse)
12267 +        {
12268 +          PUSHs(&sv_undef);
12269 +          continue;
12270 +        }
12271 +      PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12272 +      PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12273 +      PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12274 +      if (color.matte != MagickFalse)
12275 +        PUSHs(sv_2mortal(newSViv((size_t) floor(color.opacity+0.5))));
12276 +      if (color.colorspace == CMYKColorspace)
12277 +        PUSHs(sv_2mortal(newSViv((size_t) floor(color.index+0.5))));
12278 +    }
12279 +
12280 +  PerlException:
12281 +    InheritPerlException(exception,perl_exception);
12282 +    exception=DestroyExceptionInfo(exception);
12283 +    SvREFCNT_dec(perl_exception);
12284 +  }
12285 +\f
12286 +#
12287 +###############################################################################
12288 +#                                                                             #
12289 +#                                                                             #
12290 +#                                                                             #
12291 +#   Q u e r y C o l o r N a m e                                               #
12292 +#                                                                             #
12293 +#                                                                             #
12294 +#                                                                             #
12295 +###############################################################################
12296 +#
12297 +#
12298 +void
12299 +QueryColorname(ref,...)
12300 +  Image::Magick ref = NO_INIT
12301 +  ALIAS:
12302 +    querycolorname = 1
12303 +  PPCODE:
12304 +  {
12305 +    AV
12306 +      *av;
12307 +
12308 +    char
12309 +      message[MaxTextExtent];
12310 +
12311 +    ExceptionInfo
12312 +      *exception;
12313 +
12314 +    Image
12315 +      *image;
12316 +
12317 +    PixelPacket
12318 +      target_color;
12319 +
12320 +    register ssize_t
12321 +      i;
12322 +
12323 +    struct PackageInfo
12324 +      *info;
12325 +
12326 +    SV
12327 +      *perl_exception,
12328 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
12329 +
12330 +    PERL_UNUSED_VAR(ref);
12331 +    PERL_UNUSED_VAR(ix);
12332 +    exception=AcquireExceptionInfo();
12333 +    perl_exception=newSVpv("",0);
12334 +    reference=SvRV(ST(0));
12335 +    av=(AV *) reference;
12336 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12337 +      exception);
12338 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12339 +    if (image == (Image *) NULL)
12340 +      {
12341 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
12342 +          PackageName);
12343 +        goto PerlException;
12344 +      }
12345 +    EXTEND(sp,items);
12346 +    for (i=1; i < items; i++)
12347 +    {
12348 +      (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
12349 +      (void) QueryColorname(image,&target_color,SVGCompliance,message,
12350 +        exception);
12351 +      PUSHs(sv_2mortal(newSVpv(message,0)));
12352 +    }
12353 +
12354 +  PerlException:
12355 +    InheritPerlException(exception,perl_exception);
12356 +    exception=DestroyExceptionInfo(exception);
12357 +    SvREFCNT_dec(perl_exception);
12358 +  }
12359 +\f
12360 +#
12361 +###############################################################################
12362 +#                                                                             #
12363 +#                                                                             #
12364 +#                                                                             #
12365 +#   Q u e r y F o n t                                                         #
12366 +#                                                                             #
12367 +#                                                                             #
12368 +#                                                                             #
12369 +###############################################################################
12370 +#
12371 +#
12372 +void
12373 +QueryFont(ref,...)
12374 +  Image::Magick ref = NO_INIT
12375 +  ALIAS:
12376 +    queryfont = 1
12377 +  PPCODE:
12378 +  {
12379 +    char
12380 +      *name,
12381 +      message[MaxTextExtent];
12382 +
12383 +    ExceptionInfo
12384 +      *exception;
12385 +
12386 +    register ssize_t
12387 +      i;
12388 +
12389 +    SV
12390 +      *perl_exception;
12391 +
12392 +    volatile const TypeInfo
12393 +      *type_info;
12394 +
12395 +    PERL_UNUSED_VAR(ref);
12396 +    PERL_UNUSED_VAR(ix);
12397 +    exception=AcquireExceptionInfo();
12398 +    perl_exception=newSVpv("",0);
12399 +    if (items == 1)
12400 +      {
12401 +        const TypeInfo
12402 +          **typelist;
12403 +
12404 +        size_t
12405 +          types;
12406 +
12407 +        typelist=GetTypeInfoList("*",&types,exception);
12408 +        EXTEND(sp,types);
12409 +        for (i=0; i < (ssize_t) types; i++)
12410 +        {
12411 +          PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12412 +        }
12413 +        typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12414 +          typelist);
12415 +        goto PerlException;
12416 +      }
12417 +    EXTEND(sp,10*items);
12418 +    for (i=1; i < items; i++)
12419 +    {
12420 +      name=(char *) SvPV(ST(i),na);
12421 +      type_info=GetTypeInfo(name,exception);
12422 +      if (type_info == (TypeInfo *) NULL)
12423 +        {
12424 +          PUSHs(&sv_undef);
12425 +          continue;
12426 +        }
12427 +      if (type_info->name == (char *) NULL)
12428 +        PUSHs(&sv_undef);
12429 +      else
12430 +        PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12431 +      if (type_info->description == (char *) NULL)
12432 +        PUSHs(&sv_undef);
12433 +      else
12434 +        PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12435 +      if (type_info->family == (char *) NULL)
12436 +        PUSHs(&sv_undef);
12437 +      else
12438 +        PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12439 +      if (type_info->style == UndefinedStyle)
12440 +        PUSHs(&sv_undef);
12441 +      else
12442 +        PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12443 +          type_info->style),0)));
12444 +      if (type_info->stretch == UndefinedStretch)
12445 +        PUSHs(&sv_undef);
12446 +      else
12447 +        PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12448 +          type_info->stretch),0)));
12449 +      (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12450 +        type_info->weight);
12451 +      PUSHs(sv_2mortal(newSVpv(message,0)));
12452 +      if (type_info->encoding == (char *) NULL)
12453 +        PUSHs(&sv_undef);
12454 +      else
12455 +        PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12456 +      if (type_info->foundry == (char *) NULL)
12457 +        PUSHs(&sv_undef);
12458 +      else
12459 +        PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12460 +      if (type_info->format == (char *) NULL)
12461 +        PUSHs(&sv_undef);
12462 +      else
12463 +        PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12464 +      if (type_info->metrics == (char *) NULL)
12465 +        PUSHs(&sv_undef);
12466 +      else
12467 +        PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12468 +      if (type_info->glyphs == (char *) NULL)
12469 +        PUSHs(&sv_undef);
12470 +      else
12471 +        PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12472 +    }
12473 +
12474 +  PerlException:
12475 +    InheritPerlException(exception,perl_exception);
12476 +    exception=DestroyExceptionInfo(exception);
12477 +    SvREFCNT_dec(perl_exception);
12478 +  }
12479 +\f
12480 +#
12481 +###############################################################################
12482 +#                                                                             #
12483 +#                                                                             #
12484 +#                                                                             #
12485 +#   Q u e r y F o n t M e t r i c s                                           #
12486 +#                                                                             #
12487 +#                                                                             #
12488 +#                                                                             #
12489 +###############################################################################
12490 +#
12491 +#
12492 +void
12493 +QueryFontMetrics(ref,...)
12494 +  Image::Magick ref = NO_INIT
12495 +  ALIAS:
12496 +    queryfontmetrics = 1
12497 +  PPCODE:
12498 +  {
12499 +    AffineMatrix
12500 +      affine,
12501 +      current;
12502 +
12503 +    AV
12504 +      *av;
12505 +
12506 +    char
12507 +      *attribute;
12508 +
12509 +    double
12510 +      x,
12511 +      y;
12512 +
12513 +    DrawInfo
12514 +      *draw_info;
12515 +
12516 +    ExceptionInfo
12517 +      *exception;
12518 +
12519 +    GeometryInfo
12520 +      geometry_info;
12521 +
12522 +    Image
12523 +      *image;
12524 +
12525 +    MagickBooleanType
12526 +      status;
12527 +
12528 +    MagickStatusType
12529 +      flags;
12530 +
12531 +    register ssize_t
12532 +      i;
12533 +
12534 +    ssize_t
12535 +      type;
12536 +
12537 +    struct PackageInfo
12538 +      *info,
12539 +      *package_info;
12540 +
12541 +    SV
12542 +      *perl_exception,
12543 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
12544 +
12545 +    TypeMetric
12546 +      metrics;
12547 +
12548 +    PERL_UNUSED_VAR(ref);
12549 +    PERL_UNUSED_VAR(ix);
12550 +    exception=AcquireExceptionInfo();
12551 +    package_info=(struct PackageInfo *) NULL;
12552 +    perl_exception=newSVpv("",0);
12553 +    reference=SvRV(ST(0));
12554 +    av=(AV *) reference;
12555 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12556 +      exception);
12557 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12558 +    if (image == (Image *) NULL)
12559 +      {
12560 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
12561 +          PackageName);
12562 +        goto PerlException;
12563 +      }
12564 +    package_info=ClonePackageInfo(info,exception);
12565 +    draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12566 +    CloneString(&draw_info->text,"");
12567 +    current=draw_info->affine;
12568 +    GetAffineMatrix(&affine);
12569 +    x=0.0;
12570 +    y=0.0;
12571 +    EXTEND(sp,7*items);
12572 +    for (i=2; i < items; i+=2)
12573 +    {
12574 +      attribute=(char *) SvPV(ST(i-1),na);
12575 +      switch (*attribute)
12576 +      {
12577 +        case 'A':
12578 +        case 'a':
12579 +        {
12580 +          if (LocaleCompare(attribute,"antialias") == 0)
12581 +            {
12582 +              type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12583 +                SvPV(ST(i),na));
12584 +              if (type < 0)
12585 +                {
12586 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
12587 +                    SvPV(ST(i),na));
12588 +                  break;
12589 +                }
12590 +              draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12591 +              break;
12592 +            }
12593 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12594 +            attribute);
12595 +          break;
12596 +        }
12597 +        case 'd':
12598 +        case 'D':
12599 +        {
12600 +          if (LocaleCompare(attribute,"density") == 0)
12601 +            {
12602 +              CloneString(&draw_info->density,SvPV(ST(i),na));
12603 +              break;
12604 +            }
12605 +          if (LocaleCompare(attribute,"direction") == 0)
12606 +            {
12607 +              draw_info->direction=(DirectionType) ParseCommandOption(
12608 +                MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12609 +              break;
12610 +            }
12611 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12612 +            attribute);
12613 +          break;
12614 +        }
12615 +        case 'e':
12616 +        case 'E':
12617 +        {
12618 +          if (LocaleCompare(attribute,"encoding") == 0)
12619 +            {
12620 +              CloneString(&draw_info->encoding,SvPV(ST(i),na));
12621 +              break;
12622 +            }
12623 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12624 +            attribute);
12625 +          break;
12626 +        }
12627 +        case 'f':
12628 +        case 'F':
12629 +        {
12630 +          if (LocaleCompare(attribute,"family") == 0)
12631 +            {
12632 +              CloneString(&draw_info->family,SvPV(ST(i),na));
12633 +              break;
12634 +            }
12635 +          if (LocaleCompare(attribute,"fill") == 0)
12636 +            {
12637 +              if (info)
12638 +                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12639 +                  &image->exception);
12640 +              break;
12641 +            }
12642 +          if (LocaleCompare(attribute,"font") == 0)
12643 +            {
12644 +              CloneString(&draw_info->font,SvPV(ST(i),na));
12645 +              break;
12646 +            }
12647 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12648 +            attribute);
12649 +          break;
12650 +        }
12651 +        case 'g':
12652 +        case 'G':
12653 +        {
12654 +          if (LocaleCompare(attribute,"geometry") == 0)
12655 +            {
12656 +              CloneString(&draw_info->geometry,SvPV(ST(i),na));
12657 +              break;
12658 +            }
12659 +          if (LocaleCompare(attribute,"gravity") == 0)
12660 +            {
12661 +              draw_info->gravity=(GravityType) ParseCommandOption(
12662 +                MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12663 +              break;
12664 +            }
12665 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12666 +            attribute);
12667 +          break;
12668 +        }
12669 +        case 'i':
12670 +        case 'I':
12671 +        {
12672 +          if (LocaleCompare(attribute,"interline-spacing") == 0)
12673 +            {
12674 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12675 +              draw_info->interline_spacing=geometry_info.rho;
12676 +              break;
12677 +            }
12678 +          if (LocaleCompare(attribute,"interword-spacing") == 0)
12679 +            {
12680 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12681 +              draw_info->interword_spacing=geometry_info.rho;
12682 +              break;
12683 +            }
12684 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12685 +            attribute);
12686 +          break;
12687 +        }
12688 +        case 'k':
12689 +        case 'K':
12690 +        {
12691 +          if (LocaleCompare(attribute,"kerning") == 0)
12692 +            {
12693 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12694 +              draw_info->kerning=geometry_info.rho;
12695 +              break;
12696 +            }
12697 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12698 +            attribute);
12699 +          break;
12700 +        }
12701 +        case 'p':
12702 +        case 'P':
12703 +        {
12704 +          if (LocaleCompare(attribute,"pointsize") == 0)
12705 +            {
12706 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12707 +              draw_info->pointsize=geometry_info.rho;
12708 +              break;
12709 +            }
12710 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12711 +            attribute);
12712 +          break;
12713 +        }
12714 +        case 'r':
12715 +        case 'R':
12716 +        {
12717 +          if (LocaleCompare(attribute,"rotate") == 0)
12718 +            {
12719 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12720 +              affine.rx=geometry_info.rho;
12721 +              affine.ry=geometry_info.sigma;
12722 +              if ((flags & SigmaValue) == 0)
12723 +                affine.ry=affine.rx;
12724 +              break;
12725 +            }
12726 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12727 +            attribute);
12728 +          break;
12729 +        }
12730 +        case 's':
12731 +        case 'S':
12732 +        {
12733 +          if (LocaleCompare(attribute,"scale") == 0)
12734 +            {
12735 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12736 +              affine.sx=geometry_info.rho;
12737 +              affine.sy=geometry_info.sigma;
12738 +              if ((flags & SigmaValue) == 0)
12739 +                affine.sy=affine.sx;
12740 +              break;
12741 +            }
12742 +          if (LocaleCompare(attribute,"skew") == 0)
12743 +            {
12744 +              double
12745 +                x_angle,
12746 +                y_angle;
12747 +
12748 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12749 +              x_angle=geometry_info.rho;
12750 +              y_angle=geometry_info.sigma;
12751 +              if ((flags & SigmaValue) == 0)
12752 +                y_angle=x_angle;
12753 +              affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12754 +              affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12755 +              break;
12756 +            }
12757 +          if (LocaleCompare(attribute,"stroke") == 0)
12758 +            {
12759 +              if (info)
12760 +                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12761 +                  &image->exception);
12762 +              break;
12763 +            }
12764 +          if (LocaleCompare(attribute,"style") == 0)
12765 +            {
12766 +              type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12767 +                SvPV(ST(i),na));
12768 +              if (type < 0)
12769 +                {
12770 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
12771 +                    SvPV(ST(i),na));
12772 +                  break;
12773 +                }
12774 +              draw_info->style=(StyleType) type;
12775 +              break;
12776 +            }
12777 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12778 +            attribute);
12779 +          break;
12780 +        }
12781 +        case 't':
12782 +        case 'T':
12783 +        {
12784 +          if (LocaleCompare(attribute,"text") == 0)
12785 +            {
12786 +              CloneString(&draw_info->text,SvPV(ST(i),na));
12787 +              break;
12788 +            }
12789 +          if (LocaleCompare(attribute,"translate") == 0)
12790 +            {
12791 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12792 +              affine.tx=geometry_info.rho;
12793 +              affine.ty=geometry_info.sigma;
12794 +              if ((flags & SigmaValue) == 0)
12795 +                affine.ty=affine.tx;
12796 +              break;
12797 +            }
12798 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12799 +            attribute);
12800 +          break;
12801 +        }
12802 +        case 'w':
12803 +        case 'W':
12804 +        {
12805 +          if (LocaleCompare(attribute,"weight") == 0)
12806 +            {
12807 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12808 +              draw_info->weight=(size_t) geometry_info.rho;
12809 +              break;
12810 +            }
12811 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12812 +            attribute);
12813 +          break;
12814 +        }
12815 +        case 'x':
12816 +        case 'X':
12817 +        {
12818 +          if (LocaleCompare(attribute,"x") == 0)
12819 +            {
12820 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12821 +              x=geometry_info.rho;
12822 +              break;
12823 +            }
12824 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12825 +            attribute);
12826 +          break;
12827 +        }
12828 +        case 'y':
12829 +        case 'Y':
12830 +        {
12831 +          if (LocaleCompare(attribute,"y") == 0)
12832 +            {
12833 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12834 +              y=geometry_info.rho;
12835 +              break;
12836 +            }
12837 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12838 +            attribute);
12839 +          break;
12840 +        }
12841 +        default:
12842 +        {
12843 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12844 +            attribute);
12845 +          break;
12846 +        }
12847 +      }
12848 +    }
12849 +    draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12850 +    draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12851 +    draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12852 +    draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12853 +    draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12854 +    draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12855 +    if (draw_info->geometry == (char *) NULL)
12856 +      {
12857 +        draw_info->geometry=AcquireString((char *) NULL);
12858 +        (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12859 +          "%.15g,%.15g",x,y);
12860 +      }
12861 +    status=GetTypeMetrics(image,draw_info,&metrics);
12862 +    (void) CatchImageException(image);
12863 +    if (status == MagickFalse)
12864 +      PUSHs(&sv_undef);
12865 +    else
12866 +      {
12867 +        PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12868 +        PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12869 +        PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12870 +        PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12871 +        PUSHs(sv_2mortal(newSVnv(metrics.width)));
12872 +        PUSHs(sv_2mortal(newSVnv(metrics.height)));
12873 +        PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12874 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12875 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12876 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12877 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12878 +        PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12879 +        PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12880 +      }
12881 +    draw_info=DestroyDrawInfo(draw_info);
12882 +
12883 +  PerlException:
12884 +    if (package_info != (struct PackageInfo *) NULL)
12885 +      DestroyPackageInfo(package_info);
12886 +    InheritPerlException(exception,perl_exception);
12887 +    exception=DestroyExceptionInfo(exception);
12888 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
12889 +  }
12890 +\f
12891 +#
12892 +###############################################################################
12893 +#                                                                             #
12894 +#                                                                             #
12895 +#                                                                             #
12896 +#   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                         #
12897 +#                                                                             #
12898 +#                                                                             #
12899 +#                                                                             #
12900 +###############################################################################
12901 +#
12902 +#
12903 +void
12904 +QueryMultilineFontMetrics(ref,...)
12905 +  Image::Magick ref = NO_INIT
12906 +  ALIAS:
12907 +    querymultilinefontmetrics = 1
12908 +  PPCODE:
12909 +  {
12910 +    AffineMatrix
12911 +      affine,
12912 +      current;
12913 +
12914 +    AV
12915 +      *av;
12916 +
12917 +    char
12918 +      *attribute;
12919 +
12920 +    double
12921 +      x,
12922 +      y;
12923 +
12924 +    DrawInfo
12925 +      *draw_info;
12926 +
12927 +    ExceptionInfo
12928 +      *exception;
12929 +
12930 +    GeometryInfo
12931 +      geometry_info;
12932 +
12933 +    Image
12934 +      *image;
12935 +
12936 +    MagickBooleanType
12937 +      status;
12938 +
12939 +    MagickStatusType
12940 +      flags;
12941 +
12942 +    register ssize_t
12943 +      i;
12944 +
12945 +    ssize_t
12946 +      type;
12947 +
12948 +    struct PackageInfo
12949 +      *info,
12950 +      *package_info;
12951 +
12952 +    SV
12953 +      *perl_exception,
12954 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
12955 +
12956 +    TypeMetric
12957 +      metrics;
12958 +
12959 +    PERL_UNUSED_VAR(ref);
12960 +    PERL_UNUSED_VAR(ix);
12961 +    exception=AcquireExceptionInfo();
12962 +    package_info=(struct PackageInfo *) NULL;
12963 +    perl_exception=newSVpv("",0);
12964 +    reference=SvRV(ST(0));
12965 +    av=(AV *) reference;
12966 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12967 +      exception);
12968 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12969 +    if (image == (Image *) NULL)
12970 +      {
12971 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
12972 +          PackageName);
12973 +        goto PerlException;
12974 +      }
12975 +    package_info=ClonePackageInfo(info,exception);
12976 +    draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12977 +    CloneString(&draw_info->text,"");
12978 +    current=draw_info->affine;
12979 +    GetAffineMatrix(&affine);
12980 +    x=0.0;
12981 +    y=0.0;
12982 +    EXTEND(sp,7*items);
12983 +    for (i=2; i < items; i+=2)
12984 +    {
12985 +      attribute=(char *) SvPV(ST(i-1),na);
12986 +      switch (*attribute)
12987 +      {
12988 +        case 'A':
12989 +        case 'a':
12990 +        {
12991 +          if (LocaleCompare(attribute,"antialias") == 0)
12992 +            {
12993 +              type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12994 +                SvPV(ST(i),na));
12995 +              if (type < 0)
12996 +                {
12997 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
12998 +                    SvPV(ST(i),na));
12999 +                  break;
13000 +                }
13001 +              draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13002 +              break;
13003 +            }
13004 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13005 +            attribute);
13006 +          break;
13007 +        }
13008 +        case 'd':
13009 +        case 'D':
13010 +        {
13011 +          if (LocaleCompare(attribute,"density") == 0)
13012 +            {
13013 +              CloneString(&draw_info->density,SvPV(ST(i),na));
13014 +              break;
13015 +            }
13016 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13017 +            attribute);
13018 +          break;
13019 +        }
13020 +        case 'e':
13021 +        case 'E':
13022 +        {
13023 +          if (LocaleCompare(attribute,"encoding") == 0)
13024 +            {
13025 +              CloneString(&draw_info->encoding,SvPV(ST(i),na));
13026 +              break;
13027 +            }
13028 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13029 +            attribute);
13030 +          break;
13031 +        }
13032 +        case 'f':
13033 +        case 'F':
13034 +        {
13035 +          if (LocaleCompare(attribute,"family") == 0)
13036 +            {
13037 +              CloneString(&draw_info->family,SvPV(ST(i),na));
13038 +              break;
13039 +            }
13040 +          if (LocaleCompare(attribute,"fill") == 0)
13041 +            {
13042 +              if (info)
13043 +                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
13044 +                  &image->exception);
13045 +              break;
13046 +            }
13047 +          if (LocaleCompare(attribute,"font") == 0)
13048 +            {
13049 +              CloneString(&draw_info->font,SvPV(ST(i),na));
13050 +              break;
13051 +            }
13052 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13053 +            attribute);
13054 +          break;
13055 +        }
13056 +        case 'g':
13057 +        case 'G':
13058 +        {
13059 +          if (LocaleCompare(attribute,"geometry") == 0)
13060 +            {
13061 +              CloneString(&draw_info->geometry,SvPV(ST(i),na));
13062 +              break;
13063 +            }
13064 +          if (LocaleCompare(attribute,"gravity") == 0)
13065 +            {
13066 +              draw_info->gravity=(GravityType) ParseCommandOption(
13067 +                MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13068 +              break;
13069 +            }
13070 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13071 +            attribute);
13072 +          break;
13073 +        }
13074 +        case 'p':
13075 +        case 'P':
13076 +        {
13077 +          if (LocaleCompare(attribute,"pointsize") == 0)
13078 +            {
13079 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13080 +              draw_info->pointsize=geometry_info.rho;
13081 +              break;
13082 +            }
13083 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13084 +            attribute);
13085 +          break;
13086 +        }
13087 +        case 'r':
13088 +        case 'R':
13089 +        {
13090 +          if (LocaleCompare(attribute,"rotate") == 0)
13091 +            {
13092 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13093 +              affine.rx=geometry_info.rho;
13094 +              affine.ry=geometry_info.sigma;
13095 +              if ((flags & SigmaValue) == 0)
13096 +                affine.ry=affine.rx;
13097 +              break;
13098 +            }
13099 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13100 +            attribute);
13101 +          break;
13102 +        }
13103 +        case 's':
13104 +        case 'S':
13105 +        {
13106 +          if (LocaleCompare(attribute,"scale") == 0)
13107 +            {
13108 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13109 +              affine.sx=geometry_info.rho;
13110 +              affine.sy=geometry_info.sigma;
13111 +              if ((flags & SigmaValue) == 0)
13112 +                affine.sy=affine.sx;
13113 +              break;
13114 +            }
13115 +          if (LocaleCompare(attribute,"skew") == 0)
13116 +            {
13117 +              double
13118 +                x_angle,
13119 +                y_angle;
13120 +
13121 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13122 +              x_angle=geometry_info.rho;
13123 +              y_angle=geometry_info.sigma;
13124 +              if ((flags & SigmaValue) == 0)
13125 +                y_angle=x_angle;
13126 +              affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13127 +              affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13128 +              break;
13129 +            }
13130 +          if (LocaleCompare(attribute,"stroke") == 0)
13131 +            {
13132 +              if (info)
13133 +                (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
13134 +                  &image->exception);
13135 +              break;
13136 +            }
13137 +          if (LocaleCompare(attribute,"style") == 0)
13138 +            {
13139 +              type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13140 +                SvPV(ST(i),na));
13141 +              if (type < 0)
13142 +                {
13143 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
13144 +                    SvPV(ST(i),na));
13145 +                  break;
13146 +                }
13147 +              draw_info->style=(StyleType) type;
13148 +              break;
13149 +            }
13150 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13151 +            attribute);
13152 +          break;
13153 +        }
13154 +        case 't':
13155 +        case 'T':
13156 +        {
13157 +          if (LocaleCompare(attribute,"text") == 0)
13158 +            {
13159 +              CloneString(&draw_info->text,SvPV(ST(i),na));
13160 +              break;
13161 +            }
13162 +          if (LocaleCompare(attribute,"translate") == 0)
13163 +            {
13164 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13165 +              affine.tx=geometry_info.rho;
13166 +              affine.ty=geometry_info.sigma;
13167 +              if ((flags & SigmaValue) == 0)
13168 +                affine.ty=affine.tx;
13169 +              break;
13170 +            }
13171 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13172 +            attribute);
13173 +          break;
13174 +        }
13175 +        case 'w':
13176 +        case 'W':
13177 +        {
13178 +          if (LocaleCompare(attribute,"weight") == 0)
13179 +            {
13180 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13181 +              draw_info->weight=(size_t) geometry_info.rho;
13182 +              break;
13183 +            }
13184 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13185 +            attribute);
13186 +          break;
13187 +        }
13188 +        case 'x':
13189 +        case 'X':
13190 +        {
13191 +          if (LocaleCompare(attribute,"x") == 0)
13192 +            {
13193 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13194 +              x=geometry_info.rho;
13195 +              break;
13196 +            }
13197 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13198 +            attribute);
13199 +          break;
13200 +        }
13201 +        case 'y':
13202 +        case 'Y':
13203 +        {
13204 +          if (LocaleCompare(attribute,"y") == 0)
13205 +            {
13206 +              flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13207 +              y=geometry_info.rho;
13208 +              break;
13209 +            }
13210 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13211 +            attribute);
13212 +          break;
13213 +        }
13214 +        default:
13215 +        {
13216 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13217 +            attribute);
13218 +          break;
13219 +        }
13220 +      }
13221 +    }
13222 +    draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13223 +    draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13224 +    draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13225 +    draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13226 +    draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13227 +    draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13228 +    if (draw_info->geometry == (char *) NULL)
13229 +      {
13230 +        draw_info->geometry=AcquireString((char *) NULL);
13231 +        (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
13232 +          "%.15g,%.15g",x,y);
13233 +      }
13234 +    status=GetMultilineTypeMetrics(image,draw_info,&metrics);
13235 +    (void) CatchImageException(image);
13236 +    if (status == MagickFalse)
13237 +      PUSHs(&sv_undef);
13238 +    else
13239 +      {
13240 +        PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13241 +        PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13242 +        PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13243 +        PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13244 +        PUSHs(sv_2mortal(newSVnv(metrics.width)));
13245 +        PUSHs(sv_2mortal(newSVnv(metrics.height)));
13246 +        PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13247 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13248 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13249 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13250 +        PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13251 +        PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13252 +        PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13253 +      }
13254 +    draw_info=DestroyDrawInfo(draw_info);
13255 +
13256 +  PerlException:
13257 +    if (package_info != (struct PackageInfo *) NULL)
13258 +      DestroyPackageInfo(package_info);
13259 +    InheritPerlException(exception,perl_exception);
13260 +    exception=DestroyExceptionInfo(exception);
13261 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
13262 +  }
13263 +\f
13264 +#
13265 +###############################################################################
13266 +#                                                                             #
13267 +#                                                                             #
13268 +#                                                                             #
13269 +#   Q u e r y F o r m a t                                                     #
13270 +#                                                                             #
13271 +#                                                                             #
13272 +#                                                                             #
13273 +###############################################################################
13274 +#
13275 +#
13276 +void
13277 +QueryFormat(ref,...)
13278 +  Image::Magick ref = NO_INIT
13279 +  ALIAS:
13280 +    queryformat = 1
13281 +  PPCODE:
13282 +  {
13283 +    char
13284 +      *name;
13285 +
13286 +    ExceptionInfo
13287 +      *exception;
13288 +
13289 +    register ssize_t
13290 +      i;
13291 +
13292 +    SV
13293 +      *perl_exception;
13294 +
13295 +    volatile const MagickInfo
13296 +      *magick_info;
13297 +
13298 +    PERL_UNUSED_VAR(ref);
13299 +    PERL_UNUSED_VAR(ix);
13300 +    exception=AcquireExceptionInfo();
13301 +    perl_exception=newSVpv("",0);
13302 +    if (items == 1)
13303 +      {
13304 +        char
13305 +          format[MaxTextExtent];
13306 +
13307 +        const MagickInfo
13308 +          **format_list;
13309 +
13310 +        size_t
13311 +          types;
13312 +
13313 +        format_list=GetMagickInfoList("*",&types,exception);
13314 +        EXTEND(sp,types);
13315 +        for (i=0; i < (ssize_t) types; i++)
13316 +        {
13317 +          (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13318 +          LocaleLower(format);
13319 +          PUSHs(sv_2mortal(newSVpv(format,0)));
13320 +        }
13321 +        format_list=(const MagickInfo **)
13322 +          RelinquishMagickMemory((MagickInfo *) format_list);
13323 +        goto PerlException;
13324 +      }
13325 +    EXTEND(sp,8*items);
13326 +    for (i=1; i < items; i++)
13327 +    {
13328 +      name=(char *) SvPV(ST(i),na);
13329 +      magick_info=GetMagickInfo(name,exception);
13330 +      if (magick_info == (const MagickInfo *) NULL)
13331 +        {
13332 +          PUSHs(&sv_undef);
13333 +          continue;
13334 +        }
13335 +      PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13336 +      PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13337 +      PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13338 +      PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13339 +      PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13340 +      if (magick_info->description == (char *) NULL)
13341 +        PUSHs(&sv_undef);
13342 +      else
13343 +        PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13344 +      if (magick_info->module == (char *) NULL)
13345 +        PUSHs(&sv_undef);
13346 +      else
13347 +        PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13348 +    }
13349 +
13350 +  PerlException:
13351 +    InheritPerlException(exception,perl_exception);
13352 +    exception=DestroyExceptionInfo(exception);
13353 +    SvREFCNT_dec(perl_exception);
13354 +  }
13355 +\f
13356 +#
13357 +###############################################################################
13358 +#                                                                             #
13359 +#                                                                             #
13360 +#                                                                             #
13361 +#   Q u e r y O p t i o n                                                     #
13362 +#                                                                             #
13363 +#                                                                             #
13364 +#                                                                             #
13365 +###############################################################################
13366 +#
13367 +#
13368 +void
13369 +QueryOption(ref,...)
13370 +  Image::Magick ref = NO_INIT
13371 +  ALIAS:
13372 +    queryoption = 1
13373 +  PPCODE:
13374 +  {
13375 +    char
13376 +      **options;
13377 +
13378 +    ExceptionInfo
13379 +      *exception;
13380 +
13381 +    register ssize_t
13382 +      i;
13383 +
13384 +    ssize_t
13385 +      j,
13386 +      option;
13387 +
13388 +    SV
13389 +      *perl_exception;
13390 +
13391 +    PERL_UNUSED_VAR(ref);
13392 +    PERL_UNUSED_VAR(ix);
13393 +    exception=AcquireExceptionInfo();
13394 +    perl_exception=newSVpv("",0);
13395 +    EXTEND(sp,8*items);
13396 +    for (i=1; i < items; i++)
13397 +    {
13398 +      option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13399 +        SvPV(ST(i),na));
13400 +      options=GetCommandOptions((CommandOption) option);
13401 +      if (options == (char **) NULL)
13402 +        PUSHs(&sv_undef);
13403 +      else
13404 +        {
13405 +          for (j=0; options[j] != (char *) NULL; j++)
13406 +            PUSHs(sv_2mortal(newSVpv(options[j],0)));
13407 +          options=DestroyStringList(options);
13408 +        }
13409 +    }
13410 +
13411 +    InheritPerlException(exception,perl_exception);
13412 +    exception=DestroyExceptionInfo(exception);
13413 +    SvREFCNT_dec(perl_exception);
13414 +  }
13415 +\f
13416 +#
13417 +###############################################################################
13418 +#                                                                             #
13419 +#                                                                             #
13420 +#                                                                             #
13421 +#   R e a d                                                                   #
13422 +#                                                                             #
13423 +#                                                                             #
13424 +#                                                                             #
13425 +###############################################################################
13426 +#
13427 +#
13428 +void
13429 +Read(ref,...)
13430 +  Image::Magick ref = NO_INIT
13431 +  ALIAS:
13432 +    ReadImage  = 1
13433 +    read       = 2
13434 +    readimage  = 3
13435 +  PPCODE:
13436 +  {
13437 +    AV
13438 +      *av;
13439 +
13440 +    char
13441 +      **keep,
13442 +      **list;
13443 +
13444 +    ExceptionInfo
13445 +      *exception;
13446 +
13447 +    HV
13448 +      *hv;
13449 +
13450 +    Image
13451 +      *image;
13452 +
13453 +    int
13454 +      n;
13455 +
13456 +    MagickBooleanType
13457 +      status;
13458 +
13459 +    register char
13460 +      **p;
13461 +
13462 +    register ssize_t
13463 +      i;
13464 +
13465 +    ssize_t
13466 +      ac,
13467 +      number_images;
13468 +
13469 +    STRLEN
13470 +      *length;
13471 +
13472 +    struct PackageInfo
13473 +      *info,
13474 +      *package_info;
13475 +
13476 +    SV
13477 +      *perl_exception,  /* Perl variable for storing messages */
13478 +      *reference,
13479 +      *rv,
13480 +      *sv;
13481 +
13482 +    PERL_UNUSED_VAR(ref);
13483 +    PERL_UNUSED_VAR(ix);
13484 +    exception=AcquireExceptionInfo();
13485 +    perl_exception=newSVpv("",0);
13486 +    sv=NULL;
13487 +    package_info=(struct PackageInfo *) NULL;
13488 +    number_images=0;
13489 +    ac=(items < 2) ? 1 : items-1;
13490 +    list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13491 +    keep=list;
13492 +    length=(STRLEN *) NULL;
13493 +    if (list == (char **) NULL)
13494 +      {
13495 +        ThrowPerlException(exception,ResourceLimitError,
13496 +          "MemoryAllocationFailed",PackageName);
13497 +        goto PerlException;
13498 +      }
13499 +    length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13500 +    if (length == (STRLEN *) NULL)
13501 +      {
13502 +        ThrowPerlException(exception,ResourceLimitError,
13503 +          "MemoryAllocationFailed",PackageName);
13504 +        goto PerlException;
13505 +      }
13506 +    if (sv_isobject(ST(0)) == 0)
13507 +      {
13508 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13509 +          PackageName);
13510 +        goto PerlException;
13511 +      }
13512 +    reference=SvRV(ST(0));
13513 +    hv=SvSTASH(reference);
13514 +    if (SvTYPE(reference) != SVt_PVAV)
13515 +      {
13516 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13517 +          PackageName);
13518 +        goto PerlException;
13519 +      }
13520 +    av=(AV *) reference;
13521 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13522 +      exception);
13523 +    package_info=ClonePackageInfo(info,exception);
13524 +    n=1;
13525 +    if (items <= 1)
13526 +      *list=(char *) (*package_info->image_info->filename ?
13527 +        package_info->image_info->filename : "XC:black");
13528 +    else
13529 +      for (n=0, i=0; i < ac; i++)
13530 +      {
13531 +        list[n]=(char *) SvPV(ST(i+1),length[n]);
13532 +        if ((items >= 3) && strEQcase(list[n],"blob"))
13533 +          {
13534 +            void
13535 +              *blob;
13536 +
13537 +            i++;
13538 +            blob=(void *) (SvPV(ST(i+1),length[n]));
13539 +            SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13540 +          }
13541 +        if ((items >= 3) && strEQcase(list[n],"filename"))
13542 +          continue;
13543 +        if ((items >= 3) && strEQcase(list[n],"file"))
13544 +          {
13545 +            FILE
13546 +              *file;
13547 +
13548 +            PerlIO
13549 +              *io_info;
13550 +
13551 +            i++;
13552 +            io_info=IoIFP(sv_2io(ST(i+1)));
13553 +            if (io_info == (PerlIO *) NULL)
13554 +              {
13555 +                ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13556 +                  PackageName);
13557 +                continue;
13558 +              }
13559 +            file=PerlIO_findFILE(io_info);
13560 +            if (file == (FILE *) NULL)
13561 +              {
13562 +                ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13563 +                  PackageName);
13564 +                continue;
13565 +              }
13566 +            SetImageInfoFile(package_info->image_info,file);
13567 +          }
13568 +        if ((items >= 3) && strEQcase(list[n],"magick"))
13569 +          continue;
13570 +        n++;
13571 +      }
13572 +    list[n]=(char *) NULL;
13573 +    keep=list;
13574 +    status=ExpandFilenames(&n,&list);
13575 +    if (status == MagickFalse)
13576 +      {
13577 +        ThrowPerlException(exception,ResourceLimitError,
13578 +          "MemoryAllocationFailed",PackageName);
13579 +        goto PerlException;
13580 +      }
13581 +    number_images=0;
13582 +    for (i=0; i < n; i++)
13583 +    {
13584 +      if ((package_info->image_info->file != (FILE *) NULL) ||
13585 +          (package_info->image_info->blob != (void *) NULL))
13586 +        {
13587 +          image=ReadImages(package_info->image_info,exception);
13588 +          if (image != (Image *) NULL)
13589 +            DisassociateImageStream(image);
13590 +        }
13591 +      else
13592 +        {
13593 +          (void) CopyMagickString(package_info->image_info->filename,list[i],
13594 +            MaxTextExtent);
13595 +          image=ReadImages(package_info->image_info,exception);
13596 +        }
13597 +      if (image == (Image *) NULL)
13598 +        break;
13599 +      for ( ; image; image=image->next)
13600 +      {
13601 +        AddImageToRegistry(sv,image);
13602 +        rv=newRV(sv);
13603 +        av_push(av,sv_bless(rv,hv));
13604 +        SvREFCNT_dec(sv);
13605 +        number_images++;
13606 +      }
13607 +    }
13608 +    /*
13609 +      Free resources.
13610 +    */
13611 +    for (i=0; i < n; i++)
13612 +      if (list[i] != (char *) NULL)
13613 +        for (p=keep; list[i] != *p++; )
13614 +          if (*p == (char *) NULL)
13615 +            {
13616 +              list[i]=(char *) RelinquishMagickMemory(list[i]);
13617 +              break;
13618 +            }
13619 +
13620 +  PerlException:
13621 +    if (package_info != (struct PackageInfo *) NULL)
13622 +      DestroyPackageInfo(package_info);
13623 +    if (list && (list != keep))
13624 +      list=(char **) RelinquishMagickMemory(list);
13625 +    if (keep)
13626 +      keep=(char **) RelinquishMagickMemory(keep);
13627 +    if (length)
13628 +      length=(STRLEN *) RelinquishMagickMemory(length);
13629 +    InheritPerlException(exception,perl_exception);
13630 +    exception=DestroyExceptionInfo(exception);
13631 +    sv_setiv(perl_exception,(IV) number_images);
13632 +    SvPOK_on(perl_exception);
13633 +    ST(0)=sv_2mortal(perl_exception);
13634 +    XSRETURN(1);
13635 +  }
13636 +\f
13637 +#
13638 +###############################################################################
13639 +#                                                                             #
13640 +#                                                                             #
13641 +#                                                                             #
13642 +#   R e m o t e                                                               #
13643 +#                                                                             #
13644 +#                                                                             #
13645 +#                                                                             #
13646 +###############################################################################
13647 +#
13648 +#
13649 +void
13650 +Remote(ref,...)
13651 +  Image::Magick ref = NO_INIT
13652 +  ALIAS:
13653 +    RemoteCommand  = 1
13654 +    remote         = 2
13655 +    remoteCommand  = 3
13656 +  PPCODE:
13657 +  {
13658 +    AV
13659 +      *av;
13660 +
13661 +    ExceptionInfo
13662 +      *exception;
13663 +
13664 +    register ssize_t
13665 +      i;
13666 +
13667 +    SV
13668 +      *perl_exception,
13669 +      *reference;
13670 +
13671 +    struct PackageInfo
13672 +      *info;
13673 +
13674 +    PERL_UNUSED_VAR(ref);
13675 +    PERL_UNUSED_VAR(ix);
13676 +    exception=AcquireExceptionInfo();
13677 +    perl_exception=newSVpv("",0);
13678 +    reference=SvRV(ST(0));
13679 +    av=(AV *) reference;
13680 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13681 +      exception);
13682 +    for (i=1; i < items; i++)
13683 +      (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13684 +        SvPV(ST(i),na),exception);
13685 +    InheritPerlException(exception,perl_exception);
13686 +    exception=DestroyExceptionInfo(exception);
13687 +    SvREFCNT_dec(perl_exception);    /* throw away all errors */
13688 +  }
13689 +\f
13690 +#
13691 +###############################################################################
13692 +#                                                                             #
13693 +#                                                                             #
13694 +#                                                                             #
13695 +#   S e t                                                                     #
13696 +#                                                                             #
13697 +#                                                                             #
13698 +#                                                                             #
13699 +###############################################################################
13700 +#
13701 +#
13702 +void
13703 +Set(ref,...)
13704 +  Image::Magick ref = NO_INIT
13705 +  ALIAS:
13706 +    SetAttributes  = 1
13707 +    SetAttribute   = 2
13708 +    set            = 3
13709 +    setattributes  = 4
13710 +    setattribute   = 5
13711 +  PPCODE:
13712 +  {
13713 +    ExceptionInfo
13714 +      *exception;
13715 +
13716 +    Image
13717 +      *image;
13718 +
13719 +    register ssize_t
13720 +      i;
13721 +
13722 +    struct PackageInfo
13723 +      *info;
13724 +
13725 +    SV
13726 +      *perl_exception,
13727 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
13728 +
13729 +    PERL_UNUSED_VAR(ref);
13730 +    PERL_UNUSED_VAR(ix);
13731 +    exception=AcquireExceptionInfo();
13732 +    perl_exception=newSVpv("",0);
13733 +    if (sv_isobject(ST(0)) == 0)
13734 +      {
13735 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13736 +          PackageName);
13737 +        goto PerlException;
13738 +      }
13739 +    reference=SvRV(ST(0));
13740 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13741 +    if (items == 2)
13742 +      SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13743 +    else
13744 +      for (i=2; i < items; i+=2)
13745 +        SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13746 +
13747 +  PerlException:
13748 +    InheritPerlException(exception,perl_exception);
13749 +    exception=DestroyExceptionInfo(exception);
13750 +    sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13751 +    SvPOK_on(perl_exception);
13752 +    ST(0)=sv_2mortal(perl_exception);
13753 +    XSRETURN(1);
13754 +  }
13755 +\f
13756 +#
13757 +###############################################################################
13758 +#                                                                             #
13759 +#                                                                             #
13760 +#                                                                             #
13761 +#   S e t P i x e l                                                           #
13762 +#                                                                             #
13763 +#                                                                             #
13764 +#                                                                             #
13765 +###############################################################################
13766 +#
13767 +#
13768 +void
13769 +SetPixel(ref,...)
13770 +  Image::Magick ref = NO_INIT
13771 +  ALIAS:
13772 +    setpixel = 1
13773 +    setPixel = 2
13774 +  PPCODE:
13775 +  {
13776 +    AV
13777 +      *av;
13778 +
13779 +    char
13780 +      *attribute;
13781 +
13782 +    ChannelType
13783 +      channel;
13784 +
13785 +    ExceptionInfo
13786 +      *exception;
13787 +
13788 +    Image
13789 +      *image;
13790 +
13791 +    MagickBooleanType
13792 +      normalize;
13793 +
13794 +    RectangleInfo
13795 +      region;
13796 +
13797 +    register IndexPacket
13798 +      *indexes;
13799 +
13800 +    register ssize_t
13801 +      i;
13802 +
13803 +    register PixelPacket
13804 +      *q;
13805 +
13806 +    ssize_t
13807 +      option;
13808 +
13809 +    struct PackageInfo
13810 +      *info;
13811 +
13812 +    SV
13813 +      *perl_exception,
13814 +      *reference;  /* reference is the SV* of ref=SvIV(reference) */
13815 +
13816 +    PERL_UNUSED_VAR(ref);
13817 +    PERL_UNUSED_VAR(ix);
13818 +    exception=AcquireExceptionInfo();
13819 +    perl_exception=newSVpv("",0);
13820 +    reference=SvRV(ST(0));
13821 +    av=(AV *) reference;
13822 +    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13823 +      exception);
13824 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13825 +    if (image == (Image *) NULL)
13826 +      {
13827 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
13828 +          PackageName);
13829 +        goto PerlException;
13830 +      }
13831 +    av=(AV *) NULL;
13832 +    channel=DefaultChannels;
13833 +    normalize=MagickTrue;
13834 +    region.x=0;
13835 +    region.y=0;
13836 +    region.width=image->columns;
13837 +    region.height=1;
13838 +    if (items == 1)
13839 +      (void) ParseAbsoluteGeometry(SvPV(ST(1),na),&region);
13840 +    for (i=2; i < items; i+=2)
13841 +    {
13842 +      attribute=(char *) SvPV(ST(i-1),na);
13843 +      switch (*attribute)
13844 +      {
13845 +        case 'C':
13846 +        case 'c':
13847 +        {
13848 +          if (LocaleCompare(attribute,"channel") == 0)
13849 +            {
13850 +              ssize_t
13851 +                option;
13852 +
13853 +              option=ParseChannelOption(SvPV(ST(i),na));
13854 +              if (option < 0)
13855 +                {
13856 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
13857 +                    SvPV(ST(i),na));
13858 +                  return;
13859 +                }
13860 +               channel=(ChannelType) option;
13861 +              break;
13862 +            }
13863 +          if (LocaleCompare(attribute,"color") == 0)
13864 +            {
13865 +              if (SvTYPE(ST(i)) != SVt_RV)
13866 +                {
13867 +                  char
13868 +                    message[MaxTextExtent];
13869 +
13870 +                  (void) FormatLocaleString(message,MaxTextExtent,
13871 +                    "invalid %.60s value",attribute);
13872 +                  ThrowPerlException(exception,OptionError,message,
13873 +                    SvPV(ST(i),na));
13874 +                }
13875 +              av=(AV *) SvRV(ST(i));
13876 +              break;
13877 +            }
13878 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13879 +            attribute);
13880 +          break;
13881 +        }
13882 +        case 'g':
13883 +        case 'G':
13884 +        {
13885 +          if (LocaleCompare(attribute,"geometry") == 0)
13886 +            {
13887 +              (void) ParseAbsoluteGeometry(SvPV(ST(i),na),&region);
13888 +              break;
13889 +            }
13890 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13891 +            attribute);
13892 +          break;
13893 +        }
13894 +        case 'N':
13895 +        case 'n':
13896 +        {
13897 +          if (LocaleCompare(attribute,"normalize") == 0)
13898 +            {
13899 +              option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13900 +                SvPV(ST(i),na));
13901 +              if (option < 0)
13902 +                {
13903 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
13904 +                    SvPV(ST(i),na));
13905 +                  break;
13906 +                }
13907 +             normalize=option != 0 ? MagickTrue : MagickFalse;
13908 +             break;
13909 +            }
13910 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13911 +            attribute);
13912 +          break;
13913 +        }
13914 +        case 'x':
13915 +        case 'X':
13916 +        {
13917 +          if (LocaleCompare(attribute,"x") == 0)
13918 +            {
13919 +              region.x=SvIV(ST(i));
13920 +              break;
13921 +            }
13922 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13923 +            attribute);
13924 +          break;
13925 +        }
13926 +        case 'y':
13927 +        case 'Y':
13928 +        {
13929 +          if (LocaleCompare(attribute,"y") == 0)
13930 +            {
13931 +              region.y=SvIV(ST(i));
13932 +              break;
13933 +            }
13934 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13935 +            attribute);
13936 +          break;
13937 +        }
13938 +        default:
13939 +        {
13940 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13941 +            attribute);
13942 +          break;
13943 +        }
13944 +      }
13945 +    }
13946 +    (void) SetImageStorageClass(image,DirectClass);
13947 +    q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13948 +    if ((q == (PixelPacket *) NULL) || (av == (AV *) NULL) ||
13949 +        (SvTYPE(av) != SVt_PVAV))
13950 +      PUSHs(&sv_undef);
13951 +    else
13952 +      {
13953 +        double
13954 +          scale;
13955 +
13956 +        register ssize_t
13957 +          i;
13958 +
13959 +        i=0;
13960 +        indexes=GetAuthenticIndexQueue(image);
13961 +        scale=1.0;
13962 +        if (normalize != MagickFalse)
13963 +          scale=QuantumRange;
13964 +        if (((channel & RedChannel) != 0) && (i <= av_len(av)))
13965 +          {
13966 +            SetPixelRed(q,ClampToQuantum(scale*SvNV(*(
13967 +              av_fetch(av,i,0)))));
13968 +            i++;
13969 +          }
13970 +        if (((channel & GreenChannel) != 0) && (i <= av_len(av)))
13971 +          {
13972 +            SetPixelGreen(q,ClampToQuantum(scale*SvNV(*(
13973 +              av_fetch(av,i,0)))));
13974 +            i++;
13975 +          }
13976 +        if (((channel & BlueChannel) != 0) && (i <= av_len(av)))
13977 +          {
13978 +            SetPixelBlue(q,ClampToQuantum(scale*SvNV(*(
13979 +              av_fetch(av,i,0)))));
13980 +            i++;
13981 +          }
13982 +        if ((((channel & IndexChannel) != 0) &&
13983 +            (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13984 +          {
13985 +            SetPixelIndex(indexes,ClampToQuantum(scale*
13986 +              SvNV(*(av_fetch(av,i,0)))));
13987 +            i++;
13988 +          }
13989 +        if (((channel & OpacityChannel) != 0) && (i <= av_len(av)))
13990 +          {
13991 +            SetPixelOpacity(q,ClampToQuantum(scale*
13992 +              SvNV(*(av_fetch(av,i,0)))));
13993 +            i++;
13994 +          }
13995 +        (void) SyncAuthenticPixels(image,exception);
13996 +      }
13997 +
13998 +  PerlException:
13999 +    InheritPerlException(exception,perl_exception);
14000 +    exception=DestroyExceptionInfo(exception);
14001 +    SvREFCNT_dec(perl_exception);
14002 +  }
14003 +\f
14004 +#
14005 +###############################################################################
14006 +#                                                                             #
14007 +#                                                                             #
14008 +#                                                                             #
14009 +#   S m u s h                                                                 #
14010 +#                                                                             #
14011 +#                                                                             #
14012 +#                                                                             #
14013 +###############################################################################
14014 +#
14015 +#
14016 +void
14017 +Smush(ref,...)
14018 +  Image::Magick ref = NO_INIT
14019 +  ALIAS:
14020 +    SmushImage  = 1
14021 +    smush       = 2
14022 +    smushimage  = 3
14023 +  PPCODE:
14024 +  {
14025 +    AV
14026 +      *av;
14027 +
14028 +    char
14029 +      *attribute;
14030 +
14031 +    ExceptionInfo
14032 +      *exception;
14033 +
14034 +    HV
14035 +      *hv;
14036 +
14037 +    Image
14038 +      *image;
14039 +
14040 +    register ssize_t
14041 +      i;
14042 +
14043 +    ssize_t
14044 +      offset,
14045 +      stack;
14046 +
14047 +    struct PackageInfo
14048 +      *info;
14049 +
14050 +    SV
14051 +      *av_reference,
14052 +      *perl_exception,
14053 +      *reference,
14054 +      *rv,
14055 +      *sv;
14056 +
14057 +    PERL_UNUSED_VAR(ref);
14058 +    PERL_UNUSED_VAR(ix);
14059 +    exception=AcquireExceptionInfo();
14060 +    perl_exception=newSVpv("",0);
14061 +    sv=NULL;
14062 +    attribute=NULL;
14063 +    av=NULL;
14064 +    if (sv_isobject(ST(0)) == 0)
14065 +      {
14066 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14067 +          PackageName);
14068 +        goto PerlException;
14069 +      }
14070 +    reference=SvRV(ST(0));
14071 +    hv=SvSTASH(reference);
14072 +    av=newAV();
14073 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14074 +    SvREFCNT_dec(av);
14075 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14076 +    if (image == (Image *) NULL)
14077 +      {
14078 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
14079 +          PackageName);
14080 +        goto PerlException;
14081 +      }
14082 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14083 +    /*
14084 +      Get options.
14085 +    */
14086 +    offset=0;
14087 +    stack=MagickTrue;
14088 +    for (i=2; i < items; i+=2)
14089 +    {
14090 +      attribute=(char *) SvPV(ST(i-1),na);
14091 +      switch (*attribute)
14092 +      {
14093 +        case 'O':
14094 +        case 'o':
14095 +        {
14096 +          if (LocaleCompare(attribute,"offset") == 0)
14097 +            {
14098 +              offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14099 +              break;
14100 +            }
14101 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14102 +            attribute);
14103 +          break;
14104 +        }
14105 +        case 'S':
14106 +        case 's':
14107 +        {
14108 +          if (LocaleCompare(attribute,"stack") == 0)
14109 +            {
14110 +              stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14111 +                SvPV(ST(i),na));
14112 +              if (stack < 0)
14113 +                {
14114 +                  ThrowPerlException(exception,OptionError,"UnrecognizedType",
14115 +                    SvPV(ST(i),na));
14116 +                  return;
14117 +                }
14118 +              break;
14119 +            }
14120 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14121 +            attribute);
14122 +          break;
14123 +        }
14124 +        default:
14125 +        {
14126 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14127 +            attribute);
14128 +          break;
14129 +        }
14130 +      }
14131 +    }
14132 +    image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14133 +      exception);
14134 +    if (image == (Image *) NULL)
14135 +      goto PerlException;
14136 +    for ( ; image; image=image->next)
14137 +    {
14138 +      AddImageToRegistry(sv,image);
14139 +      rv=newRV(sv);
14140 +      av_push(av,sv_bless(rv,hv));
14141 +      SvREFCNT_dec(sv);
14142 +    }
14143 +    exception=DestroyExceptionInfo(exception);
14144 +    ST(0)=av_reference;
14145 +    SvREFCNT_dec(perl_exception);
14146 +    XSRETURN(1);
14147 +
14148 +  PerlException:
14149 +    InheritPerlException(exception,perl_exception);
14150 +    exception=DestroyExceptionInfo(exception);
14151 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14152 +    SvPOK_on(perl_exception);
14153 +    ST(0)=sv_2mortal(perl_exception);
14154 +    XSRETURN(1);
14155 +  }
14156 +\f
14157 +#
14158 +###############################################################################
14159 +#                                                                             #
14160 +#                                                                             #
14161 +#                                                                             #
14162 +#   S t a t i s t i c s                                                       #
14163 +#                                                                             #
14164 +#                                                                             #
14165 +#                                                                             #
14166 +###############################################################################
14167 +#
14168 +#
14169 +void
14170 +Statistics(ref,...)
14171 +  Image::Magick ref = NO_INIT
14172 +  ALIAS:
14173 +    StatisticsImage = 1
14174 +    statistics      = 2
14175 +    statisticsimage = 3
14176 +  PPCODE:
14177 +  {
14178 +#define ChannelStatistics(channel) \
14179 +{ \
14180 +  (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
14181 +    (double) channel_statistics[channel].depth); \
14182 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14183 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14184 +    channel_statistics[channel].minima/scale); \
14185 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14186 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14187 +    channel_statistics[channel].maxima/scale); \
14188 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14189 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14190 +    channel_statistics[channel].mean/scale); \
14191 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14192 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14193 +    channel_statistics[channel].standard_deviation/scale); \
14194 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14195 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14196 +    channel_statistics[channel].kurtosis); \
14197 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14198 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14199 +    channel_statistics[channel].skewness); \
14200 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14201 +  (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14202 +    channel_statistics[channel].entropy); \
14203 +  PUSHs(sv_2mortal(newSVpv(message,0))); \
14204 +}
14205 +
14206 +    AV
14207 +      *av;
14208 +
14209 +    char
14210 +      message[MaxTextExtent];
14211 +
14212 +    ChannelStatistics
14213 +      *channel_statistics;
14214 +
14215 +    double
14216 +      scale;
14217 +
14218 +    ExceptionInfo
14219 +      *exception;
14220 +
14221 +    Image
14222 +      *image;
14223 +
14224 +    ssize_t
14225 +      count;
14226 +
14227 +    struct PackageInfo
14228 +      *info;
14229 +
14230 +    SV
14231 +      *perl_exception,
14232 +      *reference;
14233 +
14234 +    PERL_UNUSED_VAR(ref);
14235 +    PERL_UNUSED_VAR(ix);
14236 +    exception=AcquireExceptionInfo();
14237 +    perl_exception=newSVpv("",0);
14238 +    av=NULL;
14239 +    if (sv_isobject(ST(0)) == 0)
14240 +      {
14241 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14242 +          PackageName);
14243 +        goto PerlException;
14244 +      }
14245 +    reference=SvRV(ST(0));
14246 +    av=newAV();
14247 +    SvREFCNT_dec(av);
14248 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14249 +    if (image == (Image *) NULL)
14250 +      {
14251 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
14252 +          PackageName);
14253 +        goto PerlException;
14254 +      }
14255 +    count=0;
14256 +    for ( ; image; image=image->next)
14257 +    {
14258 +      channel_statistics=GetImageChannelStatistics(image,&image->exception);
14259 +      if (channel_statistics == (ChannelStatistics *) NULL)
14260 +        continue;
14261 +      count++;
14262 +      EXTEND(sp,35*count);
14263 +      scale=(double) QuantumRange;
14264 +      ChannelStatistics(RedChannel);
14265 +      ChannelStatistics(GreenChannel);
14266 +      ChannelStatistics(BlueChannel);
14267 +      if (image->colorspace == CMYKColorspace)
14268 +        ChannelStatistics(IndexChannel);
14269 +      if (image->matte != MagickFalse)
14270 +        ChannelStatistics(OpacityChannel);
14271 +      channel_statistics=(ChannelStatistics *)
14272 +        RelinquishMagickMemory(channel_statistics);
14273 +    }
14274 +
14275 +  PerlException:
14276 +    InheritPerlException(exception,perl_exception);
14277 +    exception=DestroyExceptionInfo(exception);
14278 +    SvREFCNT_dec(perl_exception);
14279 +  }
14280 +\f
14281 +#
14282 +###############################################################################
14283 +#                                                                             #
14284 +#                                                                             #
14285 +#                                                                             #
14286 +#   S y n c A u t h e n t i c P i x e l s                                     #
14287 +#                                                                             #
14288 +#                                                                             #
14289 +#                                                                             #
14290 +###############################################################################
14291 +#
14292 +#
14293 +void
14294 +SyncAuthenticPixels(ref,...)
14295 +  Image::Magick ref = NO_INIT
14296 +  ALIAS:
14297 +    Syncauthenticpixels = 1
14298 +    SyncImagePixels = 2
14299 +    syncimagepixels = 3
14300 +  CODE:
14301 +  {
14302 +    ExceptionInfo
14303 +      *exception;
14304 +
14305 +    Image
14306 +      *image;
14307 +
14308 +    MagickBooleanType
14309 +      status;
14310 +
14311 +    struct PackageInfo
14312 +      *info;
14313 +
14314 +    SV
14315 +      *perl_exception,
14316 +      *reference;
14317 +
14318 +    PERL_UNUSED_VAR(ref);
14319 +    PERL_UNUSED_VAR(ix);
14320 +    exception=AcquireExceptionInfo();
14321 +    perl_exception=newSVpv("",0);
14322 +    if (sv_isobject(ST(0)) == 0)
14323 +      {
14324 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14325 +          PackageName);
14326 +        goto PerlException;
14327 +      }
14328 +
14329 +    reference=SvRV(ST(0));
14330 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14331 +    if (image == (Image *) NULL)
14332 +      {
14333 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
14334 +          PackageName);
14335 +        goto PerlException;
14336 +      }
14337 +
14338 +    status=SyncAuthenticPixels(image,exception);
14339 +    if (status != MagickFalse)
14340 +      return;
14341 +    InheritException(exception,&image->exception);
14342 +
14343 +  PerlException:
14344 +    InheritPerlException(exception,perl_exception);
14345 +    exception=DestroyExceptionInfo(exception);
14346 +    SvREFCNT_dec(perl_exception);  /* throw away all errors */
14347 +  }
14348 +\f
14349 +#
14350 +###############################################################################
14351 +#                                                                             #
14352 +#                                                                             #
14353 +#                                                                             #
14354 +#   T r a n s f o r m                                                         #
14355 +#                                                                             #
14356 +#                                                                             #
14357 +#                                                                             #
14358 +###############################################################################
14359 +#
14360 +#
14361 +void
14362 +Transform(ref,...)
14363 +  Image::Magick ref = NO_INIT
14364 +  ALIAS:
14365 +    TransformImage = 1
14366 +    transform      = 2
14367 +    transformimage = 3
14368 +  PPCODE:
14369 +  {
14370 +    AV
14371 +      *av;
14372 +
14373 +    char
14374 +      *attribute,
14375 +      *crop_geometry,
14376 +      *geometry;
14377 +
14378 +    ExceptionInfo
14379 +      *exception;
14380 +
14381 +    HV
14382 +      *hv;
14383 +
14384 +    Image
14385 +      *clone,
14386 +      *image;
14387 +
14388 +    register ssize_t
14389 +      i;
14390 +
14391 +    struct PackageInfo
14392 +      *info;
14393 +
14394 +    SV
14395 +      *av_reference,
14396 +      *perl_exception,
14397 +      *reference,
14398 +      *rv,
14399 +      *sv;
14400 +
14401 +    PERL_UNUSED_VAR(ref);
14402 +    PERL_UNUSED_VAR(ix);
14403 +    exception=AcquireExceptionInfo();
14404 +    perl_exception=newSVpv("",0);
14405 +    sv=NULL;
14406 +    av=NULL;
14407 +    attribute=NULL;
14408 +    if (sv_isobject(ST(0)) == 0)
14409 +      {
14410 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14411 +          PackageName);
14412 +        goto PerlException;
14413 +      }
14414 +    reference=SvRV(ST(0));
14415 +    hv=SvSTASH(reference);
14416 +    av=newAV();
14417 +    av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14418 +    SvREFCNT_dec(av);
14419 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14420 +    if (image == (Image *) NULL)
14421 +      {
14422 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
14423 +          PackageName);
14424 +        goto PerlException;
14425 +      }
14426 +    info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14427 +    /*
14428 +      Get attribute.
14429 +    */
14430 +    crop_geometry=(char *) NULL;
14431 +    geometry=(char *) NULL;
14432 +    for (i=2; i < items; i+=2)
14433 +    {
14434 +      attribute=(char *) SvPV(ST(i-1),na);
14435 +      switch (*attribute)
14436 +      {
14437 +        case 'c':
14438 +        case 'C':
14439 +        {
14440 +          if (LocaleCompare(attribute,"crop") == 0)
14441 +            {
14442 +              crop_geometry=SvPV(ST(i),na);
14443 +              break;
14444 +            }
14445 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14446 +            attribute);
14447 +          break;
14448 +        }
14449 +        case 'g':
14450 +        case 'G':
14451 +        {
14452 +          if (LocaleCompare(attribute,"geometry") == 0)
14453 +            {
14454 +              geometry=SvPV(ST(i),na);
14455 +              break;
14456 +            }
14457 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14458 +            attribute);
14459 +          break;
14460 +        }
14461 +        default:
14462 +        {
14463 +          ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14464 +            attribute);
14465 +          break;
14466 +        }
14467 +      }
14468 +    }
14469 +    for ( ; image; image=image->next)
14470 +    {
14471 +      clone=CloneImage(image,0,0,MagickTrue,exception);
14472 +      if (clone == (Image *) NULL)
14473 +        goto PerlException;
14474 +      TransformImage(&clone,crop_geometry,geometry);
14475 +      for ( ; clone; clone=clone->next)
14476 +      {
14477 +        AddImageToRegistry(sv,clone);
14478 +        rv=newRV(sv);
14479 +        av_push(av,sv_bless(rv,hv));
14480 +        SvREFCNT_dec(sv);
14481 +      }
14482 +    }
14483 +    exception=DestroyExceptionInfo(exception);
14484 +    ST(0)=av_reference;
14485 +    SvREFCNT_dec(perl_exception);  /* can't return warning messages */
14486 +    XSRETURN(1);
14487 +
14488 +  PerlException:
14489 +    InheritPerlException(exception,perl_exception);
14490 +    exception=DestroyExceptionInfo(exception);
14491 +    sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14492 +    SvPOK_on(perl_exception);
14493 +    ST(0)=sv_2mortal(perl_exception);
14494 +    XSRETURN(1);
14495 +  }
14496 +\f
14497 +#
14498 +###############################################################################
14499 +#                                                                             #
14500 +#                                                                             #
14501 +#                                                                             #
14502 +#   W r i t e                                                                 #
14503 +#                                                                             #
14504 +#                                                                             #
14505 +#                                                                             #
14506 +###############################################################################
14507 +#
14508 +#
14509 +void
14510 +Write(ref,...)
14511 +  Image::Magick ref = NO_INIT
14512 +  ALIAS:
14513 +    WriteImage    = 1
14514 +    write         = 2
14515 +    writeimage    = 3
14516 +  PPCODE:
14517 +  {
14518 +    char
14519 +      filename[MaxTextExtent];
14520 +
14521 +    ExceptionInfo
14522 +      *exception;
14523 +
14524 +    Image
14525 +      *image,
14526 +      *next;
14527 +
14528 +    register ssize_t
14529 +      i;
14530 +
14531 +    ssize_t
14532 +      number_images,
14533 +      scene;
14534 +
14535 +    struct PackageInfo
14536 +      *info,
14537 +      *package_info;
14538 +
14539 +    SV
14540 +      *perl_exception,
14541 +      *reference;
14542 +
14543 +    PERL_UNUSED_VAR(ref);
14544 +    PERL_UNUSED_VAR(ix);
14545 +    exception=AcquireExceptionInfo();
14546 +    perl_exception=newSVpv("",0);
14547 +    number_images=0;
14548 +    package_info=(struct PackageInfo *) NULL;
14549 +    if (sv_isobject(ST(0)) == 0)
14550 +      {
14551 +        ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14552 +          PackageName);
14553 +        goto PerlException;
14554 +      }
14555 +    reference=SvRV(ST(0));
14556 +    image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14557 +    if (image == (Image *) NULL)
14558 +      {
14559 +        ThrowPerlException(exception,OptionError,"NoImagesDefined",
14560 +          PackageName);
14561 +        goto PerlException;
14562 +      }
14563 +    package_info=ClonePackageInfo(info,exception);
14564 +    if (items == 2)
14565 +      SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14566 +    else
14567 +      if (items > 2)
14568 +        for (i=2; i < items; i+=2)
14569 +          SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14570 +            exception);
14571 +    (void) CopyMagickString(filename,package_info->image_info->filename,
14572 +      MaxTextExtent);
14573 +    scene=0;
14574 +    for (next=image; next; next=next->next)
14575 +    {
14576 +      (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14577 +      next->scene=scene++;
14578 +    }
14579 +    *package_info->image_info->magick='\0';
14580 +    SetImageInfo(package_info->image_info,(unsigned int)
14581 +      GetImageListLength(image),&image->exception);
14582 +    for (next=image; next; next=next->next)
14583 +    {
14584 +      (void) WriteImage(package_info->image_info,next);
14585 +      if (next->exception.severity >= ErrorException)
14586 +        InheritException(exception,&next->exception);
14587 +      GetImageException(next,exception);
14588 +      number_images++;
14589 +      if (package_info->image_info->adjoin)
14590 +        break;
14591 +    }
14592 +
14593 +  PerlException:
14594 +    if (package_info != (struct PackageInfo *) NULL)
14595 +      DestroyPackageInfo(package_info);
14596 +    InheritPerlException(exception,perl_exception);
14597 +    exception=DestroyExceptionInfo(exception);
14598 +    sv_setiv(perl_exception,(IV) number_images);
14599 +    SvPOK_on(perl_exception);
14600 +    ST(0)=sv_2mortal(perl_exception);
14601 +    XSRETURN(1);
14602 +  }
This page took 1.373395 seconds and 3 git commands to generate.