2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
55 #if defined(__cplusplus) || defined(c_plusplus)
59 #define PERL_NO_GET_CONTEXT
64 #include <magick/MagickCore.h>
67 #if defined(__cplusplus) || defined(c_plusplus)
79 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
80 #define EndOf(array) (&array[NumberOf(array)])
81 #define MagickPI 3.14159265358979323846264338327950288419716939937510
82 #define MaxArguments 33
86 #define NumberOf(array) (sizeof(array)/sizeof(*array))
87 #define PackageName "Image::Magick"
90 #define PerlIO_importFILE(f, fl) (f)
91 #define PerlIO_findFILE(f) NULL
94 #define sv_undef PL_sv_undef
97 #define AddImageToRegistry(sv,image) \
99 if (magick_registry != (SplayTreeInfo *) NULL) \
101 (void) AddValueToSplayTree(magick_registry,image,image); \
102 (sv)=newSViv((IV) image); \
106 #define DeleteImageFromRegistry(reference,image) \
108 if (magick_registry != (SplayTreeInfo *) NULL) \
110 if (GetImageReferenceCount(image) == 1) \
111 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
112 image=DestroyImage(image); \
113 sv_setiv(reference,0); \
117 #define InheritPerlException(exception,perl_exception) \
120 message[MaxTextExtent]; \
122 if ((exception)->severity != UndefinedException) \
124 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
125 (exception)->severity, (exception)->reason ? \
126 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
127 "Unknown", (exception)->description ? " (" : "", \
128 (exception)->description ? GetLocaleExceptionMessage( \
129 (exception)->severity,(exception)->description) : "", \
130 (exception)->description ? ")" : ""); \
131 if ((perl_exception) != (SV *) NULL) \
133 if (SvCUR(perl_exception)) \
134 sv_catpv(perl_exception,"\n"); \
135 sv_catpv(perl_exception,message); \
140 #define ThrowPerlException(exception,severity,tag,reason) \
141 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
142 tag,"`%s'",reason); \
145 Typedef and structure declarations.
149 ArrayReference = (~0),
150 RealReference = (~0)-1,
151 FileReference = (~0)-2,
152 ImageReference = (~0)-3,
153 IntegerReference = (~0)-4,
154 StringReference = (~0)-5
157 typedef struct _Arguments
197 *Image__Magick; /* data type for the Image::Magick package */
209 arguments[MaxArguments];
212 { "Comment", { {"comment", StringReference} } },
213 { "Label", { {"label", StringReference} } },
214 { "AddNoise", { {"noise", MagickNoiseOptions},
215 {"channel", MagickChannelOptions} } },
216 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
217 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
218 {"height", IntegerReference}, {"fill", StringReference},
219 {"bordercolor", StringReference}, {"color", StringReference},
220 {"compose", MagickComposeOptions} } },
221 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
222 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
223 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
224 {"height", IntegerReference}, {"x", IntegerReference},
225 {"y", IntegerReference} } },
226 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
227 {"height", IntegerReference}, {"x", IntegerReference},
228 {"y", IntegerReference}, {"fuzz", StringReference},
229 {"gravity", MagickGravityOptions} } },
231 { "Edge", { {"radius", RealReference} } },
232 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
233 {"sigma", RealReference} } },
237 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
238 {"height", IntegerReference}, {"inner", IntegerReference},
239 {"outer", IntegerReference}, {"fill", StringReference},
240 {"color", StringReference}, {"compose", MagickComposeOptions} } },
241 { "Implode", { {"amount", RealReference},
242 {"interpolate", MagickInterpolateOptions} } },
244 { "MedianFilter", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
248 { "OilPaint", { {"radius", RealReference} } },
249 { "ReduceNoise", { {"geometry", StringReference},
250 {"width", IntegerReference},{"height", IntegerReference},
251 {"channel", MagickChannelOptions} } },
252 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
253 {"y", IntegerReference} } },
254 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
255 {"color", StringReference}, {"background", StringReference} } },
256 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
257 {"height", IntegerReference} } },
258 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
259 {"height", IntegerReference} } },
260 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
261 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
262 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
263 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
264 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
265 {"y", RealReference}, { "fill", StringReference},
266 {"color", StringReference} } },
267 { "Spread", { {"radius", RealReference} } },
268 { "Swirl", { {"degrees", RealReference},
269 {"interpolate", MagickInterpolateOptions} } },
270 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", StringReference }, {"blur", RealReference } } },
273 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
274 {"height", IntegerReference}, {"filter", MagickFilterOptions},
275 {"support", RealReference }, {"blur", RealReference } } },
276 { "Annotate", { {"text", StringReference}, {"font", StringReference},
277 {"pointsize", RealReference}, {"density", StringReference},
278 {"undercolor", StringReference}, {"stroke", StringReference},
279 {"fill", StringReference}, {"geometry", StringReference},
280 {"pen", StringReference}, {"x", RealReference},
281 {"y", RealReference}, {"gravity", MagickGravityOptions},
282 {"translate", StringReference}, {"scale", StringReference},
283 {"rotate", RealReference}, {"skewX", RealReference},
284 {"skewY", RealReference}, {"strokewidth", RealReference},
285 {"antialias", MagickBooleanOptions}, {"family", StringReference},
286 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
287 {"weight", IntegerReference}, {"align", MagickAlignOptions},
288 {"encoding", StringReference}, {"affine", ArrayReference},
289 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
290 {"tile", ImageReference}, {"kerning", RealReference},
291 {"interline-spacing", RealReference},
292 {"interword-spacing", RealReference},
293 {"direction", MagickDirectionOptions} } },
294 { "ColorFloodfill", { {"geometry", StringReference},
295 {"x", IntegerReference}, {"y", IntegerReference},
296 {"fill", StringReference}, {"bordercolor", StringReference},
297 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
298 { "Composite", { {"image", ImageReference},
299 {"compose", MagickComposeOptions}, {"geometry", StringReference},
300 {"x", IntegerReference}, {"y", IntegerReference},
301 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
302 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
303 {"color", StringReference}, {"mask", ImageReference},
304 {"channel", MagickChannelOptions},
305 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
306 {"blend", StringReference} } },
307 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
308 { "CycleColormap", { {"display", IntegerReference} } },
309 { "Draw", { {"primitive", MagickPrimitiveOptions},
310 {"points", StringReference}, {"method", MagickMethodOptions},
311 {"stroke", StringReference}, {"fill", StringReference},
312 {"strokewidth", RealReference}, {"font", StringReference},
313 {"bordercolor", StringReference}, {"x", RealReference},
314 {"y", RealReference}, {"translate", StringReference},
315 {"scale", StringReference}, {"rotate", RealReference},
316 {"skewX", RealReference}, {"skewY", RealReference},
317 {"tile", ImageReference}, {"pointsize", RealReference},
318 {"antialias", MagickBooleanOptions}, {"density", StringReference},
319 {"linewidth", RealReference}, {"affine", ArrayReference},
320 {"stroke-dashoffset", RealReference},
321 {"stroke-dasharray", ArrayReference},
322 {"interpolate", MagickInterpolateOptions},
323 {"origin", StringReference}, {"text", StringReference},
324 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
325 {"vector-graphics", StringReference}, {"kerning", RealReference},
326 {"interline-spacing", RealReference},
327 {"interword-spacing", RealReference},
328 {"direction", MagickDirectionOptions} } },
329 { "Equalize", { {"channel", MagickChannelOptions} } },
330 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
331 {"red", RealReference}, {"green", RealReference},
332 {"blue", RealReference} } },
333 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
334 {"dither-method", MagickDitherOptions} } },
335 { "MatteFloodfill", { {"geometry", StringReference},
336 {"x", IntegerReference}, {"y", IntegerReference},
337 {"opacity", StringReference}, {"bordercolor", StringReference},
338 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
339 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
340 {"saturation", RealReference}, {"whiteness", RealReference},
341 {"brightness", RealReference}, {"lightness", RealReference},
342 {"blackness", RealReference} } },
343 { "Negate", { {"gray", MagickBooleanOptions},
344 {"channel", MagickChannelOptions} } },
345 { "Normalize", { {"channel", MagickChannelOptions} } },
347 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
348 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
349 {"invert", MagickBooleanOptions} } },
350 { "Quantize", { {"colors", IntegerReference},
351 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
352 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
353 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
354 {"dither-method", MagickDitherOptions} } },
355 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
356 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
357 { "Segment", { {"geometry", StringReference},
358 {"cluster-threshold", RealReference},
359 {"smoothing-threshold", RealReference},
360 {"colorspace", MagickColorspaceOptions},
361 {"verbose", MagickBooleanOptions} } },
363 { "Solarize", { {"geometry", StringReference},
364 {"threshold", StringReference} } },
366 { "Texture", { {"texture", ImageReference} } },
367 { "Evaluate", { {"value", RealReference},
368 {"operator", MagickEvaluateOptions},
369 {"channel", MagickChannelOptions} } },
370 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
371 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
372 { "Threshold", { {"threshold", StringReference},
373 {"channel", MagickChannelOptions} } },
374 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
375 {"sigma", RealReference} } },
376 { "Trim", { {"fuzz", StringReference} } },
377 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
378 {"wavelength", RealReference},
379 {"interpolate", MagickInterpolateOptions} } },
380 { "Separate", { {"channel", MagickChannelOptions} } },
382 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
383 {"y", IntegerReference} } },
384 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
386 { "GaussianBlur", { {"geometry", StringReference},
387 {"radius", RealReference}, {"sigma", RealReference},
388 {"channel", MagickChannelOptions} } },
389 { "Convolve", { {"coefficients", ArrayReference},
390 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
391 { "Profile", { {"name", StringReference}, {"profile", StringReference},
392 { "rendering-intent", MagickIntentOptions},
393 { "black-point-compensation", MagickBooleanOptions} } },
394 { "UnsharpMask", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"amount", RealReference}, {"threshold", RealReference},
397 {"channel", MagickChannelOptions} } },
398 { "MotionBlur", { {"geometry", StringReference},
399 {"radius", RealReference}, {"sigma", RealReference},
400 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
401 { "OrderedDither", { {"threshold", StringReference},
402 {"channel", MagickChannelOptions} } },
403 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
404 {"height", IntegerReference} } },
405 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
406 {"white-point", RealReference}, {"gamma", RealReference},
407 {"channel", MagickChannelOptions}, {"level", StringReference} } },
408 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
409 { "AffineTransform", { {"affine", ArrayReference},
410 {"translate", StringReference}, {"scale", StringReference},
411 {"rotate", RealReference}, {"skewX", RealReference},
412 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
413 {"background", StringReference} } },
414 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
415 { "AdaptiveThreshold", { {"geometry", StringReference},
416 {"width", IntegerReference}, {"height", IntegerReference},
417 {"offset", IntegerReference} } },
418 { "Resample", { {"density", StringReference}, {"x", RealReference},
419 {"y", RealReference}, {"filter", MagickFilterOptions},
420 {"support", RealReference }, {"blur", RealReference } } },
421 { "Describe", { {"file", FileReference} } },
422 { "BlackThreshold", { {"threshold", StringReference},
423 {"channel", MagickChannelOptions} } },
424 { "WhiteThreshold", { {"threshold", StringReference},
425 {"channel", MagickChannelOptions} } },
426 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
427 {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
431 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"channel", MagickChannelOptions} } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference} } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference } } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "Recolor", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference} } },
487 { "FloodfillPaint", { {"geometry", StringReference},
488 {"x", IntegerReference}, {"y", IntegerReference},
489 {"fill", StringReference}, {"bordercolor", StringReference},
490 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
491 {"invert", MagickBooleanOptions} } },
492 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
493 {"virtual-pixel", MagickVirtualPixelOptions},
494 {"best-fit", MagickBooleanOptions} } },
495 { "Clut", { {"image", ImageReference},
496 {"channel", MagickChannelOptions} } },
497 { "LiquidRescale", { {"geometry", StringReference},
498 {"width", IntegerReference}, {"height", IntegerReference},
499 {"delta-x", RealReference}, {"rigidity", RealReference } } },
500 { "Encipher", { {"passphrase", StringReference} } },
501 { "Decipher", { {"passphrase", StringReference} } },
502 { "Deskew", { {"geometry", StringReference},
503 {"threshold", StringReference} } },
504 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
505 {"dither-method", MagickDitherOptions} } },
506 { "SparseColor", { {"points", ArrayReference},
507 {"method", MagickSparseColorOptions},
508 {"virtual-pixel", MagickVirtualPixelOptions},
509 {"channel", MagickChannelOptions} } },
510 { "Function", { {"parameters", ArrayReference},
511 {"function", MagickFunctionOptions},
512 {"virtual-pixel", MagickVirtualPixelOptions} } },
513 { "SelectiveBlur", { {"geometry", StringReference},
514 {"radius", RealReference}, {"sigma", RealReference},
515 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
516 { "HaldClut", { {"image", ImageReference},
517 {"channel", MagickChannelOptions} } },
518 { "BlueShift", { {"factor", StringReference} } },
519 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
521 { "ColorDecisionList", {
522 {"color-correction-collection", StringReference} } },
523 { "AutoGamma", { {"channel", MagickChannelOptions} } },
524 { "AutoLevel", { {"channel", MagickChannelOptions} } },
525 { "LevelColors", { {"invert", MagickBooleanOptions},
526 {"black-point", StringReference}, {"white-point", StringReference},
527 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
528 { "Clamp", { {"channel", MagickChannelOptions} } },
529 { "Filter", { {"kernel", StringReference},
530 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
531 { "BrightnessContrast", { {"levels", StringReference},
532 {"brightness", RealReference},{"contrast", RealReference},
533 {"channel", MagickChannelOptions} } },
534 { "Morphology", { {"kernel", StringReference},
535 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
536 {"iterations", IntegerReference} } },
537 { "ColorMatrix", { {"matrix", ArrayReference} } },
538 { "Color", { {"color", StringReference} } },
539 { "Mode", { {"geometry", StringReference},
540 {"width", IntegerReference},{"height", IntegerReference},
541 {"channel", MagickChannelOptions} } },
542 { "Statistic", { {"geometry", StringReference},
543 {"width", IntegerReference},{"height", IntegerReference},
544 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
548 *magick_registry = (SplayTreeInfo *) NULL;
551 Forward declarations.
554 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
557 strEQcase(const char *,const char *);
560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 % C l o n e P a c k a g e I n f o %
568 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
573 % The format of the ClonePackageInfo routine is:
575 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
578 % A description of each parameter follows:
580 % o info: a structure of type info.
582 % o exception: Return any errors or warnings in this structure.
585 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
586 ExceptionInfo *exception)
591 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
592 if (clone_info == (struct PackageInfo *) NULL)
594 ThrowPerlException(exception,ResourceLimitError,
595 "UnableToClonePackageInfo",PackageName);
596 return((struct PackageInfo *) NULL);
598 if (info == (struct PackageInfo *) NULL)
600 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
604 clone_info->image_info=CloneImageInfo(info->image_info);
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 % constant() returns a double value for the specified name.
621 % The format of the constant routine is:
623 % double constant(char *name,ssize_t sans)
625 % A description of each parameter follows:
627 % o value: Method constant returns a double value for the specified name.
629 % o name: The name of the constant.
631 % o sans: This integer value is not used.
634 static double constant(char *name,ssize_t sans)
642 if (strEQ(name,"BlobError"))
644 if (strEQ(name,"BlobWarning"))
650 if (strEQ(name,"CacheError"))
652 if (strEQ(name,"CacheWarning"))
653 return(CacheWarning);
654 if (strEQ(name,"CoderError"))
656 if (strEQ(name,"CoderWarning"))
657 return(CoderWarning);
658 if (strEQ(name,"ConfigureError"))
659 return(ConfigureError);
660 if (strEQ(name,"ConfigureWarning"))
661 return(ConfigureWarning);
662 if (strEQ(name,"CorruptImageError"))
663 return(CorruptImageError);
664 if (strEQ(name,"CorruptImageWarning"))
665 return(CorruptImageWarning);
670 if (strEQ(name,"DelegateError"))
671 return(DelegateError);
672 if (strEQ(name,"DelegateWarning"))
673 return(DelegateWarning);
674 if (strEQ(name,"DrawError"))
676 if (strEQ(name,"DrawWarning"))
682 if (strEQ(name,"ErrorException"))
683 return(ErrorException);
684 if (strEQ(name,"ExceptionError"))
686 if (strEQ(name,"ExceptionWarning"))
687 return(CoderWarning);
692 if (strEQ(name,"FatalErrorException"))
693 return(FatalErrorException);
694 if (strEQ(name,"FileOpenError"))
695 return(FileOpenError);
696 if (strEQ(name,"FileOpenWarning"))
697 return(FileOpenWarning);
702 if (strEQ(name,"ImageError"))
704 if (strEQ(name,"ImageWarning"))
705 return(ImageWarning);
710 if (strEQ(name,"MaxRGB"))
711 return(QuantumRange);
712 if (strEQ(name,"MissingDelegateError"))
713 return(MissingDelegateError);
714 if (strEQ(name,"MissingDelegateWarning"))
715 return(MissingDelegateWarning);
716 if (strEQ(name,"ModuleError"))
718 if (strEQ(name,"ModuleWarning"))
719 return(ModuleWarning);
724 if (strEQ(name,"Opaque"))
725 return(OpaqueOpacity);
726 if (strEQ(name,"OptionError"))
728 if (strEQ(name,"OptionWarning"))
729 return(OptionWarning);
734 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
735 return(MAGICKCORE_QUANTUM_DEPTH);
736 if (strEQ(name,"QuantumDepth"))
737 return(MAGICKCORE_QUANTUM_DEPTH);
738 if (strEQ(name,"QuantumRange"))
739 return(QuantumRange);
744 if (strEQ(name,"ResourceLimitError"))
745 return(ResourceLimitError);
746 if (strEQ(name,"ResourceLimitWarning"))
747 return(ResourceLimitWarning);
748 if (strEQ(name,"RegistryError"))
749 return(RegistryError);
750 if (strEQ(name,"RegistryWarning"))
751 return(RegistryWarning);
756 if (strEQ(name,"StreamError"))
758 if (strEQ(name,"StreamWarning"))
759 return(StreamWarning);
760 if (strEQ(name,"Success"))
766 if (strEQ(name,"Transparent"))
767 return(TransparentOpacity);
768 if (strEQ(name,"TypeError"))
770 if (strEQ(name,"TypeWarning"))
776 if (strEQ(name,"WarningException"))
777 return(WarningException);
782 if (strEQ(name,"XServerError"))
783 return(XServerError);
784 if (strEQ(name,"XServerWarning"))
785 return(XServerWarning);
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 % D e s t r o y P a c k a g e I n f o %
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804 % Method DestroyPackageInfo frees a previously created info structure.
806 % The format of the DestroyPackageInfo routine is:
808 % DestroyPackageInfo(struct PackageInfo *info)
810 % A description of each parameter follows:
812 % o info: a structure of type info.
815 static void DestroyPackageInfo(struct PackageInfo *info)
817 info->image_info=DestroyImageInfo(info->image_info);
818 info=(struct PackageInfo *) RelinquishMagickMemory(info);
822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % Method GetList is recursively called by SetupList to traverse the
833 % Image__Magick reference. If building an reference_vector (see SetupList),
834 % *current is the current position in *reference_vector and *last is the final
835 % entry in *reference_vector.
837 % The format of the GetList routine is:
841 % A description of each parameter follows:
843 % o info: a structure of type info.
846 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
847 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
852 if (reference == (SV *) NULL)
854 switch (SvTYPE(reference))
874 previous=(Image *) NULL;
878 for (i=0; i <= n; i++)
884 if (rv && *rv && sv_isobject(*rv))
886 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
888 if (image == (Image *) NULL)
890 if (image == previous)
892 image=CloneImage(image,0,0,MagickTrue,exception);
893 if (image == (Image *) NULL)
896 image->previous=previous;
897 *(previous ? &previous->next : &head)=image;
898 for (previous=image; previous->next; previous=previous->next) ;
906 Blessed scalar, one image.
908 image=(Image *) SvIV(reference);
909 if (image == (Image *) NULL)
911 image->previous=(Image *) NULL;
912 image->next=(Image *) NULL;
913 if (reference_vector)
915 if (*current == *last)
918 if (*reference_vector == (SV **) NULL)
919 *reference_vector=(SV **) AcquireQuantumMemory(*last,
920 sizeof(*reference_vector));
922 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
923 *last,sizeof(*reference_vector));
925 if (*reference_vector == (SV **) NULL)
927 ThrowPerlException(exception,ResourceLimitError,
928 "MemoryAllocationFailed",PackageName);
929 return((Image *) NULL);
931 (*reference_vector)[*current]=reference;
932 (*reference_vector)[++(*current)]=NULL;
939 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
940 (double) SvTYPE(reference));
941 return((Image *) NULL);
945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
949 % G e t P a c k a g e I n f o %
953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
955 % Method GetPackageInfo looks up or creates an info structure for the given
956 % Image__Magick reference. If it does create a new one, the information in
957 % package_info is used to initialize it.
959 % The format of the GetPackageInfo routine is:
961 % struct PackageInfo *GetPackageInfo(void *reference,
962 % struct PackageInfo *package_info,ExceptionInfo *exception)
964 % A description of each parameter follows:
966 % o info: a structure of type info.
968 % o exception: Return any errors or warnings in this structure.
971 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
972 struct PackageInfo *package_info,ExceptionInfo *exception)
975 message[MaxTextExtent];
983 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
984 PackageName,XS_VERSION,reference);
985 sv=perl_get_sv(message,(TRUE | 0x02));
986 if (sv == (SV *) NULL)
988 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
990 return(package_info);
992 if (SvREFCNT(sv) == 0)
993 (void) SvREFCNT_inc(sv);
994 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
996 clone_info=ClonePackageInfo(package_info,exception);
997 sv_setiv(sv,(IV) clone_info);
1002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 % S e t A t t r i b u t e %
1010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 % SetAttribute() sets the attribute to the value in sval. This can change
1013 % either or both of image or info.
1015 % The format of the SetAttribute routine is:
1017 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1018 % SV *sval,ExceptionInfo *exception)
1020 % A description of each parameter follows:
1022 % o list: a list of strings.
1024 % o string: a character string.
1028 static double SiPrefixToDouble(const char *string,const double interval)
1037 value=InterpretLocaleValue(string,&q);
1039 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1041 switch (tolower((int) ((unsigned char) *q)))
1043 case '%': value*=pow(scale,0)*interval/100.0; break;
1044 case 'k': value*=pow(scale,1); break;
1045 case 'm': value*=pow(scale,2); break;
1046 case 'g': value*=pow(scale,3); break;
1047 case 't': value*=pow(scale,4); break;
1048 case 'p': value*=pow(scale,5); break;
1049 case 'e': value*=pow(scale,6); break;
1050 case 'z': value*=pow(scale,7); break;
1051 case 'y': value*=pow(scale,8); break;
1057 static inline ssize_t StringToLong(const char *value)
1059 return(strtol(value,(char **) NULL,10));
1062 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1063 const char *attribute,SV *sval,ExceptionInfo *exception)
1090 if (LocaleCompare(attribute,"adjoin") == 0)
1092 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1093 SvPV(sval,na)) : SvIV(sval);
1096 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1101 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1104 if (LocaleCompare(attribute,"alpha") == 0)
1106 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1107 SvPV(sval,na)) : SvIV(sval);
1110 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1114 for ( ; image; image=image->next)
1115 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1118 if (LocaleCompare(attribute,"antialias") == 0)
1120 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1121 SvPV(sval,na)) : SvIV(sval);
1124 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1129 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1132 if (LocaleCompare(attribute,"area-limit") == 0)
1137 limit=MagickResourceInfinity;
1138 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1139 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1140 (void) SetMagickResourceLimit(AreaResource,limit);
1143 if (LocaleCompare(attribute,"attenuate") == 0)
1146 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1149 if (LocaleCompare(attribute,"authenticate") == 0)
1152 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1156 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1157 for ( ; image; image=image->next)
1158 SetImageProperty(image,attribute,SvPV(sval,na));
1164 if (LocaleCompare(attribute,"background") == 0)
1166 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1168 info->image_info->background_color=target_color;
1169 for ( ; image; image=image->next)
1170 image->background_color=target_color;
1173 if (LocaleCompare(attribute,"bias") == 0)
1175 for ( ; image; image=image->next)
1176 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1179 if (LocaleCompare(attribute,"blue-primary") == 0)
1181 for ( ; image; image=image->next)
1183 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1184 image->chromaticity.blue_primary.x=geometry_info.rho;
1185 image->chromaticity.blue_primary.y=geometry_info.sigma;
1186 if ((flags & SigmaValue) == 0)
1187 image->chromaticity.blue_primary.y=
1188 image->chromaticity.blue_primary.x;
1192 if (LocaleCompare(attribute,"bordercolor") == 0)
1194 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1196 info->image_info->border_color=target_color;
1197 for ( ; image; image=image->next)
1198 image->border_color=target_color;
1202 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1203 for ( ; image; image=image->next)
1204 SetImageProperty(image,attribute,SvPV(sval,na));
1210 if (LocaleCompare(attribute,"cache-threshold") == 0)
1212 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1213 SiPrefixToDouble(SvPV(sval,na),100.0));
1214 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1215 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1218 if (LocaleCompare(attribute,"clip-mask") == 0)
1223 clip_mask=(Image *) NULL;
1225 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1226 for ( ; image; image=image->next)
1227 SetImageClipMask(image,clip_mask);
1230 if (LocaleNCompare(attribute,"colormap",8) == 0)
1232 for ( ; image; image=image->next)
1240 if (image->storage_class == DirectClass)
1243 items=sscanf(attribute,"%*[^[][%ld",&i);
1245 if (i > (ssize_t) image->colors)
1247 if ((strchr(SvPV(sval,na),',') == 0) ||
1248 (strchr(SvPV(sval,na),')') != 0))
1249 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1252 color=image->colormap+i;
1253 pixel.red=color->red;
1254 pixel.green=color->green;
1255 pixel.blue=color->blue;
1256 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1257 pixel.red=geometry_info.rho;
1258 pixel.green=geometry_info.sigma;
1259 pixel.blue=geometry_info.xi;
1260 color->red=ClampToQuantum(pixel.red);
1261 color->green=ClampToQuantum(pixel.green);
1262 color->blue=ClampToQuantum(pixel.blue);
1267 if (LocaleCompare(attribute,"colorspace") == 0)
1269 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1270 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1273 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1277 for ( ; image; image=image->next)
1278 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1281 if (LocaleCompare(attribute,"comment") == 0)
1283 for ( ; image; image=image->next)
1284 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1285 info ? info->image_info : (ImageInfo *) NULL,image,
1289 if (LocaleCompare(attribute,"compression") == 0)
1291 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1292 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1295 ThrowPerlException(exception,OptionError,
1296 "UnrecognizedImageCompression",SvPV(sval,na));
1300 info->image_info->compression=(CompressionType) sp;
1301 for ( ; image; image=image->next)
1302 image->compression=(CompressionType) sp;
1306 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1307 for ( ; image; image=image->next)
1308 SetImageProperty(image,attribute,SvPV(sval,na));
1314 if (LocaleCompare(attribute,"debug") == 0)
1316 SetLogEventMask(SvPV(sval,na));
1319 if (LocaleCompare(attribute,"delay") == 0)
1321 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1322 for ( ; image; image=image->next)
1324 image->delay=(size_t) floor(geometry_info.rho+0.5);
1325 if ((flags & SigmaValue) != 0)
1326 image->ticks_per_second=(ssize_t)
1327 floor(geometry_info.sigma+0.5);
1331 if (LocaleCompare(attribute,"disk-limit") == 0)
1336 limit=MagickResourceInfinity;
1337 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1338 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1339 (void) SetMagickResourceLimit(DiskResource,limit);
1342 if (LocaleCompare(attribute,"density") == 0)
1344 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1346 ThrowPerlException(exception,OptionError,"MissingGeometry",
1351 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1352 for ( ; image; image=image->next)
1354 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1355 image->x_resolution=geometry_info.rho;
1356 image->y_resolution=geometry_info.sigma;
1357 if ((flags & SigmaValue) == 0)
1358 image->y_resolution=image->x_resolution;
1362 if (LocaleCompare(attribute,"depth") == 0)
1365 info->image_info->depth=SvIV(sval);
1366 for ( ; image; image=image->next)
1367 (void) SetImageDepth(image,SvIV(sval));
1370 if (LocaleCompare(attribute,"dispose") == 0)
1372 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1373 SvPV(sval,na)) : SvIV(sval);
1376 ThrowPerlException(exception,OptionError,
1377 "UnrecognizedDisposeMethod",SvPV(sval,na));
1380 for ( ; image; image=image->next)
1381 image->dispose=(DisposeType) sp;
1384 if (LocaleCompare(attribute,"dither") == 0)
1388 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1389 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1392 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1396 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1400 if (LocaleCompare(attribute,"display") == 0)
1404 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1408 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1409 for ( ; image; image=image->next)
1410 SetImageProperty(image,attribute,SvPV(sval,na));
1416 if (LocaleCompare(attribute,"endian") == 0)
1418 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1419 SvPV(sval,na)) : SvIV(sval);
1422 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1427 info->image_info->endian=(EndianType) sp;
1428 for ( ; image; image=image->next)
1429 image->endian=(EndianType) sp;
1432 if (LocaleCompare(attribute,"extract") == 0)
1435 Set image extract geometry.
1437 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1441 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1442 for ( ; image; image=image->next)
1443 SetImageProperty(image,attribute,SvPV(sval,na));
1449 if (LocaleCompare(attribute,"filename") == 0)
1452 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1454 for ( ; image; image=image->next)
1455 (void) CopyMagickString(image->filename,SvPV(sval,na),
1459 if (LocaleCompare(attribute,"file") == 0)
1467 if (info == (struct PackageInfo *) NULL)
1469 io_info=IoIFP(sv_2io(sval));
1470 if (io_info == (PerlIO *) NULL)
1472 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1476 file=PerlIO_findFILE(io_info);
1477 if (file == (FILE *) NULL)
1479 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1483 SetImageInfoFile(info->image_info,file);
1486 if (LocaleCompare(attribute,"fill") == 0)
1489 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1492 if (LocaleCompare(attribute,"font") == 0)
1495 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1498 if (LocaleCompare(attribute,"foreground") == 0)
1500 if (LocaleCompare(attribute,"fuzz") == 0)
1503 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1504 for ( ; image; image=image->next)
1505 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1509 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1510 for ( ; image; image=image->next)
1511 SetImageProperty(image,attribute,SvPV(sval,na));
1517 if (LocaleCompare(attribute,"gamma") == 0)
1519 for ( ; image; image=image->next)
1520 image->gamma=SvNV(sval);
1523 if (LocaleCompare(attribute,"gravity") == 0)
1525 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1526 SvPV(sval,na)) : SvIV(sval);
1529 ThrowPerlException(exception,OptionError,
1530 "UnrecognizedGravityType",SvPV(sval,na));
1534 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1535 for ( ; image; image=image->next)
1536 image->gravity=(GravityType) sp;
1539 if (LocaleCompare(attribute,"green-primary") == 0)
1541 for ( ; image; image=image->next)
1543 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1544 image->chromaticity.green_primary.x=geometry_info.rho;
1545 image->chromaticity.green_primary.y=geometry_info.sigma;
1546 if ((flags & SigmaValue) == 0)
1547 image->chromaticity.green_primary.y=
1548 image->chromaticity.green_primary.x;
1553 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1554 for ( ; image; image=image->next)
1555 SetImageProperty(image,attribute,SvPV(sval,na));
1561 if (LocaleNCompare(attribute,"index",5) == 0)
1572 register PixelPacket
1578 for ( ; image; image=image->next)
1580 if (image->storage_class != PseudoClass)
1584 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1586 image_view=AcquireCacheView(image);
1587 p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1588 if (p != (PixelPacket *) NULL)
1590 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1591 items=sscanf(SvPV(sval,na),"%ld",&index);
1592 if ((index >= 0) && (index < (ssize_t) image->colors))
1593 SetIndexPixelComponent(indexes,index);
1594 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1596 image_view=DestroyCacheView(image_view);
1600 if (LocaleCompare(attribute,"iterations") == 0)
1603 for ( ; image; image=image->next)
1604 image->iterations=SvIV(sval);
1607 if (LocaleCompare(attribute,"interlace") == 0)
1609 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1610 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1613 ThrowPerlException(exception,OptionError,
1614 "UnrecognizedInterlaceType",SvPV(sval,na));
1618 info->image_info->interlace=(InterlaceType) sp;
1619 for ( ; image; image=image->next)
1620 image->interlace=(InterlaceType) sp;
1624 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1625 for ( ; image; image=image->next)
1626 SetImageProperty(image,attribute,SvPV(sval,na));
1632 if (LocaleCompare(attribute,"label") == 0)
1634 for ( ; image; image=image->next)
1635 (void) SetImageProperty(image,"label",InterpretImageProperties(
1636 info ? info->image_info : (ImageInfo *) NULL,image,
1640 if (LocaleCompare(attribute,"loop") == 0)
1643 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1644 for ( ; image; image=image->next)
1645 SetImageProperty(image,attribute,SvPV(sval,na));
1651 if (LocaleCompare(attribute,"magick") == 0)
1654 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1655 "%s:",SvPV(sval,na));
1656 for ( ; image; image=image->next)
1657 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1660 if (LocaleCompare(attribute,"map-limit") == 0)
1665 limit=MagickResourceInfinity;
1666 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1667 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1668 (void) SetMagickResourceLimit(MapResource,limit);
1671 if (LocaleCompare(attribute,"mask") == 0)
1676 mask=(Image *) NULL;
1678 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1679 for ( ; image; image=image->next)
1680 SetImageMask(image,mask);
1683 if (LocaleCompare(attribute,"mattecolor") == 0)
1685 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1687 info->image_info->matte_color=target_color;
1688 for ( ; image; image=image->next)
1689 image->matte_color=target_color;
1692 if (LocaleCompare(attribute,"matte") == 0)
1694 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1695 SvPV(sval,na)) : SvIV(sval);
1698 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1702 for ( ; image; image=image->next)
1703 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1706 if (LocaleCompare(attribute,"memory-limit") == 0)
1711 limit=MagickResourceInfinity;
1712 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1713 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1714 (void) SetMagickResourceLimit(MemoryResource,limit);
1717 if (LocaleCompare(attribute,"monochrome") == 0)
1719 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1720 SvPV(sval,na)) : SvIV(sval);
1723 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1728 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1729 for ( ; image; image=image->next)
1730 (void) SetImageType(image,BilevelType);
1734 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1735 for ( ; image; image=image->next)
1736 SetImageProperty(image,attribute,SvPV(sval,na));
1742 if (LocaleCompare(attribute,"option") == 0)
1745 DefineImageOption(info->image_info,SvPV(sval,na));
1748 if (LocaleCompare(attribute,"orientation") == 0)
1750 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1751 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1754 ThrowPerlException(exception,OptionError,
1755 "UnrecognizedOrientationType",SvPV(sval,na));
1759 info->image_info->orientation=(OrientationType) sp;
1760 for ( ; image; image=image->next)
1761 image->orientation=(OrientationType) sp;
1765 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1766 for ( ; image; image=image->next)
1767 SetImageProperty(image,attribute,SvPV(sval,na));
1773 if (LocaleCompare(attribute,"page") == 0)
1778 geometry=GetPageGeometry(SvPV(sval,na));
1780 (void) CloneString(&info->image_info->page,geometry);
1781 for ( ; image; image=image->next)
1782 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1783 geometry=(char *) RelinquishMagickMemory(geometry);
1786 if (LocaleCompare(attribute,"pen") == 0)
1789 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1792 if (LocaleNCompare(attribute,"pixel",5) == 0)
1800 register IndexPacket
1803 register PixelPacket
1809 for ( ; image; image=image->next)
1811 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1815 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1817 image_view=AcquireCacheView(image);
1818 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1819 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1820 if (q != (PixelPacket *) NULL)
1822 if ((strchr(SvPV(sval,na),',') == 0) ||
1823 (strchr(SvPV(sval,na),')') != 0))
1824 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1827 GetMagickPixelPacket(image,&pixel);
1828 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1829 pixel.red=geometry_info.rho;
1830 if ((flags & SigmaValue) != 0)
1831 pixel.green=geometry_info.sigma;
1832 if ((flags & XiValue) != 0)
1833 pixel.blue=geometry_info.xi;
1834 if ((flags & PsiValue) != 0)
1835 pixel.opacity=geometry_info.psi;
1836 if ((flags & ChiValue) != 0)
1837 pixel.index=geometry_info.chi;
1839 SetRedPixelComponent(q,ClampToQuantum(pixel.red));
1840 SetGreenPixelComponent(q,ClampToQuantum(pixel.green));
1841 SetBluePixelComponent(q,ClampToQuantum(pixel.blue));
1842 SetOpacityPixelComponent(q,ClampToQuantum(pixel.opacity));
1843 if (((image->colorspace == CMYKColorspace) ||
1844 (image->storage_class == PseudoClass)) &&
1845 (indexes != (IndexPacket *) NULL))
1846 SetIndexPixelComponent(indexes,ClampToQuantum(pixel.index));
1847 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1849 image_view=DestroyCacheView(image_view);
1853 if (LocaleCompare(attribute,"pointsize") == 0)
1857 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1858 info->image_info->pointsize=geometry_info.rho;
1862 if (LocaleCompare(attribute,"preview") == 0)
1864 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1865 SvPV(sval,na)) : SvIV(sval);
1868 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1873 info->image_info->preview_type=(PreviewType) sp;
1877 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1878 for ( ; image; image=image->next)
1879 SetImageProperty(image,attribute,SvPV(sval,na));
1885 if (LocaleCompare(attribute,"quality") == 0)
1888 info->image_info->quality=SvIV(sval);
1889 for ( ; image; image=image->next)
1890 image->quality=SvIV(sval);
1894 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1895 for ( ; image; image=image->next)
1896 SetImageProperty(image,attribute,SvPV(sval,na));
1902 if (LocaleCompare(attribute,"red-primary") == 0)
1904 for ( ; image; image=image->next)
1906 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1907 image->chromaticity.red_primary.x=geometry_info.rho;
1908 image->chromaticity.red_primary.y=geometry_info.sigma;
1909 if ((flags & SigmaValue) == 0)
1910 image->chromaticity.red_primary.y=
1911 image->chromaticity.red_primary.x;
1915 if (LocaleCompare(attribute,"render") == 0)
1917 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1918 SvPV(sval,na)) : SvIV(sval);
1921 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1925 for ( ; image; image=image->next)
1926 image->rendering_intent=(RenderingIntent) sp;
1929 if (LocaleCompare(attribute,"repage") == 0)
1934 for ( ; image; image=image->next)
1936 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1937 if ((flags & WidthValue) != 0)
1939 if ((flags & HeightValue) == 0)
1940 geometry.height=geometry.width;
1941 image->page.width=geometry.width;
1942 image->page.height=geometry.height;
1944 if ((flags & AspectValue) != 0)
1946 if ((flags & XValue) != 0)
1947 image->page.x+=geometry.x;
1948 if ((flags & YValue) != 0)
1949 image->page.y+=geometry.y;
1953 if ((flags & XValue) != 0)
1955 image->page.x=geometry.x;
1956 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1957 image->page.width=image->columns+geometry.x;
1959 if ((flags & YValue) != 0)
1961 image->page.y=geometry.y;
1962 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1963 image->page.height=image->rows+geometry.y;
1970 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1971 for ( ; image; image=image->next)
1972 SetImageProperty(image,attribute,SvPV(sval,na));
1978 if (LocaleCompare(attribute,"sampling-factor") == 0)
1980 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1982 ThrowPerlException(exception,OptionError,"MissingGeometry",
1987 (void) CloneString(&info->image_info->sampling_factor,
1991 if (LocaleCompare(attribute,"scene") == 0)
1993 for ( ; image; image=image->next)
1994 image->scene=SvIV(sval);
1997 if (LocaleCompare(attribute,"subimage") == 0)
2000 info->image_info->subimage=SvIV(sval);
2003 if (LocaleCompare(attribute,"subrange") == 0)
2006 info->image_info->subrange=SvIV(sval);
2009 if (LocaleCompare(attribute,"server") == 0)
2011 if (LocaleCompare(attribute,"size") == 0)
2015 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2017 ThrowPerlException(exception,OptionError,"MissingGeometry",
2021 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2025 if (LocaleCompare(attribute,"stroke") == 0)
2028 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2032 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2033 for ( ; image; image=image->next)
2034 SetImageProperty(image,attribute,SvPV(sval,na));
2040 if (LocaleCompare(attribute,"texture") == 0)
2043 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2046 if (LocaleCompare(attribute,"thread-limit") == 0)
2051 limit=MagickResourceInfinity;
2052 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2053 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2054 (void) SetMagickResourceLimit(ThreadResource,limit);
2057 if (LocaleCompare(attribute,"tile") == 0)
2060 (void) CloneString(&info->image_info->tile,SvPV(sval,na));
2063 if (LocaleCompare(attribute,"tile-offset") == 0)
2068 geometry=GetPageGeometry(SvPV(sval,na));
2070 (void) CloneString(&info->image_info->page,geometry);
2071 for ( ; image; image=image->next)
2072 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2074 geometry=(char *) RelinquishMagickMemory(geometry);
2077 if (LocaleCompare(attribute,"time-limit") == 0)
2082 limit=MagickResourceInfinity;
2083 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2084 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2085 (void) SetMagickResourceLimit(TimeResource,limit);
2088 if (LocaleCompare(attribute,"transparent-color") == 0)
2090 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2092 info->image_info->transparent_color=target_color;
2093 for ( ; image; image=image->next)
2094 image->transparent_color=target_color;
2097 if (LocaleCompare(attribute,"type") == 0)
2099 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2100 SvPV(sval,na)) : SvIV(sval);
2103 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2108 info->image_info->type=(ImageType) sp;
2109 for ( ; image; image=image->next)
2110 SetImageType(image,(ImageType) sp);
2114 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2115 for ( ; image; image=image->next)
2116 SetImageProperty(image,attribute,SvPV(sval,na));
2122 if (LocaleCompare(attribute,"units") == 0)
2124 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2125 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2128 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2133 info->image_info->units=(ResolutionType) sp;
2134 for ( ; image; image=image->next)
2139 units=(ResolutionType) sp;
2140 if (image->units != units)
2141 switch (image->units)
2143 case UndefinedResolution:
2144 case PixelsPerInchResolution:
2146 if (units == PixelsPerCentimeterResolution)
2148 image->x_resolution*=2.54;
2149 image->y_resolution*=2.54;
2153 case PixelsPerCentimeterResolution:
2155 if (units == PixelsPerInchResolution)
2157 image->x_resolution/=2.54;
2158 image->y_resolution/=2.54;
2168 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2169 for ( ; image; image=image->next)
2170 SetImageProperty(image,attribute,SvPV(sval,na));
2176 if (LocaleCompare(attribute,"verbose") == 0)
2178 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2179 SvPV(sval,na)) : SvIV(sval);
2182 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2187 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2190 if (LocaleCompare(attribute,"view") == 0)
2193 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2196 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2198 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2199 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2202 ThrowPerlException(exception,OptionError,
2203 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2207 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2208 for ( ; image; image=image->next)
2209 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2213 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2214 for ( ; image; image=image->next)
2215 SetImageProperty(image,attribute,SvPV(sval,na));
2221 if (LocaleCompare(attribute,"white-point") == 0)
2223 for ( ; image; image=image->next)
2225 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2226 image->chromaticity.white_point.x=geometry_info.rho;
2227 image->chromaticity.white_point.y=geometry_info.sigma;
2228 if ((flags & SigmaValue) == 0)
2229 image->chromaticity.white_point.y=
2230 image->chromaticity.white_point.x;
2235 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2236 for ( ; image; image=image->next)
2237 SetImageProperty(image,attribute,SvPV(sval,na));
2243 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2244 for ( ; image; image=image->next)
2245 SetImageProperty(image,attribute,SvPV(sval,na));
2252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2256 % S e t u p L i s t %
2260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2262 % Method SetupList returns the list of all the images linked by their
2263 % image->next and image->previous link lists for use with ImageMagick. If
2264 % info is non-NULL, an info structure is returned in *info. If
2265 % reference_vector is non-NULL,an array of SV* are returned in
2266 % *reference_vector. Reference_vector is used when the images are going to be
2267 % replaced with new Image*'s.
2269 % The format of the SetupList routine is:
2271 % Image *SetupList(SV *reference,struct PackageInfo **info,
2272 % SV ***reference_vector,ExceptionInfo *exception)
2274 % A description of each parameter follows:
2276 % o list: a list of strings.
2278 % o string: a character string.
2280 % o exception: Return any errors or warnings in this structure.
2283 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2284 SV ***reference_vector,ExceptionInfo *exception)
2293 if (reference_vector)
2294 *reference_vector=NULL;
2299 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2300 if (info && (SvTYPE(reference) == SVt_PVAV))
2301 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2311 % s t r E Q c a s e %
2315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2317 % strEQcase() compares two strings and returns 0 if they are the
2318 % same or if the second string runs out first. The comparison is case
2321 % The format of the strEQcase routine is:
2323 % ssize_t strEQcase(const char *p,const char *q)
2325 % A description of each parameter follows:
2327 % o p: a character string.
2329 % o q: a character string.
2333 static ssize_t strEQcase(const char *p,const char *q)
2341 for (i=0 ; (c=(*q)) != 0; i++)
2343 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2344 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2349 return(((*q == 0) && (*p == 0)) ? i : 0);
2353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2357 % I m a g e : : M a g i c k %
2361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2365 MODULE = Image::Magick PACKAGE = Image::Magick
2370 MagickCoreGenesis("PerlMagick",MagickFalse);
2371 SetWarningHandler(NULL);
2372 SetErrorHandler(NULL);
2373 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2374 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2380 if (magick_registry != (SplayTreeInfo *) NULL)
2381 magick_registry=DestroySplayTree(magick_registry);
2382 MagickCoreTerminus();
2386 constant(name,argument)
2391 ###############################################################################
2399 ###############################################################################
2404 Image::Magick ref=NO_INIT
2428 PERL_UNUSED_VAR(ref);
2429 PERL_UNUSED_VAR(ix);
2430 exception=AcquireExceptionInfo();
2431 perl_exception=newSVpv("",0);
2432 package_info=(struct PackageInfo *) NULL;
2433 if (sv_isobject(ST(0)) == 0)
2435 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2439 reference=SvRV(ST(0));
2440 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2441 if (image == (Image *) NULL)
2443 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2447 package_info=ClonePackageInfo(info,exception);
2449 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2452 for (i=2; i < items; i+=2)
2453 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2455 (void) AnimateImages(package_info->image_info,image);
2456 (void) CatchImageException(image);
2457 InheritException(exception,&image->exception);
2460 if (package_info != (struct PackageInfo *) NULL)
2461 DestroyPackageInfo(package_info);
2462 InheritPerlException(exception,perl_exception);
2463 exception=DestroyExceptionInfo(exception);
2464 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2465 SvPOK_on(perl_exception);
2466 ST(0)=sv_2mortal(perl_exception);
2471 ###############################################################################
2479 ###############################################################################
2484 Image::Magick ref=NO_INIT
2522 PERL_UNUSED_VAR(ref);
2523 PERL_UNUSED_VAR(ix);
2524 exception=AcquireExceptionInfo();
2525 perl_exception=newSVpv("",0);
2529 if (sv_isobject(ST(0)) == 0)
2531 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2535 reference=SvRV(ST(0));
2536 hv=SvSTASH(reference);
2538 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2540 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2541 if (image == (Image *) NULL)
2543 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2547 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2552 for (i=2; i < items; i+=2)
2554 attribute=(char *) SvPV(ST(i-1),na);
2560 if (LocaleCompare(attribute,"stack") == 0)
2562 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2566 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2572 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2578 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2584 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2585 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2587 for ( ; image; image=image->next)
2589 AddImageToRegistry(sv,image);
2591 av_push(av,sv_bless(rv,hv));
2594 exception=DestroyExceptionInfo(exception);
2596 SvREFCNT_dec(perl_exception);
2600 InheritPerlException(exception,perl_exception);
2601 exception=DestroyExceptionInfo(exception);
2602 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2603 SvPOK_on(perl_exception);
2604 ST(0)=sv_2mortal(perl_exception);
2609 ###############################################################################
2617 ###############################################################################
2622 Image::Magick ref=NO_INIT
2653 PERL_UNUSED_VAR(ref);
2654 PERL_UNUSED_VAR(ix);
2655 exception=AcquireExceptionInfo();
2656 perl_exception=newSVpv("",0);
2658 if (sv_isobject(ST(0)) == 0)
2660 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2664 reference=SvRV(ST(0));
2665 hv=SvSTASH(reference);
2666 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2667 if (image == (Image *) NULL)
2669 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2673 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2674 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2677 Create blessed Perl array for the returned image.
2680 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2682 AddImageToRegistry(sv,image);
2684 av_push(av,sv_bless(rv,hv));
2686 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2687 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2688 "average-%.*s",(int) (MaxTextExtent-9),
2689 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2690 (void) CopyMagickString(image->filename,info->image_info->filename,
2692 SetImageInfo(info->image_info,0,exception);
2693 exception=DestroyExceptionInfo(exception);
2694 SvREFCNT_dec(perl_exception);
2698 InheritPerlException(exception,perl_exception);
2699 exception=DestroyExceptionInfo(exception);
2700 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2701 SvPOK_on(perl_exception);
2702 ST(0)=sv_2mortal(perl_exception);
2707 ###############################################################################
2711 # B l o b T o I m a g e #
2715 ###############################################################################
2719 BlobToImage(ref,...)
2720 Image::Magick ref=NO_INIT
2766 PERL_UNUSED_VAR(ref);
2767 PERL_UNUSED_VAR(ix);
2768 exception=AcquireExceptionInfo();
2769 perl_exception=newSVpv("",0);
2772 ac=(items < 2) ? 1 : items-1;
2773 length=(STRLEN *) NULL;
2774 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2775 if (list == (char **) NULL)
2777 ThrowPerlException(exception,ResourceLimitError,
2778 "MemoryAllocationFailed",PackageName);
2781 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2782 if (length == (STRLEN *) NULL)
2784 ThrowPerlException(exception,ResourceLimitError,
2785 "MemoryAllocationFailed",PackageName);
2788 if (sv_isobject(ST(0)) == 0)
2790 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2794 reference=SvRV(ST(0));
2795 hv=SvSTASH(reference);
2796 if (SvTYPE(reference) != SVt_PVAV)
2798 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2802 av=(AV *) reference;
2803 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2808 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2811 for (n=0, i=0; i < ac; i++)
2813 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2814 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2816 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2821 list[n]=(char *) NULL;
2823 for (i=number_images=0; i < n; i++)
2825 image=BlobToImage(info->image_info,list[i],length[i],exception);
2826 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2828 for ( ; image; image=image->next)
2830 AddImageToRegistry(sv,image);
2832 av_push(av,sv_bless(rv,hv));
2840 for (i=0; i < n; i++)
2841 if (list[i] != (char *) NULL)
2842 for (p=keep; list[i] != *p++; )
2843 if (*p == (char *) NULL)
2845 list[i]=(char *) RelinquishMagickMemory(list[i]);
2851 list=(char **) RelinquishMagickMemory(list);
2853 length=(STRLEN *) RelinquishMagickMemory(length);
2854 InheritPerlException(exception,perl_exception);
2855 exception=DestroyExceptionInfo(exception);
2856 sv_setiv(perl_exception,(IV) number_images);
2857 SvPOK_on(perl_exception);
2858 ST(0)=sv_2mortal(perl_exception);
2863 ###############################################################################
2871 ###############################################################################
2876 Image::Magick ref=NO_INIT
2909 PERL_UNUSED_VAR(ref);
2910 PERL_UNUSED_VAR(ix);
2911 exception=AcquireExceptionInfo();
2912 perl_exception=newSVpv("",0);
2914 if (sv_isobject(ST(0)) == 0)
2916 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2920 reference=SvRV(ST(0));
2921 hv=SvSTASH(reference);
2922 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2923 if (image == (Image *) NULL)
2925 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2930 Create blessed Perl array for the returned image.
2933 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2935 for ( ; image; image=image->next)
2937 clone=CloneImage(image,0,0,MagickTrue,exception);
2938 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2940 AddImageToRegistry(sv,clone);
2942 av_push(av,sv_bless(rv,hv));
2945 exception=DestroyExceptionInfo(exception);
2946 SvREFCNT_dec(perl_exception);
2950 InheritPerlException(exception,perl_exception);
2951 exception=DestroyExceptionInfo(exception);
2952 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2953 SvPOK_on(perl_exception);
2954 ST(0)=sv_2mortal(perl_exception);
2959 ###############################################################################
2967 ###############################################################################
2975 PERL_UNUSED_VAR(ref);
2976 if (magick_registry != (SplayTreeInfo *) NULL)
2981 ResetSplayTreeIterator(magick_registry);
2982 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2983 while (p != (Image *) NULL)
2986 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2992 ###############################################################################
3000 ###############################################################################
3005 Image::Magick ref=NO_INIT
3034 PERL_UNUSED_VAR(ref);
3035 PERL_UNUSED_VAR(ix);
3036 exception=AcquireExceptionInfo();
3037 perl_exception=newSVpv("",0);
3039 if (sv_isobject(ST(0)) == 0)
3041 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3045 reference=SvRV(ST(0));
3046 hv=SvSTASH(reference);
3048 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3050 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3051 if (image == (Image *) NULL)
3053 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3057 image=CoalesceImages(image,exception);
3058 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3060 for ( ; image; image=image->next)
3062 AddImageToRegistry(sv,image);
3064 av_push(av,sv_bless(rv,hv));
3067 exception=DestroyExceptionInfo(exception);
3069 SvREFCNT_dec(perl_exception);
3073 InheritPerlException(exception,perl_exception);
3074 exception=DestroyExceptionInfo(exception);
3075 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3076 SvPOK_on(perl_exception);
3077 ST(0)=sv_2mortal(perl_exception);
3082 ###############################################################################
3090 ###############################################################################
3095 Image::Magick ref=NO_INIT
3144 PERL_UNUSED_VAR(ref);
3145 PERL_UNUSED_VAR(ix);
3146 exception=AcquireExceptionInfo();
3147 perl_exception=newSVpv("",0);
3151 if (sv_isobject(ST(0)) == 0)
3153 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3157 reference=SvRV(ST(0));
3158 hv=SvSTASH(reference);
3160 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3162 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3163 if (image == (Image *) NULL)
3165 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3169 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3173 channel=DefaultChannels;
3174 reconstruct_image=image;
3175 metric=RootMeanSquaredErrorMetric;
3176 for (i=2; i < items; i+=2)
3178 attribute=(char *) SvPV(ST(i-1),na);
3184 if (LocaleCompare(attribute,"channel") == 0)
3189 option=ParseChannelOption(SvPV(ST(i),na));
3192 ThrowPerlException(exception,OptionError,
3193 "UnrecognizedType",SvPV(ST(i),na));
3196 channel=(ChannelType) option;
3199 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3206 if (LocaleCompare(attribute,"fuzz") == 0)
3208 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3218 if (LocaleCompare(attribute,"image") == 0)
3220 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3221 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3224 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3231 if (LocaleCompare(attribute,"metric") == 0)
3233 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3237 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3241 metric=(MetricType) option;
3244 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3250 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3256 difference_image=CompareImageChannels(image,reconstruct_image,channel,
3257 metric,&distortion,exception);
3258 if (difference_image != (Image *) NULL)
3260 difference_image->error.mean_error_per_pixel=distortion;
3261 AddImageToRegistry(sv,difference_image);
3263 av_push(av,sv_bless(rv,hv));
3266 exception=DestroyExceptionInfo(exception);
3268 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3272 InheritPerlException(exception,perl_exception);
3273 exception=DestroyExceptionInfo(exception);
3274 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3275 SvPOK_on(perl_exception);
3276 ST(0)=sv_2mortal(perl_exception);
3281 ###############################################################################
3285 # C o m p a r e L a y e r s #
3289 ###############################################################################
3294 Image::Magick ref=NO_INIT
3296 CompareImageLayers = 1
3298 compareimagelayers = 3
3335 PERL_UNUSED_VAR(ref);
3336 PERL_UNUSED_VAR(ix);
3337 exception=AcquireExceptionInfo();
3338 perl_exception=newSVpv("",0);
3340 if (sv_isobject(ST(0)) == 0)
3342 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3346 reference=SvRV(ST(0));
3347 hv=SvSTASH(reference);
3349 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3351 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3352 if (image == (Image *) NULL)
3354 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3358 method=CompareAnyLayer;
3359 for (i=2; i < items; i+=2)
3361 attribute=(char *) SvPV(ST(i-1),na);
3367 if (LocaleCompare(attribute,"method") == 0)
3369 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3373 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3377 method=(ImageLayerMethod) option;
3380 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3386 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3392 image=CompareImageLayers(image,method,exception);
3393 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3395 for ( ; image; image=image->next)
3397 AddImageToRegistry(sv,image);
3399 av_push(av,sv_bless(rv,hv));
3402 exception=DestroyExceptionInfo(exception);
3404 SvREFCNT_dec(perl_exception);
3408 InheritPerlException(exception,perl_exception);
3409 exception=DestroyExceptionInfo(exception);
3410 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3411 SvPOK_on(perl_exception);
3412 ST(0)=sv_2mortal(perl_exception);
3417 ###############################################################################
3425 ###############################################################################
3430 Image::Magick ref=NO_INIT
3436 PERL_UNUSED_VAR(ref);
3437 if (sv_isobject(ST(0)) == 0)
3438 croak("ReferenceIsNotMyType");
3439 reference=SvRV(ST(0));
3440 switch (SvTYPE(reference))
3445 message[MaxTextExtent];
3463 Array (AV *) reference
3465 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3466 XS_VERSION,reference);
3467 hv=gv_stashpv(PackageName, FALSE);
3470 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3474 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3476 info=(struct PackageInfo *) SvIV(sv);
3477 DestroyPackageInfo(info);
3479 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3489 Blessed scalar = (Image *) SvIV(reference)
3491 image=(Image *) SvIV(reference);
3492 if (image != (Image *) NULL)
3493 DeleteImageFromRegistry(reference,image);
3502 ###############################################################################
3510 ###############################################################################
3515 Image::Magick ref=NO_INIT
3539 PERL_UNUSED_VAR(ref);
3540 PERL_UNUSED_VAR(ix);
3541 exception=AcquireExceptionInfo();
3542 perl_exception=newSVpv("",0);
3543 package_info=(struct PackageInfo *) NULL;
3544 if (sv_isobject(ST(0)) == 0)
3546 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3550 reference=SvRV(ST(0));
3551 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3552 if (image == (Image *) NULL)
3554 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3558 package_info=ClonePackageInfo(info,exception);
3560 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3563 for (i=2; i < items; i+=2)
3564 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3566 (void) DisplayImages(package_info->image_info,image);
3567 (void) CatchImageException(image);
3568 InheritException(exception,&image->exception);
3571 if (package_info != (struct PackageInfo *) NULL)
3572 DestroyPackageInfo(package_info);
3573 InheritPerlException(exception,perl_exception);
3574 exception=DestroyExceptionInfo(exception);
3575 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3576 SvPOK_on(perl_exception);
3577 ST(0)=sv_2mortal(perl_exception);
3582 ###############################################################################
3586 # E v a l u a t e I m a g e s #
3590 ###############################################################################
3595 Image::Magick ref=NO_INIT
3617 MagickEvaluateOperator
3632 PERL_UNUSED_VAR(ref);
3633 PERL_UNUSED_VAR(ix);
3634 exception=AcquireExceptionInfo();
3635 perl_exception=newSVpv("",0);
3637 if (sv_isobject(ST(0)) == 0)
3639 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3643 reference=SvRV(ST(0));
3644 hv=SvSTASH(reference);
3645 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3646 if (image == (Image *) NULL)
3648 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3652 op=MeanEvaluateOperator;
3658 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3662 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3666 op=(MagickEvaluateOperator) in;
3669 for (i=2; i < items; i+=2)
3671 attribute=(char *) SvPV(ST(i-1),na);
3677 if (LocaleCompare(attribute,"operator") == 0)
3682 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3683 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3686 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3690 op=(MagickEvaluateOperator) in;
3693 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3699 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3705 image=EvaluateImages(image,op,exception);
3706 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3709 Create blessed Perl array for the returned image.
3712 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3714 AddImageToRegistry(sv,image);
3716 av_push(av,sv_bless(rv,hv));
3718 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3719 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3720 "evaluate-%.*s",(int) (MaxTextExtent-9),
3721 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3722 (void) CopyMagickString(image->filename,info->image_info->filename,
3724 SetImageInfo(info->image_info,0,exception);
3725 exception=DestroyExceptionInfo(exception);
3726 SvREFCNT_dec(perl_exception);
3730 InheritPerlException(exception,perl_exception);
3731 exception=DestroyExceptionInfo(exception);
3732 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3733 SvPOK_on(perl_exception);
3734 ST(0)=sv_2mortal(perl_exception);
3739 ###############################################################################
3747 ###############################################################################
3752 Image::Magick ref=NO_INIT
3759 #define ChannelFeatures(channel,direction) \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].angular_second_moment[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].contrast[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].contrast[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3770 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3771 channel_features[channel].variance_sum_of_squares[direction]); \
3772 PUSHs(sv_2mortal(newSVpv(message,0))); \
3773 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3774 channel_features[channel].inverse_difference_moment[direction]); \
3775 PUSHs(sv_2mortal(newSVpv(message,0))); \
3776 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3777 channel_features[channel].sum_average[direction]); \
3778 PUSHs(sv_2mortal(newSVpv(message,0))); \
3779 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3780 channel_features[channel].sum_variance[direction]); \
3781 PUSHs(sv_2mortal(newSVpv(message,0))); \
3782 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3783 channel_features[channel].sum_entropy[direction]); \
3784 PUSHs(sv_2mortal(newSVpv(message,0))); \
3785 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3786 channel_features[channel].entropy[direction]); \
3787 PUSHs(sv_2mortal(newSVpv(message,0))); \
3788 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3789 channel_features[channel].difference_variance[direction]); \
3790 PUSHs(sv_2mortal(newSVpv(message,0))); \
3791 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3792 channel_features[channel].difference_entropy[direction]); \
3793 PUSHs(sv_2mortal(newSVpv(message,0))); \
3794 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3795 channel_features[channel].measure_of_correlation_1[direction]); \
3796 PUSHs(sv_2mortal(newSVpv(message,0))); \
3797 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3798 channel_features[channel].measure_of_correlation_2[direction]); \
3799 PUSHs(sv_2mortal(newSVpv(message,0))); \
3800 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3801 channel_features[channel].maximum_correlation_coefficient[direction]); \
3802 PUSHs(sv_2mortal(newSVpv(message,0))); \
3810 message[MaxTextExtent];
3837 PERL_UNUSED_VAR(ref);
3838 PERL_UNUSED_VAR(ix);
3839 exception=AcquireExceptionInfo();
3840 perl_exception=newSVpv("",0);
3842 if (sv_isobject(ST(0)) == 0)
3844 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3848 reference=SvRV(ST(0));
3851 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3852 if (image == (Image *) NULL)
3854 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3858 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3860 for (i=2; i < items; i+=2)
3862 attribute=(char *) SvPV(ST(i-1),na);
3868 if (LocaleCompare(attribute,"distance") == 0)
3870 distance=StringToLong((char *) SvPV(ST(1),na));
3873 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3879 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3886 for ( ; image; image=image->next)
3888 channel_features=GetImageChannelFeatures(image,distance,
3890 if (channel_features == (ChannelFeatures *) NULL)
3893 EXTEND(sp,75*count);
3894 for (i=0; i < 4; i++)
3896 ChannelFeatures(RedChannel,i);
3897 ChannelFeatures(GreenChannel,i);
3898 ChannelFeatures(BlueChannel,i);
3899 if (image->colorspace == CMYKColorspace)
3900 ChannelFeatures(IndexChannel,i);
3901 if (image->matte != MagickFalse)
3902 ChannelFeatures(OpacityChannel,i);
3904 channel_features=(ChannelFeatures *)
3905 RelinquishMagickMemory(channel_features);
3909 InheritPerlException(exception,perl_exception);
3910 exception=DestroyExceptionInfo(exception);
3911 SvREFCNT_dec(perl_exception);
3915 ###############################################################################
3923 ###############################################################################
3928 Image::Magick ref=NO_INIT
3966 PERL_UNUSED_VAR(ref);
3967 PERL_UNUSED_VAR(ix);
3968 exception=AcquireExceptionInfo();
3969 perl_exception=newSVpv("",0);
3971 if (sv_isobject(ST(0)) == 0)
3973 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3977 reference=SvRV(ST(0));
3978 hv=SvSTASH(reference);
3979 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3980 if (image == (Image *) NULL)
3982 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3986 background_color=image->background_color;
3988 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3991 for (i=2; i < items; i+=2)
3993 attribute=(char *) SvPV(ST(i-1),na);
3999 if (LocaleCompare(attribute,"background") == 0)
4001 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
4002 &background_color,exception);
4005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4011 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4017 image->background_color=background_color;
4018 image=MergeImageLayers(image,FlattenLayer,exception);
4019 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4022 Create blessed Perl array for the returned image.
4025 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4027 AddImageToRegistry(sv,image);
4029 av_push(av,sv_bless(rv,hv));
4031 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4032 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4033 "flatten-%.*s",(int) (MaxTextExtent-9),
4034 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4035 (void) CopyMagickString(image->filename,info->image_info->filename,
4037 SetImageInfo(info->image_info,0,exception);
4038 exception=DestroyExceptionInfo(exception);
4039 SvREFCNT_dec(perl_exception);
4043 InheritPerlException(exception,perl_exception);
4044 exception=DestroyExceptionInfo(exception);
4045 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4046 SvPOK_on(perl_exception); /* return messages in string context */
4047 ST(0)=sv_2mortal(perl_exception);
4052 ###############################################################################
4060 ###############################################################################
4065 Image::Magick ref=NO_INIT
4077 expression[MaxTextExtent];
4104 PERL_UNUSED_VAR(ref);
4105 PERL_UNUSED_VAR(ix);
4106 exception=AcquireExceptionInfo();
4107 perl_exception=newSVpv("",0);
4111 if (sv_isobject(ST(0)) == 0)
4113 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4117 reference=SvRV(ST(0));
4118 hv=SvSTASH(reference);
4120 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4122 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4123 if (image == (Image *) NULL)
4125 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4129 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4133 channel=DefaultChannels;
4134 (void) CopyMagickString(expression,"u",MaxTextExtent);
4136 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4138 for (i=2; i < items; i+=2)
4140 attribute=(char *) SvPV(ST(i-1),na);
4146 if (LocaleCompare(attribute,"channel") == 0)
4151 option=ParseChannelOption(SvPV(ST(i),na));
4154 ThrowPerlException(exception,OptionError,
4155 "UnrecognizedType",SvPV(ST(i),na));
4158 channel=(ChannelType) option;
4161 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4168 if (LocaleCompare(attribute,"expression") == 0)
4170 (void) CopyMagickString(expression,SvPV(ST(i),na),
4174 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4180 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4186 image=FxImageChannel(image,channel,expression,exception);
4187 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4189 for ( ; image; image=image->next)
4191 AddImageToRegistry(sv,image);
4193 av_push(av,sv_bless(rv,hv));
4196 exception=DestroyExceptionInfo(exception);
4198 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4202 InheritPerlException(exception,perl_exception);
4203 exception=DestroyExceptionInfo(exception);
4204 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4205 SvPOK_on(perl_exception);
4206 ST(0)=sv_2mortal(perl_exception);
4211 ###############################################################################
4219 ###############################################################################
4224 Image::Magick ref=NO_INIT
4235 color[MaxTextExtent];
4260 PERL_UNUSED_VAR(ref);
4261 PERL_UNUSED_VAR(ix);
4262 exception=AcquireExceptionInfo();
4263 perl_exception=newSVpv("",0);
4264 if (sv_isobject(ST(0)) == 0)
4266 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4270 reference=SvRV(ST(0));
4271 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4272 if (image == (Image *) NULL && !info)
4275 for (i=1; i < items; i++)
4277 attribute=(char *) SvPV(ST(i),na);
4284 if (LocaleCompare(attribute,"adjoin") == 0)
4287 s=newSViv((ssize_t) info->image_info->adjoin);
4288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4291 if (LocaleCompare(attribute,"antialias") == 0)
4294 s=newSViv((ssize_t) info->image_info->antialias);
4295 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4298 if (LocaleCompare(attribute,"area") == 0)
4300 s=newSViv(GetMagickResource(AreaResource));
4301 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4304 if (LocaleCompare(attribute,"attenuate") == 0)
4309 value=GetImageProperty(image,attribute);
4310 if (value != (const char *) NULL)
4312 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4315 if (LocaleCompare(attribute,"authenticate") == 0)
4318 s=newSVpv(info->image_info->authenticate,0);
4319 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4322 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4329 if (LocaleCompare(attribute,"background") == 0)
4331 if (image == (Image *) NULL)
4333 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4334 QuantumFormat "," QuantumFormat "," QuantumFormat,
4335 image->background_color.red,image->background_color.green,
4336 image->background_color.blue,image->background_color.opacity);
4338 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4341 if (LocaleCompare(attribute,"base-columns") == 0)
4343 if (image != (Image *) NULL)
4344 s=newSViv((ssize_t) image->magick_columns);
4345 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4348 if (LocaleCompare(attribute,"base-filename") == 0)
4350 if (image != (Image *) NULL)
4351 s=newSVpv(image->magick_filename,0);
4352 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4355 if (LocaleCompare(attribute,"base-height") == 0)
4357 if (image != (Image *) NULL)
4358 s=newSViv((ssize_t) image->magick_rows);
4359 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4362 if (LocaleCompare(attribute,"base-rows") == 0)
4364 if (image != (Image *) NULL)
4365 s=newSViv((ssize_t) image->magick_rows);
4366 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4369 if (LocaleCompare(attribute,"base-width") == 0)
4371 if (image != (Image *) NULL)
4372 s=newSViv((ssize_t) image->magick_columns);
4373 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4376 if (LocaleCompare(attribute,"bias") == 0)
4378 if (image != (Image *) NULL)
4379 s=newSVnv(image->bias);
4380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4383 if (LocaleCompare(attribute,"blue-primary") == 0)
4385 if (image == (Image *) NULL)
4387 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4388 image->chromaticity.blue_primary.x,
4389 image->chromaticity.blue_primary.y);
4391 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4394 if (LocaleCompare(attribute,"bordercolor") == 0)
4396 if (image == (Image *) NULL)
4398 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4399 QuantumFormat "," QuantumFormat "," QuantumFormat,
4400 image->border_color.red,image->border_color.green,
4401 image->border_color.blue,image->border_color.opacity);
4403 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4406 if (LocaleCompare(attribute,"bounding-box") == 0)
4409 geometry[MaxTextExtent];
4414 if (image == (Image *) NULL)
4416 page=GetImageBoundingBox(image,&image->exception);
4417 (void) FormatLocaleString(geometry,MaxTextExtent,
4418 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4419 page.height,(double) page.x,(double) page.y);
4420 s=newSVpv(geometry,0);
4421 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4424 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4431 if (LocaleCompare(attribute,"class") == 0)
4433 if (image == (Image *) NULL)
4435 s=newSViv(image->storage_class);
4436 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4437 image->storage_class));
4439 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4442 if (LocaleCompare(attribute,"clip-mask") == 0)
4444 if (image != (Image *) NULL)
4450 if (image->mask == (Image *) NULL)
4452 if (image->mask != (Image *) NULL)
4454 AddImageToRegistry(sv,image->mask);
4455 s=sv_bless(newRV(sv),SvSTASH(reference));
4458 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4461 if (LocaleCompare(attribute,"clip-path") == 0)
4463 if (image != (Image *) NULL)
4469 if (image->clip_mask == (Image *) NULL)
4471 if (image->clip_mask != (Image *) NULL)
4473 AddImageToRegistry(sv,image->clip_mask);
4474 s=sv_bless(newRV(sv),SvSTASH(reference));
4477 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4480 if (LocaleCompare(attribute,"compression") == 0)
4482 j=info ? info->image_info->compression : image ?
4483 image->compression : UndefinedCompression;
4485 if (info->image_info->compression == UndefinedCompression)
4486 j=image->compression;
4488 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4491 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4494 if (LocaleCompare(attribute,"colorspace") == 0)
4496 j=image ? image->colorspace : RGBColorspace;
4498 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4501 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4504 if (LocaleCompare(attribute,"colors") == 0)
4506 if (image != (Image *) NULL)
4507 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4508 &image->exception));
4509 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4512 if (LocaleNCompare(attribute,"colormap",8) == 0)
4517 if (image == (Image *) NULL || !image->colormap)
4520 items=sscanf(attribute,"%*[^[][%ld",&j);
4522 if (j > (ssize_t) image->colors)
4524 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4525 QuantumFormat "," QuantumFormat "," QuantumFormat,
4526 image->colormap[j].red,image->colormap[j].green,
4527 image->colormap[j].blue,image->colormap[j].opacity);
4529 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4532 if (LocaleCompare(attribute,"columns") == 0)
4534 if (image != (Image *) NULL)
4535 s=newSViv((ssize_t) image->columns);
4536 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4539 if (LocaleCompare(attribute,"comment") == 0)
4544 value=GetImageProperty(image,attribute);
4545 if (value != (const char *) NULL)
4547 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4550 if (LocaleCompare(attribute,"copyright") == 0)
4552 s=newSVpv(GetMagickCopyright(),0);
4553 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4556 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4563 if (LocaleCompare(attribute,"density") == 0)
4566 geometry[MaxTextExtent];
4568 if (image == (Image *) NULL)
4570 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4571 image->x_resolution,image->y_resolution);
4572 s=newSVpv(geometry,0);
4573 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4576 if (LocaleCompare(attribute,"delay") == 0)
4578 if (image != (Image *) NULL)
4579 s=newSViv((ssize_t) image->delay);
4580 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4583 if (LocaleCompare(attribute,"depth") == 0)
4585 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4586 if (image != (Image *) NULL)
4587 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4588 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4591 if (LocaleCompare(attribute,"directory") == 0)
4593 if (image && image->directory)
4594 s=newSVpv(image->directory,0);
4595 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4598 if (LocaleCompare(attribute,"dispose") == 0)
4600 if (image == (Image *) NULL)
4603 s=newSViv(image->dispose);
4605 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4607 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4610 if (LocaleCompare(attribute,"disk") == 0)
4612 s=newSViv(GetMagickResource(DiskResource));
4613 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4616 if (LocaleCompare(attribute,"dither") == 0)
4619 s=newSViv((ssize_t) info->image_info->dither);
4620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4623 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4625 if (info && info->image_info->server_name)
4626 s=newSVpv(info->image_info->server_name,0);
4627 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4630 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4637 if (LocaleCompare(attribute,"elapsed-time") == 0)
4639 if (image != (Image *) NULL)
4640 s=newSVnv(GetElapsedTime(&image->timer));
4641 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4644 if (LocaleCompare(attribute,"endian") == 0)
4646 j=info ? info->image_info->endian : image ? image->endian :
4649 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4651 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4654 if (LocaleCompare(attribute,"error") == 0)
4656 if (image != (Image *) NULL)
4657 s=newSVnv(image->error.mean_error_per_pixel);
4658 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4661 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4668 if (LocaleCompare(attribute,"filesize") == 0)
4670 if (image != (Image *) NULL)
4671 s=newSViv((ssize_t) GetBlobSize(image));
4672 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4675 if (LocaleCompare(attribute,"filename") == 0)
4677 if (info && info->image_info->filename &&
4678 *info->image_info->filename)
4679 s=newSVpv(info->image_info->filename,0);
4680 if (image != (Image *) NULL)
4681 s=newSVpv(image->filename,0);
4682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4685 if (LocaleCompare(attribute,"filter") == 0)
4687 s=image ? newSViv(image->filter) : newSViv(0);
4688 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4691 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4694 if (LocaleCompare(attribute,"font") == 0)
4696 if (info && info->image_info->font)
4697 s=newSVpv(info->image_info->font,0);
4698 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4701 if (LocaleCompare(attribute,"foreground") == 0)
4703 if (LocaleCompare(attribute,"format") == 0)
4708 magick_info=(const MagickInfo *) NULL;
4709 if (info && (*info->image_info->magick != '\0'))
4710 magick_info=GetMagickInfo(info->image_info->magick,exception);
4711 if (image != (Image *) NULL)
4712 magick_info=GetMagickInfo(image->magick,&image->exception);
4713 if ((magick_info != (const MagickInfo *) NULL) &&
4714 (*magick_info->description != '\0'))
4715 s=newSVpv((char *) magick_info->description,0);
4716 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4719 if (LocaleCompare(attribute,"fuzz") == 0)
4722 s=newSVnv(info->image_info->fuzz);
4723 if (image != (Image *) NULL)
4724 s=newSVnv(image->fuzz);
4725 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4728 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4735 if (LocaleCompare(attribute,"gamma") == 0)
4737 if (image != (Image *) NULL)
4738 s=newSVnv(image->gamma);
4739 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4742 if (LocaleCompare(attribute,"geometry") == 0)
4744 if (image && image->geometry)
4745 s=newSVpv(image->geometry,0);
4746 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4749 if (LocaleCompare(attribute,"gravity") == 0)
4751 s=image ? newSViv(image->gravity) : newSViv(0);
4752 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4755 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4758 if (LocaleCompare(attribute,"green-primary") == 0)
4760 if (image == (Image *) NULL)
4762 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4763 image->chromaticity.green_primary.x,
4764 image->chromaticity.green_primary.y);
4766 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4769 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4776 if (LocaleCompare(attribute,"height") == 0)
4778 if (image != (Image *) NULL)
4779 s=newSViv((ssize_t) image->rows);
4780 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4783 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4790 if (LocaleCompare(attribute,"icc") == 0)
4792 if (image != (Image *) NULL)
4797 profile=GetImageProfile(image,"icc");
4798 if (profile != (StringInfo *) NULL)
4799 s=newSVpv((const char *) GetStringInfoDatum(profile),
4800 GetStringInfoLength(profile));
4802 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4805 if (LocaleCompare(attribute,"icm") == 0)
4807 if (image != (Image *) NULL)
4812 profile=GetImageProfile(image,"icm");
4813 if (profile != (const StringInfo *) NULL)
4814 s=newSVpv((const char *) GetStringInfoDatum(profile),
4815 GetStringInfoLength(profile));
4817 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4820 if (LocaleCompare(attribute,"id") == 0)
4822 if (image != (Image *) NULL)
4833 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4835 status=SetImageRegistry(ImageRegistryType,key,image,
4840 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4843 if (LocaleNCompare(attribute,"index",5) == 0)
4846 name[MaxTextExtent];
4855 register const IndexPacket
4858 register const PixelPacket
4864 if (image == (Image *) NULL)
4866 if (image->storage_class != PseudoClass)
4870 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4872 image_view=AcquireCacheView(image);
4873 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4874 if (p != (const PixelPacket *) NULL)
4876 indexes=GetCacheViewVirtualIndexQueue(image_view);
4877 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4878 GetIndexPixelComponent(indexes));
4880 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4882 image_view=DestroyCacheView(image_view);
4885 if (LocaleCompare(attribute,"iptc") == 0)
4887 if (image != (Image *) NULL)
4892 profile=GetImageProfile(image,"iptc");
4893 if (profile != (const StringInfo *) NULL)
4894 s=newSVpv((const char *) GetStringInfoDatum(profile),
4895 GetStringInfoLength(profile));
4897 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4900 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4902 if (image != (Image *) NULL)
4903 s=newSViv((ssize_t) image->iterations);
4904 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4907 if (LocaleCompare(attribute,"interlace") == 0)
4909 j=info ? info->image_info->interlace : image ? image->interlace :
4912 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4915 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4918 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4925 if (LocaleCompare(attribute,"label") == 0)
4930 if (image == (Image *) NULL)
4932 value=GetImageProperty(image,"Label");
4933 if (value != (const char *) NULL)
4935 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4938 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4940 if (image != (Image *) NULL)
4941 s=newSViv((ssize_t) image->iterations);
4942 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4945 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4952 if (LocaleCompare(attribute,"magick") == 0)
4954 if (info && *info->image_info->magick)
4955 s=newSVpv(info->image_info->magick,0);
4956 if (image != (Image *) NULL)
4957 s=newSVpv(image->magick,0);
4958 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4961 if (LocaleCompare(attribute,"map") == 0)
4963 s=newSViv(GetMagickResource(MapResource));
4964 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4967 if (LocaleCompare(attribute,"maximum-error") == 0)
4969 if (image != (Image *) NULL)
4970 s=newSVnv(image->error.normalized_maximum_error);
4971 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4974 if (LocaleCompare(attribute,"memory") == 0)
4976 s=newSViv(GetMagickResource(MemoryResource));
4977 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4980 if (LocaleCompare(attribute,"mean-error") == 0)
4982 if (image != (Image *) NULL)
4983 s=newSVnv(image->error.normalized_mean_error);
4984 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4987 if (LocaleCompare(attribute,"mime") == 0)
4989 if (info && *info->image_info->magick)
4990 s=newSVpv(MagickToMime(info->image_info->magick),0);
4991 if (image != (Image *) NULL)
4992 s=newSVpv(MagickToMime(image->magick),0);
4993 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4996 if (LocaleCompare(attribute,"mattecolor") == 0)
4998 if (image == (Image *) NULL)
5000 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5001 QuantumFormat "," QuantumFormat "," QuantumFormat,
5002 image->matte_color.red,image->matte_color.green,
5003 image->matte_color.blue,image->matte_color.opacity);
5005 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5008 if (LocaleCompare(attribute,"matte") == 0)
5010 if (image != (Image *) NULL)
5011 s=newSViv((ssize_t) image->matte);
5012 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5015 if (LocaleCompare(attribute,"mime") == 0)
5021 if (info && *info->image_info->magick)
5022 magick=info->image_info->magick;
5023 if (image != (Image *) NULL)
5024 magick=image->magick;
5030 mime=MagickToMime(magick);
5032 mime=(char *) RelinquishMagickMemory(mime);
5034 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5037 if (LocaleCompare(attribute,"monochrome") == 0)
5039 if (image == (Image *) NULL)
5041 j=info ? info->image_info->monochrome :
5042 IsMonochromeImage(image,&image->exception);
5044 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5047 if (LocaleCompare(attribute,"montage") == 0)
5049 if (image && image->montage)
5050 s=newSVpv(image->montage,0);
5051 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5054 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5061 if (LocaleCompare(attribute,"orientation") == 0)
5063 j=info ? info->image_info->orientation : image ?
5064 image->orientation : UndefinedOrientation;
5066 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5069 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5072 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5079 if (LocaleCompare(attribute,"page") == 0)
5081 if (info && info->image_info->page)
5082 s=newSVpv(info->image_info->page,0);
5083 if (image != (Image *) NULL)
5086 geometry[MaxTextExtent];
5088 (void) FormatLocaleString(geometry,MaxTextExtent,
5089 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5090 (double) image->page.height,(double) image->page.x,(double)
5092 s=newSVpv(geometry,0);
5094 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5097 if (LocaleCompare(attribute,"page.x") == 0)
5099 if (image != (Image *) NULL)
5100 s=newSViv((ssize_t) image->page.x);
5101 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5104 if (LocaleCompare(attribute,"page.y") == 0)
5106 if (image != (Image *) NULL)
5107 s=newSViv((ssize_t) image->page.y);
5108 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5111 if (LocaleNCompare(attribute,"pixel",5) == 0)
5114 tuple[MaxTextExtent];
5123 register const PixelPacket
5126 register const IndexPacket
5129 if (image == (Image *) NULL)
5133 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5135 p=GetVirtualPixels(image,x,y,1,1,exception);
5136 indexes=GetVirtualIndexQueue(image);
5137 if (image->colorspace != CMYKColorspace)
5138 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5139 QuantumFormat "," QuantumFormat "," QuantumFormat,
5140 GetRedPixelComponent(p),GetGreenPixelComponent(p),
5141 GetBluePixelComponent(p),GetOpacityPixelComponent(p));
5143 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5144 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5145 QuantumFormat,GetRedPixelComponent(p),
5146 GetGreenPixelComponent(p),GetBluePixelComponent(p),
5147 GetIndexPixelComponent(indexes),GetOpacityPixelComponent(p));
5149 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5152 if (LocaleCompare(attribute,"pointsize") == 0)
5155 s=newSViv((ssize_t) info->image_info->pointsize);
5156 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5159 if (LocaleCompare(attribute,"preview") == 0)
5161 s=newSViv(info->image_info->preview_type);
5162 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5163 info->image_info->preview_type));
5165 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5168 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5175 if (LocaleCompare(attribute,"quality") == 0)
5178 s=newSViv((ssize_t) info->image_info->quality);
5179 if (image != (Image *) NULL)
5180 s=newSViv((ssize_t) image->quality);
5181 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5184 if (LocaleCompare(attribute,"quantum") == 0)
5187 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5188 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5191 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5198 if (LocaleCompare(attribute,"rendering-intent") == 0)
5200 s=newSViv(image->rendering_intent);
5201 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5202 image->rendering_intent));
5204 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5207 if (LocaleCompare(attribute,"red-primary") == 0)
5209 if (image == (Image *) NULL)
5211 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5212 image->chromaticity.red_primary.x,
5213 image->chromaticity.red_primary.y);
5215 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5218 if (LocaleCompare(attribute,"rows") == 0)
5220 if (image != (Image *) NULL)
5221 s=newSViv((ssize_t) image->rows);
5222 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5225 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5232 if (LocaleCompare(attribute,"sampling-factor") == 0)
5234 if (info && info->image_info->sampling_factor)
5235 s=newSVpv(info->image_info->sampling_factor,0);
5236 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5239 if (LocaleCompare(attribute,"subimage") == 0)
5242 s=newSViv((ssize_t) info->image_info->subimage);
5243 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5246 if (LocaleCompare(attribute,"subrange") == 0)
5249 s=newSViv((ssize_t) info->image_info->subrange);
5250 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5253 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5255 if (info && info->image_info->server_name)
5256 s=newSVpv(info->image_info->server_name,0);
5257 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5260 if (LocaleCompare(attribute,"size") == 0)
5262 if (info && info->image_info->size)
5263 s=newSVpv(info->image_info->size,0);
5264 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5267 if (LocaleCompare(attribute,"scene") == 0)
5269 if (image != (Image *) NULL)
5270 s=newSViv((ssize_t) image->scene);
5271 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5274 if (LocaleCompare(attribute,"scenes") == 0)
5276 if (image != (Image *) NULL)
5277 s=newSViv((ssize_t) info->image_info->number_scenes);
5278 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5281 if (LocaleCompare(attribute,"signature") == 0)
5286 if (image == (Image *) NULL)
5288 (void) SignatureImage(image);
5289 value=GetImageProperty(image,"Signature");
5290 if (value != (const char *) NULL)
5292 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5302 if (LocaleCompare(attribute,"taint") == 0)
5304 if (image != (Image *) NULL)
5305 s=newSViv((ssize_t) IsTaintImage(image));
5306 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5309 if (LocaleCompare(attribute,"tile") == 0)
5311 if (info && info->image_info->tile)
5312 s=newSVpv(info->image_info->tile,0);
5313 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5316 if (LocaleCompare(attribute,"texture") == 0)
5318 if (info && info->image_info->texture)
5319 s=newSVpv(info->image_info->texture,0);
5320 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5323 if (LocaleCompare(attribute,"total-ink-density") == 0)
5325 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5326 if (image != (Image *) NULL)
5327 s=newSVnv(GetImageTotalInkDensity(image));
5328 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5331 if (LocaleCompare(attribute,"transparent-color") == 0)
5333 if (image == (Image *) NULL)
5335 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5336 QuantumFormat "," QuantumFormat "," QuantumFormat,
5337 image->transparent_color.red,image->transparent_color.green,
5338 image->transparent_color.blue,image->transparent_color.opacity);
5340 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5343 if (LocaleCompare(attribute,"type") == 0)
5345 if (image == (Image *) NULL)
5347 j=(ssize_t) GetImageType(image,&image->exception);
5349 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5354 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5361 if (LocaleCompare(attribute,"units") == 0)
5363 j=info ? info->image_info->units : image ? image->units :
5364 UndefinedResolution;
5365 if (info && (info->image_info->units == UndefinedResolution))
5368 if (j == UndefinedResolution)
5369 s=newSVpv("undefined units",0);
5371 if (j == PixelsPerInchResolution)
5372 s=newSVpv("pixels / inch",0);
5374 s=newSVpv("pixels / centimeter",0);
5375 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5378 if (LocaleCompare(attribute,"user-time") == 0)
5380 if (image != (Image *) NULL)
5381 s=newSVnv(GetUserTime(&image->timer));
5382 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5392 if (LocaleCompare(attribute,"verbose") == 0)
5395 s=newSViv((ssize_t) info->image_info->verbose);
5396 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5399 if (LocaleCompare(attribute,"version") == 0)
5401 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5402 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5405 if (LocaleCompare(attribute,"view") == 0)
5407 if (info && info->image_info->view)
5408 s=newSVpv(info->image_info->view,0);
5409 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5412 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5414 if (image == (Image *) NULL)
5416 j=(ssize_t) GetImageVirtualPixelMethod(image);
5418 (void) sv_setpv(s,CommandOptionToMnemonic(
5419 MagickVirtualPixelOptions,j));
5421 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5424 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5431 if (LocaleCompare(attribute,"white-point") == 0)
5433 if (image == (Image *) NULL)
5435 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5436 image->chromaticity.white_point.x,
5437 image->chromaticity.white_point.y);
5439 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5442 if (LocaleCompare(attribute,"width") == 0)
5444 if (image != (Image *) NULL)
5445 s=newSViv((ssize_t) image->columns);
5446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5449 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5456 if (LocaleCompare(attribute,"x-resolution") == 0)
5458 if (image != (Image *) NULL)
5459 s=newSVnv(image->x_resolution);
5460 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5463 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5470 if (LocaleCompare(attribute,"y-resolution") == 0)
5472 if (image != (Image *) NULL)
5473 s=newSVnv(image->y_resolution);
5474 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5484 if (image == (Image *) NULL)
5485 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5489 value=GetImageProperty(image,attribute);
5490 if (value != (const char *) NULL)
5493 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5496 if (*attribute != '%')
5497 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5504 meta=InterpretImageProperties(info ? info->image_info :
5505 (ImageInfo *) NULL,image,attribute);
5507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5508 meta=(char *) RelinquishMagickMemory(meta);
5512 exception=DestroyExceptionInfo(exception);
5513 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5517 ###############################################################################
5521 # G e t A u t h e n t i c P i x e l s #
5525 ###############################################################################
5529 GetAuthenticPixels(ref,...)
5530 Image::Magick ref = NO_INIT
5532 getauthenticpixels = 1
5562 PERL_UNUSED_VAR(ref);
5563 PERL_UNUSED_VAR(ix);
5564 exception=AcquireExceptionInfo();
5565 perl_exception=newSVpv("",0);
5566 if (sv_isobject(ST(0)) == 0)
5568 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5572 reference=SvRV(ST(0));
5574 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5575 if (image == (Image *) NULL)
5577 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5584 region.width=image->columns;
5587 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5588 for (i=2; i < items; i+=2)
5590 attribute=(char *) SvPV(ST(i-1),na);
5596 if (LocaleCompare(attribute,"geometry") == 0)
5598 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5608 if (LocaleCompare(attribute,"height") == 0)
5610 region.height=SvIV(ST(i));
5613 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5620 if (LocaleCompare(attribute,"x") == 0)
5622 region.x=SvIV(ST(i));
5625 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5632 if (LocaleCompare(attribute,"y") == 0)
5634 region.y=SvIV(ST(i));
5637 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5644 if (LocaleCompare(attribute,"width") == 0)
5646 region.width=SvIV(ST(i));
5649 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5655 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5656 region.height,exception);
5657 if (blob != (void *) NULL)
5661 InheritPerlException(exception,perl_exception);
5662 exception=DestroyExceptionInfo(exception);
5663 SvREFCNT_dec(perl_exception); /* throw away all errors */
5672 ###############################################################################
5676 # G e t V i r t u a l P i x e l s #
5680 ###############################################################################
5684 GetVirtualPixels(ref,...)
5685 Image::Magick ref = NO_INIT
5687 getvirtualpixels = 1
5688 AcquireImagePixels = 2
5689 acquireimagepixels = 3
5717 PERL_UNUSED_VAR(ref);
5718 PERL_UNUSED_VAR(ix);
5719 exception=AcquireExceptionInfo();
5720 perl_exception=newSVpv("",0);
5721 if (sv_isobject(ST(0)) == 0)
5723 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5727 reference=SvRV(ST(0));
5729 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5730 if (image == (Image *) NULL)
5732 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5739 region.width=image->columns;
5742 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5743 for (i=2; i < items; i+=2)
5745 attribute=(char *) SvPV(ST(i-1),na);
5751 if (LocaleCompare(attribute,"geometry") == 0)
5753 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5763 if (LocaleCompare(attribute,"height") == 0)
5765 region.height=SvIV(ST(i));
5768 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5775 if (LocaleCompare(attribute,"x") == 0)
5777 region.x=SvIV(ST(i));
5780 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5787 if (LocaleCompare(attribute,"y") == 0)
5789 region.y=SvIV(ST(i));
5792 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5799 if (LocaleCompare(attribute,"width") == 0)
5801 region.width=SvIV(ST(i));
5804 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5810 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5811 region.height,exception);
5812 if (blob != (void *) NULL)
5816 InheritPerlException(exception,perl_exception);
5817 exception=DestroyExceptionInfo(exception);
5818 SvREFCNT_dec(perl_exception); /* throw away all errors */
5821 RETVAL = (void *) blob;
5827 ###############################################################################
5831 # G e t A u t h e n t i c I n d e x Q u e u e #
5835 ###############################################################################
5839 GetAuthenticIndexQueue(ref,...)
5840 Image::Magick ref = NO_INIT
5842 getauthenticindexqueue = 1
5863 PERL_UNUSED_VAR(ref);
5864 PERL_UNUSED_VAR(ix);
5865 exception=AcquireExceptionInfo();
5866 perl_exception=newSVpv("",0);
5867 if (sv_isobject(ST(0)) == 0)
5869 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5873 reference=SvRV(ST(0));
5875 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5876 if (image == (Image *) NULL)
5878 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5883 blob=(void *) GetAuthenticIndexQueue(image);
5884 if (blob != (void *) NULL)
5888 InheritPerlException(exception,perl_exception);
5889 exception=DestroyExceptionInfo(exception);
5890 SvREFCNT_dec(perl_exception); /* throw away all errors */
5899 ###############################################################################
5903 # G e t V i r t u a l I n d e x Q u e u e #
5907 ###############################################################################
5911 GetVirtualIndexQueue(ref,...)
5912 Image::Magick ref = NO_INIT
5914 getvirtualindexqueue = 1
5933 PERL_UNUSED_VAR(ref);
5934 PERL_UNUSED_VAR(ix);
5935 exception=AcquireExceptionInfo();
5936 perl_exception=newSVpv("",0);
5937 if (sv_isobject(ST(0)) == 0)
5939 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5943 reference=SvRV(ST(0));
5945 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5946 if (image == (Image *) NULL)
5948 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5953 blob=(void *) GetVirtualIndexQueue(image);
5954 if (blob != (void *) NULL)
5958 InheritPerlException(exception,perl_exception);
5959 exception=DestroyExceptionInfo(exception);
5960 SvREFCNT_dec(perl_exception); /* throw away all errors */
5969 ###############################################################################
5973 # H i s t o g r a m #
5977 ###############################################################################
5982 Image::Magick ref=NO_INIT
5993 message[MaxTextExtent];
6020 PERL_UNUSED_VAR(ref);
6021 PERL_UNUSED_VAR(ix);
6022 exception=AcquireExceptionInfo();
6023 perl_exception=newSVpv("",0);
6025 if (sv_isobject(ST(0)) == 0)
6027 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6031 reference=SvRV(ST(0));
6034 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6035 if (image == (Image *) NULL)
6037 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6041 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6043 for ( ; image; image=image->next)
6045 histogram=GetImageHistogram(image,&number_colors,&image->exception);
6046 if (histogram == (ColorPacket *) NULL)
6048 count+=(ssize_t) number_colors;
6050 for (i=0; i < (ssize_t) number_colors; i++)
6052 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6053 histogram[i].pixel.red);
6054 PUSHs(sv_2mortal(newSVpv(message,0)));
6055 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6056 histogram[i].pixel.green);
6057 PUSHs(sv_2mortal(newSVpv(message,0)));
6058 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6059 histogram[i].pixel.blue);
6060 PUSHs(sv_2mortal(newSVpv(message,0)));
6061 if (image->colorspace == CMYKColorspace)
6063 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6064 histogram[i].index);
6065 PUSHs(sv_2mortal(newSVpv(message,0)));
6067 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6068 histogram[i].pixel.opacity);
6069 PUSHs(sv_2mortal(newSVpv(message,0)));
6070 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6071 histogram[i].count);
6072 PUSHs(sv_2mortal(newSVpv(message,0)));
6074 histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
6078 InheritPerlException(exception,perl_exception);
6079 exception=DestroyExceptionInfo(exception);
6080 SvREFCNT_dec(perl_exception);
6084 ###############################################################################
6092 ###############################################################################
6097 Image::Magick ref=NO_INIT
6124 register const IndexPacket
6127 register const PixelPacket
6141 *reference; /* reference is the SV* of ref=SvIV(reference) */
6143 PERL_UNUSED_VAR(ref);
6144 PERL_UNUSED_VAR(ix);
6145 exception=AcquireExceptionInfo();
6146 perl_exception=newSVpv("",0);
6147 reference=SvRV(ST(0));
6148 av=(AV *) reference;
6149 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6151 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6152 if (image == (Image *) NULL)
6154 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6158 channel=DefaultChannels;
6159 normalize=MagickTrue;
6162 region.width=image->columns;
6165 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6166 for (i=2; i < items; i+=2)
6168 attribute=(char *) SvPV(ST(i-1),na);
6174 if (LocaleCompare(attribute,"channel") == 0)
6179 option=ParseChannelOption(SvPV(ST(i),na));
6182 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6186 channel=(ChannelType) option;
6189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6196 if (LocaleCompare(attribute,"geometry") == 0)
6198 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6208 if (LocaleCompare(attribute,"normalize") == 0)
6210 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6214 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6218 normalize=option != 0 ? MagickTrue : MagickFalse;
6221 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6228 if (LocaleCompare(attribute,"x") == 0)
6230 region.x=SvIV(ST(i));
6233 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6240 if (LocaleCompare(attribute,"y") == 0)
6242 region.y=SvIV(ST(i));
6245 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6251 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6257 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6258 if (p == (const PixelPacket *) NULL)
6265 indexes=GetVirtualIndexQueue(image);
6267 if (normalize != MagickFalse)
6268 scale=1.0/QuantumRange;
6269 if ((channel & RedChannel) != 0)
6270 PUSHs(sv_2mortal(newSVnv(scale*GetRedPixelComponent(p))));
6271 if ((channel & GreenChannel) != 0)
6272 PUSHs(sv_2mortal(newSVnv(scale*GetGreenPixelComponent(p))));
6273 if ((channel & BlueChannel) != 0)
6274 PUSHs(sv_2mortal(newSVnv(scale*GetBluePixelComponent(p))));
6275 if (((channel & IndexChannel) != 0) &&
6276 (image->colorspace == CMYKColorspace))
6277 PUSHs(sv_2mortal(newSVnv(scale*GetIndexPixelComponent(indexes))));
6278 if ((channel & OpacityChannel) != 0)
6279 PUSHs(sv_2mortal(newSVnv(scale*GetOpacityPixelComponent(p))));
6283 InheritPerlException(exception,perl_exception);
6284 exception=DestroyExceptionInfo(exception);
6285 SvREFCNT_dec(perl_exception);
6289 ###############################################################################
6293 # G e t P i x e l s #
6297 ###############################################################################
6302 Image::Magick ref=NO_INIT
6341 *reference; /* reference is the SV* of ref=SvIV(reference) */
6343 PERL_UNUSED_VAR(ref);
6344 PERL_UNUSED_VAR(ix);
6345 exception=AcquireExceptionInfo();
6346 perl_exception=newSVpv("",0);
6347 reference=SvRV(ST(0));
6348 av=(AV *) reference;
6349 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6351 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6352 if (image == (Image *) NULL)
6354 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6359 if (image->matte != MagickFalse)
6361 if (image->colorspace == CMYKColorspace)
6364 if (image->matte != MagickFalse)
6367 normalize=MagickFalse;
6370 region.width=image->columns;
6373 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6374 for (i=2; i < items; i+=2)
6376 attribute=(char *) SvPV(ST(i-1),na);
6382 if (LocaleCompare(attribute,"geometry") == 0)
6384 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6387 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6394 if (LocaleCompare(attribute,"height") == 0)
6396 region.height=SvIV(ST(i));
6399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6406 if (LocaleCompare(attribute,"map") == 0)
6411 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6418 if (LocaleCompare(attribute,"normalize") == 0)
6420 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6424 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6428 normalize=option != 0 ? MagickTrue : MagickFalse;
6431 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6438 if (LocaleCompare(attribute,"width") == 0)
6440 region.width=SvIV(ST(i));
6443 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6450 if (LocaleCompare(attribute,"x") == 0)
6452 region.x=SvIV(ST(i));
6455 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6462 if (LocaleCompare(attribute,"y") == 0)
6464 region.y=SvIV(ST(i));
6467 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6473 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6479 if (normalize != MagickFalse)
6484 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6485 region.height*sizeof(*pixels));
6486 if (pixels == (float *) NULL)
6488 ThrowPerlException(exception,ResourceLimitError,
6489 "MemoryAllocationFailed",PackageName);
6492 status=ExportImagePixels(image,region.x,region.y,region.width,
6493 region.height,map,FloatPixel,pixels,exception);
6494 if (status == MagickFalse)
6498 EXTEND(sp,strlen(map)*region.width*region.height);
6499 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6500 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6502 pixels=(float *) RelinquishMagickMemory(pixels);
6509 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6510 region.height*sizeof(*pixels));
6511 if (pixels == (Quantum *) NULL)
6513 ThrowPerlException(exception,ResourceLimitError,
6514 "MemoryAllocationFailed",PackageName);
6517 status=ExportImagePixels(image,region.x,region.y,region.width,
6518 region.height,map,QuantumPixel,pixels,exception);
6519 if (status == MagickFalse)
6523 EXTEND(sp,strlen(map)*region.width*region.height);
6524 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6525 PUSHs(sv_2mortal(newSViv(pixels[i])));
6527 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6531 InheritPerlException(exception,perl_exception);
6532 exception=DestroyExceptionInfo(exception);
6533 SvREFCNT_dec(perl_exception);
6537 ###############################################################################
6541 # I m a g e T o B l o b #
6545 ###############################################################################
6549 ImageToBlob(ref,...)
6550 Image::Magick ref=NO_INIT
6559 filename[MaxTextExtent];
6588 PERL_UNUSED_VAR(ref);
6589 PERL_UNUSED_VAR(ix);
6590 exception=AcquireExceptionInfo();
6591 perl_exception=newSVpv("",0);
6592 package_info=(struct PackageInfo *) NULL;
6593 if (sv_isobject(ST(0)) == 0)
6595 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6599 reference=SvRV(ST(0));
6600 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6601 if (image == (Image *) NULL)
6603 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6607 package_info=ClonePackageInfo(info,exception);
6608 for (i=2; i < items; i+=2)
6609 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6610 (void) CopyMagickString(filename,package_info->image_info->filename,
6613 for (next=image; next; next=next->next)
6615 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6616 next->scene=scene++;
6618 SetImageInfo(package_info->image_info,(unsigned int)
6619 GetImageListLength(image),&image->exception);
6620 EXTEND(sp,(ssize_t) GetImageListLength(image));
6621 for ( ; image; image=image->next)
6624 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6625 if (blob != (char *) NULL)
6627 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6628 blob=(unsigned char *) RelinquishMagickMemory(blob);
6630 if (package_info->image_info->adjoin)
6635 if (package_info != (struct PackageInfo *) NULL)
6636 DestroyPackageInfo(package_info);
6637 InheritPerlException(exception,perl_exception);
6638 exception=DestroyExceptionInfo(exception);
6639 SvREFCNT_dec(perl_exception); /* throw away all errors */
6643 ###############################################################################
6651 ###############################################################################
6656 Image::Magick ref=NO_INIT
6660 OptimizeImageLayers = 3
6662 optimizeimagelayers = 5
6704 PERL_UNUSED_VAR(ref);
6705 PERL_UNUSED_VAR(ix);
6706 exception=AcquireExceptionInfo();
6707 perl_exception=newSVpv("",0);
6709 if (sv_isobject(ST(0)) == 0)
6711 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6715 reference=SvRV(ST(0));
6716 hv=SvSTASH(reference);
6718 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6720 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6721 if (image == (Image *) NULL)
6723 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6727 compose=image->compose;
6728 method=OptimizeLayer;
6729 for (i=2; i < items; i+=2)
6731 attribute=(char *) SvPV(ST(i-1),na);
6737 if (LocaleCompare(attribute,"compose") == 0)
6739 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6740 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6743 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6747 compose=(CompositeOperator) sp;
6750 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6757 if (LocaleCompare(attribute,"method") == 0)
6759 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6763 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6767 method=(ImageLayerMethod) option;
6770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6782 layers=(Image *) NULL;
6785 case CompareAnyLayer:
6786 case CompareClearLayer:
6787 case CompareOverlayLayer:
6790 layers=CompareImageLayers(image,method,exception);
6797 layers=MergeImageLayers(image,method,exception);
6802 layers=DisposeImages(image,exception);
6805 case OptimizeImageLayer:
6807 layers=OptimizeImageLayers(image,exception);
6810 case OptimizePlusLayer:
6812 layers=OptimizePlusImageLayers(image,exception);
6815 case OptimizeTransLayer:
6817 OptimizeImageTransparency(image,exception);
6818 InheritException(&(image->exception),exception);
6821 case RemoveDupsLayer:
6823 RemoveDuplicateLayers(&image,exception);
6824 InheritException(&(image->exception),exception);
6827 case RemoveZeroLayer:
6829 RemoveZeroDelayLayers(&image,exception);
6830 InheritException(&(image->exception),exception);
6839 General Purpose, GIF Animation Optimizer.
6841 layers=CoalesceImages(image,exception);
6842 if (layers == (Image *) NULL)
6844 InheritException(&(layers->exception),exception);
6846 layers=OptimizeImageLayers(image,exception);
6847 if (layers == (Image *) NULL)
6849 InheritException(&(layers->exception),exception);
6850 image=DestroyImageList(image);
6852 layers=(Image *) NULL;
6853 OptimizeImageTransparency(image,exception);
6854 InheritException(&(image->exception),exception);
6855 quantize_info=AcquireQuantizeInfo(info->image_info);
6856 (void) RemapImages(quantize_info,image,(Image *) NULL);
6857 quantize_info=DestroyQuantizeInfo(quantize_info);
6860 case CompositeLayer:
6869 Split image sequence at the first 'NULL:' image.
6872 while (source != (Image *) NULL)
6874 source=GetNextImageInList(source);
6875 if ((source != (Image *) NULL) &&
6876 (LocaleCompare(source->magick,"NULL") == 0))
6879 if (source != (Image *) NULL)
6881 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6882 (GetNextImageInList(source) == (Image *) NULL))
6883 source=(Image *) NULL;
6887 Separate the two lists, junk the null: image.
6889 source=SplitImageList(source->previous);
6890 DeleteImageFromList(&source);
6893 if (source == (Image *) NULL)
6895 (void) ThrowMagickException(exception,GetMagickModule(),
6896 OptionError,"MissingNullSeparator","layers Composite");
6900 Adjust offset with gravity and virtual canvas.
6902 SetGeometry(image,&geometry);
6903 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6904 geometry.width=source->page.width != 0 ? source->page.width :
6906 geometry.height=source->page.height != 0 ? source->page.height :
6908 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6909 image->columns,image->page.height != 0 ? image->page.height :
6910 image->rows,image->gravity,&geometry);
6911 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6912 source=DestroyImageList(source);
6913 InheritException(&(image->exception),exception);
6917 if (layers != (Image *) NULL)
6919 InheritException(&(layers->exception),exception);
6922 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6924 for ( ; image; image=image->next)
6926 AddImageToRegistry(sv,image);
6928 av_push(av,sv_bless(rv,hv));
6931 exception=DestroyExceptionInfo(exception);
6933 SvREFCNT_dec(perl_exception);
6937 InheritPerlException(exception,perl_exception);
6938 exception=DestroyExceptionInfo(exception);
6939 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6940 SvPOK_on(perl_exception);
6941 ST(0)=sv_2mortal(perl_exception);
6946 ###############################################################################
6950 # M a g i c k T o M i m e #
6954 ###############################################################################
6958 MagickToMime(ref,name)
6959 Image::Magick ref=NO_INIT
6968 PERL_UNUSED_VAR(ref);
6969 PERL_UNUSED_VAR(ix);
6970 mime=MagickToMime(name);
6971 RETVAL=newSVpv(mime,0);
6972 mime=(char *) RelinquishMagickMemory(mime);
6978 ###############################################################################
6986 ###############################################################################
6991 Image::Magick ref=NO_INIT
7028 MedianFilterImage = 36
7034 ReduceNoiseImage = 42
7060 ColorFloodfillImage= 68
7066 CycleColormapImage = 74
7076 MatteFloodfillImage= 84
7084 NumberColorsImage = 92
7094 SignatureImage = 102
7104 TransparentImage = 112
7106 ThresholdImage = 114
7120 DeconstructImage = 130
7122 GaussianBlurImage = 132
7128 UnsharpMaskImage = 138
7130 MotionBlurImage = 140
7132 OrderedDitherImage = 142
7139 AffineTransform = 149
7140 AffineTransformImage = 150
7142 DifferenceImage = 152
7143 AdaptiveThreshold = 153
7144 AdaptiveThresholdImage = 154
7149 BlackThreshold = 159
7150 BlackThresholdImage= 160
7151 WhiteThreshold = 161
7152 WhiteThresholdImage= 162
7154 RadialBlurImage = 164
7156 ThumbnailImage = 166
7166 PosterizeImage = 176
7172 SepiaToneImage = 182
7173 SigmoidalContrast = 183
7174 SigmoidalContrastImage = 184
7179 ContrastStretch = 189
7180 ContrastStretchImage = 190
7185 AdaptiveSharpen = 195
7186 AdaptiveSharpenImage = 196
7188 TransposeImage = 198
7190 TransverseImage = 200
7192 AutoOrientImage = 202
7194 AdaptiveBlurImage = 204
7198 UniqueColorsImage = 208
7199 AdaptiveResize = 209
7200 AdaptiveResizeImage= 210
7204 LinearStretchImage = 214
7211 FloodfillPaint = 221
7212 FloodfillPaintImage= 222
7218 LiquidRescaleImage = 228
7228 SparseColorImage = 238
7232 SelectiveBlurImage = 242
7236 BlueShiftImage = 246
7237 ForwardFourierTransform = 247
7238 ForwardFourierTransformImage = 248
7239 InverseFourierTransform = 249
7240 InverseFourierTransformImage = 250
7241 ColorDecisionList = 251
7242 ColorDecisionListImage = 252
7244 AutoGammaImage = 254
7246 AutoLevelImage = 256
7248 LevelColorsImage = 258
7253 BrightnessContrast = 263
7254 BrightnessContrastImage = 264
7256 MorphologyImage = 266
7258 ColorMatrixImage = 268
7264 StatisticImage = 274
7273 attribute_flag[MaxArguments],
7274 message[MaxTextExtent];
7334 argument_list[MaxArguments];
7336 PERL_UNUSED_VAR(ref);
7337 PERL_UNUSED_VAR(ix);
7338 exception=AcquireExceptionInfo();
7339 perl_exception=newSVpv("",0);
7340 reference_vector=NULL;
7344 if (sv_isobject(ST(0)) == 0)
7346 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7350 reference=SvRV(ST(0));
7351 region_info.width=0;
7352 region_info.height=0;
7355 region_image=(Image *) NULL;
7356 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7357 if (ix && (ix != 666))
7360 Called as Method(...)
7363 rp=(&Methods[ix-1]);
7369 Called as Mogrify("Method",...)
7371 attribute=(char *) SvPV(ST(1),na);
7374 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7375 attribute=(char *) SvPV(ST(2),na);
7378 for (rp=Methods; ; rp++)
7380 if (rp >= EndOf(Methods))
7382 ThrowPerlException(exception,OptionError,
7383 "UnrecognizedPerlMagickMethod",attribute);
7386 if (strEQcase(attribute,rp->name))
7392 if (image == (Image *) NULL)
7394 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7397 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7398 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7399 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7416 pp=(Arguments *) NULL;
7424 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7426 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7428 if (strEQcase(attribute,qq->method) > ssize_test)
7431 ssize_test=strEQcase(attribute,qq->method);
7434 if (pp == (Arguments *) NULL)
7436 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7438 goto continue_outer_loop;
7440 al=(&argument_list[pp-rp->arguments]);
7443 case ArrayReference:
7445 if (SvTYPE(sv) != SVt_RV)
7447 (void) FormatLocaleString(message,MaxTextExtent,
7448 "invalid %.60s value",pp->method);
7449 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7450 goto continue_outer_loop;
7452 al->array_reference=SvRV(sv);
7457 al->real_reference=SvNV(sv);
7462 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7465 case ImageReference:
7467 if (!sv_isobject(sv) ||
7468 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7469 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7471 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7477 case IntegerReference:
7479 al->integer_reference=SvIV(sv);
7482 case StringReference:
7484 al->string_reference=(char *) SvPV(sv,al->length);
7485 if (sv_isobject(sv))
7486 al->image_reference=SetupList(aTHX_ SvRV(sv),
7487 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7493 Is a string; look up name.
7495 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7497 al->string_reference=(char *) SvPV(sv,al->length);
7498 al->integer_reference=(-1);
7501 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7502 MagickFalse,SvPV(sv,na));
7503 if (pp->type == MagickChannelOptions)
7504 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7505 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7507 (void) FormatLocaleString(message,MaxTextExtent,
7508 "invalid %.60s value",pp->method);
7509 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7510 goto continue_outer_loop;
7515 attribute_flag[pp-rp->arguments]++;
7516 continue_outer_loop: ;
7518 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7519 pv=reference_vector;
7520 SetGeometryInfo(&geometry_info);
7521 channel=DefaultChannels;
7522 for (next=image; next; next=next->next)
7525 SetGeometry(image,&geometry);
7526 if ((region_info.width*region_info.height) != 0)
7529 image=CropImage(image,®ion_info,exception);
7535 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7536 ThrowPerlException(exception,OptionError,
7537 "UnrecognizedPerlMagickMethod",message);
7540 case 1: /* Comment */
7542 if (attribute_flag[0] == 0)
7543 argument_list[0].string_reference=(char *) NULL;
7544 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7545 info ? info->image_info : (ImageInfo *) NULL,image,
7546 argument_list[0].string_reference));
7551 if (attribute_flag[0] == 0)
7552 argument_list[0].string_reference=(char *) NULL;
7553 (void) SetImageProperty(image,"label",InterpretImageProperties(
7554 info ? info->image_info : (ImageInfo *) NULL,image,
7555 argument_list[0].string_reference));
7558 case 3: /* AddNoise */
7560 if (attribute_flag[0] == 0)
7561 argument_list[0].integer_reference=UniformNoise;
7562 if (attribute_flag[1] != 0)
7563 channel=(ChannelType) argument_list[1].integer_reference;
7564 image=AddNoiseImageChannel(image,channel,(NoiseType)
7565 argument_list[0].integer_reference,exception);
7568 case 4: /* Colorize */
7573 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7574 if (attribute_flag[0] != 0)
7575 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7577 if (attribute_flag[1] == 0)
7578 argument_list[1].string_reference="100%";
7579 image=ColorizeImage(image,argument_list[1].string_reference,target,
7583 case 5: /* Border */
7587 if (attribute_flag[0] != 0)
7589 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7590 &geometry,exception);
7591 if ((flags & HeightValue) == 0)
7592 geometry.height=geometry.width;
7594 if (attribute_flag[1] != 0)
7595 geometry.width=argument_list[1].integer_reference;
7596 if (attribute_flag[2] != 0)
7597 geometry.height=argument_list[2].integer_reference;
7598 if (attribute_flag[3] != 0)
7599 QueryColorDatabase(argument_list[3].string_reference,
7600 &image->border_color,exception);
7601 if (attribute_flag[4] != 0)
7602 QueryColorDatabase(argument_list[4].string_reference,
7603 &image->border_color,exception);
7604 if (attribute_flag[5] != 0)
7605 QueryColorDatabase(argument_list[5].string_reference,
7606 &image->border_color,exception);
7607 if (attribute_flag[6] != 0)
7608 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7609 image=BorderImage(image,&geometry,exception);
7614 if (attribute_flag[0] != 0)
7616 flags=ParseGeometry(argument_list[0].string_reference,
7618 if ((flags & SigmaValue) == 0)
7619 geometry_info.sigma=1.0;
7621 if (attribute_flag[1] != 0)
7622 geometry_info.rho=argument_list[1].real_reference;
7623 if (attribute_flag[2] != 0)
7624 geometry_info.sigma=argument_list[2].real_reference;
7625 if (attribute_flag[3] != 0)
7626 channel=(ChannelType) argument_list[3].integer_reference;
7627 image=BlurImageChannel(image,channel,geometry_info.rho,
7628 geometry_info.sigma,exception);
7633 if (attribute_flag[0] != 0)
7634 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7635 &geometry,exception);
7636 if (attribute_flag[1] != 0)
7637 geometry.width=argument_list[1].integer_reference;
7638 if (attribute_flag[2] != 0)
7639 geometry.height=argument_list[2].integer_reference;
7640 if (attribute_flag[3] != 0)
7641 geometry.x=argument_list[3].integer_reference;
7642 if (attribute_flag[4] != 0)
7643 geometry.y=argument_list[4].integer_reference;
7644 image=ChopImage(image,&geometry,exception);
7649 if (attribute_flag[6] != 0)
7650 image->gravity=(GravityType) argument_list[6].integer_reference;
7651 if (attribute_flag[0] != 0)
7652 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7653 &geometry,exception);
7654 if (attribute_flag[1] != 0)
7655 geometry.width=argument_list[1].integer_reference;
7656 if (attribute_flag[2] != 0)
7657 geometry.height=argument_list[2].integer_reference;
7658 if (attribute_flag[3] != 0)
7659 geometry.x=argument_list[3].integer_reference;
7660 if (attribute_flag[4] != 0)
7661 geometry.y=argument_list[4].integer_reference;
7662 if (attribute_flag[5] != 0)
7664 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7665 image=CropImage(image,&geometry,exception);
7668 case 9: /* Despeckle */
7670 image=DespeckleImage(image,exception);
7675 if (attribute_flag[0] != 0)
7676 geometry_info.rho=argument_list[0].real_reference;
7677 image=EdgeImage(image,geometry_info.rho,exception);
7680 case 11: /* Emboss */
7682 if (attribute_flag[0] != 0)
7684 flags=ParseGeometry(argument_list[0].string_reference,
7686 if ((flags & SigmaValue) == 0)
7687 geometry_info.sigma=1.0;
7689 if (attribute_flag[1] != 0)
7690 geometry_info.rho=argument_list[1].real_reference;
7691 if (attribute_flag[2] != 0)
7692 geometry_info.sigma=argument_list[2].real_reference;
7693 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7697 case 12: /* Enhance */
7699 image=EnhanceImage(image,exception);
7704 image=FlipImage(image,exception);
7709 image=FlopImage(image,exception);
7712 case 15: /* Frame */
7717 if (attribute_flag[0] != 0)
7719 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7720 &geometry,exception);
7721 if ((flags & HeightValue) == 0)
7722 geometry.height=geometry.width;
7723 frame_info.width=geometry.width;
7724 frame_info.height=geometry.height;
7725 frame_info.outer_bevel=geometry.x;
7726 frame_info.inner_bevel=geometry.y;
7728 if (attribute_flag[1] != 0)
7729 frame_info.width=argument_list[1].integer_reference;
7730 if (attribute_flag[2] != 0)
7731 frame_info.height=argument_list[2].integer_reference;
7732 if (attribute_flag[3] != 0)
7733 frame_info.inner_bevel=argument_list[3].integer_reference;
7734 if (attribute_flag[4] != 0)
7735 frame_info.outer_bevel=argument_list[4].integer_reference;
7736 if (attribute_flag[5] != 0)
7737 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7739 if (attribute_flag[6] != 0)
7740 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7742 frame_info.x=(ssize_t) frame_info.width;
7743 frame_info.y=(ssize_t) frame_info.height;
7744 frame_info.width=image->columns+2*frame_info.x;
7745 frame_info.height=image->rows+2*frame_info.y;
7746 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7747 image->matte_color=fill_color;
7748 if (attribute_flag[7] != 0)
7749 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7750 image=FrameImage(image,&frame_info,exception);
7753 case 16: /* Implode */
7755 if (attribute_flag[0] == 0)
7756 argument_list[0].real_reference=0.5;
7757 if (attribute_flag[1] != 0)
7758 image->interpolate=(InterpolatePixelMethod)
7759 argument_list[1].integer_reference;
7760 image=ImplodeImage(image,argument_list[0].real_reference,
7764 case 17: /* Magnify */
7766 image=MagnifyImage(image,exception);
7769 case 18: /* MedianFilter */
7771 if (attribute_flag[0] != 0)
7773 flags=ParseGeometry(argument_list[0].string_reference,
7775 if ((flags & SigmaValue) == 0)
7776 geometry_info.sigma=1.0;
7778 if (attribute_flag[1] != 0)
7779 geometry_info.rho=argument_list[1].real_reference;
7780 if (attribute_flag[2] != 0)
7781 geometry_info.sigma=argument_list[2].real_reference;
7782 if (attribute_flag[3] != 0)
7783 channel=(ChannelType) argument_list[3].integer_reference;
7784 image=StatisticImageChannel(image,channel,MedianStatistic,
7785 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7788 case 19: /* Minify */
7790 image=MinifyImage(image,exception);
7793 case 20: /* OilPaint */
7795 if (attribute_flag[0] == 0)
7796 argument_list[0].real_reference=0.0;
7797 image=OilPaintImage(image,argument_list[0].real_reference,
7801 case 21: /* ReduceNoise */
7803 if (attribute_flag[0] != 0)
7805 flags=ParseGeometry(argument_list[0].string_reference,
7807 if ((flags & SigmaValue) == 0)
7808 geometry_info.sigma=1.0;
7810 if (attribute_flag[1] != 0)
7811 geometry_info.rho=argument_list[1].real_reference;
7812 if (attribute_flag[2] != 0)
7813 geometry_info.sigma=argument_list[2].real_reference;
7814 if (attribute_flag[3] != 0)
7815 channel=(ChannelType) argument_list[3].integer_reference;
7816 image=StatisticImageChannel(image,channel,NonpeakStatistic,
7817 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7822 if (attribute_flag[0] != 0)
7823 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7824 &geometry,exception);
7825 if (attribute_flag[1] != 0)
7826 geometry.x=argument_list[1].integer_reference;
7827 if (attribute_flag[2] != 0)
7828 geometry.y=argument_list[2].integer_reference;
7829 image=RollImage(image,geometry.x,geometry.y,exception);
7832 case 23: /* Rotate */
7834 if (attribute_flag[0] == 0)
7835 argument_list[0].real_reference=90.0;
7836 if (attribute_flag[1] != 0)
7837 QueryColorDatabase(argument_list[1].string_reference,
7838 &image->background_color,exception);
7839 if (attribute_flag[2] != 0)
7840 QueryColorDatabase(argument_list[2].string_reference,
7841 &image->background_color,exception);
7842 if (attribute_flag[3] != 0)
7843 QueryColorDatabase(argument_list[3].string_reference,
7844 &image->background_color,exception);
7845 image=RotateImage(image,argument_list[0].real_reference,exception);
7848 case 24: /* Sample */
7850 if (attribute_flag[0] != 0)
7851 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7852 &geometry,exception);
7853 if (attribute_flag[1] != 0)
7854 geometry.width=argument_list[1].integer_reference;
7855 if (attribute_flag[2] != 0)
7856 geometry.height=argument_list[2].integer_reference;
7857 image=SampleImage(image,geometry.width,geometry.height,exception);
7860 case 25: /* Scale */
7862 if (attribute_flag[0] != 0)
7863 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7864 &geometry,exception);
7865 if (attribute_flag[1] != 0)
7866 geometry.width=argument_list[1].integer_reference;
7867 if (attribute_flag[2] != 0)
7868 geometry.height=argument_list[2].integer_reference;
7869 image=ScaleImage(image,geometry.width,geometry.height,exception);
7872 case 26: /* Shade */
7874 if (attribute_flag[0] != 0)
7876 flags=ParseGeometry(argument_list[0].string_reference,
7878 if ((flags & SigmaValue) == 0)
7879 geometry_info.sigma=0.0;
7881 if (attribute_flag[1] != 0)
7882 geometry_info.rho=argument_list[1].real_reference;
7883 if (attribute_flag[2] != 0)
7884 geometry_info.sigma=argument_list[2].real_reference;
7885 image=ShadeImage(image,
7886 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7887 geometry_info.rho,geometry_info.sigma,exception);
7890 case 27: /* Sharpen */
7892 if (attribute_flag[0] != 0)
7894 flags=ParseGeometry(argument_list[0].string_reference,
7896 if ((flags & SigmaValue) == 0)
7897 geometry_info.sigma=1.0;
7899 if (attribute_flag[1] != 0)
7900 geometry_info.rho=argument_list[1].real_reference;
7901 if (attribute_flag[2] != 0)
7902 geometry_info.sigma=argument_list[2].real_reference;
7903 if (attribute_flag[3] != 0)
7904 channel=(ChannelType) argument_list[3].integer_reference;
7905 image=SharpenImageChannel(image,channel,geometry_info.rho,
7906 geometry_info.sigma,exception);
7909 case 28: /* Shear */
7911 if (attribute_flag[0] != 0)
7913 flags=ParseGeometry(argument_list[0].string_reference,
7915 if ((flags & SigmaValue) == 0)
7916 geometry_info.sigma=geometry_info.rho;
7918 if (attribute_flag[1] != 0)
7919 geometry_info.rho=argument_list[1].real_reference;
7920 if (attribute_flag[2] != 0)
7921 geometry_info.sigma=argument_list[2].real_reference;
7922 if (attribute_flag[3] != 0)
7923 QueryColorDatabase(argument_list[3].string_reference,
7924 &image->background_color,exception);
7925 if (attribute_flag[4] != 0)
7926 QueryColorDatabase(argument_list[4].string_reference,
7927 &image->background_color,exception);
7928 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7932 case 29: /* Spread */
7934 if (attribute_flag[0] == 0)
7935 argument_list[0].real_reference=1.0;
7936 image=SpreadImage(image,argument_list[0].real_reference,exception);
7939 case 30: /* Swirl */
7941 if (attribute_flag[0] == 0)
7942 argument_list[0].real_reference=50.0;
7943 if (attribute_flag[1] != 0)
7944 image->interpolate=(InterpolatePixelMethod)
7945 argument_list[1].integer_reference;
7946 image=SwirlImage(image,argument_list[0].real_reference,exception);
7949 case 31: /* Resize */
7952 if (attribute_flag[0] != 0)
7953 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7954 &geometry,exception);
7955 if (attribute_flag[1] != 0)
7956 geometry.width=argument_list[1].integer_reference;
7957 if (attribute_flag[2] != 0)
7958 geometry.height=argument_list[2].integer_reference;
7959 if (attribute_flag[3] == 0)
7960 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7961 if (attribute_flag[4] != 0)
7962 SetImageArtifact(image,"filter:support",
7963 argument_list[4].string_reference);
7964 if (attribute_flag[5] == 0)
7965 argument_list[5].real_reference=1.0;
7966 image=ResizeImage(image,geometry.width,geometry.height,
7967 (FilterTypes) argument_list[3].integer_reference,
7968 argument_list[5].real_reference,exception);
7971 case 33: /* Annotate */
7976 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7978 if (attribute_flag[0] != 0)
7983 text=InterpretImageProperties(info ? info->image_info :
7984 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7985 (void) CloneString(&draw_info->text,text);
7986 text=DestroyString(text);
7988 if (attribute_flag[1] != 0)
7989 (void) CloneString(&draw_info->font,
7990 argument_list[1].string_reference);
7991 if (attribute_flag[2] != 0)
7992 draw_info->pointsize=argument_list[2].real_reference;
7993 if (attribute_flag[3] != 0)
7994 (void) CloneString(&draw_info->density,
7995 argument_list[3].string_reference);
7996 if (attribute_flag[4] != 0)
7997 (void) QueryColorDatabase(argument_list[4].string_reference,
7998 &draw_info->undercolor,exception);
7999 if (attribute_flag[5] != 0)
8001 (void) QueryColorDatabase(argument_list[5].string_reference,
8002 &draw_info->stroke,exception);
8003 if (argument_list[5].image_reference != (Image *) NULL)
8004 draw_info->stroke_pattern=CloneImage(
8005 argument_list[5].image_reference,0,0,MagickTrue,exception);
8007 if (attribute_flag[6] != 0)
8009 (void) QueryColorDatabase(argument_list[6].string_reference,
8010 &draw_info->fill,exception);
8011 if (argument_list[6].image_reference != (Image *) NULL)
8012 draw_info->fill_pattern=CloneImage(
8013 argument_list[6].image_reference,0,0,MagickTrue,exception);
8015 if (attribute_flag[7] != 0)
8017 (void) CloneString(&draw_info->geometry,
8018 argument_list[7].string_reference);
8019 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8020 &geometry,exception);
8021 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8022 geometry_info.sigma=geometry_info.xi;
8024 if (attribute_flag[8] != 0)
8025 (void) QueryColorDatabase(argument_list[8].string_reference,
8026 &draw_info->fill,exception);
8027 if (attribute_flag[11] != 0)
8028 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
8029 if (attribute_flag[25] != 0)
8034 av=(AV *) argument_list[25].array_reference;
8035 if ((av_len(av) != 3) && (av_len(av) != 5))
8037 ThrowPerlException(exception,OptionError,
8038 "affine matrix must have 4 or 6 elements",PackageName);
8041 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8042 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8043 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8044 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8045 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8046 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8048 ThrowPerlException(exception,OptionError,
8049 "affine matrix is singular",PackageName);
8052 if (av_len(av) == 5)
8054 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8055 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8058 for (j=12; j < 17; j++)
8060 if (attribute_flag[j] == 0)
8062 value=argument_list[j].string_reference;
8063 angle=argument_list[j].real_reference;
8064 current=draw_info->affine;
8065 GetAffineMatrix(&affine);
8073 flags=ParseGeometry(value,&geometry_info);
8074 affine.tx=geometry_info.xi;
8075 affine.ty=geometry_info.psi;
8076 if ((flags & PsiValue) == 0)
8077 affine.ty=affine.tx;
8085 flags=ParseGeometry(value,&geometry_info);
8086 affine.sx=geometry_info.rho;
8087 affine.sy=geometry_info.sigma;
8088 if ((flags & SigmaValue) == 0)
8089 affine.sy=affine.sx;
8099 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8100 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8101 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8102 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8110 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8118 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8122 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8123 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8124 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8125 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8126 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8128 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8131 if (attribute_flag[9] == 0)
8132 argument_list[9].real_reference=0.0;
8133 if (attribute_flag[10] == 0)
8134 argument_list[10].real_reference=0.0;
8135 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8138 geometry[MaxTextExtent];
8140 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8141 (double) argument_list[9].real_reference+draw_info->affine.tx,
8142 (double) argument_list[10].real_reference+draw_info->affine.ty);
8143 (void) CloneString(&draw_info->geometry,geometry);
8145 if (attribute_flag[17] != 0)
8146 draw_info->stroke_width=argument_list[17].real_reference;
8147 if (attribute_flag[18] != 0)
8149 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8150 MagickTrue : MagickFalse;
8151 draw_info->stroke_antialias=draw_info->text_antialias;
8153 if (attribute_flag[19] != 0)
8154 (void) CloneString(&draw_info->family,
8155 argument_list[19].string_reference);
8156 if (attribute_flag[20] != 0)
8157 draw_info->style=(StyleType) argument_list[20].integer_reference;
8158 if (attribute_flag[21] != 0)
8159 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8160 if (attribute_flag[22] != 0)
8161 draw_info->weight=argument_list[22].integer_reference;
8162 if (attribute_flag[23] != 0)
8163 draw_info->align=(AlignType) argument_list[23].integer_reference;
8164 if (attribute_flag[24] != 0)
8165 (void) CloneString(&draw_info->encoding,
8166 argument_list[24].string_reference);
8167 if (attribute_flag[25] != 0)
8168 draw_info->fill_pattern=CloneImage(
8169 argument_list[25].image_reference,0,0,MagickTrue,exception);
8170 if (attribute_flag[26] != 0)
8171 draw_info->fill_pattern=CloneImage(
8172 argument_list[26].image_reference,0,0,MagickTrue,exception);
8173 if (attribute_flag[27] != 0)
8174 draw_info->stroke_pattern=CloneImage(
8175 argument_list[27].image_reference,0,0,MagickTrue,exception);
8176 if (attribute_flag[29] != 0)
8177 draw_info->kerning=argument_list[29].real_reference;
8178 if (attribute_flag[30] != 0)
8179 draw_info->interline_spacing=argument_list[30].real_reference;
8180 if (attribute_flag[31] != 0)
8181 draw_info->interword_spacing=argument_list[31].real_reference;
8182 if (attribute_flag[32] != 0)
8183 draw_info->direction=(DirectionType)
8184 argument_list[32].integer_reference;
8185 (void) AnnotateImage(image,draw_info);
8186 draw_info=DestroyDrawInfo(draw_info);
8189 case 34: /* ColorFloodfill */
8200 draw_info=CloneDrawInfo(info ? info->image_info :
8201 (ImageInfo *) NULL,(DrawInfo *) NULL);
8202 if (attribute_flag[0] != 0)
8203 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8204 &geometry,exception);
8205 if (attribute_flag[1] != 0)
8206 geometry.x=argument_list[1].integer_reference;
8207 if (attribute_flag[2] != 0)
8208 geometry.y=argument_list[2].integer_reference;
8209 if (attribute_flag[3] != 0)
8210 (void) QueryColorDatabase(argument_list[3].string_reference,
8211 &draw_info->fill,exception);
8212 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8215 if (attribute_flag[4] != 0)
8217 QueryMagickColor(argument_list[4].string_reference,&target,
8221 if (attribute_flag[5] != 0)
8222 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8224 if (attribute_flag[6] != 0)
8225 invert=(MagickBooleanType) argument_list[6].integer_reference;
8226 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8227 geometry.x,geometry.y,invert);
8228 draw_info=DestroyDrawInfo(draw_info);
8231 case 35: /* Composite */
8234 composite_geometry[MaxTextExtent];
8240 compose=OverCompositeOp;
8241 if (attribute_flag[0] != 0)
8242 composite_image=argument_list[0].image_reference;
8245 ThrowPerlException(exception,OptionError,
8246 "CompositeImageRequired",PackageName);
8250 Parameter Handling used for BOTH normal and tiled composition.
8252 if (attribute_flag[1] != 0) /* compose */
8253 compose=(CompositeOperator) argument_list[1].integer_reference;
8254 if (attribute_flag[6] != 0) /* opacity */
8256 if (compose != DissolveCompositeOp)
8257 (void) SetImageOpacity(composite_image,(Quantum) (QuantumRange-
8258 SiPrefixToDouble(argument_list[6].string_reference,
8274 register PixelPacket
8281 Handle dissolve composite operator (patch by
8284 (void) CloneString(&image->geometry,
8285 argument_list[6].string_reference);
8286 opacity=(Quantum) (QuantumRange-SiPrefixToDouble(
8287 argument_list[6].string_reference,QuantumRange));
8288 if (composite_image->matte != MagickTrue)
8289 (void) SetImageOpacity(composite_image,OpaqueOpacity);
8290 composite_view=AcquireCacheView(composite_image);
8291 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8293 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8294 composite_image->columns,1,exception);
8295 for (x=0; x < (ssize_t) composite_image->columns; x++)
8297 if (q->opacity == OpaqueOpacity)
8298 q->opacity=ClampToQuantum(opacity);
8301 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8302 if (sync == MagickFalse)
8305 composite_view=DestroyCacheView(composite_view);
8308 if (attribute_flag[9] != 0) /* "color=>" */
8309 QueryColorDatabase(argument_list[9].string_reference,
8310 &composite_image->background_color,exception);
8311 if (attribute_flag[12] != 0) /* "interpolate=>" */
8312 image->interpolate=(InterpolatePixelMethod)
8313 argument_list[12].integer_reference;
8314 if (attribute_flag[13] != 0) /* "args=>" */
8315 (void) SetImageArtifact(composite_image,"compose:args",
8316 argument_list[13].string_reference);
8317 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8318 (void) SetImageArtifact(composite_image,"compose:args",
8319 argument_list[14].string_reference);
8321 Tiling Composition (with orthogonal rotate).
8323 rotate_image=(Image *) NULL;
8324 if (attribute_flag[8] != 0) /* "rotate=>" */
8329 rotate_image=RotateImage(composite_image,
8330 argument_list[8].real_reference,exception);
8331 if (rotate_image == (Image *) NULL)
8334 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8341 Tile the composite image.
8343 if (attribute_flag[8] != 0) /* "tile=>" */
8344 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8347 (void) SetImageArtifact(composite_image,
8348 "compose:outside-overlay","false");
8349 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8350 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8352 if (attribute_flag[8] != 0) /* rotate */
8353 (void) CompositeImage(image,compose,rotate_image,x,y);
8355 (void) CompositeImage(image,compose,composite_image,x,y);
8357 if (attribute_flag[8] != 0) /* rotate */
8358 rotate_image=DestroyImage(rotate_image);
8362 Parameter Handling used used ONLY for normal composition.
8364 if (attribute_flag[5] != 0) /* gravity */
8365 image->gravity=(GravityType) argument_list[5].integer_reference;
8366 if (attribute_flag[2] != 0) /* geometry offset */
8368 SetGeometry(image,&geometry);
8369 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8371 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8374 if (attribute_flag[3] != 0) /* x offset */
8375 geometry.x=argument_list[3].integer_reference;
8376 if (attribute_flag[4] != 0) /* y offset */
8377 geometry.y=argument_list[4].integer_reference;
8378 if (attribute_flag[10] != 0) /* mask */
8380 if ((image->compose == DisplaceCompositeOp) ||
8381 (image->compose == DistortCompositeOp))
8384 Merge Y displacement into X displacement image.
8386 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8388 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8389 argument_list[10].image_reference,0,0);
8394 Set a blending mask for the composition.
8396 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8397 MagickTrue,&image->exception);
8398 (void) NegateImage(image->mask,MagickFalse);
8401 if (attribute_flag[11] != 0) /* channel */
8402 channel=(ChannelType) argument_list[11].integer_reference;
8404 Composite two images (normal composition).
8406 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8407 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8408 (double) composite_image->rows,(double) geometry.x,(double)
8410 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8412 if (attribute_flag[8] == 0) /* no rotate */
8413 CompositeImageChannel(image,channel,compose,composite_image,
8414 geometry.x,geometry.y);
8418 Position adjust rotated image then composite.
8420 geometry.x-=(ssize_t) (rotate_image->columns-
8421 composite_image->columns)/2;
8422 geometry.y-=(ssize_t) (rotate_image->rows-
8423 composite_image->rows)/2;
8424 CompositeImageChannel(image,channel,compose,rotate_image,
8425 geometry.x,geometry.y);
8426 rotate_image=DestroyImage(rotate_image);
8428 if (attribute_flag[10] != 0) /* mask */
8430 if ((image->compose == DisplaceCompositeOp) ||
8431 (image->compose == DistortCompositeOp))
8432 composite_image=DestroyImage(composite_image);
8434 image->mask=DestroyImage(image->mask);
8438 case 36: /* Contrast */
8440 if (attribute_flag[0] == 0)
8441 argument_list[0].integer_reference=0;
8442 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8443 MagickTrue : MagickFalse);
8446 case 37: /* CycleColormap */
8448 if (attribute_flag[0] == 0)
8449 argument_list[0].integer_reference=6;
8450 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8458 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8460 (void) CloneString(&draw_info->primitive,"point");
8461 if (attribute_flag[0] != 0)
8463 if (argument_list[0].integer_reference < 0)
8464 (void) CloneString(&draw_info->primitive,
8465 argument_list[0].string_reference);
8467 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8468 MagickPrimitiveOptions,argument_list[0].integer_reference));
8470 if (attribute_flag[1] != 0)
8472 if (LocaleCompare(draw_info->primitive,"path") == 0)
8474 (void) ConcatenateString(&draw_info->primitive," '");
8475 ConcatenateString(&draw_info->primitive,
8476 argument_list[1].string_reference);
8477 (void) ConcatenateString(&draw_info->primitive,"'");
8481 (void) ConcatenateString(&draw_info->primitive," ");
8482 ConcatenateString(&draw_info->primitive,
8483 argument_list[1].string_reference);
8486 if (attribute_flag[2] != 0)
8488 (void) ConcatenateString(&draw_info->primitive," ");
8489 (void) ConcatenateString(&draw_info->primitive,
8490 CommandOptionToMnemonic(MagickMethodOptions,
8491 argument_list[2].integer_reference));
8493 if (attribute_flag[3] != 0)
8495 (void) QueryColorDatabase(argument_list[3].string_reference,
8496 &draw_info->stroke,exception);
8497 if (argument_list[3].image_reference != (Image *) NULL)
8498 draw_info->stroke_pattern=CloneImage(
8499 argument_list[3].image_reference,0,0,MagickTrue,exception);
8501 if (attribute_flag[4] != 0)
8503 (void) QueryColorDatabase(argument_list[4].string_reference,
8504 &draw_info->fill,exception);
8505 if (argument_list[4].image_reference != (Image *) NULL)
8506 draw_info->fill_pattern=CloneImage(
8507 argument_list[4].image_reference,0,0,MagickTrue,exception);
8509 if (attribute_flag[5] != 0)
8510 draw_info->stroke_width=argument_list[5].real_reference;
8511 if (attribute_flag[6] != 0)
8512 (void) CloneString(&draw_info->font,
8513 argument_list[6].string_reference);
8514 if (attribute_flag[7] != 0)
8515 (void) QueryColorDatabase(argument_list[7].string_reference,
8516 &draw_info->border_color,exception);
8517 if (attribute_flag[8] != 0)
8518 draw_info->affine.tx=argument_list[8].real_reference;
8519 if (attribute_flag[9] != 0)
8520 draw_info->affine.ty=argument_list[9].real_reference;
8521 if (attribute_flag[20] != 0)
8526 av=(AV *) argument_list[20].array_reference;
8527 if ((av_len(av) != 3) && (av_len(av) != 5))
8529 ThrowPerlException(exception,OptionError,
8530 "affine matrix must have 4 or 6 elements",PackageName);
8533 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8534 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8535 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8536 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8537 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8538 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8540 ThrowPerlException(exception,OptionError,
8541 "affine matrix is singular",PackageName);
8544 if (av_len(av) == 5)
8546 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8547 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8550 for (j=10; j < 15; j++)
8552 if (attribute_flag[j] == 0)
8554 value=argument_list[j].string_reference;
8555 angle=argument_list[j].real_reference;
8556 current=draw_info->affine;
8557 GetAffineMatrix(&affine);
8565 flags=ParseGeometry(value,&geometry_info);
8566 affine.tx=geometry_info.xi;
8567 affine.ty=geometry_info.psi;
8568 if ((flags & PsiValue) == 0)
8569 affine.ty=affine.tx;
8577 flags=ParseGeometry(value,&geometry_info);
8578 affine.sx=geometry_info.rho;
8579 affine.sy=geometry_info.sigma;
8580 if ((flags & SigmaValue) == 0)
8581 affine.sy=affine.sx;
8591 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8592 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8593 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8594 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8602 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8610 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8614 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8615 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8616 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8617 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8618 draw_info->affine.tx=
8619 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8620 draw_info->affine.ty=
8621 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8623 if (attribute_flag[15] != 0)
8624 draw_info->fill_pattern=CloneImage(
8625 argument_list[15].image_reference,0,0,MagickTrue,exception);
8626 if (attribute_flag[16] != 0)
8627 draw_info->pointsize=argument_list[16].real_reference;
8628 if (attribute_flag[17] != 0)
8630 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8631 ? MagickTrue : MagickFalse;
8632 draw_info->text_antialias=draw_info->stroke_antialias;
8634 if (attribute_flag[18] != 0)
8635 (void) CloneString(&draw_info->density,
8636 argument_list[18].string_reference);
8637 if (attribute_flag[19] != 0)
8638 draw_info->stroke_width=argument_list[19].real_reference;
8639 if (attribute_flag[21] != 0)
8640 draw_info->dash_offset=argument_list[21].real_reference;
8641 if (attribute_flag[22] != 0)
8646 av=(AV *) argument_list[22].array_reference;
8647 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8648 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8649 if (draw_info->dash_pattern != (double *) NULL)
8651 for (i=0; i <= av_len(av); i++)
8652 draw_info->dash_pattern[i]=(double)
8653 SvNV(*(av_fetch(av,i,0)));
8654 draw_info->dash_pattern[i]=0.0;
8657 if (attribute_flag[23] != 0)
8658 image->interpolate=(InterpolatePixelMethod)
8659 argument_list[23].integer_reference;
8660 if ((attribute_flag[24] != 0) &&
8661 (draw_info->fill_pattern != (Image *) NULL))
8662 flags=ParsePageGeometry(draw_info->fill_pattern,
8663 argument_list[24].string_reference,
8664 &draw_info->fill_pattern->tile_offset,exception);
8665 if (attribute_flag[25] != 0)
8667 (void) ConcatenateString(&draw_info->primitive," '");
8668 (void) ConcatenateString(&draw_info->primitive,
8669 argument_list[25].string_reference);
8670 (void) ConcatenateString(&draw_info->primitive,"'");
8672 if (attribute_flag[26] != 0)
8673 draw_info->fill_pattern=CloneImage(
8674 argument_list[26].image_reference,0,0,MagickTrue,exception);
8675 if (attribute_flag[27] != 0)
8676 draw_info->stroke_pattern=CloneImage(
8677 argument_list[27].image_reference,0,0,MagickTrue,exception);
8678 if (attribute_flag[28] != 0)
8679 (void) CloneString(&draw_info->primitive,
8680 argument_list[28].string_reference);
8681 if (attribute_flag[29] != 0)
8682 draw_info->kerning=argument_list[29].real_reference;
8683 if (attribute_flag[30] != 0)
8684 draw_info->interline_spacing=argument_list[30].real_reference;
8685 if (attribute_flag[31] != 0)
8686 draw_info->interword_spacing=argument_list[31].real_reference;
8687 if (attribute_flag[32] != 0)
8688 draw_info->direction=(DirectionType)
8689 argument_list[32].integer_reference;
8690 DrawImage(image,draw_info);
8691 draw_info=DestroyDrawInfo(draw_info);
8694 case 39: /* Equalize */
8696 if (attribute_flag[0] != 0)
8697 channel=(ChannelType) argument_list[0].integer_reference;
8698 EqualizeImageChannel(image,channel);
8701 case 40: /* Gamma */
8703 if (attribute_flag[1] != 0)
8704 channel=(ChannelType) argument_list[1].integer_reference;
8705 if (attribute_flag[2] == 0)
8706 argument_list[2].real_reference=1.0;
8707 if (attribute_flag[3] == 0)
8708 argument_list[3].real_reference=1.0;
8709 if (attribute_flag[4] == 0)
8710 argument_list[4].real_reference=1.0;
8711 if (attribute_flag[0] == 0)
8713 (void) FormatLocaleString(message,MaxTextExtent,
8714 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8715 (double) argument_list[3].real_reference,
8716 (double) argument_list[4].real_reference);
8717 argument_list[0].string_reference=message;
8719 if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
8720 (void) GammaImage(image,argument_list[0].string_reference);
8722 (void) GammaImageChannel(image,channel,InterpretLocaleValue(
8723 argument_list[0].string_reference,(char **) NULL));
8731 if (attribute_flag[0] == 0)
8733 ThrowPerlException(exception,OptionError,"MapImageRequired",
8737 quantize_info=AcquireQuantizeInfo(info->image_info);
8738 if (attribute_flag[1] != 0)
8739 quantize_info->dither=(MagickBooleanType)
8740 argument_list[1].integer_reference;
8741 if (attribute_flag[2] != 0)
8742 quantize_info->dither_method=(DitherMethod)
8743 argument_list[2].integer_reference;
8744 (void) RemapImages(quantize_info,image,
8745 argument_list[0].image_reference);
8746 quantize_info=DestroyQuantizeInfo(quantize_info);
8749 case 42: /* MatteFloodfill */
8760 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8762 if (attribute_flag[0] != 0)
8763 if (attribute_flag[0] != 0)
8764 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8765 &geometry,exception);
8766 if (attribute_flag[1] != 0)
8767 geometry.x=argument_list[1].integer_reference;
8768 if (attribute_flag[2] != 0)
8769 geometry.y=argument_list[2].integer_reference;
8770 if (image->matte == MagickFalse)
8771 (void) SetImageOpacity(image,OpaqueOpacity);
8772 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8774 if (attribute_flag[4] != 0)
8775 QueryMagickColor(argument_list[4].string_reference,&target,
8777 if (attribute_flag[3] != 0)
8778 target.opacity=SiPrefixToDouble(argument_list[3].string_reference,
8780 if (attribute_flag[5] != 0)
8781 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8784 if (attribute_flag[6] != 0)
8785 invert=(MagickBooleanType) argument_list[6].integer_reference;
8786 (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
8787 geometry.x,geometry.y,invert);
8788 draw_info=DestroyDrawInfo(draw_info);
8791 case 43: /* Modulate */
8794 modulate[MaxTextExtent];
8796 geometry_info.rho=100.0;
8797 geometry_info.sigma=100.0;
8798 geometry_info.xi=100.0;
8799 if (attribute_flag[0] != 0)
8800 (void)ParseGeometry(argument_list[0].string_reference,
8802 if (attribute_flag[1] != 0)
8803 geometry_info.xi=argument_list[1].real_reference;
8804 if (attribute_flag[2] != 0)
8805 geometry_info.sigma=argument_list[2].real_reference;
8806 if (attribute_flag[3] != 0)
8808 geometry_info.sigma=argument_list[3].real_reference;
8809 SetImageArtifact(image,"modulate:colorspace","HWB");
8811 if (attribute_flag[4] != 0)
8813 geometry_info.rho=argument_list[4].real_reference;
8814 SetImageArtifact(image,"modulate:colorspace","HSB");
8816 if (attribute_flag[5] != 0)
8818 geometry_info.sigma=argument_list[5].real_reference;
8819 SetImageArtifact(image,"modulate:colorspace","HSL");
8821 if (attribute_flag[6] != 0)
8823 geometry_info.rho=argument_list[6].real_reference;
8824 SetImageArtifact(image,"modulate:colorspace","HWB");
8826 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8827 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8828 (void) ModulateImage(image,modulate);
8831 case 44: /* Negate */
8833 if (attribute_flag[0] == 0)
8834 argument_list[0].integer_reference=0;
8835 if (attribute_flag[1] != 0)
8836 channel=(ChannelType) argument_list[1].integer_reference;
8837 (void) NegateImageChannel(image,channel,
8838 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
8841 case 45: /* Normalize */
8843 if (attribute_flag[0] != 0)
8844 channel=(ChannelType) argument_list[0].integer_reference;
8845 NormalizeImageChannel(image,channel);
8848 case 46: /* NumberColors */
8850 case 47: /* Opaque */
8859 (void) QueryMagickColor("none",&target,exception);
8860 (void) QueryMagickColor("none",&fill_color,exception);
8861 if (attribute_flag[0] != 0)
8862 (void) QueryMagickColor(argument_list[0].string_reference,
8864 if (attribute_flag[1] != 0)
8865 (void) QueryMagickColor(argument_list[1].string_reference,
8866 &fill_color,exception);
8867 if (attribute_flag[2] != 0)
8868 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8870 if (attribute_flag[3] != 0)
8871 channel=(ChannelType) argument_list[3].integer_reference;
8873 if (attribute_flag[4] != 0)
8874 invert=(MagickBooleanType) argument_list[4].integer_reference;
8875 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8879 case 48: /* Quantize */
8884 quantize_info=AcquireQuantizeInfo(info->image_info);
8885 if (attribute_flag[0] != 0)
8886 quantize_info->number_colors=(size_t)
8887 argument_list[0].integer_reference;
8888 if (attribute_flag[1] != 0)
8889 quantize_info->tree_depth=(size_t)
8890 argument_list[1].integer_reference;
8891 if (attribute_flag[2] != 0)
8892 quantize_info->colorspace=(ColorspaceType)
8893 argument_list[2].integer_reference;
8894 if (attribute_flag[3] != 0)
8895 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8896 MagickTrue : MagickFalse;
8897 if (attribute_flag[4] != 0)
8898 quantize_info->measure_error=
8899 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8900 if (attribute_flag[5] != 0)
8901 (void) QueryColorDatabase(argument_list[5].string_reference,
8902 &image->transparent_color,exception);
8903 if (attribute_flag[5] && argument_list[5].integer_reference)
8905 (void) QuantizeImages(quantize_info,image);
8908 if (attribute_flag[6] != 0)
8909 quantize_info->dither_method=(DitherMethod)
8910 argument_list[6].integer_reference;
8911 if ((image->storage_class == DirectClass) ||
8912 (image->colors > quantize_info->number_colors) ||
8913 (quantize_info->colorspace == GRAYColorspace))
8914 (void) QuantizeImage(quantize_info,image);
8916 CompressImageColormap(image);
8917 quantize_info=DestroyQuantizeInfo(quantize_info);
8920 case 49: /* Raise */
8922 if (attribute_flag[0] != 0)
8923 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8924 &geometry,exception);
8925 if (attribute_flag[1] != 0)
8926 geometry.width=argument_list[1].integer_reference;
8927 if (attribute_flag[2] != 0)
8928 geometry.height=argument_list[2].integer_reference;
8929 if (attribute_flag[3] == 0)
8930 argument_list[3].integer_reference=1;
8931 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8932 0 ? MagickTrue : MagickFalse);
8935 case 50: /* Segment */
8942 smoothing_threshold;
8947 cluster_threshold=1.0;
8948 smoothing_threshold=1.5;
8949 colorspace=RGBColorspace;
8950 verbose=MagickFalse;
8951 if (attribute_flag[0] != 0)
8953 flags=ParseGeometry(argument_list[0].string_reference,
8955 cluster_threshold=geometry_info.rho;
8956 if (flags & SigmaValue)
8957 smoothing_threshold=geometry_info.sigma;
8959 if (attribute_flag[1] != 0)
8960 cluster_threshold=argument_list[1].real_reference;
8961 if (attribute_flag[2] != 0)
8962 smoothing_threshold=argument_list[2].real_reference;
8963 if (attribute_flag[3] != 0)
8964 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8965 if (attribute_flag[4] != 0)
8966 verbose=argument_list[4].integer_reference != 0 ?
8967 MagickTrue : MagickFalse;
8968 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8969 smoothing_threshold);
8972 case 51: /* Signature */
8974 (void) SignatureImage(image);
8977 case 52: /* Solarize */
8979 geometry_info.rho=QuantumRange/2.0;
8980 if (attribute_flag[0] != 0)
8981 flags=ParseGeometry(argument_list[0].string_reference,
8983 if (attribute_flag[1] != 0)
8984 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8986 (void) SolarizeImage(image,geometry_info.rho);
8991 (void) SyncImage(image);
8994 case 54: /* Texture */
8996 if (attribute_flag[0] == 0)
8998 TextureImage(image,argument_list[0].image_reference);
9001 case 55: /* Evalute */
9003 MagickEvaluateOperator
9006 op=SetEvaluateOperator;
9007 if (attribute_flag[0] == MagickFalse)
9008 argument_list[0].real_reference=0.0;
9009 if (attribute_flag[1] != MagickFalse)
9010 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9011 if (attribute_flag[2] != MagickFalse)
9012 channel=(ChannelType) argument_list[2].integer_reference;
9013 (void) EvaluateImageChannel(image,channel,op,
9014 argument_list[0].real_reference,exception);
9017 case 56: /* Transparent */
9028 (void) QueryMagickColor("none",&target,exception);
9029 if (attribute_flag[0] != 0)
9030 (void) QueryMagickColor(argument_list[0].string_reference,&target,
9032 opacity=TransparentOpacity;
9033 if (attribute_flag[1] != 0)
9034 opacity=SiPrefixToDouble(argument_list[1].string_reference,
9036 if (attribute_flag[2] != 0)
9037 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
9039 if (attribute_flag[3] == 0)
9040 argument_list[3].integer_reference=0;
9042 if (attribute_flag[3] != 0)
9043 invert=(MagickBooleanType) argument_list[3].integer_reference;
9044 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9048 case 57: /* Threshold */
9053 if (attribute_flag[0] == 0)
9054 argument_list[0].string_reference="50%";
9055 if (attribute_flag[1] != 0)
9056 channel=(ChannelType) argument_list[1].integer_reference;
9057 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9059 (void) BilevelImageChannel(image,channel,threshold);
9062 case 58: /* Charcoal */
9064 if (attribute_flag[0] != 0)
9066 flags=ParseGeometry(argument_list[0].string_reference,
9068 if ((flags & SigmaValue) == 0)
9069 geometry_info.sigma=1.0;
9071 if (attribute_flag[1] != 0)
9072 geometry_info.rho=argument_list[1].real_reference;
9073 if (attribute_flag[2] != 0)
9074 geometry_info.sigma=argument_list[2].real_reference;
9075 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9081 if (attribute_flag[0] != 0)
9082 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9084 image=TrimImage(image,exception);
9089 if (attribute_flag[0] != 0)
9091 flags=ParseGeometry(argument_list[0].string_reference,
9093 if ((flags & SigmaValue) == 0)
9094 geometry_info.sigma=1.0;
9096 if (attribute_flag[1] != 0)
9097 geometry_info.rho=argument_list[1].real_reference;
9098 if (attribute_flag[2] != 0)
9099 geometry_info.sigma=argument_list[2].real_reference;
9100 if (attribute_flag[3] != 0)
9101 image->interpolate=(InterpolatePixelMethod)
9102 argument_list[3].integer_reference;
9103 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9107 case 61: /* Separate */
9109 if (attribute_flag[0] != 0)
9110 channel=(ChannelType) argument_list[0].integer_reference;
9111 (void) SeparateImageChannel(image,channel);
9114 case 63: /* Stereo */
9116 if (attribute_flag[0] == 0)
9118 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9122 if (attribute_flag[1] != 0)
9123 geometry.x=argument_list[1].integer_reference;
9124 if (attribute_flag[2] != 0)
9125 geometry.y=argument_list[2].integer_reference;
9126 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9127 geometry.x,geometry.y,exception);
9130 case 64: /* Stegano */
9132 if (attribute_flag[0] == 0)
9134 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9138 if (attribute_flag[1] == 0)
9139 argument_list[1].integer_reference=0;
9140 image->offset=argument_list[1].integer_reference;
9141 image=SteganoImage(image,argument_list[0].image_reference,exception);
9144 case 65: /* Deconstruct */
9146 image=DeconstructImages(image,exception);
9149 case 66: /* GaussianBlur */
9151 if (attribute_flag[0] != 0)
9153 flags=ParseGeometry(argument_list[0].string_reference,
9155 if ((flags & SigmaValue) == 0)
9156 geometry_info.sigma=1.0;
9158 if (attribute_flag[1] != 0)
9159 geometry_info.rho=argument_list[1].real_reference;
9160 if (attribute_flag[2] != 0)
9161 geometry_info.sigma=argument_list[2].real_reference;
9162 if (attribute_flag[3] != 0)
9163 channel=(ChannelType) argument_list[3].integer_reference;
9164 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9165 geometry_info.sigma,exception);
9168 case 67: /* Convolve */
9179 if (attribute_flag[0] == 0)
9181 if (attribute_flag[1] != 0)
9182 channel=(ChannelType) argument_list[1].integer_reference;
9183 if (attribute_flag[2] != 0)
9184 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9186 av=(AV *) argument_list[0].array_reference;
9187 order=(size_t) sqrt(av_len(av)+1);
9188 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9189 if (kernel == (double *) NULL)
9191 ThrowPerlException(exception,ResourceLimitFatalError,
9192 "MemoryAllocationFailed",PackageName);
9195 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9196 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9197 for ( ; j < (ssize_t) (order*order); j++)
9199 image=ConvolveImageChannel(image,channel,order,kernel,exception);
9200 kernel=(double *) RelinquishMagickMemory(kernel);
9203 case 68: /* Profile */
9218 if (attribute_flag[0] != 0)
9219 name=argument_list[0].string_reference;
9220 if (attribute_flag[2] != 0)
9221 image->rendering_intent=(RenderingIntent)
9222 argument_list[2].integer_reference;
9223 if (attribute_flag[3] != 0)
9224 image->black_point_compensation=
9225 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9226 if (attribute_flag[1] != 0)
9228 if (argument_list[1].length == 0)
9231 Remove a profile from the image.
9233 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9238 Associate user supplied profile with the image.
9240 profile=AcquireStringInfo(argument_list[1].length);
9241 SetStringInfoDatum(profile,(const unsigned char *)
9242 argument_list[1].string_reference);
9243 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9244 (size_t) GetStringInfoLength(profile),MagickFalse);
9245 profile=DestroyStringInfo(profile);
9249 Associate a profile with the image.
9252 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9253 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9254 profile_image=ReadImages(profile_info,&image->exception);
9255 if (profile_image == (Image *) NULL)
9257 ResetImageProfileIterator(profile_image);
9258 name=GetNextImageProfile(profile_image);
9259 while (name != (const char *) NULL)
9264 profile=GetImageProfile(profile_image,name);
9265 if (profile != (const StringInfo *) NULL)
9266 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9267 (size_t) GetStringInfoLength(profile),MagickFalse);
9268 name=GetNextImageProfile(profile_image);
9270 profile_image=DestroyImage(profile_image);
9271 profile_info=DestroyImageInfo(profile_info);
9274 case 69: /* UnsharpMask */
9276 if (attribute_flag[0] != 0)
9278 flags=ParseGeometry(argument_list[0].string_reference,
9280 if ((flags & SigmaValue) == 0)
9281 geometry_info.sigma=1.0;
9282 if ((flags & XiValue) == 0)
9283 geometry_info.xi=1.0;
9284 if ((flags & PsiValue) == 0)
9285 geometry_info.psi=0.5;
9287 if (attribute_flag[1] != 0)
9288 geometry_info.rho=argument_list[1].real_reference;
9289 if (attribute_flag[2] != 0)
9290 geometry_info.sigma=argument_list[2].real_reference;
9291 if (attribute_flag[3] != 0)
9292 geometry_info.xi=argument_list[3].real_reference;
9293 if (attribute_flag[4] != 0)
9294 geometry_info.psi=argument_list[4].real_reference;
9295 if (attribute_flag[5] != 0)
9296 channel=(ChannelType) argument_list[5].integer_reference;
9297 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9298 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9301 case 70: /* MotionBlur */
9303 if (attribute_flag[0] != 0)
9305 flags=ParseGeometry(argument_list[0].string_reference,
9307 if ((flags & SigmaValue) == 0)
9308 geometry_info.sigma=1.0;
9309 if ((flags & XiValue) == 0)
9310 geometry_info.xi=1.0;
9312 if (attribute_flag[1] != 0)
9313 geometry_info.rho=argument_list[1].real_reference;
9314 if (attribute_flag[2] != 0)
9315 geometry_info.sigma=argument_list[2].real_reference;
9316 if (attribute_flag[3] != 0)
9317 geometry_info.xi=argument_list[3].real_reference;
9318 if (attribute_flag[4] != 0)
9319 channel=(ChannelType) argument_list[4].integer_reference;
9320 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9321 geometry_info.sigma,geometry_info.xi,exception);
9324 case 71: /* OrderedDither */
9326 if (attribute_flag[0] == 0)
9327 argument_list[0].string_reference="o8x8";
9328 if (attribute_flag[1] != 0)
9329 channel=(ChannelType) argument_list[1].integer_reference;
9330 (void) OrderedPosterizeImageChannel(image,channel,
9331 argument_list[0].string_reference,exception);
9334 case 72: /* Shave */
9336 if (attribute_flag[0] != 0)
9337 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9338 &geometry,exception);
9339 if (attribute_flag[1] != 0)
9340 geometry.width=argument_list[1].integer_reference;
9341 if (attribute_flag[2] != 0)
9342 geometry.height=argument_list[2].integer_reference;
9343 image=ShaveImage(image,&geometry,exception);
9346 case 73: /* Level */
9354 white_point=(MagickRealType) image->columns*image->rows;
9356 if (attribute_flag[0] != 0)
9358 flags=ParseGeometry(argument_list[0].string_reference,
9360 black_point=geometry_info.rho;
9361 if ((flags & SigmaValue) != 0)
9362 white_point=geometry_info.sigma;
9363 if ((flags & XiValue) != 0)
9364 gamma=geometry_info.xi;
9365 if ((flags & PercentValue) != 0)
9367 black_point*=(double) (QuantumRange/100.0);
9368 white_point*=(double) (QuantumRange/100.0);
9370 if ((flags & SigmaValue) == 0)
9371 white_point=(double) QuantumRange-black_point;
9373 if (attribute_flag[1] != 0)
9374 black_point=argument_list[1].real_reference;
9375 if (attribute_flag[2] != 0)
9376 white_point=argument_list[2].real_reference;
9377 if (attribute_flag[3] != 0)
9378 gamma=argument_list[3].real_reference;
9379 if (attribute_flag[4] != 0)
9380 channel=(ChannelType) argument_list[4].integer_reference;
9381 if (attribute_flag[5] != 0)
9383 argument_list[0].real_reference=argument_list[5].real_reference;
9384 attribute_flag[0]=attribute_flag[5];
9386 (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
9391 if (attribute_flag[0] == 0)
9392 argument_list[0].string_reference="#1";
9393 if (attribute_flag[1] == 0)
9394 argument_list[1].integer_reference=MagickTrue;
9395 (void) ClipImagePath(image,argument_list[0].string_reference,
9396 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9399 case 75: /* AffineTransform */
9404 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9406 if (attribute_flag[0] != 0)
9411 av=(AV *) argument_list[0].array_reference;
9412 if ((av_len(av) != 3) && (av_len(av) != 5))
9414 ThrowPerlException(exception,OptionError,
9415 "affine matrix must have 4 or 6 elements",PackageName);
9418 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9419 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9420 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9421 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9422 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9423 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9425 ThrowPerlException(exception,OptionError,
9426 "affine matrix is singular",PackageName);
9429 if (av_len(av) == 5)
9431 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9432 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9435 for (j=1; j < 6; j++)
9437 if (attribute_flag[j] == 0)
9439 value=argument_list[j].string_reference;
9440 angle=argument_list[j].real_reference;
9441 current=draw_info->affine;
9442 GetAffineMatrix(&affine);
9450 flags=ParseGeometry(value,&geometry_info);
9451 affine.tx=geometry_info.xi;
9452 affine.ty=geometry_info.psi;
9453 if ((flags & PsiValue) == 0)
9454 affine.ty=affine.tx;
9462 flags=ParseGeometry(value,&geometry_info);
9463 affine.sx=geometry_info.rho;
9464 affine.sy=geometry_info.sigma;
9465 if ((flags & SigmaValue) == 0)
9466 affine.sy=affine.sx;
9476 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9477 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9478 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9479 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9487 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9495 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9499 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9500 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9501 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9502 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9503 draw_info->affine.tx=
9504 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9505 draw_info->affine.ty=
9506 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9508 if (attribute_flag[6] != 0)
9509 image->interpolate=(InterpolatePixelMethod)
9510 argument_list[6].integer_reference;
9511 if (attribute_flag[7] != 0)
9512 QueryColorDatabase(argument_list[7].string_reference,
9513 &image->background_color,exception);
9514 image=AffineTransformImage(image,&draw_info->affine,exception);
9515 draw_info=DestroyDrawInfo(draw_info);
9518 case 76: /* Difference */
9520 if (attribute_flag[0] == 0)
9522 ThrowPerlException(exception,OptionError,
9523 "ReferenceImageRequired",PackageName);
9526 if (attribute_flag[1] != 0)
9527 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9529 (void) IsImagesEqual(image,argument_list[0].image_reference);
9532 case 77: /* AdaptiveThreshold */
9534 if (attribute_flag[0] != 0)
9536 flags=ParseGeometry(argument_list[0].string_reference,
9538 if ((flags & PercentValue) != 0)
9539 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9541 if (attribute_flag[1] != 0)
9542 geometry_info.rho=argument_list[1].integer_reference;
9543 if (attribute_flag[2] != 0)
9544 geometry_info.sigma=argument_list[2].integer_reference;
9545 if (attribute_flag[3] != 0)
9546 geometry_info.xi=argument_list[3].integer_reference;;
9547 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9548 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9552 case 78: /* Resample */
9558 if (attribute_flag[0] != 0)
9560 flags=ParseGeometry(argument_list[0].string_reference,
9562 if ((flags & SigmaValue) == 0)
9563 geometry_info.sigma=geometry_info.rho;
9565 if (attribute_flag[1] != 0)
9566 geometry_info.rho=argument_list[1].real_reference;
9567 if (attribute_flag[2] != 0)
9568 geometry_info.sigma=argument_list[2].real_reference;
9569 if (attribute_flag[3] == 0)
9570 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9571 if (attribute_flag[4] == 0)
9572 SetImageArtifact(image,"filter:support",
9573 argument_list[4].string_reference);
9574 if (attribute_flag[5] != 0)
9575 argument_list[5].real_reference=1.0;
9576 width=(size_t) (geometry_info.rho*image->columns/
9577 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9578 height=(size_t) (geometry_info.sigma*image->rows/
9579 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9580 image=ResizeImage(image,width,height,(FilterTypes)
9581 argument_list[3].integer_reference,argument_list[5].real_reference,
9583 if (image != (Image *) NULL)
9585 image->x_resolution=geometry_info.rho;
9586 image->y_resolution=geometry_info.sigma;
9590 case 79: /* Describe */
9592 if (attribute_flag[0] == 0)
9593 argument_list[0].file_reference=(FILE *) NULL;
9594 if (attribute_flag[1] != 0)
9595 (void) SetImageArtifact(image,"identify:features",
9596 argument_list[1].string_reference);
9597 (void) IdentifyImage(image,argument_list[0].file_reference,
9601 case 80: /* BlackThreshold */
9603 if (attribute_flag[0] == 0)
9604 argument_list[0].string_reference="50%";
9605 if (attribute_flag[2] != 0)
9606 channel=(ChannelType) argument_list[2].integer_reference;
9607 BlackThresholdImageChannel(image,channel,
9608 argument_list[0].string_reference,exception);
9611 case 81: /* WhiteThreshold */
9613 if (attribute_flag[0] == 0)
9614 argument_list[0].string_reference="50%";
9615 if (attribute_flag[2] != 0)
9616 channel=(ChannelType) argument_list[2].integer_reference;
9617 WhiteThresholdImageChannel(image,channel,
9618 argument_list[0].string_reference,exception);
9621 case 82: /* RadialBlur */
9623 if (attribute_flag[0] != 0)
9625 flags=ParseGeometry(argument_list[0].string_reference,
9627 if ((flags & SigmaValue) == 0)
9628 geometry_info.sigma=1.0;
9630 if (attribute_flag[1] != 0)
9631 geometry_info.rho=argument_list[1].real_reference;
9632 if (attribute_flag[2] != 0)
9633 channel=(ChannelType) argument_list[2].integer_reference;
9634 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9638 case 83: /* Thumbnail */
9640 if (attribute_flag[0] != 0)
9641 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9642 &geometry,exception);
9643 if (attribute_flag[1] != 0)
9644 geometry.width=argument_list[1].integer_reference;
9645 if (attribute_flag[2] != 0)
9646 geometry.height=argument_list[2].integer_reference;
9647 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9650 case 84: /* Strip */
9652 (void) StripImage(image);
9660 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9661 if (attribute_flag[0] != 0)
9662 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9664 if (attribute_flag[1] == 0)
9665 argument_list[1].string_reference="100";
9666 image=TintImage(image,argument_list[1].string_reference,target,
9670 case 86: /* Channel */
9672 if (attribute_flag[0] != 0)
9673 channel=(ChannelType) argument_list[0].integer_reference;
9674 (void) SeparateImageChannel(image,channel);
9677 case 87: /* Splice */
9679 if (attribute_flag[0] != 0)
9680 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9681 &geometry,exception);
9682 if (attribute_flag[1] != 0)
9683 geometry.width=argument_list[1].integer_reference;
9684 if (attribute_flag[2] != 0)
9685 geometry.height=argument_list[2].integer_reference;
9686 if (attribute_flag[3] != 0)
9687 geometry.x=argument_list[3].integer_reference;
9688 if (attribute_flag[4] != 0)
9689 geometry.y=argument_list[4].integer_reference;
9690 if (attribute_flag[5] != 0)
9691 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9693 if (attribute_flag[6] != 0)
9694 (void) QueryColorDatabase(argument_list[6].string_reference,
9695 &image->background_color,exception);
9696 if (attribute_flag[7] != 0)
9697 image->gravity=(GravityType) argument_list[7].integer_reference;
9698 image=SpliceImage(image,&geometry,exception);
9701 case 88: /* Posterize */
9703 if (attribute_flag[0] == 0)
9704 argument_list[0].integer_reference=3;
9705 if (attribute_flag[1] == 0)
9706 argument_list[1].integer_reference=0;
9707 (void) PosterizeImage(image,argument_list[0].integer_reference,
9708 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9711 case 89: /* Shadow */
9713 if (attribute_flag[0] != 0)
9715 flags=ParseGeometry(argument_list[0].string_reference,
9717 if ((flags & SigmaValue) == 0)
9718 geometry_info.sigma=1.0;
9719 if ((flags & XiValue) == 0)
9720 geometry_info.xi=4.0;
9721 if ((flags & PsiValue) == 0)
9722 geometry_info.psi=4.0;
9724 if (attribute_flag[1] != 0)
9725 geometry_info.rho=argument_list[1].real_reference;
9726 if (attribute_flag[2] != 0)
9727 geometry_info.sigma=argument_list[2].real_reference;
9728 if (attribute_flag[3] != 0)
9729 geometry_info.xi=argument_list[3].integer_reference;
9730 if (attribute_flag[4] != 0)
9731 geometry_info.psi=argument_list[4].integer_reference;
9732 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9733 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9737 case 90: /* Identify */
9739 if (attribute_flag[0] == 0)
9740 argument_list[0].file_reference=(FILE *) NULL;
9741 if (attribute_flag[1] != 0)
9742 (void) SetImageArtifact(image,"identify:features",
9743 argument_list[1].string_reference);
9744 if ((attribute_flag[2] != 0) &&
9745 (argument_list[2].integer_reference != 0))
9746 (void) SetImageArtifact(image,"identify:unique","true");
9747 (void) IdentifyImage(image,argument_list[0].file_reference,
9751 case 91: /* SepiaTone */
9753 if (attribute_flag[0] == 0)
9754 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9755 image=SepiaToneImage(image,argument_list[0].real_reference,
9759 case 92: /* SigmoidalContrast */
9764 if (attribute_flag[0] != 0)
9766 flags=ParseGeometry(argument_list[0].string_reference,
9768 if ((flags & SigmaValue) == 0)
9769 geometry_info.sigma=QuantumRange/2.0;
9770 if ((flags & PercentValue) != 0)
9771 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9773 if (attribute_flag[1] != 0)
9774 geometry_info.rho=argument_list[1].real_reference;
9775 if (attribute_flag[2] != 0)
9776 geometry_info.sigma=argument_list[2].real_reference;
9777 if (attribute_flag[3] != 0)
9778 channel=(ChannelType) argument_list[3].integer_reference;
9780 if (attribute_flag[4] != 0)
9781 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9783 (void) SigmoidalContrastImageChannel(image,channel,sharpen,
9784 geometry_info.rho,geometry_info.sigma);
9787 case 93: /* Extent */
9789 if (attribute_flag[7] != 0)
9790 image->gravity=(GravityType) argument_list[7].integer_reference;
9791 if (attribute_flag[0] != 0)
9796 flags=ParseGravityGeometry(image,
9797 argument_list[0].string_reference,&geometry,exception);
9799 if (geometry.width == 0)
9800 geometry.width=image->columns;
9801 if (geometry.height == 0)
9802 geometry.height=image->rows;
9804 if (attribute_flag[1] != 0)
9805 geometry.width=argument_list[1].integer_reference;
9806 if (attribute_flag[2] != 0)
9807 geometry.height=argument_list[2].integer_reference;
9808 if (attribute_flag[3] != 0)
9809 geometry.x=argument_list[3].integer_reference;
9810 if (attribute_flag[4] != 0)
9811 geometry.y=argument_list[4].integer_reference;
9812 if (attribute_flag[5] != 0)
9813 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9815 if (attribute_flag[6] != 0)
9816 (void) QueryColorDatabase(argument_list[6].string_reference,
9817 &image->background_color,exception);
9818 image=ExtentImage(image,&geometry,exception);
9821 case 94: /* Vignette */
9823 if (attribute_flag[0] != 0)
9825 flags=ParseGeometry(argument_list[0].string_reference,
9827 if ((flags & SigmaValue) == 0)
9828 geometry_info.sigma=1.0;
9829 if ((flags & XiValue) == 0)
9830 geometry_info.xi=0.1*image->columns;
9831 if ((flags & PsiValue) == 0)
9832 geometry_info.psi=0.1*image->rows;
9834 if (attribute_flag[1] != 0)
9835 geometry_info.rho=argument_list[1].real_reference;
9836 if (attribute_flag[2] != 0)
9837 geometry_info.sigma=argument_list[2].real_reference;
9838 if (attribute_flag[3] != 0)
9839 geometry_info.xi=argument_list[3].integer_reference;
9840 if (attribute_flag[4] != 0)
9841 geometry_info.psi=argument_list[4].integer_reference;
9842 if (attribute_flag[5] != 0)
9843 (void) QueryColorDatabase(argument_list[5].string_reference,
9844 &image->background_color,exception);
9845 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9846 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9850 case 95: /* ContrastStretch */
9857 white_point=(MagickRealType) image->columns*image->rows;
9858 if (attribute_flag[0] != 0)
9860 flags=ParseGeometry(argument_list[0].string_reference,
9862 black_point=geometry_info.rho;
9863 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9865 if ((flags & PercentValue) != 0)
9867 black_point*=(double) image->columns*image->rows/100.0;
9868 white_point*=(double) image->columns*image->rows/100.0;
9870 white_point=(MagickRealType) image->columns*image->rows-
9873 if (attribute_flag[1] != 0)
9874 black_point=argument_list[1].real_reference;
9875 if (attribute_flag[2] != 0)
9876 white_point=argument_list[2].real_reference;
9877 if (attribute_flag[4] != 0)
9878 channel=(ChannelType) argument_list[4].integer_reference;
9879 (void) ContrastStretchImageChannel(image,channel,black_point,
9883 case 96: /* Sans0 */
9887 case 97: /* Sans1 */
9891 case 98: /* AdaptiveSharpen */
9893 if (attribute_flag[0] != 0)
9895 flags=ParseGeometry(argument_list[0].string_reference,
9897 if ((flags & SigmaValue) == 0)
9898 geometry_info.sigma=1.0;
9900 if (attribute_flag[1] != 0)
9901 geometry_info.rho=argument_list[1].real_reference;
9902 if (attribute_flag[2] != 0)
9903 geometry_info.sigma=argument_list[2].real_reference;
9904 if (attribute_flag[3] != 0)
9905 channel=(ChannelType) argument_list[3].integer_reference;
9906 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9907 geometry_info.sigma,exception);
9910 case 99: /* Transpose */
9912 image=TransposeImage(image,exception);
9915 case 100: /* Tranverse */
9917 image=TransverseImage(image,exception);
9920 case 101: /* AutoOrient */
9922 switch (image->orientation)
9924 case TopRightOrientation:
9926 image=FlopImage(image,exception);
9929 case BottomRightOrientation:
9931 image=RotateImage(image,180.0,exception);
9934 case BottomLeftOrientation:
9936 image=FlipImage(image,exception);
9939 case LeftTopOrientation:
9941 image=TransposeImage(image,exception);
9944 case RightTopOrientation:
9946 image=RotateImage(image,90.0,exception);
9949 case RightBottomOrientation:
9951 image=TransverseImage(image,exception);
9954 case LeftBottomOrientation:
9956 image=RotateImage(image,270.0,exception);
9964 case 102: /* AdaptiveBlur */
9966 if (attribute_flag[0] != 0)
9968 flags=ParseGeometry(argument_list[0].string_reference,
9970 if ((flags & SigmaValue) == 0)
9971 geometry_info.sigma=1.0;
9973 if (attribute_flag[1] != 0)
9974 geometry_info.rho=argument_list[1].real_reference;
9975 if (attribute_flag[2] != 0)
9976 geometry_info.sigma=argument_list[2].real_reference;
9977 if (attribute_flag[3] != 0)
9978 channel=(ChannelType) argument_list[3].integer_reference;
9979 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
9980 geometry_info.sigma,exception);
9983 case 103: /* Sketch */
9985 if (attribute_flag[0] != 0)
9987 flags=ParseGeometry(argument_list[0].string_reference,
9989 if ((flags & SigmaValue) == 0)
9990 geometry_info.sigma=1.0;
9991 if ((flags & XiValue) == 0)
9992 geometry_info.xi=1.0;
9994 if (attribute_flag[1] != 0)
9995 geometry_info.rho=argument_list[1].real_reference;
9996 if (attribute_flag[2] != 0)
9997 geometry_info.sigma=argument_list[2].real_reference;
9998 if (attribute_flag[3] != 0)
9999 geometry_info.xi=argument_list[3].real_reference;
10000 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10001 geometry_info.xi,exception);
10004 case 104: /* UniqueColors */
10006 image=UniqueImageColors(image,exception);
10009 case 105: /* AdaptiveResize */
10011 if (attribute_flag[0] != 0)
10012 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10013 &geometry,exception);
10014 if (attribute_flag[1] != 0)
10015 geometry.width=argument_list[1].integer_reference;
10016 if (attribute_flag[2] != 0)
10017 geometry.height=argument_list[2].integer_reference;
10018 if (attribute_flag[3] != 0)
10019 image->filter=(FilterTypes) argument_list[4].integer_reference;
10020 if (attribute_flag[4] != 0)
10021 SetImageArtifact(image,"filter:support",
10022 argument_list[4].string_reference);
10023 if (attribute_flag[5] != 0)
10024 image->blur=argument_list[5].real_reference;
10025 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10029 case 106: /* ClipMask */
10031 if (attribute_flag[0] == 0)
10033 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10035 goto PerlException;
10037 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10038 MagickTrue,exception);
10039 (void) NegateImage(image->clip_mask,MagickFalse);
10042 case 107: /* LinearStretch */
10049 white_point=(MagickRealType) image->columns*image->rows;
10050 if (attribute_flag[0] != 0)
10052 flags=ParseGeometry(argument_list[0].string_reference,
10054 if ((flags & SigmaValue) != 0)
10055 white_point=geometry_info.sigma;
10056 if ((flags & PercentValue) != 0)
10058 black_point*=(double) image->columns*image->rows/100.0;
10059 white_point*=(double) image->columns*image->rows/100.0;
10061 if ((flags & SigmaValue) == 0)
10062 white_point=(double) image->columns*image->rows-black_point;
10064 if (attribute_flag[1] != 0)
10065 black_point=argument_list[1].real_reference;
10066 if (attribute_flag[2] != 0)
10067 white_point=argument_list[2].real_reference;
10068 (void) LinearStretchImage(image,black_point,white_point);
10071 case 109: /* Mask */
10073 if (attribute_flag[0] == 0)
10075 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10077 goto PerlException;
10079 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10080 MagickTrue,exception);
10081 (void) NegateImage(image->mask,MagickFalse);
10084 case 110: /* Polaroid */
10092 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10093 (DrawInfo *) NULL);
10094 if (attribute_flag[0] != 0)
10095 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10096 info ? info->image_info : (ImageInfo *) NULL,image,
10097 argument_list[0].string_reference));
10099 if (attribute_flag[1] != 0)
10100 angle=argument_list[1].real_reference;
10101 if (attribute_flag[2] != 0)
10102 (void) CloneString(&draw_info->font,
10103 argument_list[2].string_reference);
10104 if (attribute_flag[3] != 0)
10105 (void) QueryColorDatabase(argument_list[3].string_reference,
10106 &draw_info->stroke,exception);
10107 if (attribute_flag[4] != 0)
10108 (void) QueryColorDatabase(argument_list[4].string_reference,
10109 &draw_info->fill,exception);
10110 if (attribute_flag[5] != 0)
10111 draw_info->stroke_width=argument_list[5].real_reference;
10112 if (attribute_flag[6] != 0)
10113 draw_info->pointsize=argument_list[6].real_reference;
10114 if (attribute_flag[7] != 0)
10115 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10116 if (attribute_flag[8] != 0)
10117 (void) QueryColorDatabase(argument_list[8].string_reference,
10118 &image->background_color,exception);
10119 image=PolaroidImage(image,draw_info,angle,exception);
10120 draw_info=DestroyDrawInfo(draw_info);
10123 case 111: /* FloodfillPaint */
10134 draw_info=CloneDrawInfo(info ? info->image_info :
10135 (ImageInfo *) NULL,(DrawInfo *) NULL);
10136 if (attribute_flag[0] != 0)
10137 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10138 &geometry,exception);
10139 if (attribute_flag[1] != 0)
10140 geometry.x=argument_list[1].integer_reference;
10141 if (attribute_flag[2] != 0)
10142 geometry.y=argument_list[2].integer_reference;
10143 if (attribute_flag[3] != 0)
10144 (void) QueryColorDatabase(argument_list[3].string_reference,
10145 &draw_info->fill,exception);
10146 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10148 if (attribute_flag[4] != 0)
10149 QueryMagickColor(argument_list[4].string_reference,&target,
10151 if (attribute_flag[5] != 0)
10152 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10154 if (attribute_flag[6] != 0)
10155 channel=(ChannelType) argument_list[6].integer_reference;
10156 invert=MagickFalse;
10157 if (attribute_flag[7] != 0)
10158 invert=(MagickBooleanType) argument_list[7].integer_reference;
10159 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10160 geometry.y,invert);
10161 draw_info=DestroyDrawInfo(draw_info);
10164 case 112: /* Distort */
10176 number_coordinates;
10181 if (attribute_flag[0] == 0)
10183 method=UndefinedDistortion;
10184 if (attribute_flag[1] != 0)
10185 method=(DistortImageMethod) argument_list[1].integer_reference;
10186 av=(AV *) argument_list[0].array_reference;
10187 number_coordinates=(size_t) av_len(av)+1;
10188 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10189 sizeof(*coordinates));
10190 if (coordinates == (double *) NULL)
10192 ThrowPerlException(exception,ResourceLimitFatalError,
10193 "MemoryAllocationFailed",PackageName);
10194 goto PerlException;
10196 for (j=0; j < (ssize_t) number_coordinates; j++)
10197 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10198 virtual_pixel=UndefinedVirtualPixelMethod;
10199 if (attribute_flag[2] != 0)
10200 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10201 argument_list[2].integer_reference);
10202 image=DistortImage(image,method,number_coordinates,coordinates,
10203 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10205 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10206 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10207 coordinates=(double *) RelinquishMagickMemory(coordinates);
10210 case 113: /* Clut */
10212 if (attribute_flag[0] == 0)
10214 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10216 goto PerlException;
10218 if (attribute_flag[1] != 0)
10219 channel=(ChannelType) argument_list[1].integer_reference;
10220 (void) ClutImageChannel(image,channel,
10221 argument_list[0].image_reference);
10224 case 114: /* LiquidRescale */
10226 if (attribute_flag[0] != 0)
10227 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10228 &geometry,exception);
10229 if (attribute_flag[1] != 0)
10230 geometry.width=argument_list[1].integer_reference;
10231 if (attribute_flag[2] != 0)
10232 geometry.height=argument_list[2].integer_reference;
10233 if (attribute_flag[3] == 0)
10234 argument_list[3].real_reference=1.0;
10235 if (attribute_flag[4] == 0)
10236 argument_list[4].real_reference=0.0;
10237 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10238 argument_list[3].real_reference,argument_list[4].real_reference,
10242 case 115: /* EncipherImage */
10244 (void) EncipherImage(image,argument_list[0].string_reference,
10248 case 116: /* DecipherImage */
10250 (void) DecipherImage(image,argument_list[0].string_reference,
10254 case 117: /* Deskew */
10256 geometry_info.rho=QuantumRange/2.0;
10257 if (attribute_flag[0] != 0)
10258 flags=ParseGeometry(argument_list[0].string_reference,
10260 if (attribute_flag[1] != 0)
10261 geometry_info.rho=SiPrefixToDouble(
10262 argument_list[1].string_reference,QuantumRange);
10263 image=DeskewImage(image,geometry_info.rho,exception);
10266 case 118: /* Remap */
10271 if (attribute_flag[0] == 0)
10273 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10275 goto PerlException;
10277 quantize_info=AcquireQuantizeInfo(info->image_info);
10278 if (attribute_flag[1] != 0)
10279 quantize_info->dither=(MagickBooleanType)
10280 argument_list[1].integer_reference;
10281 if (attribute_flag[2] != 0)
10282 quantize_info->dither_method=(DitherMethod)
10283 argument_list[2].integer_reference;
10284 (void) RemapImages(quantize_info,image,
10285 argument_list[0].image_reference);
10286 quantize_info=DestroyQuantizeInfo(quantize_info);
10289 case 119: /* SparseColor */
10301 number_coordinates;
10306 if (attribute_flag[0] == 0)
10308 method=UndefinedColorInterpolate;
10309 if (attribute_flag[1] != 0)
10310 method=(SparseColorMethod) argument_list[1].integer_reference;
10311 av=(AV *) argument_list[0].array_reference;
10312 number_coordinates=(size_t) av_len(av)+1;
10313 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10314 sizeof(*coordinates));
10315 if (coordinates == (double *) NULL)
10317 ThrowPerlException(exception,ResourceLimitFatalError,
10318 "MemoryAllocationFailed",PackageName);
10319 goto PerlException;
10321 for (j=0; j < (ssize_t) number_coordinates; j++)
10322 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10323 virtual_pixel=UndefinedVirtualPixelMethod;
10324 if (attribute_flag[2] != 0)
10325 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10326 argument_list[2].integer_reference);
10327 if (attribute_flag[3] != 0)
10328 channel=(ChannelType) argument_list[3].integer_reference;
10329 image=SparseColorImage(image,channel,method,number_coordinates,
10330 coordinates,exception);
10331 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10332 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10333 coordinates=(double *) RelinquishMagickMemory(coordinates);
10336 case 120: /* Function */
10353 if (attribute_flag[0] == 0)
10355 function=UndefinedFunction;
10356 if (attribute_flag[1] != 0)
10357 function=(MagickFunction) argument_list[1].integer_reference;
10358 av=(AV *) argument_list[0].array_reference;
10359 number_parameters=(size_t) av_len(av)+1;
10360 parameters=(double *) AcquireQuantumMemory(number_parameters,
10361 sizeof(*parameters));
10362 if (parameters == (double *) NULL)
10364 ThrowPerlException(exception,ResourceLimitFatalError,
10365 "MemoryAllocationFailed",PackageName);
10366 goto PerlException;
10368 for (j=0; j < (ssize_t) number_parameters; j++)
10369 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10370 virtual_pixel=UndefinedVirtualPixelMethod;
10371 if (attribute_flag[2] != 0)
10372 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10373 argument_list[2].integer_reference);
10374 (void) FunctionImage(image,function,number_parameters,parameters,
10376 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10377 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10378 parameters=(double *) RelinquishMagickMemory(parameters);
10381 case 121: /* SelectiveBlur */
10383 if (attribute_flag[0] != 0)
10385 flags=ParseGeometry(argument_list[0].string_reference,
10387 if ((flags & SigmaValue) == 0)
10388 geometry_info.sigma=1.0;
10389 if ((flags & PercentValue) != 0)
10390 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10392 if (attribute_flag[1] != 0)
10393 geometry_info.rho=argument_list[1].real_reference;
10394 if (attribute_flag[2] != 0)
10395 geometry_info.sigma=argument_list[2].real_reference;
10396 if (attribute_flag[3] != 0)
10397 geometry_info.xi=argument_list[3].integer_reference;;
10398 if (attribute_flag[4] != 0)
10399 channel=(ChannelType) argument_list[4].integer_reference;
10400 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10401 geometry_info.sigma,geometry_info.xi,exception);
10404 case 122: /* HaldClut */
10406 if (attribute_flag[0] == 0)
10408 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10410 goto PerlException;
10412 if (attribute_flag[1] != 0)
10413 channel=(ChannelType) argument_list[1].integer_reference;
10414 (void) HaldClutImageChannel(image,channel,
10415 argument_list[0].image_reference);
10418 case 123: /* BlueShift */
10420 if (attribute_flag[0] != 0)
10421 (void) ParseGeometry(argument_list[0].string_reference,
10423 image=BlueShiftImage(image,geometry_info.rho,exception);
10426 case 124: /* ForwardFourierTransformImage */
10428 image=ForwardFourierTransformImage(image,
10429 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10433 case 125: /* InverseFourierTransformImage */
10435 image=InverseFourierTransformImage(image,image->next,
10436 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10440 case 126: /* ColorDecisionList */
10442 if (attribute_flag[0] == 0)
10443 argument_list[0].string_reference=(char *) NULL;
10444 (void) ColorDecisionListImage(image,
10445 argument_list[0].string_reference);
10448 case 127: /* AutoGamma */
10450 if (attribute_flag[0] != 0)
10451 channel=(ChannelType) argument_list[0].integer_reference;
10452 (void) AutoGammaImageChannel(image,channel);
10455 case 128: /* AutoLevel */
10457 if (attribute_flag[0] != 0)
10458 channel=(ChannelType) argument_list[0].integer_reference;
10459 (void) AutoLevelImageChannel(image,channel);
10462 case 129: /* LevelColors */
10468 (void) QueryMagickColor("#000000",&black_point,exception);
10469 (void) QueryMagickColor("#ffffff",&white_point,exception);
10470 if (attribute_flag[1] != 0)
10471 (void) QueryMagickColor(argument_list[1].string_reference,
10472 &black_point,exception);
10473 if (attribute_flag[2] != 0)
10474 (void) QueryMagickColor(argument_list[2].string_reference,
10475 &white_point,exception);
10476 if (attribute_flag[3] != 0)
10477 channel=(ChannelType) argument_list[3].integer_reference;
10478 (void) LevelColorsImageChannel(image,channel,&black_point,
10479 &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
10483 case 130: /* Clamp */
10485 if (attribute_flag[0] != 0)
10486 channel=(ChannelType) argument_list[0].integer_reference;
10487 (void) ClampImageChannel(image,channel);
10490 case 131: /* Filter */
10495 if (attribute_flag[0] == 0)
10497 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10498 if (kernel == (KernelInfo *) NULL)
10500 if (attribute_flag[1] != 0)
10501 channel=(ChannelType) argument_list[1].integer_reference;
10502 if (attribute_flag[2] != 0)
10503 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10505 image=FilterImageChannel(image,channel,kernel,exception);
10506 kernel=DestroyKernelInfo(kernel);
10509 case 132: /* BrightnessContrast */
10517 if (attribute_flag[0] != 0)
10519 flags=ParseGeometry(argument_list[0].string_reference,
10521 brightness=geometry_info.rho;
10522 if ((flags & SigmaValue) == 0)
10523 contrast=geometry_info.sigma;
10525 if (attribute_flag[1] != 0)
10526 brightness=argument_list[1].real_reference;
10527 if (attribute_flag[2] != 0)
10528 contrast=argument_list[2].real_reference;
10529 if (attribute_flag[4] != 0)
10530 channel=(ChannelType) argument_list[4].integer_reference;
10531 (void) BrightnessContrastImageChannel(image,channel,brightness,
10535 case 133: /* Morphology */
10546 if (attribute_flag[0] == 0)
10548 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10549 if (kernel == (KernelInfo *) NULL)
10551 if (attribute_flag[1] != 0)
10552 channel=(ChannelType) argument_list[1].integer_reference;
10553 method=UndefinedMorphology;
10554 if (attribute_flag[2] != 0)
10555 method=argument_list[2].integer_reference;
10557 if (attribute_flag[3] != 0)
10558 iterations=argument_list[4].integer_reference;
10559 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10561 kernel=DestroyKernelInfo(kernel);
10564 case 108: /* Recolor */
10565 case 134: /* ColorMatrix */
10579 if (attribute_flag[0] == 0)
10581 av=(AV *) argument_list[0].array_reference;
10582 order=(size_t) sqrt(av_len(av)+1);
10583 color_matrix=(double *) AcquireQuantumMemory(order,order*
10584 sizeof(*color_matrix));
10585 if (color_matrix == (double *) NULL)
10587 ThrowPerlException(exception,ResourceLimitFatalError,
10588 "MemoryAllocationFailed",PackageName);
10589 goto PerlException;
10591 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10592 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10593 for ( ; j < (ssize_t) (order*order); j++)
10594 color_matrix[j]=0.0;
10595 kernel_info=AcquireKernelInfo("1");
10596 if (kernel_info == (KernelInfo *) NULL)
10598 kernel_info->width=order;
10599 kernel_info->height=order;
10600 kernel_info->values=color_matrix;
10601 image=ColorMatrixImage(image,kernel_info,exception);
10602 kernel_info->values=(double *) NULL;
10603 kernel_info=DestroyKernelInfo(kernel_info);
10604 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10607 case 135: /* Color */
10612 (void) QueryMagickColor("none",&color,exception);
10613 if (attribute_flag[0] != 0)
10614 (void) QueryMagickColor(argument_list[0].string_reference,
10616 (void) SetImageColor(image,&color);
10619 case 136: /* Mode */
10621 if (attribute_flag[0] != 0)
10623 flags=ParseGeometry(argument_list[0].string_reference,
10625 if ((flags & SigmaValue) == 0)
10626 geometry_info.sigma=1.0;
10628 if (attribute_flag[1] != 0)
10629 geometry_info.rho=argument_list[1].real_reference;
10630 if (attribute_flag[2] != 0)
10631 geometry_info.sigma=argument_list[2].real_reference;
10632 if (attribute_flag[3] != 0)
10633 channel=(ChannelType) argument_list[3].integer_reference;
10634 image=StatisticImageChannel(image,channel,ModeStatistic,
10635 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10638 case 137: /* Statistic */
10643 statistic=UndefinedStatistic;
10644 if (attribute_flag[0] != 0)
10646 flags=ParseGeometry(argument_list[0].string_reference,
10648 if ((flags & SigmaValue) == 0)
10649 geometry_info.sigma=1.0;
10651 if (attribute_flag[1] != 0)
10652 geometry_info.rho=argument_list[1].real_reference;
10653 if (attribute_flag[2] != 0)
10654 geometry_info.sigma=argument_list[2].real_reference;
10655 if (attribute_flag[3] != 0)
10656 channel=(ChannelType) argument_list[3].integer_reference;
10657 if (attribute_flag[4] != 0)
10658 statistic=(StatisticType) argument_list[4].integer_reference;
10659 image=StatisticImageChannel(image,channel,statistic,
10660 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10664 if (next != (Image *) NULL)
10665 (void) CatchImageException(next);
10666 if (region_image != (Image *) NULL)
10671 status=CompositeImage(region_image,CopyCompositeOp,image,
10672 region_info.x,region_info.y);
10674 (void) CatchImageException(region_image);
10675 image=DestroyImage(image);
10676 image=region_image;
10678 if (image != (Image *) NULL)
10681 if (next && (next != image))
10683 image->next=next->next;
10684 DeleteImageFromRegistry(*pv,next);
10686 sv_setiv(*pv,(IV) image);
10694 if (reference_vector)
10695 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10696 InheritPerlException(exception,perl_exception);
10697 exception=DestroyExceptionInfo(exception);
10698 sv_setiv(perl_exception,(IV) number_images);
10699 SvPOK_on(perl_exception);
10700 ST(0)=sv_2mortal(perl_exception);
10705 ###############################################################################
10713 ###############################################################################
10718 Image::Magick ref=NO_INIT
10763 PERL_UNUSED_VAR(ref);
10764 PERL_UNUSED_VAR(ix);
10765 exception=AcquireExceptionInfo();
10766 perl_exception=newSVpv("",0);
10769 if (sv_isobject(ST(0)) == 0)
10771 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10773 goto PerlException;
10775 reference=SvRV(ST(0));
10776 hv=SvSTASH(reference);
10778 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10780 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10781 if (image == (Image *) NULL)
10783 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10785 goto PerlException;
10790 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10791 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10792 (void) QueryMagickColor("none",&transparent_color,exception);
10793 for (i=2; i < items; i+=2)
10795 attribute=(char *) SvPV(ST(i-1),na);
10796 switch (*attribute)
10801 if (LocaleCompare(attribute,"background") == 0)
10803 (void) QueryColorDatabase(SvPV(ST(i),na),
10804 &montage_info->background_color,exception);
10805 for (next=image; next; next=next->next)
10806 next->background_color=montage_info->background_color;
10809 if (LocaleCompare(attribute,"border") == 0)
10811 montage_info->border_width=SvIV(ST(i));
10814 if (LocaleCompare(attribute,"bordercolor") == 0)
10816 (void) QueryColorDatabase(SvPV(ST(i),na),
10817 &montage_info->border_color,exception);
10818 for (next=image; next; next=next->next)
10819 next->border_color=montage_info->border_color;
10822 if (LocaleCompare(attribute,"borderwidth") == 0)
10824 montage_info->border_width=SvIV(ST(i));
10827 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10834 if (LocaleCompare(attribute,"compose") == 0)
10836 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10837 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10840 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10844 for (next=image; next; next=next->next)
10845 next->compose=(CompositeOperator) sp;
10848 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10855 if (LocaleCompare(attribute,"fill") == 0)
10857 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10861 if (LocaleCompare(attribute,"font") == 0)
10863 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10866 if (LocaleCompare(attribute,"frame") == 0)
10872 if (IsGeometry(p) == MagickFalse)
10874 ThrowPerlException(exception,OptionError,"MissingGeometry",
10878 (void) CloneString(&montage_info->frame,p);
10880 montage_info->frame=(char *) NULL;
10883 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10890 if (LocaleCompare(attribute,"geometry") == 0)
10896 if (IsGeometry(p) == MagickFalse)
10898 ThrowPerlException(exception,OptionError,"MissingGeometry",
10902 (void) CloneString(&montage_info->geometry,p);
10904 montage_info->geometry=(char *) NULL;
10907 if (LocaleCompare(attribute,"gravity") == 0)
10912 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10913 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10916 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10920 montage_info->gravity=(GravityType) in;
10921 for (next=image; next; next=next->next)
10922 next->gravity=(GravityType) in;
10925 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10932 if (LocaleCompare(attribute,"label") == 0)
10934 for (next=image; next; next=next->next)
10935 (void) SetImageProperty(next,"label",InterpretImageProperties(
10936 info ? info->image_info : (ImageInfo *) NULL,next,
10940 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10947 if (LocaleCompare(attribute,"mattecolor") == 0)
10949 (void) QueryColorDatabase(SvPV(ST(i),na),
10950 &montage_info->matte_color,exception);
10951 for (next=image; next; next=next->next)
10952 next->matte_color=montage_info->matte_color;
10955 if (LocaleCompare(attribute,"mode") == 0)
10960 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10961 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10966 ThrowPerlException(exception,OptionError,
10967 "UnrecognizedModeType",SvPV(ST(i),na));
10972 (void) CloneString(&montage_info->frame,"15x15+3+3");
10973 montage_info->shadow=MagickTrue;
10978 montage_info->frame=(char *) NULL;
10979 montage_info->shadow=MagickFalse;
10980 montage_info->border_width=0;
10983 case ConcatenateMode:
10985 montage_info->frame=(char *) NULL;
10986 montage_info->shadow=MagickFalse;
10987 (void) CloneString(&montage_info->geometry,"+0+0");
10988 montage_info->border_width=0;
10993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11000 if (LocaleCompare(attribute,"pointsize") == 0)
11002 montage_info->pointsize=SvIV(ST(i));
11005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11012 if (LocaleCompare(attribute,"shadow") == 0)
11014 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11015 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11018 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11022 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11025 if (LocaleCompare(attribute,"stroke") == 0)
11027 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11031 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11038 if (LocaleCompare(attribute,"texture") == 0)
11040 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11043 if (LocaleCompare(attribute,"tile") == 0)
11045 char *p=SvPV(ST(i),na);
11046 if (IsGeometry(p) == MagickFalse)
11048 ThrowPerlException(exception,OptionError,"MissingGeometry",
11052 (void) CloneString(&montage_info->tile,p);
11054 montage_info->tile=(char *) NULL;
11057 if (LocaleCompare(attribute,"title") == 0)
11059 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11062 if (LocaleCompare(attribute,"transparent") == 0)
11067 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11068 for (next=image; next; next=next->next)
11069 (void) TransparentPaintImage(next,&transparent_color,
11070 TransparentOpacity,MagickFalse);
11073 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11079 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11085 image=MontageImageList(info->image_info,montage_info,image,exception);
11086 montage_info=DestroyMontageInfo(montage_info);
11087 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11088 goto PerlException;
11089 if (transparent_color.opacity != TransparentOpacity)
11090 for (next=image; next; next=next->next)
11091 (void) TransparentPaintImage(next,&transparent_color,
11092 TransparentOpacity,MagickFalse);
11093 for ( ; image; image=image->next)
11095 AddImageToRegistry(sv,image);
11097 av_push(av,sv_bless(rv,hv));
11100 exception=DestroyExceptionInfo(exception);
11101 ST(0)=av_reference;
11102 SvREFCNT_dec(perl_exception);
11106 InheritPerlException(exception,perl_exception);
11107 exception=DestroyExceptionInfo(exception);
11108 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11109 SvPOK_on(perl_exception);
11110 ST(0)=sv_2mortal(perl_exception);
11115 ###############################################################################
11123 ###############################################################################
11128 Image::Magick ref=NO_INIT
11166 PERL_UNUSED_VAR(ref);
11167 PERL_UNUSED_VAR(ix);
11168 exception=AcquireExceptionInfo();
11169 perl_exception=newSVpv("",0);
11173 if (sv_isobject(ST(0)) == 0)
11175 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11177 goto PerlException;
11179 reference=SvRV(ST(0));
11180 hv=SvSTASH(reference);
11182 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11184 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11185 if (image == (Image *) NULL)
11187 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11189 goto PerlException;
11191 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11196 for (i=2; i < items; i+=2)
11198 attribute=(char *) SvPV(ST(i-1),na);
11199 switch (*attribute)
11204 if (LocaleCompare(attribute,"frames") == 0)
11206 number_frames=SvIV(ST(i));
11209 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11221 image=MorphImages(image,number_frames,exception);
11222 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11223 goto PerlException;
11224 for ( ; image; image=image->next)
11226 AddImageToRegistry(sv,image);
11228 av_push(av,sv_bless(rv,hv));
11231 exception=DestroyExceptionInfo(exception);
11232 ST(0)=av_reference;
11233 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11237 InheritPerlException(exception,perl_exception);
11238 exception=DestroyExceptionInfo(exception);
11239 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11240 SvPOK_on(perl_exception);
11241 ST(0)=sv_2mortal(perl_exception);
11246 ###############################################################################
11254 ###############################################################################
11259 Image::Magick ref=NO_INIT
11287 PERL_UNUSED_VAR(ref);
11288 PERL_UNUSED_VAR(ix);
11289 exception=AcquireExceptionInfo();
11290 perl_exception=newSVpv("",0);
11292 if (sv_isobject(ST(0)) == 0)
11294 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11296 goto PerlException;
11298 reference=SvRV(ST(0));
11299 hv=SvSTASH(reference);
11300 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11301 if (image == (Image *) NULL)
11303 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11305 goto PerlException;
11307 image=MergeImageLayers(image,MosaicLayer,exception);
11309 Create blessed Perl array for the returned image.
11312 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11314 AddImageToRegistry(sv,image);
11316 av_push(av,sv_bless(rv,hv));
11318 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11319 (void) CopyMagickString(image->filename,info->image_info->filename,
11321 SetImageInfo(info->image_info,0,&image->exception);
11322 exception=DestroyExceptionInfo(exception);
11323 SvREFCNT_dec(perl_exception);
11327 InheritPerlException(exception,perl_exception);
11328 exception=DestroyExceptionInfo(exception);
11329 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11330 SvPOK_on(perl_exception); /* return messages in string context */
11331 ST(0)=sv_2mortal(perl_exception);
11336 ###############################################################################
11344 ###############################################################################
11349 Image::Magick ref=NO_INIT
11399 PERL_UNUSED_VAR(ref);
11400 PERL_UNUSED_VAR(ix);
11401 exception=AcquireExceptionInfo();
11402 perl_exception=newSVpv("",0);
11403 package_info=(struct PackageInfo *) NULL;
11404 ac=(items < 2) ? 1 : items-1;
11405 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11407 length=(STRLEN *) NULL;
11408 if (list == (char **) NULL)
11410 ThrowPerlException(exception,ResourceLimitError,
11411 "MemoryAllocationFailed",PackageName);
11412 goto PerlException;
11415 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11416 if (length == (STRLEN *) NULL)
11418 ThrowPerlException(exception,ResourceLimitError,
11419 "MemoryAllocationFailed",PackageName);
11420 goto PerlException;
11422 if (sv_isobject(ST(0)) == 0)
11424 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11426 goto PerlException;
11428 reference=SvRV(ST(0));
11429 if (SvTYPE(reference) != SVt_PVAV)
11431 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11433 goto PerlException;
11435 av=(AV *) reference;
11436 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11438 package_info=ClonePackageInfo(info,exception);
11441 *list=(char *) (*package_info->image_info->filename ?
11442 package_info->image_info->filename : "XC:black");
11444 for (n=0, i=0; i < ac; i++)
11446 list[n]=(char *) SvPV(ST(i+1),length[n]);
11447 if ((items >= 3) && strEQcase(list[n],"blob"))
11453 blob=(void *) (SvPV(ST(i+1),length[n]));
11454 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11456 if ((items >= 3) && strEQcase(list[n],"filename"))
11458 if ((items >= 3) && strEQcase(list[n],"file"))
11467 io_info=IoIFP(sv_2io(ST(i+1)));
11468 if (io_info == (PerlIO *) NULL)
11470 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11474 file=PerlIO_findFILE(io_info);
11475 if (file == (FILE *) NULL)
11477 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11481 SetImageInfoFile(package_info->image_info,file);
11483 if ((items >= 3) && strEQcase(list[n],"magick"))
11487 list[n]=(char *) NULL;
11489 status=ExpandFilenames(&n,&list);
11490 if (status == MagickFalse)
11492 ThrowPerlException(exception,ResourceLimitError,
11493 "MemoryAllocationFailed",PackageName);
11494 goto PerlException;
11497 for (i=0; i < n; i++)
11499 (void) CopyMagickString(package_info->image_info->filename,list[i],
11501 image=PingImage(package_info->image_info,exception);
11502 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11504 if ((package_info->image_info->file != (FILE *) NULL) ||
11505 (package_info->image_info->blob != (void *) NULL))
11506 DisassociateImageStream(image);
11507 count+=GetImageListLength(image);
11508 EXTEND(sp,4*count);
11509 for (next=image; next; next=next->next)
11511 PUSHs(sv_2mortal(newSViv(next->columns)));
11512 PUSHs(sv_2mortal(newSViv(next->rows)));
11513 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11514 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11516 image=DestroyImageList(image);
11521 for (i=0; i < n; i++)
11522 if (list[i] != (char *) NULL)
11523 for (p=keep; list[i] != *p++; )
11526 list[i]=(char *) RelinquishMagickMemory(list[i]);
11531 if (package_info != (struct PackageInfo *) NULL)
11532 DestroyPackageInfo(package_info);
11533 if (list && (list != keep))
11534 list=(char **) RelinquishMagickMemory(list);
11536 keep=(char **) RelinquishMagickMemory(keep);
11538 length=(STRLEN *) RelinquishMagickMemory(length);
11539 InheritPerlException(exception,perl_exception);
11540 exception=DestroyExceptionInfo(exception);
11541 SvREFCNT_dec(perl_exception); /* throw away all errors */
11545 ###############################################################################
11553 ###############################################################################
11558 Image::Magick ref=NO_INIT
11591 PERL_UNUSED_VAR(ref);
11592 PERL_UNUSED_VAR(ix);
11593 exception=AcquireExceptionInfo();
11594 perl_exception=newSVpv("",0);
11597 if (sv_isobject(ST(0)) == 0)
11599 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11601 goto PerlException;
11603 reference=SvRV(ST(0));
11604 hv=SvSTASH(reference);
11606 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11608 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11609 if (image == (Image *) NULL)
11611 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11613 goto PerlException;
11615 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11616 preview_type=GammaPreview;
11618 preview_type=(PreviewType)
11619 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11620 for ( ; image; image=image->next)
11622 preview_image=PreviewImage(image,preview_type,exception);
11623 if (preview_image == (Image *) NULL)
11624 goto PerlException;
11625 AddImageToRegistry(sv,preview_image);
11627 av_push(av,sv_bless(rv,hv));
11630 exception=DestroyExceptionInfo(exception);
11631 ST(0)=av_reference;
11632 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11636 InheritPerlException(exception,perl_exception);
11637 exception=DestroyExceptionInfo(exception);
11638 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11639 SvPOK_on(perl_exception);
11640 ST(0)=sv_2mortal(perl_exception);
11645 ###############################################################################
11649 # Q u e r y C o l o r #
11653 ###############################################################################
11657 QueryColor(ref,...)
11658 Image::Magick ref=NO_INIT
11678 PERL_UNUSED_VAR(ref);
11679 PERL_UNUSED_VAR(ix);
11680 exception=AcquireExceptionInfo();
11681 perl_exception=newSVpv("",0);
11690 colorlist=GetColorInfoList("*",&colors,exception);
11692 for (i=0; i < (ssize_t) colors; i++)
11694 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11696 colorlist=(const ColorInfo **)
11697 RelinquishMagickMemory((ColorInfo **) colorlist);
11698 goto PerlException;
11700 EXTEND(sp,5*items);
11701 for (i=1; i < items; i++)
11703 name=(char *) SvPV(ST(i),na);
11704 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11709 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11710 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11711 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11712 if (color.matte != MagickFalse)
11713 PUSHs(sv_2mortal(newSViv((size_t) floor(color.opacity+0.5))));
11714 if (color.colorspace == CMYKColorspace)
11715 PUSHs(sv_2mortal(newSViv((size_t) floor(color.index+0.5))));
11719 InheritPerlException(exception,perl_exception);
11720 exception=DestroyExceptionInfo(exception);
11721 SvREFCNT_dec(perl_exception);
11725 ###############################################################################
11729 # Q u e r y C o l o r N a m e #
11733 ###############################################################################
11737 QueryColorname(ref,...)
11738 Image::Magick ref=NO_INIT
11747 message[MaxTextExtent];
11766 *reference; /* reference is the SV* of ref=SvIV(reference) */
11768 PERL_UNUSED_VAR(ref);
11769 PERL_UNUSED_VAR(ix);
11770 exception=AcquireExceptionInfo();
11771 perl_exception=newSVpv("",0);
11772 reference=SvRV(ST(0));
11773 av=(AV *) reference;
11774 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11776 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11777 if (image == (Image *) NULL)
11779 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11781 goto PerlException;
11784 for (i=1; i < items; i++)
11786 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11787 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11789 PUSHs(sv_2mortal(newSVpv(message,0)));
11793 InheritPerlException(exception,perl_exception);
11794 exception=DestroyExceptionInfo(exception);
11795 SvREFCNT_dec(perl_exception);
11799 ###############################################################################
11803 # Q u e r y F o n t #
11807 ###############################################################################
11812 Image::Magick ref=NO_INIT
11819 message[MaxTextExtent];
11830 volatile const TypeInfo
11833 PERL_UNUSED_VAR(ref);
11834 PERL_UNUSED_VAR(ix);
11835 exception=AcquireExceptionInfo();
11836 perl_exception=newSVpv("",0);
11845 typelist=GetTypeInfoList("*",&types,exception);
11847 for (i=0; i < (ssize_t) types; i++)
11849 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11851 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11853 goto PerlException;
11855 EXTEND(sp,10*items);
11856 for (i=1; i < items; i++)
11858 name=(char *) SvPV(ST(i),na);
11859 type_info=GetTypeInfo(name,exception);
11860 if (type_info == (TypeInfo *) NULL)
11865 if (type_info->name == (char *) NULL)
11868 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11869 if (type_info->description == (char *) NULL)
11872 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11873 if (type_info->family == (char *) NULL)
11876 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11877 if (type_info->style == UndefinedStyle)
11880 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11881 type_info->style),0)));
11882 if (type_info->stretch == UndefinedStretch)
11885 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11886 type_info->stretch),0)));
11887 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11888 type_info->weight);
11889 PUSHs(sv_2mortal(newSVpv(message,0)));
11890 if (type_info->encoding == (char *) NULL)
11893 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11894 if (type_info->foundry == (char *) NULL)
11897 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11898 if (type_info->format == (char *) NULL)
11901 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11902 if (type_info->metrics == (char *) NULL)
11905 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11906 if (type_info->glyphs == (char *) NULL)
11909 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11913 InheritPerlException(exception,perl_exception);
11914 exception=DestroyExceptionInfo(exception);
11915 SvREFCNT_dec(perl_exception);
11919 ###############################################################################
11923 # Q u e r y F o n t M e t r i c s #
11927 ###############################################################################
11931 QueryFontMetrics(ref,...)
11932 Image::Magick ref=NO_INIT
11934 queryfontmetrics = 1
11981 *reference; /* reference is the SV* of ref=SvIV(reference) */
11986 PERL_UNUSED_VAR(ref);
11987 PERL_UNUSED_VAR(ix);
11988 exception=AcquireExceptionInfo();
11989 package_info=(struct PackageInfo *) NULL;
11990 perl_exception=newSVpv("",0);
11991 reference=SvRV(ST(0));
11992 av=(AV *) reference;
11993 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11995 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11996 if (image == (Image *) NULL)
11998 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12000 goto PerlException;
12002 package_info=ClonePackageInfo(info,exception);
12003 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12004 CloneString(&draw_info->text,"");
12005 current=draw_info->affine;
12006 GetAffineMatrix(&affine);
12009 EXTEND(sp,7*items);
12010 for (i=2; i < items; i+=2)
12012 attribute=(char *) SvPV(ST(i-1),na);
12013 switch (*attribute)
12018 if (LocaleCompare(attribute,"antialias") == 0)
12020 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12024 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12028 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12031 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12038 if (LocaleCompare(attribute,"density") == 0)
12040 CloneString(&draw_info->density,SvPV(ST(i),na));
12043 if (LocaleCompare(attribute,"direction") == 0)
12045 draw_info->direction=(DirectionType) ParseCommandOption(
12046 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12049 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12056 if (LocaleCompare(attribute,"encoding") == 0)
12058 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12061 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12068 if (LocaleCompare(attribute,"family") == 0)
12070 CloneString(&draw_info->family,SvPV(ST(i),na));
12073 if (LocaleCompare(attribute,"fill") == 0)
12076 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12077 &image->exception);
12080 if (LocaleCompare(attribute,"font") == 0)
12082 CloneString(&draw_info->font,SvPV(ST(i),na));
12085 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12092 if (LocaleCompare(attribute,"geometry") == 0)
12094 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12097 if (LocaleCompare(attribute,"gravity") == 0)
12099 draw_info->gravity=(GravityType) ParseCommandOption(
12100 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12103 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12110 if (LocaleCompare(attribute,"interline-spacing") == 0)
12112 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12113 draw_info->interline_spacing=geometry_info.rho;
12116 if (LocaleCompare(attribute,"interword-spacing") == 0)
12118 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12119 draw_info->interword_spacing=geometry_info.rho;
12122 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12129 if (LocaleCompare(attribute,"kerning") == 0)
12131 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12132 draw_info->kerning=geometry_info.rho;
12135 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12142 if (LocaleCompare(attribute,"pointsize") == 0)
12144 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12145 draw_info->pointsize=geometry_info.rho;
12148 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12155 if (LocaleCompare(attribute,"rotate") == 0)
12157 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12158 affine.rx=geometry_info.rho;
12159 affine.ry=geometry_info.sigma;
12160 if ((flags & SigmaValue) == 0)
12161 affine.ry=affine.rx;
12164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12171 if (LocaleCompare(attribute,"scale") == 0)
12173 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12174 affine.sx=geometry_info.rho;
12175 affine.sy=geometry_info.sigma;
12176 if ((flags & SigmaValue) == 0)
12177 affine.sy=affine.sx;
12180 if (LocaleCompare(attribute,"skew") == 0)
12186 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12187 x_angle=geometry_info.rho;
12188 y_angle=geometry_info.sigma;
12189 if ((flags & SigmaValue) == 0)
12191 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12192 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12195 if (LocaleCompare(attribute,"stroke") == 0)
12198 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12199 &image->exception);
12202 if (LocaleCompare(attribute,"style") == 0)
12204 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12208 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12212 draw_info->style=(StyleType) type;
12215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12222 if (LocaleCompare(attribute,"text") == 0)
12224 CloneString(&draw_info->text,SvPV(ST(i),na));
12227 if (LocaleCompare(attribute,"translate") == 0)
12229 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12230 affine.tx=geometry_info.rho;
12231 affine.ty=geometry_info.sigma;
12232 if ((flags & SigmaValue) == 0)
12233 affine.ty=affine.tx;
12236 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12243 if (LocaleCompare(attribute,"weight") == 0)
12245 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12246 draw_info->weight=(size_t) geometry_info.rho;
12249 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12256 if (LocaleCompare(attribute,"x") == 0)
12258 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12259 x=geometry_info.rho;
12262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12269 if (LocaleCompare(attribute,"y") == 0)
12271 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12272 y=geometry_info.rho;
12275 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12281 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12287 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12288 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12289 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12290 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12291 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12292 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12293 if (draw_info->geometry == (char *) NULL)
12295 draw_info->geometry=AcquireString((char *) NULL);
12296 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12297 "%.15g,%.15g",x,y);
12299 status=GetTypeMetrics(image,draw_info,&metrics);
12300 (void) CatchImageException(image);
12301 if (status == MagickFalse)
12305 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12306 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12307 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12308 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12309 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12310 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12311 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12312 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12313 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12314 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12315 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12316 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12317 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12319 draw_info=DestroyDrawInfo(draw_info);
12322 if (package_info != (struct PackageInfo *) NULL)
12323 DestroyPackageInfo(package_info);
12324 InheritPerlException(exception,perl_exception);
12325 exception=DestroyExceptionInfo(exception);
12326 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12330 ###############################################################################
12334 # 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 #
12338 ###############################################################################
12342 QueryMultilineFontMetrics(ref,...)
12343 Image::Magick ref=NO_INIT
12345 querymultilinefontmetrics = 1
12392 *reference; /* reference is the SV* of ref=SvIV(reference) */
12397 PERL_UNUSED_VAR(ref);
12398 PERL_UNUSED_VAR(ix);
12399 exception=AcquireExceptionInfo();
12400 package_info=(struct PackageInfo *) NULL;
12401 perl_exception=newSVpv("",0);
12402 reference=SvRV(ST(0));
12403 av=(AV *) reference;
12404 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12406 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12407 if (image == (Image *) NULL)
12409 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12411 goto PerlException;
12413 package_info=ClonePackageInfo(info,exception);
12414 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12415 CloneString(&draw_info->text,"");
12416 current=draw_info->affine;
12417 GetAffineMatrix(&affine);
12420 EXTEND(sp,7*items);
12421 for (i=2; i < items; i+=2)
12423 attribute=(char *) SvPV(ST(i-1),na);
12424 switch (*attribute)
12429 if (LocaleCompare(attribute,"antialias") == 0)
12431 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12435 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12439 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12442 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12449 if (LocaleCompare(attribute,"density") == 0)
12451 CloneString(&draw_info->density,SvPV(ST(i),na));
12454 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12461 if (LocaleCompare(attribute,"encoding") == 0)
12463 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12473 if (LocaleCompare(attribute,"family") == 0)
12475 CloneString(&draw_info->family,SvPV(ST(i),na));
12478 if (LocaleCompare(attribute,"fill") == 0)
12481 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12482 &image->exception);
12485 if (LocaleCompare(attribute,"font") == 0)
12487 CloneString(&draw_info->font,SvPV(ST(i),na));
12490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12497 if (LocaleCompare(attribute,"geometry") == 0)
12499 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12502 if (LocaleCompare(attribute,"gravity") == 0)
12504 draw_info->gravity=(GravityType) ParseCommandOption(
12505 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12508 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12515 if (LocaleCompare(attribute,"pointsize") == 0)
12517 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12518 draw_info->pointsize=geometry_info.rho;
12521 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12528 if (LocaleCompare(attribute,"rotate") == 0)
12530 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12531 affine.rx=geometry_info.rho;
12532 affine.ry=geometry_info.sigma;
12533 if ((flags & SigmaValue) == 0)
12534 affine.ry=affine.rx;
12537 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12544 if (LocaleCompare(attribute,"scale") == 0)
12546 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12547 affine.sx=geometry_info.rho;
12548 affine.sy=geometry_info.sigma;
12549 if ((flags & SigmaValue) == 0)
12550 affine.sy=affine.sx;
12553 if (LocaleCompare(attribute,"skew") == 0)
12559 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12560 x_angle=geometry_info.rho;
12561 y_angle=geometry_info.sigma;
12562 if ((flags & SigmaValue) == 0)
12564 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12565 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12568 if (LocaleCompare(attribute,"stroke") == 0)
12571 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12572 &image->exception);
12575 if (LocaleCompare(attribute,"style") == 0)
12577 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12581 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12585 draw_info->style=(StyleType) type;
12588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12595 if (LocaleCompare(attribute,"text") == 0)
12597 CloneString(&draw_info->text,SvPV(ST(i),na));
12600 if (LocaleCompare(attribute,"translate") == 0)
12602 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12603 affine.tx=geometry_info.rho;
12604 affine.ty=geometry_info.sigma;
12605 if ((flags & SigmaValue) == 0)
12606 affine.ty=affine.tx;
12609 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12616 if (LocaleCompare(attribute,"weight") == 0)
12618 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12619 draw_info->weight=(size_t) geometry_info.rho;
12622 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12629 if (LocaleCompare(attribute,"x") == 0)
12631 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12632 x=geometry_info.rho;
12635 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12642 if (LocaleCompare(attribute,"y") == 0)
12644 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12645 y=geometry_info.rho;
12648 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12654 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12660 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12661 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12662 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12663 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12664 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12665 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12666 if (draw_info->geometry == (char *) NULL)
12668 draw_info->geometry=AcquireString((char *) NULL);
12669 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12670 "%.15g,%.15g",x,y);
12672 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12673 (void) CatchImageException(image);
12674 if (status == MagickFalse)
12678 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12679 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12680 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12681 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12682 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12683 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12684 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12685 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12686 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12687 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12688 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12689 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12690 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12692 draw_info=DestroyDrawInfo(draw_info);
12695 if (package_info != (struct PackageInfo *) NULL)
12696 DestroyPackageInfo(package_info);
12697 InheritPerlException(exception,perl_exception);
12698 exception=DestroyExceptionInfo(exception);
12699 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12703 ###############################################################################
12707 # Q u e r y F o r m a t #
12711 ###############################################################################
12715 QueryFormat(ref,...)
12716 Image::Magick ref=NO_INIT
12733 volatile const MagickInfo
12736 PERL_UNUSED_VAR(ref);
12737 PERL_UNUSED_VAR(ix);
12738 exception=AcquireExceptionInfo();
12739 perl_exception=newSVpv("",0);
12743 format[MaxTextExtent];
12751 format_list=GetMagickInfoList("*",&types,exception);
12753 for (i=0; i < (ssize_t) types; i++)
12755 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12756 LocaleLower(format);
12757 PUSHs(sv_2mortal(newSVpv(format,0)));
12759 format_list=(const MagickInfo **)
12760 RelinquishMagickMemory((MagickInfo *) format_list);
12761 goto PerlException;
12763 EXTEND(sp,8*items);
12764 for (i=1; i < items; i++)
12766 name=(char *) SvPV(ST(i),na);
12767 magick_info=GetMagickInfo(name,exception);
12768 if (magick_info == (const MagickInfo *) NULL)
12773 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12774 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12775 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12776 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12777 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12778 if (magick_info->description == (char *) NULL)
12781 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12782 if (magick_info->module == (char *) NULL)
12785 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12789 InheritPerlException(exception,perl_exception);
12790 exception=DestroyExceptionInfo(exception);
12791 SvREFCNT_dec(perl_exception);
12795 ###############################################################################
12799 # Q u e r y O p t i o n #
12803 ###############################################################################
12807 QueryOption(ref,...)
12808 Image::Magick ref=NO_INIT
12829 PERL_UNUSED_VAR(ref);
12830 PERL_UNUSED_VAR(ix);
12831 exception=AcquireExceptionInfo();
12832 perl_exception=newSVpv("",0);
12833 EXTEND(sp,8*items);
12834 for (i=1; i < items; i++)
12836 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12838 options=GetCommandOptions((CommandOption) option);
12839 if (options == (char **) NULL)
12843 for (j=0; options[j] != (char *) NULL; j++)
12844 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12845 options=DestroyStringList(options);
12849 InheritPerlException(exception,perl_exception);
12850 exception=DestroyExceptionInfo(exception);
12851 SvREFCNT_dec(perl_exception);
12855 ###############################################################################
12863 ###############################################################################
12868 Image::Magick ref=NO_INIT
12915 *perl_exception, /* Perl variable for storing messages */
12920 PERL_UNUSED_VAR(ref);
12921 PERL_UNUSED_VAR(ix);
12922 exception=AcquireExceptionInfo();
12923 perl_exception=newSVpv("",0);
12925 package_info=(struct PackageInfo *) NULL;
12927 ac=(items < 2) ? 1 : items-1;
12928 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12930 length=(STRLEN *) NULL;
12931 if (list == (char **) NULL)
12933 ThrowPerlException(exception,ResourceLimitError,
12934 "MemoryAllocationFailed",PackageName);
12935 goto PerlException;
12937 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12938 if (length == (STRLEN *) NULL)
12940 ThrowPerlException(exception,ResourceLimitError,
12941 "MemoryAllocationFailed",PackageName);
12942 goto PerlException;
12944 if (sv_isobject(ST(0)) == 0)
12946 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12948 goto PerlException;
12950 reference=SvRV(ST(0));
12951 hv=SvSTASH(reference);
12952 if (SvTYPE(reference) != SVt_PVAV)
12954 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12956 goto PerlException;
12958 av=(AV *) reference;
12959 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12961 package_info=ClonePackageInfo(info,exception);
12964 *list=(char *) (*package_info->image_info->filename ?
12965 package_info->image_info->filename : "XC:black");
12967 for (n=0, i=0; i < ac; i++)
12969 list[n]=(char *) SvPV(ST(i+1),length[n]);
12970 if ((items >= 3) && strEQcase(list[n],"blob"))
12976 blob=(void *) (SvPV(ST(i+1),length[n]));
12977 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12979 if ((items >= 3) && strEQcase(list[n],"filename"))
12981 if ((items >= 3) && strEQcase(list[n],"file"))
12990 io_info=IoIFP(sv_2io(ST(i+1)));
12991 if (io_info == (PerlIO *) NULL)
12993 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12997 file=PerlIO_findFILE(io_info);
12998 if (file == (FILE *) NULL)
13000 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13004 SetImageInfoFile(package_info->image_info,file);
13006 if ((items >= 3) && strEQcase(list[n],"magick"))
13010 list[n]=(char *) NULL;
13012 status=ExpandFilenames(&n,&list);
13013 if (status == MagickFalse)
13015 ThrowPerlException(exception,ResourceLimitError,
13016 "MemoryAllocationFailed",PackageName);
13017 goto PerlException;
13020 for (i=0; i < n; i++)
13022 if ((package_info->image_info->file != (FILE *) NULL) ||
13023 (package_info->image_info->blob != (void *) NULL))
13025 image=ReadImages(package_info->image_info,exception);
13026 if (image != (Image *) NULL)
13027 DisassociateImageStream(image);
13031 (void) CopyMagickString(package_info->image_info->filename,list[i],
13033 image=ReadImages(package_info->image_info,exception);
13035 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13037 for ( ; image; image=image->next)
13039 AddImageToRegistry(sv,image);
13041 av_push(av,sv_bless(rv,hv));
13049 for (i=0; i < n; i++)
13050 if (list[i] != (char *) NULL)
13051 for (p=keep; list[i] != *p++; )
13052 if (*p == (char *) NULL)
13054 list[i]=(char *) RelinquishMagickMemory(list[i]);
13059 if (package_info != (struct PackageInfo *) NULL)
13060 DestroyPackageInfo(package_info);
13061 if (list && (list != keep))
13062 list=(char **) RelinquishMagickMemory(list);
13064 keep=(char **) RelinquishMagickMemory(keep);
13066 length=(STRLEN *) RelinquishMagickMemory(length);
13067 InheritPerlException(exception,perl_exception);
13068 exception=DestroyExceptionInfo(exception);
13069 sv_setiv(perl_exception,(IV) number_images);
13070 SvPOK_on(perl_exception);
13071 ST(0)=sv_2mortal(perl_exception);
13076 ###############################################################################
13084 ###############################################################################
13089 Image::Magick ref=NO_INIT
13112 PERL_UNUSED_VAR(ref);
13113 PERL_UNUSED_VAR(ix);
13114 exception=AcquireExceptionInfo();
13115 perl_exception=newSVpv("",0);
13116 reference=SvRV(ST(0));
13117 av=(AV *) reference;
13118 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13120 for (i=1; i < items; i++)
13121 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13122 SvPV(ST(i),na),exception);
13123 InheritPerlException(exception,perl_exception);
13124 exception=DestroyExceptionInfo(exception);
13125 SvREFCNT_dec(perl_exception); /* throw away all errors */
13129 ###############################################################################
13137 ###############################################################################
13142 Image::Magick ref=NO_INIT
13165 *reference; /* reference is the SV* of ref=SvIV(reference) */
13167 PERL_UNUSED_VAR(ref);
13168 PERL_UNUSED_VAR(ix);
13169 exception=AcquireExceptionInfo();
13170 perl_exception=newSVpv("",0);
13171 if (sv_isobject(ST(0)) == 0)
13173 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13175 goto PerlException;
13177 reference=SvRV(ST(0));
13178 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13180 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13182 for (i=2; i < items; i+=2)
13183 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13186 InheritPerlException(exception,perl_exception);
13187 exception=DestroyExceptionInfo(exception);
13188 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13189 SvPOK_on(perl_exception);
13190 ST(0)=sv_2mortal(perl_exception);
13195 ###############################################################################
13199 # S e t P i x e l #
13203 ###############################################################################
13208 Image::Magick ref=NO_INIT
13235 register IndexPacket
13241 register PixelPacket
13252 *reference; /* reference is the SV* of ref=SvIV(reference) */
13254 PERL_UNUSED_VAR(ref);
13255 PERL_UNUSED_VAR(ix);
13256 exception=AcquireExceptionInfo();
13257 perl_exception=newSVpv("",0);
13258 reference=SvRV(ST(0));
13259 av=(AV *) reference;
13260 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13262 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13263 if (image == (Image *) NULL)
13265 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13267 goto PerlException;
13270 channel=DefaultChannels;
13271 normalize=MagickTrue;
13274 region.width=image->columns;
13277 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13278 for (i=2; i < items; i+=2)
13280 attribute=(char *) SvPV(ST(i-1),na);
13281 switch (*attribute)
13286 if (LocaleCompare(attribute,"channel") == 0)
13291 option=ParseChannelOption(SvPV(ST(i),na));
13294 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13298 channel=(ChannelType) option;
13301 if (LocaleCompare(attribute,"color") == 0)
13303 if (SvTYPE(ST(i)) != SVt_RV)
13306 message[MaxTextExtent];
13308 (void) FormatLocaleString(message,MaxTextExtent,
13309 "invalid %.60s value",attribute);
13310 ThrowPerlException(exception,OptionError,message,
13313 av=(AV *) SvRV(ST(i));
13316 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13323 if (LocaleCompare(attribute,"geometry") == 0)
13325 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13328 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13335 if (LocaleCompare(attribute,"normalize") == 0)
13337 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13341 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13345 normalize=option != 0 ? MagickTrue : MagickFalse;
13348 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13355 if (LocaleCompare(attribute,"x") == 0)
13357 region.x=SvIV(ST(i));
13360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13367 if (LocaleCompare(attribute,"y") == 0)
13369 region.y=SvIV(ST(i));
13372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13378 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13384 (void) SetImageStorageClass(image,DirectClass);
13385 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13386 if ((q == (PixelPacket *) NULL) || (av == (AV *) NULL) ||
13387 (SvTYPE(av) != SVt_PVAV))
13398 indexes=GetAuthenticIndexQueue(image);
13400 if (normalize != MagickFalse)
13401 scale=QuantumRange;
13402 if (((channel & RedChannel) != 0) && (i <= av_len(av)))
13404 SetRedPixelComponent(q,ClampToQuantum(scale*SvNV(*(
13405 av_fetch(av,i,0)))));
13408 if (((channel & GreenChannel) != 0) && (i <= av_len(av)))
13410 SetGreenPixelComponent(q,ClampToQuantum(scale*SvNV(*(
13411 av_fetch(av,i,0)))));
13414 if (((channel & BlueChannel) != 0) && (i <= av_len(av)))
13416 SetBluePixelComponent(q,ClampToQuantum(scale*SvNV(*(
13417 av_fetch(av,i,0)))));
13420 if ((((channel & IndexChannel) != 0) &&
13421 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13423 SetIndexPixelComponent(indexes,ClampToQuantum(scale*
13424 SvNV(*(av_fetch(av,i,0)))));
13427 if (((channel & OpacityChannel) != 0) && (i <= av_len(av)))
13429 SetOpacityPixelComponent(q,ClampToQuantum(scale*
13430 SvNV(*(av_fetch(av,i,0)))));
13433 (void) SyncAuthenticPixels(image,exception);
13437 InheritPerlException(exception,perl_exception);
13438 exception=DestroyExceptionInfo(exception);
13439 SvREFCNT_dec(perl_exception);
13443 ###############################################################################
13451 ###############################################################################
13456 Image::Magick ref=NO_INIT
13495 PERL_UNUSED_VAR(ref);
13496 PERL_UNUSED_VAR(ix);
13497 exception=AcquireExceptionInfo();
13498 perl_exception=newSVpv("",0);
13502 if (sv_isobject(ST(0)) == 0)
13504 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13506 goto PerlException;
13508 reference=SvRV(ST(0));
13509 hv=SvSTASH(reference);
13511 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13513 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13514 if (image == (Image *) NULL)
13516 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13518 goto PerlException;
13520 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13526 for (i=2; i < items; i+=2)
13528 attribute=(char *) SvPV(ST(i-1),na);
13529 switch (*attribute)
13534 if (LocaleCompare(attribute,"offset") == 0)
13536 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13539 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13546 if (LocaleCompare(attribute,"stack") == 0)
13548 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13552 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13558 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13564 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13570 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13572 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13573 goto PerlException;
13574 for ( ; image; image=image->next)
13576 AddImageToRegistry(sv,image);
13578 av_push(av,sv_bless(rv,hv));
13581 exception=DestroyExceptionInfo(exception);
13582 ST(0)=av_reference;
13583 SvREFCNT_dec(perl_exception);
13587 InheritPerlException(exception,perl_exception);
13588 exception=DestroyExceptionInfo(exception);
13589 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13590 SvPOK_on(perl_exception);
13591 ST(0)=sv_2mortal(perl_exception);
13596 ###############################################################################
13600 # S t a t i s t i c s #
13604 ###############################################################################
13608 Statistics(ref,...)
13609 Image::Magick ref=NO_INIT
13611 StatisticsImage = 1
13613 statisticsimage = 3
13616 #define ChannelStatistics(channel) \
13618 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13619 (double) channel_statistics[channel].depth); \
13620 PUSHs(sv_2mortal(newSVpv(message,0))); \
13621 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13622 channel_statistics[channel].minima/scale); \
13623 PUSHs(sv_2mortal(newSVpv(message,0))); \
13624 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13625 channel_statistics[channel].maxima/scale); \
13626 PUSHs(sv_2mortal(newSVpv(message,0))); \
13627 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13628 channel_statistics[channel].mean/scale); \
13629 PUSHs(sv_2mortal(newSVpv(message,0))); \
13630 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13631 channel_statistics[channel].standard_deviation/scale); \
13632 PUSHs(sv_2mortal(newSVpv(message,0))); \
13633 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13634 channel_statistics[channel].kurtosis); \
13635 PUSHs(sv_2mortal(newSVpv(message,0))); \
13636 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13637 channel_statistics[channel].skewness); \
13638 PUSHs(sv_2mortal(newSVpv(message,0))); \
13645 message[MaxTextExtent];
13648 *channel_statistics;
13669 PERL_UNUSED_VAR(ref);
13670 PERL_UNUSED_VAR(ix);
13671 exception=AcquireExceptionInfo();
13672 perl_exception=newSVpv("",0);
13674 if (sv_isobject(ST(0)) == 0)
13676 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13678 goto PerlException;
13680 reference=SvRV(ST(0));
13683 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13684 if (image == (Image *) NULL)
13686 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13688 goto PerlException;
13690 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13692 for ( ; image; image=image->next)
13694 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13695 if (channel_statistics == (ChannelStatistics *) NULL)
13698 EXTEND(sp,35*count);
13699 scale=(double) QuantumRange;
13700 ChannelStatistics(RedChannel);
13701 ChannelStatistics(GreenChannel);
13702 ChannelStatistics(BlueChannel);
13703 if (image->colorspace == CMYKColorspace)
13704 ChannelStatistics(IndexChannel);
13705 if (image->matte != MagickFalse)
13706 ChannelStatistics(OpacityChannel);
13707 channel_statistics=(ChannelStatistics *)
13708 RelinquishMagickMemory(channel_statistics);
13712 InheritPerlException(exception,perl_exception);
13713 exception=DestroyExceptionInfo(exception);
13714 SvREFCNT_dec(perl_exception);
13718 ###############################################################################
13722 # S y n c A u t h e n t i c P i x e l s #
13726 ###############################################################################
13730 SyncAuthenticPixels(ref,...)
13731 Image::Magick ref = NO_INIT
13733 Syncauthenticpixels = 1
13734 SyncImagePixels = 2
13735 syncimagepixels = 3
13754 PERL_UNUSED_VAR(ref);
13755 PERL_UNUSED_VAR(ix);
13756 exception=AcquireExceptionInfo();
13757 perl_exception=newSVpv("",0);
13758 if (sv_isobject(ST(0)) == 0)
13760 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13762 goto PerlException;
13765 reference=SvRV(ST(0));
13766 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13767 if (image == (Image *) NULL)
13769 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13771 goto PerlException;
13774 status=SyncAuthenticPixels(image,exception);
13775 if (status != MagickFalse)
13777 InheritException(exception,&image->exception);
13780 InheritPerlException(exception,perl_exception);
13781 exception=DestroyExceptionInfo(exception);
13782 SvREFCNT_dec(perl_exception); /* throw away all errors */
13786 ###############################################################################
13790 # T r a n s f o r m #
13794 ###############################################################################
13799 Image::Magick ref=NO_INIT
13837 PERL_UNUSED_VAR(ref);
13838 PERL_UNUSED_VAR(ix);
13839 exception=AcquireExceptionInfo();
13840 perl_exception=newSVpv("",0);
13844 if (sv_isobject(ST(0)) == 0)
13846 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13848 goto PerlException;
13850 reference=SvRV(ST(0));
13851 hv=SvSTASH(reference);
13853 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13855 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13856 if (image == (Image *) NULL)
13858 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13860 goto PerlException;
13862 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13866 crop_geometry=(char *) NULL;
13867 geometry=(char *) NULL;
13868 for (i=2; i < items; i+=2)
13870 attribute=(char *) SvPV(ST(i-1),na);
13871 switch (*attribute)
13876 if (LocaleCompare(attribute,"crop") == 0)
13878 crop_geometry=SvPV(ST(i),na);
13881 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13888 if (LocaleCompare(attribute,"geometry") == 0)
13890 geometry=SvPV(ST(i),na);
13893 if (LocaleCompare(attribute,"gravity") == 0)
13901 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13902 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13905 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13909 for (next=image; next; next=next->next)
13910 next->gravity=(GravityType) in;
13913 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13919 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13925 for ( ; image; image=image->next)
13927 clone=CloneImage(image,0,0,MagickTrue,exception);
13928 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13929 goto PerlException;
13930 TransformImage(&clone,crop_geometry,geometry);
13931 for ( ; clone; clone=clone->next)
13933 AddImageToRegistry(sv,clone);
13935 av_push(av,sv_bless(rv,hv));
13939 exception=DestroyExceptionInfo(exception);
13940 ST(0)=av_reference;
13941 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13945 InheritPerlException(exception,perl_exception);
13946 exception=DestroyExceptionInfo(exception);
13947 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13948 SvPOK_on(perl_exception);
13949 ST(0)=sv_2mortal(perl_exception);
13954 ###############################################################################
13962 ###############################################################################
13967 Image::Magick ref=NO_INIT
13975 filename[MaxTextExtent];
13999 PERL_UNUSED_VAR(ref);
14000 PERL_UNUSED_VAR(ix);
14001 exception=AcquireExceptionInfo();
14002 perl_exception=newSVpv("",0);
14004 package_info=(struct PackageInfo *) NULL;
14005 if (sv_isobject(ST(0)) == 0)
14007 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14009 goto PerlException;
14011 reference=SvRV(ST(0));
14012 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14013 if (image == (Image *) NULL)
14015 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14017 goto PerlException;
14019 package_info=ClonePackageInfo(info,exception);
14021 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14024 for (i=2; i < items; i+=2)
14025 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14027 (void) CopyMagickString(filename,package_info->image_info->filename,
14030 for (next=image; next; next=next->next)
14032 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14033 next->scene=scene++;
14035 SetImageInfo(package_info->image_info,(unsigned int)
14036 GetImageListLength(image),&image->exception);
14037 for (next=image; next; next=next->next)
14039 (void) WriteImage(package_info->image_info,next);
14040 if (next->exception.severity >= ErrorException)
14041 InheritException(exception,&next->exception);
14042 GetImageException(next,exception);
14044 if (package_info->image_info->adjoin)
14049 if (package_info != (struct PackageInfo *) NULL)
14050 DestroyPackageInfo(package_info);
14051 InheritPerlException(exception,perl_exception);
14052 exception=DestroyExceptionInfo(exception);
14053 sv_setiv(perl_exception,(IV) number_images);
14054 SvPOK_on(perl_exception);
14055 ST(0)=sv_2mortal(perl_exception);