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 <MagickCore/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 MaxArguments 33
85 #define NumberOf(array) (sizeof(array)/sizeof(*array))
86 #define PackageName "Image::Magick"
89 #define PerlIO_importFILE(f, fl) (f)
90 #define PerlIO_findFILE(f) NULL
93 #define sv_undef PL_sv_undef
96 #define AddImageToRegistry(sv,image) \
98 if (magick_registry != (SplayTreeInfo *) NULL) \
100 (void) AddValueToSplayTree(magick_registry,image,image); \
101 (sv)=newSViv((IV) image); \
105 #define DeleteImageFromRegistry(reference,image) \
107 if (magick_registry != (SplayTreeInfo *) NULL) \
109 if (GetImageReferenceCount(image) == 1) \
110 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
111 image=DestroyImage(image); \
112 sv_setiv(reference,0); \
116 #define InheritPerlException(exception,perl_exception) \
119 message[MaxTextExtent]; \
121 if ((exception)->severity != UndefinedException) \
123 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
124 (exception)->severity, (exception)->reason ? \
125 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
126 "Unknown", (exception)->description ? " (" : "", \
127 (exception)->description ? GetLocaleExceptionMessage( \
128 (exception)->severity,(exception)->description) : "", \
129 (exception)->description ? ")" : ""); \
130 if ((perl_exception) != (SV *) NULL) \
132 if (SvCUR(perl_exception)) \
133 sv_catpv(perl_exception,"\n"); \
134 sv_catpv(perl_exception,message); \
139 #define ThrowPerlException(exception,severity,tag,reason) \
140 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
141 tag,"`%s'",reason); \
144 Typedef and structure declarations.
148 ArrayReference = (~0),
149 RealReference = (~0)-1,
150 FileReference = (~0)-2,
151 ImageReference = (~0)-3,
152 IntegerReference = (~0)-4,
153 StringReference = (~0)-5
156 typedef struct _Arguments
196 *Image__Magick; /* data type for the Image::Magick package */
208 arguments[MaxArguments];
211 { "Comment", { {"comment", StringReference} } },
212 { "Label", { {"label", StringReference} } },
213 { "AddNoise", { {"noise", MagickNoiseOptions},
214 {"channel", MagickChannelOptions} } },
215 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
216 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
217 {"height", IntegerReference}, {"fill", StringReference},
218 {"bordercolor", StringReference}, {"color", StringReference},
219 {"compose", MagickComposeOptions} } },
220 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
221 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
222 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference} } },
225 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
226 {"height", IntegerReference}, {"x", IntegerReference},
227 {"y", IntegerReference}, {"fuzz", StringReference},
228 {"gravity", MagickGravityOptions} } },
230 { "Edge", { {"radius", RealReference} } },
231 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
232 {"sigma", RealReference} } },
236 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
237 {"height", IntegerReference}, {"inner", IntegerReference},
238 {"outer", IntegerReference}, {"fill", StringReference},
239 {"color", StringReference}, {"compose", MagickComposeOptions} } },
240 { "Implode", { {"amount", RealReference},
241 {"interpolate", MagickInterpolateOptions} } },
243 { "MedianFilter", { {"geometry", StringReference},
244 {"width", IntegerReference},{"height", IntegerReference},
245 {"channel", MagickChannelOptions} } },
247 { "OilPaint", { {"radius", RealReference} } },
248 { "ReduceNoise", { {"geometry", StringReference},
249 {"width", IntegerReference},{"height", IntegerReference},
250 {"channel", MagickChannelOptions} } },
251 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
252 {"y", IntegerReference} } },
253 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
254 {"color", StringReference}, {"background", StringReference} } },
255 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
256 {"height", IntegerReference} } },
257 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
258 {"height", IntegerReference} } },
259 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
260 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
261 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
262 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
263 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
264 {"y", RealReference}, { "fill", StringReference},
265 {"color", StringReference} } },
266 { "Spread", { {"radius", RealReference} } },
267 { "Swirl", { {"degrees", RealReference},
268 {"interpolate", MagickInterpolateOptions} } },
269 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", StringReference }, {"blur", RealReference } } },
272 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
273 {"height", IntegerReference}, {"filter", MagickFilterOptions},
274 {"support", RealReference }, {"blur", RealReference } } },
275 { "Annotate", { {"text", StringReference}, {"font", StringReference},
276 {"pointsize", RealReference}, {"density", StringReference},
277 {"undercolor", StringReference}, {"stroke", StringReference},
278 {"fill", StringReference}, {"geometry", StringReference},
279 {"pen", StringReference}, {"x", RealReference},
280 {"y", RealReference}, {"gravity", MagickGravityOptions},
281 {"translate", StringReference}, {"scale", StringReference},
282 {"rotate", RealReference}, {"skewX", RealReference},
283 {"skewY", RealReference}, {"strokewidth", RealReference},
284 {"antialias", MagickBooleanOptions}, {"family", StringReference},
285 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
286 {"weight", IntegerReference}, {"align", MagickAlignOptions},
287 {"encoding", StringReference}, {"affine", ArrayReference},
288 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
289 {"tile", ImageReference}, {"kerning", RealReference},
290 {"interline-spacing", RealReference},
291 {"interword-spacing", RealReference},
292 {"direction", MagickDirectionOptions} } },
293 { "ColorFloodfill", { {"geometry", StringReference},
294 {"x", IntegerReference}, {"y", IntegerReference},
295 {"fill", StringReference}, {"bordercolor", StringReference},
296 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
297 { "Composite", { {"image", ImageReference},
298 {"compose", MagickComposeOptions}, {"geometry", StringReference},
299 {"x", IntegerReference}, {"y", IntegerReference},
300 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
301 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
302 {"color", StringReference}, {"mask", ImageReference},
303 {"channel", MagickChannelOptions},
304 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
305 {"blend", StringReference} } },
306 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
307 { "CycleColormap", { {"display", IntegerReference} } },
308 { "Draw", { {"primitive", MagickPrimitiveOptions},
309 {"points", StringReference}, {"method", MagickMethodOptions},
310 {"stroke", StringReference}, {"fill", StringReference},
311 {"strokewidth", RealReference}, {"font", StringReference},
312 {"bordercolor", StringReference}, {"x", RealReference},
313 {"y", RealReference}, {"translate", StringReference},
314 {"scale", StringReference}, {"rotate", RealReference},
315 {"skewX", RealReference}, {"skewY", RealReference},
316 {"tile", ImageReference}, {"pointsize", RealReference},
317 {"antialias", MagickBooleanOptions}, {"density", StringReference},
318 {"linewidth", RealReference}, {"affine", ArrayReference},
319 {"stroke-dashoffset", RealReference},
320 {"stroke-dasharray", ArrayReference},
321 {"interpolate", MagickInterpolateOptions},
322 {"origin", StringReference}, {"text", StringReference},
323 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
324 {"vector-graphics", StringReference}, {"kerning", RealReference},
325 {"interline-spacing", RealReference},
326 {"interword-spacing", RealReference},
327 {"direction", MagickDirectionOptions} } },
328 { "Equalize", { {"channel", MagickChannelOptions} } },
329 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
330 {"red", RealReference}, {"green", RealReference},
331 {"blue", RealReference} } },
332 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
333 {"dither-method", MagickDitherOptions} } },
334 { "MatteFloodfill", { {"geometry", StringReference},
335 {"x", IntegerReference}, {"y", IntegerReference},
336 {"opacity", StringReference}, {"bordercolor", StringReference},
337 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
338 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
339 {"saturation", RealReference}, {"whiteness", RealReference},
340 {"brightness", RealReference}, {"lightness", RealReference},
341 {"blackness", RealReference} } },
342 { "Negate", { {"gray", MagickBooleanOptions},
343 {"channel", MagickChannelOptions} } },
344 { "Normalize", { {"channel", MagickChannelOptions} } },
346 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
347 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
348 {"invert", MagickBooleanOptions} } },
349 { "Quantize", { {"colors", IntegerReference},
350 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
351 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
352 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
353 {"dither-method", MagickDitherOptions} } },
354 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
355 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
356 { "Segment", { {"geometry", StringReference},
357 {"cluster-threshold", RealReference},
358 {"smoothing-threshold", RealReference},
359 {"colorspace", MagickColorspaceOptions},
360 {"verbose", MagickBooleanOptions} } },
362 { "Solarize", { {"geometry", StringReference},
363 {"threshold", StringReference} } },
365 { "Texture", { {"texture", ImageReference} } },
366 { "Evaluate", { {"value", RealReference},
367 {"operator", MagickEvaluateOptions},
368 {"channel", MagickChannelOptions} } },
369 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
370 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
371 { "Threshold", { {"threshold", StringReference},
372 {"channel", MagickChannelOptions} } },
373 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
374 {"sigma", RealReference} } },
375 { "Trim", { {"fuzz", StringReference} } },
376 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
377 {"wavelength", RealReference},
378 {"interpolate", MagickInterpolateOptions} } },
379 { "Separate", { {"channel", MagickChannelOptions} } },
381 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
382 {"y", IntegerReference} } },
383 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
385 { "GaussianBlur", { {"geometry", StringReference},
386 {"radius", RealReference}, {"sigma", RealReference},
387 {"channel", MagickChannelOptions} } },
388 { "Convolve", { {"coefficients", ArrayReference},
389 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
390 { "Profile", { {"name", StringReference}, {"profile", StringReference},
391 { "rendering-intent", MagickIntentOptions},
392 { "black-point-compensation", MagickBooleanOptions} } },
393 { "UnsharpMask", { {"geometry", StringReference},
394 {"radius", RealReference}, {"sigma", RealReference},
395 {"amount", RealReference}, {"threshold", RealReference},
396 {"channel", MagickChannelOptions} } },
397 { "MotionBlur", { {"geometry", StringReference},
398 {"radius", RealReference}, {"sigma", RealReference},
399 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
400 { "OrderedDither", { {"threshold", StringReference},
401 {"channel", MagickChannelOptions} } },
402 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
403 {"height", IntegerReference} } },
404 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
405 {"white-point", RealReference}, {"gamma", RealReference},
406 {"channel", MagickChannelOptions}, {"level", StringReference} } },
407 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
408 { "AffineTransform", { {"affine", ArrayReference},
409 {"translate", StringReference}, {"scale", StringReference},
410 {"rotate", RealReference}, {"skewX", RealReference},
411 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
412 {"background", StringReference} } },
413 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
414 { "AdaptiveThreshold", { {"geometry", StringReference},
415 {"width", IntegerReference}, {"height", IntegerReference},
416 {"offset", IntegerReference} } },
417 { "Resample", { {"density", StringReference}, {"x", RealReference},
418 {"y", RealReference}, {"filter", MagickFilterOptions},
419 {"support", RealReference }, {"blur", RealReference } } },
420 { "Describe", { {"file", FileReference} } },
421 { "BlackThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "WhiteThreshold", { {"threshold", StringReference},
424 {"channel", MagickChannelOptions} } },
425 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
426 {"channel", MagickChannelOptions} } },
427 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
428 {"height", IntegerReference} } },
430 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
431 { "Channel", { {"channel", MagickChannelOptions} } },
432 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
433 {"height", IntegerReference}, {"x", IntegerReference},
434 {"y", IntegerReference}, {"fuzz", StringReference},
435 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
436 { "Posterize", { {"levels", IntegerReference},
437 {"dither", MagickBooleanOptions} } },
438 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
439 {"sigma", RealReference}, {"x", IntegerReference},
440 {"y", IntegerReference} } },
441 { "Identify", { {"file", FileReference}, {"features", StringReference},
442 {"unique", MagickBooleanOptions} } },
443 { "SepiaTone", { {"threshold", RealReference} } },
444 { "SigmoidalContrast", { {"geometry", StringReference},
445 {"contrast", RealReference}, {"mid-point", RealReference},
446 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
447 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
448 {"height", IntegerReference}, {"x", IntegerReference},
449 {"y", IntegerReference}, {"fuzz", StringReference},
450 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
451 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
452 {"sigma", RealReference}, {"x", IntegerReference},
453 {"y", IntegerReference}, {"background", StringReference} } },
454 { "ContrastStretch", { {"levels", StringReference},
455 {"black-point", RealReference},{"white-point", RealReference},
456 {"channel", MagickChannelOptions} } },
459 { "AdaptiveSharpen", { {"geometry", StringReference},
460 {"radius", RealReference}, {"sigma", RealReference},
461 {"channel", MagickChannelOptions} } },
465 { "AdaptiveBlur", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"channel", MagickChannelOptions} } },
468 { "Sketch", { {"geometry", StringReference},
469 {"radius", RealReference}, {"sigma", RealReference},
470 {"angle", RealReference} } },
472 { "AdaptiveResize", { {"geometry", StringReference},
473 {"width", IntegerReference}, {"height", IntegerReference},
474 {"filter", MagickFilterOptions}, {"support", StringReference },
475 {"blur", RealReference } } },
476 { "ClipMask", { {"mask", ImageReference} } },
477 { "LinearStretch", { {"levels", StringReference},
478 {"black-point", RealReference},{"white-point", RealReference} } },
479 { "Recolor", { {"matrix", ArrayReference} } },
480 { "Mask", { {"mask", ImageReference} } },
481 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
482 {"font", StringReference}, {"stroke", StringReference},
483 {"fill", StringReference}, {"strokewidth", RealReference},
484 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
485 {"background", StringReference} } },
486 { "FloodfillPaint", { {"geometry", StringReference},
487 {"x", IntegerReference}, {"y", IntegerReference},
488 {"fill", StringReference}, {"bordercolor", StringReference},
489 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
490 {"invert", MagickBooleanOptions} } },
491 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
492 {"virtual-pixel", MagickVirtualPixelOptions},
493 {"best-fit", MagickBooleanOptions} } },
494 { "Clut", { {"image", ImageReference},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "Filter", { {"kernel", StringReference},
529 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
530 { "BrightnessContrast", { {"levels", StringReference},
531 {"brightness", RealReference},{"contrast", RealReference},
532 {"channel", MagickChannelOptions} } },
533 { "Morphology", { {"kernel", StringReference},
534 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
535 {"iterations", IntegerReference} } },
536 { "ColorMatrix", { {"matrix", ArrayReference} } },
537 { "Color", { {"color", StringReference} } },
538 { "Mode", { {"geometry", StringReference},
539 {"width", IntegerReference},{"height", IntegerReference},
540 {"channel", MagickChannelOptions} } },
541 { "Statistic", { {"geometry", StringReference},
542 {"width", IntegerReference},{"height", IntegerReference},
543 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
547 *magick_registry = (SplayTreeInfo *) NULL;
550 Forward declarations.
553 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
556 strEQcase(const char *,const char *);
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 % C l o n e P a c k a g e I n f o %
567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
572 % The format of the ClonePackageInfo routine is:
574 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
577 % A description of each parameter follows:
579 % o info: a structure of type info.
581 % o exception: Return any errors or warnings in this structure.
584 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
585 ExceptionInfo *exception)
590 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
591 if (clone_info == (struct PackageInfo *) NULL)
593 ThrowPerlException(exception,ResourceLimitError,
594 "UnableToClonePackageInfo",PackageName);
595 return((struct PackageInfo *) NULL);
597 if (info == (struct PackageInfo *) NULL)
599 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
603 clone_info->image_info=CloneImageInfo(info->image_info);
608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618 % constant() returns a double value for the specified name.
620 % The format of the constant routine is:
622 % double constant(char *name,ssize_t sans)
624 % A description of each parameter follows:
626 % o value: Method constant returns a double value for the specified name.
628 % o name: The name of the constant.
630 % o sans: This integer value is not used.
633 static double constant(char *name,ssize_t sans)
641 if (strEQ(name,"BlobError"))
643 if (strEQ(name,"BlobWarning"))
649 if (strEQ(name,"CacheError"))
651 if (strEQ(name,"CacheWarning"))
652 return(CacheWarning);
653 if (strEQ(name,"CoderError"))
655 if (strEQ(name,"CoderWarning"))
656 return(CoderWarning);
657 if (strEQ(name,"ConfigureError"))
658 return(ConfigureError);
659 if (strEQ(name,"ConfigureWarning"))
660 return(ConfigureWarning);
661 if (strEQ(name,"CorruptImageError"))
662 return(CorruptImageError);
663 if (strEQ(name,"CorruptImageWarning"))
664 return(CorruptImageWarning);
669 if (strEQ(name,"DelegateError"))
670 return(DelegateError);
671 if (strEQ(name,"DelegateWarning"))
672 return(DelegateWarning);
673 if (strEQ(name,"DrawError"))
675 if (strEQ(name,"DrawWarning"))
681 if (strEQ(name,"ErrorException"))
682 return(ErrorException);
683 if (strEQ(name,"ExceptionError"))
685 if (strEQ(name,"ExceptionWarning"))
686 return(CoderWarning);
691 if (strEQ(name,"FatalErrorException"))
692 return(FatalErrorException);
693 if (strEQ(name,"FileOpenError"))
694 return(FileOpenError);
695 if (strEQ(name,"FileOpenWarning"))
696 return(FileOpenWarning);
701 if (strEQ(name,"ImageError"))
703 if (strEQ(name,"ImageWarning"))
704 return(ImageWarning);
709 if (strEQ(name,"MaxRGB"))
710 return(QuantumRange);
711 if (strEQ(name,"MissingDelegateError"))
712 return(MissingDelegateError);
713 if (strEQ(name,"MissingDelegateWarning"))
714 return(MissingDelegateWarning);
715 if (strEQ(name,"ModuleError"))
717 if (strEQ(name,"ModuleWarning"))
718 return(ModuleWarning);
723 if (strEQ(name,"Opaque"))
725 if (strEQ(name,"OptionError"))
727 if (strEQ(name,"OptionWarning"))
728 return(OptionWarning);
733 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
734 return(MAGICKCORE_QUANTUM_DEPTH);
735 if (strEQ(name,"QuantumDepth"))
736 return(MAGICKCORE_QUANTUM_DEPTH);
737 if (strEQ(name,"QuantumRange"))
738 return(QuantumRange);
743 if (strEQ(name,"ResourceLimitError"))
744 return(ResourceLimitError);
745 if (strEQ(name,"ResourceLimitWarning"))
746 return(ResourceLimitWarning);
747 if (strEQ(name,"RegistryError"))
748 return(RegistryError);
749 if (strEQ(name,"RegistryWarning"))
750 return(RegistryWarning);
755 if (strEQ(name,"StreamError"))
757 if (strEQ(name,"StreamWarning"))
758 return(StreamWarning);
759 if (strEQ(name,"Success"))
765 if (strEQ(name,"Transparent"))
766 return(TransparentAlpha);
767 if (strEQ(name,"TypeError"))
769 if (strEQ(name,"TypeWarning"))
775 if (strEQ(name,"WarningException"))
776 return(WarningException);
781 if (strEQ(name,"XServerError"))
782 return(XServerError);
783 if (strEQ(name,"XServerWarning"))
784 return(XServerWarning);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % D e s t r o y P a c k a g e I n f o %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % Method DestroyPackageInfo frees a previously created info structure.
805 % The format of the DestroyPackageInfo routine is:
807 % DestroyPackageInfo(struct PackageInfo *info)
809 % A description of each parameter follows:
811 % o info: a structure of type info.
814 static void DestroyPackageInfo(struct PackageInfo *info)
816 info->image_info=DestroyImageInfo(info->image_info);
817 info=(struct PackageInfo *) RelinquishMagickMemory(info);
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 % Method GetList is recursively called by SetupList to traverse the
832 % Image__Magick reference. If building an reference_vector (see SetupList),
833 % *current is the current position in *reference_vector and *last is the final
834 % entry in *reference_vector.
836 % The format of the GetList routine is:
840 % A description of each parameter follows:
842 % o info: a structure of type info.
845 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
846 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
851 if (reference == (SV *) NULL)
853 switch (SvTYPE(reference))
873 previous=(Image *) NULL;
877 for (i=0; i <= n; i++)
883 if (rv && *rv && sv_isobject(*rv))
885 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
887 if (image == (Image *) NULL)
889 if (image == previous)
891 image=CloneImage(image,0,0,MagickTrue,exception);
892 if (image == (Image *) NULL)
895 image->previous=previous;
896 *(previous ? &previous->next : &head)=image;
897 for (previous=image; previous->next; previous=previous->next) ;
905 Blessed scalar, one image.
907 image=(Image *) SvIV(reference);
908 if (image == (Image *) NULL)
910 image->previous=(Image *) NULL;
911 image->next=(Image *) NULL;
912 if (reference_vector)
914 if (*current == *last)
917 if (*reference_vector == (SV **) NULL)
918 *reference_vector=(SV **) AcquireQuantumMemory(*last,
919 sizeof(*reference_vector));
921 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
922 *last,sizeof(*reference_vector));
924 if (*reference_vector == (SV **) NULL)
926 ThrowPerlException(exception,ResourceLimitError,
927 "MemoryAllocationFailed",PackageName);
928 return((Image *) NULL);
930 (*reference_vector)[*current]=reference;
931 (*reference_vector)[++(*current)]=NULL;
938 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
939 (double) SvTYPE(reference));
940 return((Image *) NULL);
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 % G e t P a c k a g e I n f o %
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % Method GetPackageInfo looks up or creates an info structure for the given
955 % Image__Magick reference. If it does create a new one, the information in
956 % package_info is used to initialize it.
958 % The format of the GetPackageInfo routine is:
960 % struct PackageInfo *GetPackageInfo(void *reference,
961 % struct PackageInfo *package_info,ExceptionInfo *exception)
963 % A description of each parameter follows:
965 % o info: a structure of type info.
967 % o exception: Return any errors or warnings in this structure.
970 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
971 struct PackageInfo *package_info,ExceptionInfo *exception)
974 message[MaxTextExtent];
982 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
983 PackageName,XS_VERSION,reference);
984 sv=perl_get_sv(message,(TRUE | 0x02));
985 if (sv == (SV *) NULL)
987 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
989 return(package_info);
991 if (SvREFCNT(sv) == 0)
992 (void) SvREFCNT_inc(sv);
993 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
995 clone_info=ClonePackageInfo(package_info,exception);
996 sv_setiv(sv,(IV) clone_info);
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 % S e t A t t r i b u t e %
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1011 % SetAttribute() sets the attribute to the value in sval. This can change
1012 % either or both of image or info.
1014 % The format of the SetAttribute routine is:
1016 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1017 % SV *sval,ExceptionInfo *exception)
1019 % A description of each parameter follows:
1021 % o list: a list of strings.
1023 % o string: a character string.
1027 static double SiPrefixToDouble(const char *string,const double interval)
1036 value=InterpretLocaleValue(string,&q);
1038 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1040 switch (tolower((int) ((unsigned char) *q)))
1042 case '%': value*=pow(scale,0)*interval/100.0; break;
1043 case 'k': value*=pow(scale,1); break;
1044 case 'm': value*=pow(scale,2); break;
1045 case 'g': value*=pow(scale,3); break;
1046 case 't': value*=pow(scale,4); break;
1047 case 'p': value*=pow(scale,5); break;
1048 case 'e': value*=pow(scale,6); break;
1049 case 'z': value*=pow(scale,7); break;
1050 case 'y': value*=pow(scale,8); break;
1056 static inline ssize_t StringToLong(const char *value)
1058 return(strtol(value,(char **) NULL,10));
1061 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1062 const char *attribute,SV *sval,ExceptionInfo *exception)
1089 if (LocaleCompare(attribute,"adjoin") == 0)
1091 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1092 SvPV(sval,na)) : SvIV(sval);
1095 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1100 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1103 if (LocaleCompare(attribute,"alpha") == 0)
1105 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1106 SvPV(sval,na)) : SvIV(sval);
1109 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1113 for ( ; image; image=image->next)
1114 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1117 if (LocaleCompare(attribute,"antialias") == 0)
1119 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1120 SvPV(sval,na)) : SvIV(sval);
1123 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1128 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1131 if (LocaleCompare(attribute,"area-limit") == 0)
1136 limit=MagickResourceInfinity;
1137 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1138 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1139 (void) SetMagickResourceLimit(AreaResource,limit);
1142 if (LocaleCompare(attribute,"attenuate") == 0)
1145 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1148 if (LocaleCompare(attribute,"authenticate") == 0)
1151 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1155 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1156 for ( ; image; image=image->next)
1157 SetImageProperty(image,attribute,SvPV(sval,na));
1163 if (LocaleCompare(attribute,"background") == 0)
1165 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1167 info->image_info->background_color=target_color;
1168 for ( ; image; image=image->next)
1169 image->background_color=target_color;
1172 if (LocaleCompare(attribute,"bias") == 0)
1174 for ( ; image; image=image->next)
1175 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1178 if (LocaleCompare(attribute,"blue-primary") == 0)
1180 for ( ; image; image=image->next)
1182 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1183 image->chromaticity.blue_primary.x=geometry_info.rho;
1184 image->chromaticity.blue_primary.y=geometry_info.sigma;
1185 if ((flags & SigmaValue) == 0)
1186 image->chromaticity.blue_primary.y=
1187 image->chromaticity.blue_primary.x;
1191 if (LocaleCompare(attribute,"bordercolor") == 0)
1193 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1195 info->image_info->border_color=target_color;
1196 for ( ; image; image=image->next)
1197 image->border_color=target_color;
1201 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1202 for ( ; image; image=image->next)
1203 SetImageProperty(image,attribute,SvPV(sval,na));
1209 if (LocaleCompare(attribute,"cache-threshold") == 0)
1211 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1212 SiPrefixToDouble(SvPV(sval,na),100.0));
1213 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1214 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1217 if (LocaleCompare(attribute,"clip-mask") == 0)
1222 clip_mask=(Image *) NULL;
1224 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1225 for ( ; image; image=image->next)
1226 SetImageClipMask(image,clip_mask);
1229 if (LocaleNCompare(attribute,"colormap",8) == 0)
1231 for ( ; image; image=image->next)
1239 if (image->storage_class == DirectClass)
1242 items=sscanf(attribute,"%*[^[][%ld",&i);
1244 if (i > (ssize_t) image->colors)
1246 if ((strchr(SvPV(sval,na),',') == 0) ||
1247 (strchr(SvPV(sval,na),')') != 0))
1248 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1251 color=image->colormap+i;
1252 pixel.red=color->red;
1253 pixel.green=color->green;
1254 pixel.blue=color->blue;
1255 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1256 pixel.red=geometry_info.rho;
1257 pixel.green=geometry_info.sigma;
1258 pixel.blue=geometry_info.xi;
1259 color->red=ClampToQuantum(pixel.red);
1260 color->green=ClampToQuantum(pixel.green);
1261 color->blue=ClampToQuantum(pixel.blue);
1266 if (LocaleCompare(attribute,"colorspace") == 0)
1268 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1269 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1272 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1276 for ( ; image; image=image->next)
1277 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1280 if (LocaleCompare(attribute,"comment") == 0)
1282 for ( ; image; image=image->next)
1283 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1284 info ? info->image_info : (ImageInfo *) NULL,image,
1288 if (LocaleCompare(attribute,"compression") == 0)
1290 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1291 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1294 ThrowPerlException(exception,OptionError,
1295 "UnrecognizedImageCompression",SvPV(sval,na));
1299 info->image_info->compression=(CompressionType) sp;
1300 for ( ; image; image=image->next)
1301 image->compression=(CompressionType) sp;
1305 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1306 for ( ; image; image=image->next)
1307 SetImageProperty(image,attribute,SvPV(sval,na));
1313 if (LocaleCompare(attribute,"debug") == 0)
1315 SetLogEventMask(SvPV(sval,na));
1318 if (LocaleCompare(attribute,"delay") == 0)
1320 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1321 for ( ; image; image=image->next)
1323 image->delay=(size_t) floor(geometry_info.rho+0.5);
1324 if ((flags & SigmaValue) != 0)
1325 image->ticks_per_second=(ssize_t)
1326 floor(geometry_info.sigma+0.5);
1330 if (LocaleCompare(attribute,"disk-limit") == 0)
1335 limit=MagickResourceInfinity;
1336 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1337 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1338 (void) SetMagickResourceLimit(DiskResource,limit);
1341 if (LocaleCompare(attribute,"density") == 0)
1343 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1345 ThrowPerlException(exception,OptionError,"MissingGeometry",
1350 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1351 for ( ; image; image=image->next)
1353 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1354 image->x_resolution=geometry_info.rho;
1355 image->y_resolution=geometry_info.sigma;
1356 if ((flags & SigmaValue) == 0)
1357 image->y_resolution=image->x_resolution;
1361 if (LocaleCompare(attribute,"depth") == 0)
1364 info->image_info->depth=SvIV(sval);
1365 for ( ; image; image=image->next)
1366 (void) SetImageDepth(image,SvIV(sval));
1369 if (LocaleCompare(attribute,"dispose") == 0)
1371 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1372 SvPV(sval,na)) : SvIV(sval);
1375 ThrowPerlException(exception,OptionError,
1376 "UnrecognizedDisposeMethod",SvPV(sval,na));
1379 for ( ; image; image=image->next)
1380 image->dispose=(DisposeType) sp;
1383 if (LocaleCompare(attribute,"dither") == 0)
1387 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1388 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1391 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1395 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1399 if (LocaleCompare(attribute,"display") == 0)
1403 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1407 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1408 for ( ; image; image=image->next)
1409 SetImageProperty(image,attribute,SvPV(sval,na));
1415 if (LocaleCompare(attribute,"endian") == 0)
1417 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1418 SvPV(sval,na)) : SvIV(sval);
1421 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1426 info->image_info->endian=(EndianType) sp;
1427 for ( ; image; image=image->next)
1428 image->endian=(EndianType) sp;
1431 if (LocaleCompare(attribute,"extract") == 0)
1434 Set image extract geometry.
1436 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1440 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1441 for ( ; image; image=image->next)
1442 SetImageProperty(image,attribute,SvPV(sval,na));
1448 if (LocaleCompare(attribute,"filename") == 0)
1451 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1453 for ( ; image; image=image->next)
1454 (void) CopyMagickString(image->filename,SvPV(sval,na),
1458 if (LocaleCompare(attribute,"file") == 0)
1466 if (info == (struct PackageInfo *) NULL)
1468 io_info=IoIFP(sv_2io(sval));
1469 if (io_info == (PerlIO *) NULL)
1471 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1475 file=PerlIO_findFILE(io_info);
1476 if (file == (FILE *) NULL)
1478 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1482 SetImageInfoFile(info->image_info,file);
1485 if (LocaleCompare(attribute,"fill") == 0)
1488 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1491 if (LocaleCompare(attribute,"font") == 0)
1494 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1497 if (LocaleCompare(attribute,"foreground") == 0)
1499 if (LocaleCompare(attribute,"fuzz") == 0)
1502 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1503 for ( ; image; image=image->next)
1504 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1508 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1509 for ( ; image; image=image->next)
1510 SetImageProperty(image,attribute,SvPV(sval,na));
1516 if (LocaleCompare(attribute,"gamma") == 0)
1518 for ( ; image; image=image->next)
1519 image->gamma=SvNV(sval);
1522 if (LocaleCompare(attribute,"gravity") == 0)
1524 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1525 SvPV(sval,na)) : SvIV(sval);
1528 ThrowPerlException(exception,OptionError,
1529 "UnrecognizedGravityType",SvPV(sval,na));
1533 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1534 for ( ; image; image=image->next)
1535 image->gravity=(GravityType) sp;
1538 if (LocaleCompare(attribute,"green-primary") == 0)
1540 for ( ; image; image=image->next)
1542 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1543 image->chromaticity.green_primary.x=geometry_info.rho;
1544 image->chromaticity.green_primary.y=geometry_info.sigma;
1545 if ((flags & SigmaValue) == 0)
1546 image->chromaticity.green_primary.y=
1547 image->chromaticity.green_primary.x;
1552 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1553 for ( ; image; image=image->next)
1554 SetImageProperty(image,attribute,SvPV(sval,na));
1560 if (LocaleNCompare(attribute,"index",5) == 0)
1574 for ( ; image; image=image->next)
1576 if (image->storage_class != PseudoClass)
1580 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1582 image_view=AcquireCacheView(image);
1583 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1584 if (q != (Quantum *) NULL)
1586 items=sscanf(SvPV(sval,na),"%ld",&index);
1587 if ((index >= 0) && (index < (ssize_t) image->colors))
1588 SetPixelIndex(image,index,q);
1589 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1591 image_view=DestroyCacheView(image_view);
1595 if (LocaleCompare(attribute,"iterations") == 0)
1598 for ( ; image; image=image->next)
1599 image->iterations=SvIV(sval);
1602 if (LocaleCompare(attribute,"interlace") == 0)
1604 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1605 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1608 ThrowPerlException(exception,OptionError,
1609 "UnrecognizedInterlaceType",SvPV(sval,na));
1613 info->image_info->interlace=(InterlaceType) sp;
1614 for ( ; image; image=image->next)
1615 image->interlace=(InterlaceType) sp;
1619 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1620 for ( ; image; image=image->next)
1621 SetImageProperty(image,attribute,SvPV(sval,na));
1627 if (LocaleCompare(attribute,"label") == 0)
1629 for ( ; image; image=image->next)
1630 (void) SetImageProperty(image,"label",InterpretImageProperties(
1631 info ? info->image_info : (ImageInfo *) NULL,image,
1635 if (LocaleCompare(attribute,"loop") == 0)
1638 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1639 for ( ; image; image=image->next)
1640 SetImageProperty(image,attribute,SvPV(sval,na));
1646 if (LocaleCompare(attribute,"magick") == 0)
1649 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1650 "%s:",SvPV(sval,na));
1651 for ( ; image; image=image->next)
1652 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1655 if (LocaleCompare(attribute,"map-limit") == 0)
1660 limit=MagickResourceInfinity;
1661 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1662 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1663 (void) SetMagickResourceLimit(MapResource,limit);
1666 if (LocaleCompare(attribute,"mask") == 0)
1671 mask=(Image *) NULL;
1673 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1674 for ( ; image; image=image->next)
1675 SetImageMask(image,mask);
1678 if (LocaleCompare(attribute,"mattecolor") == 0)
1680 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1682 info->image_info->matte_color=target_color;
1683 for ( ; image; image=image->next)
1684 image->matte_color=target_color;
1687 if (LocaleCompare(attribute,"matte") == 0)
1689 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1690 SvPV(sval,na)) : SvIV(sval);
1693 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1697 for ( ; image; image=image->next)
1698 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1701 if (LocaleCompare(attribute,"memory-limit") == 0)
1706 limit=MagickResourceInfinity;
1707 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1708 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1709 (void) SetMagickResourceLimit(MemoryResource,limit);
1712 if (LocaleCompare(attribute,"monochrome") == 0)
1714 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1715 SvPV(sval,na)) : SvIV(sval);
1718 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1723 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1724 for ( ; image; image=image->next)
1725 (void) SetImageType(image,BilevelType);
1729 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1730 for ( ; image; image=image->next)
1731 SetImageProperty(image,attribute,SvPV(sval,na));
1737 if (LocaleCompare(attribute,"option") == 0)
1740 DefineImageOption(info->image_info,SvPV(sval,na));
1743 if (LocaleCompare(attribute,"orientation") == 0)
1745 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1746 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1749 ThrowPerlException(exception,OptionError,
1750 "UnrecognizedOrientationType",SvPV(sval,na));
1754 info->image_info->orientation=(OrientationType) sp;
1755 for ( ; image; image=image->next)
1756 image->orientation=(OrientationType) sp;
1760 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1761 for ( ; image; image=image->next)
1762 SetImageProperty(image,attribute,SvPV(sval,na));
1768 if (LocaleCompare(attribute,"page") == 0)
1773 geometry=GetPageGeometry(SvPV(sval,na));
1775 (void) CloneString(&info->image_info->page,geometry);
1776 for ( ; image; image=image->next)
1777 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1778 geometry=(char *) RelinquishMagickMemory(geometry);
1781 if (LocaleCompare(attribute,"pen") == 0)
1784 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1787 if (LocaleNCompare(attribute,"pixel",5) == 0)
1801 for ( ; image; image=image->next)
1803 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1807 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1809 image_view=AcquireCacheView(image);
1810 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1811 if (q != (Quantum *) NULL)
1813 if ((strchr(SvPV(sval,na),',') == 0) ||
1814 (strchr(SvPV(sval,na),')') != 0))
1815 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1818 GetPixelInfo(image,&pixel);
1819 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1820 pixel.red=geometry_info.rho;
1821 if ((flags & SigmaValue) != 0)
1822 pixel.green=geometry_info.sigma;
1823 if ((flags & XiValue) != 0)
1824 pixel.blue=geometry_info.xi;
1825 if ((flags & PsiValue) != 0)
1826 pixel.alpha=geometry_info.psi;
1827 if ((flags & ChiValue) != 0)
1828 pixel.black=geometry_info.chi;
1830 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1831 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1832 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1833 if (image->colorspace == CMYKColorspace)
1834 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1835 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1836 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1838 image_view=DestroyCacheView(image_view);
1842 if (LocaleCompare(attribute,"pointsize") == 0)
1846 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1847 info->image_info->pointsize=geometry_info.rho;
1851 if (LocaleCompare(attribute,"preview") == 0)
1853 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1854 SvPV(sval,na)) : SvIV(sval);
1857 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1862 info->image_info->preview_type=(PreviewType) sp;
1866 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1867 for ( ; image; image=image->next)
1868 SetImageProperty(image,attribute,SvPV(sval,na));
1874 if (LocaleCompare(attribute,"quality") == 0)
1877 info->image_info->quality=SvIV(sval);
1878 for ( ; image; image=image->next)
1879 image->quality=SvIV(sval);
1883 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1884 for ( ; image; image=image->next)
1885 SetImageProperty(image,attribute,SvPV(sval,na));
1891 if (LocaleCompare(attribute,"red-primary") == 0)
1893 for ( ; image; image=image->next)
1895 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1896 image->chromaticity.red_primary.x=geometry_info.rho;
1897 image->chromaticity.red_primary.y=geometry_info.sigma;
1898 if ((flags & SigmaValue) == 0)
1899 image->chromaticity.red_primary.y=
1900 image->chromaticity.red_primary.x;
1904 if (LocaleCompare(attribute,"render") == 0)
1906 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1907 SvPV(sval,na)) : SvIV(sval);
1910 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1914 for ( ; image; image=image->next)
1915 image->rendering_intent=(RenderingIntent) sp;
1918 if (LocaleCompare(attribute,"repage") == 0)
1923 for ( ; image; image=image->next)
1925 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1926 if ((flags & WidthValue) != 0)
1928 if ((flags & HeightValue) == 0)
1929 geometry.height=geometry.width;
1930 image->page.width=geometry.width;
1931 image->page.height=geometry.height;
1933 if ((flags & AspectValue) != 0)
1935 if ((flags & XValue) != 0)
1936 image->page.x+=geometry.x;
1937 if ((flags & YValue) != 0)
1938 image->page.y+=geometry.y;
1942 if ((flags & XValue) != 0)
1944 image->page.x=geometry.x;
1945 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1946 image->page.width=image->columns+geometry.x;
1948 if ((flags & YValue) != 0)
1950 image->page.y=geometry.y;
1951 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1952 image->page.height=image->rows+geometry.y;
1959 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1960 for ( ; image; image=image->next)
1961 SetImageProperty(image,attribute,SvPV(sval,na));
1967 if (LocaleCompare(attribute,"sampling-factor") == 0)
1969 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1971 ThrowPerlException(exception,OptionError,"MissingGeometry",
1976 (void) CloneString(&info->image_info->sampling_factor,
1980 if (LocaleCompare(attribute,"scene") == 0)
1982 for ( ; image; image=image->next)
1983 image->scene=SvIV(sval);
1986 if (LocaleCompare(attribute,"server") == 0)
1988 if (LocaleCompare(attribute,"size") == 0)
1992 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1994 ThrowPerlException(exception,OptionError,"MissingGeometry",
1998 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2002 if (LocaleCompare(attribute,"stroke") == 0)
2005 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2009 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2010 for ( ; image; image=image->next)
2011 SetImageProperty(image,attribute,SvPV(sval,na));
2017 if (LocaleCompare(attribute,"texture") == 0)
2020 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2023 if (LocaleCompare(attribute,"thread-limit") == 0)
2028 limit=MagickResourceInfinity;
2029 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2030 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2031 (void) SetMagickResourceLimit(ThreadResource,limit);
2034 if (LocaleCompare(attribute,"tile-offset") == 0)
2039 geometry=GetPageGeometry(SvPV(sval,na));
2041 (void) CloneString(&info->image_info->page,geometry);
2042 for ( ; image; image=image->next)
2043 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2045 geometry=(char *) RelinquishMagickMemory(geometry);
2048 if (LocaleCompare(attribute,"time-limit") == 0)
2053 limit=MagickResourceInfinity;
2054 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2055 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2056 (void) SetMagickResourceLimit(TimeResource,limit);
2059 if (LocaleCompare(attribute,"transparent-color") == 0)
2061 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2063 info->image_info->transparent_color=target_color;
2064 for ( ; image; image=image->next)
2065 image->transparent_color=target_color;
2068 if (LocaleCompare(attribute,"type") == 0)
2070 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2071 SvPV(sval,na)) : SvIV(sval);
2074 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2079 info->image_info->type=(ImageType) sp;
2080 for ( ; image; image=image->next)
2081 SetImageType(image,(ImageType) sp);
2085 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2086 for ( ; image; image=image->next)
2087 SetImageProperty(image,attribute,SvPV(sval,na));
2093 if (LocaleCompare(attribute,"units") == 0)
2095 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2096 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2099 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2104 info->image_info->units=(ResolutionType) sp;
2105 for ( ; image; image=image->next)
2110 units=(ResolutionType) sp;
2111 if (image->units != units)
2112 switch (image->units)
2114 case UndefinedResolution:
2115 case PixelsPerInchResolution:
2117 if (units == PixelsPerCentimeterResolution)
2119 image->x_resolution*=2.54;
2120 image->y_resolution*=2.54;
2124 case PixelsPerCentimeterResolution:
2126 if (units == PixelsPerInchResolution)
2128 image->x_resolution/=2.54;
2129 image->y_resolution/=2.54;
2139 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2140 for ( ; image; image=image->next)
2141 SetImageProperty(image,attribute,SvPV(sval,na));
2147 if (LocaleCompare(attribute,"verbose") == 0)
2149 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2150 SvPV(sval,na)) : SvIV(sval);
2153 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2158 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2161 if (LocaleCompare(attribute,"view") == 0)
2164 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2167 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2169 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2170 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2173 ThrowPerlException(exception,OptionError,
2174 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2178 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2179 for ( ; image; image=image->next)
2180 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2184 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2185 for ( ; image; image=image->next)
2186 SetImageProperty(image,attribute,SvPV(sval,na));
2192 if (LocaleCompare(attribute,"white-point") == 0)
2194 for ( ; image; image=image->next)
2196 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2197 image->chromaticity.white_point.x=geometry_info.rho;
2198 image->chromaticity.white_point.y=geometry_info.sigma;
2199 if ((flags & SigmaValue) == 0)
2200 image->chromaticity.white_point.y=
2201 image->chromaticity.white_point.x;
2206 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2207 for ( ; image; image=image->next)
2208 SetImageProperty(image,attribute,SvPV(sval,na));
2214 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2215 for ( ; image; image=image->next)
2216 SetImageProperty(image,attribute,SvPV(sval,na));
2223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2227 % S e t u p L i s t %
2231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2233 % Method SetupList returns the list of all the images linked by their
2234 % image->next and image->previous link lists for use with ImageMagick. If
2235 % info is non-NULL, an info structure is returned in *info. If
2236 % reference_vector is non-NULL,an array of SV* are returned in
2237 % *reference_vector. Reference_vector is used when the images are going to be
2238 % replaced with new Image*'s.
2240 % The format of the SetupList routine is:
2242 % Image *SetupList(SV *reference,struct PackageInfo **info,
2243 % SV ***reference_vector,ExceptionInfo *exception)
2245 % A description of each parameter follows:
2247 % o list: a list of strings.
2249 % o string: a character string.
2251 % o exception: Return any errors or warnings in this structure.
2254 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2255 SV ***reference_vector,ExceptionInfo *exception)
2264 if (reference_vector)
2265 *reference_vector=NULL;
2270 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2271 if (info && (SvTYPE(reference) == SVt_PVAV))
2272 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2282 % s t r E Q c a s e %
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 % strEQcase() compares two strings and returns 0 if they are the
2289 % same or if the second string runs out first. The comparison is case
2292 % The format of the strEQcase routine is:
2294 % ssize_t strEQcase(const char *p,const char *q)
2296 % A description of each parameter follows:
2298 % o p: a character string.
2300 % o q: a character string.
2304 static ssize_t strEQcase(const char *p,const char *q)
2312 for (i=0 ; (c=(*q)) != 0; i++)
2314 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2315 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2320 return(((*q == 0) && (*p == 0)) ? i : 0);
2324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2328 % I m a g e : : M a g i c k %
2332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2336 MODULE = Image::Magick PACKAGE = Image::Magick
2341 MagickCoreGenesis("PerlMagick",MagickFalse);
2342 SetWarningHandler(NULL);
2343 SetErrorHandler(NULL);
2344 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2345 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2351 if (magick_registry != (SplayTreeInfo *) NULL)
2352 magick_registry=DestroySplayTree(magick_registry);
2353 MagickCoreTerminus();
2357 constant(name,argument)
2362 ###############################################################################
2370 ###############################################################################
2375 Image::Magick ref=NO_INIT
2399 PERL_UNUSED_VAR(ref);
2400 PERL_UNUSED_VAR(ix);
2401 exception=AcquireExceptionInfo();
2402 perl_exception=newSVpv("",0);
2403 package_info=(struct PackageInfo *) NULL;
2404 if (sv_isobject(ST(0)) == 0)
2406 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2410 reference=SvRV(ST(0));
2411 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2412 if (image == (Image *) NULL)
2414 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2418 package_info=ClonePackageInfo(info,exception);
2420 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2423 for (i=2; i < items; i+=2)
2424 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2426 (void) AnimateImages(package_info->image_info,image);
2427 (void) CatchImageException(image);
2428 InheritException(exception,&image->exception);
2431 if (package_info != (struct PackageInfo *) NULL)
2432 DestroyPackageInfo(package_info);
2433 InheritPerlException(exception,perl_exception);
2434 exception=DestroyExceptionInfo(exception);
2435 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2436 SvPOK_on(perl_exception);
2437 ST(0)=sv_2mortal(perl_exception);
2442 ###############################################################################
2450 ###############################################################################
2455 Image::Magick ref=NO_INIT
2493 PERL_UNUSED_VAR(ref);
2494 PERL_UNUSED_VAR(ix);
2495 exception=AcquireExceptionInfo();
2496 perl_exception=newSVpv("",0);
2500 if (sv_isobject(ST(0)) == 0)
2502 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2506 reference=SvRV(ST(0));
2507 hv=SvSTASH(reference);
2509 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2511 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2512 if (image == (Image *) NULL)
2514 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2518 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2523 for (i=2; i < items; i+=2)
2525 attribute=(char *) SvPV(ST(i-1),na);
2531 if (LocaleCompare(attribute,"stack") == 0)
2533 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2537 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2555 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2556 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2558 for ( ; image; image=image->next)
2560 AddImageToRegistry(sv,image);
2562 av_push(av,sv_bless(rv,hv));
2565 exception=DestroyExceptionInfo(exception);
2567 SvREFCNT_dec(perl_exception);
2571 InheritPerlException(exception,perl_exception);
2572 exception=DestroyExceptionInfo(exception);
2573 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2574 SvPOK_on(perl_exception);
2575 ST(0)=sv_2mortal(perl_exception);
2580 ###############################################################################
2588 ###############################################################################
2593 Image::Magick ref=NO_INIT
2624 PERL_UNUSED_VAR(ref);
2625 PERL_UNUSED_VAR(ix);
2626 exception=AcquireExceptionInfo();
2627 perl_exception=newSVpv("",0);
2629 if (sv_isobject(ST(0)) == 0)
2631 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2635 reference=SvRV(ST(0));
2636 hv=SvSTASH(reference);
2637 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2638 if (image == (Image *) NULL)
2640 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2644 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2645 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2648 Create blessed Perl array for the returned image.
2651 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2653 AddImageToRegistry(sv,image);
2655 av_push(av,sv_bless(rv,hv));
2657 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2658 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2659 "average-%.*s",(int) (MaxTextExtent-9),
2660 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2661 (void) CopyMagickString(image->filename,info->image_info->filename,
2663 SetImageInfo(info->image_info,0,exception);
2664 exception=DestroyExceptionInfo(exception);
2665 SvREFCNT_dec(perl_exception);
2669 InheritPerlException(exception,perl_exception);
2670 exception=DestroyExceptionInfo(exception);
2671 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2672 SvPOK_on(perl_exception);
2673 ST(0)=sv_2mortal(perl_exception);
2678 ###############################################################################
2682 # B l o b T o I m a g e #
2686 ###############################################################################
2690 BlobToImage(ref,...)
2691 Image::Magick ref=NO_INIT
2737 PERL_UNUSED_VAR(ref);
2738 PERL_UNUSED_VAR(ix);
2739 exception=AcquireExceptionInfo();
2740 perl_exception=newSVpv("",0);
2743 ac=(items < 2) ? 1 : items-1;
2744 length=(STRLEN *) NULL;
2745 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2746 if (list == (char **) NULL)
2748 ThrowPerlException(exception,ResourceLimitError,
2749 "MemoryAllocationFailed",PackageName);
2752 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2753 if (length == (STRLEN *) NULL)
2755 ThrowPerlException(exception,ResourceLimitError,
2756 "MemoryAllocationFailed",PackageName);
2759 if (sv_isobject(ST(0)) == 0)
2761 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2765 reference=SvRV(ST(0));
2766 hv=SvSTASH(reference);
2767 if (SvTYPE(reference) != SVt_PVAV)
2769 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2773 av=(AV *) reference;
2774 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2779 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2782 for (n=0, i=0; i < ac; i++)
2784 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2785 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2787 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2792 list[n]=(char *) NULL;
2794 for (i=number_images=0; i < n; i++)
2796 image=BlobToImage(info->image_info,list[i],length[i],exception);
2797 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2799 for ( ; image; image=image->next)
2801 AddImageToRegistry(sv,image);
2803 av_push(av,sv_bless(rv,hv));
2811 for (i=0; i < n; i++)
2812 if (list[i] != (char *) NULL)
2813 for (p=keep; list[i] != *p++; )
2814 if (*p == (char *) NULL)
2816 list[i]=(char *) RelinquishMagickMemory(list[i]);
2822 list=(char **) RelinquishMagickMemory(list);
2824 length=(STRLEN *) RelinquishMagickMemory(length);
2825 InheritPerlException(exception,perl_exception);
2826 exception=DestroyExceptionInfo(exception);
2827 sv_setiv(perl_exception,(IV) number_images);
2828 SvPOK_on(perl_exception);
2829 ST(0)=sv_2mortal(perl_exception);
2834 ###############################################################################
2842 ###############################################################################
2847 Image::Magick ref=NO_INIT
2880 PERL_UNUSED_VAR(ref);
2881 PERL_UNUSED_VAR(ix);
2882 exception=AcquireExceptionInfo();
2883 perl_exception=newSVpv("",0);
2885 if (sv_isobject(ST(0)) == 0)
2887 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2891 reference=SvRV(ST(0));
2892 hv=SvSTASH(reference);
2893 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2894 if (image == (Image *) NULL)
2896 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2901 Create blessed Perl array for the returned image.
2904 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2906 for ( ; image; image=image->next)
2908 clone=CloneImage(image,0,0,MagickTrue,exception);
2909 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2911 AddImageToRegistry(sv,clone);
2913 av_push(av,sv_bless(rv,hv));
2916 exception=DestroyExceptionInfo(exception);
2917 SvREFCNT_dec(perl_exception);
2921 InheritPerlException(exception,perl_exception);
2922 exception=DestroyExceptionInfo(exception);
2923 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2924 SvPOK_on(perl_exception);
2925 ST(0)=sv_2mortal(perl_exception);
2930 ###############################################################################
2938 ###############################################################################
2946 PERL_UNUSED_VAR(ref);
2947 if (magick_registry != (SplayTreeInfo *) NULL)
2952 ResetSplayTreeIterator(magick_registry);
2953 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2954 while (p != (Image *) NULL)
2957 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2963 ###############################################################################
2971 ###############################################################################
2976 Image::Magick ref=NO_INIT
3005 PERL_UNUSED_VAR(ref);
3006 PERL_UNUSED_VAR(ix);
3007 exception=AcquireExceptionInfo();
3008 perl_exception=newSVpv("",0);
3010 if (sv_isobject(ST(0)) == 0)
3012 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3016 reference=SvRV(ST(0));
3017 hv=SvSTASH(reference);
3019 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3021 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3022 if (image == (Image *) NULL)
3024 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3028 image=CoalesceImages(image,exception);
3029 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3031 for ( ; image; image=image->next)
3033 AddImageToRegistry(sv,image);
3035 av_push(av,sv_bless(rv,hv));
3038 exception=DestroyExceptionInfo(exception);
3040 SvREFCNT_dec(perl_exception);
3044 InheritPerlException(exception,perl_exception);
3045 exception=DestroyExceptionInfo(exception);
3046 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3047 SvPOK_on(perl_exception);
3048 ST(0)=sv_2mortal(perl_exception);
3053 ###############################################################################
3061 ###############################################################################
3066 Image::Magick ref=NO_INIT
3112 PERL_UNUSED_VAR(ref);
3113 PERL_UNUSED_VAR(ix);
3114 exception=AcquireExceptionInfo();
3115 perl_exception=newSVpv("",0);
3119 if (sv_isobject(ST(0)) == 0)
3121 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3125 reference=SvRV(ST(0));
3126 hv=SvSTASH(reference);
3128 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3130 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3131 if (image == (Image *) NULL)
3133 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3137 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3141 reconstruct_image=image;
3142 metric=RootMeanSquaredErrorMetric;
3143 for (i=2; i < items; i+=2)
3145 attribute=(char *) SvPV(ST(i-1),na);
3151 if (LocaleCompare(attribute,"channel") == 0)
3156 option=ParseChannelOption(SvPV(ST(i),na));
3159 ThrowPerlException(exception,OptionError,
3160 "UnrecognizedType",SvPV(ST(i),na));
3163 SetPixelComponentMap(image,(ChannelType) option);
3166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3173 if (LocaleCompare(attribute,"fuzz") == 0)
3175 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3185 if (LocaleCompare(attribute,"image") == 0)
3187 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3188 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3191 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3198 if (LocaleCompare(attribute,"metric") == 0)
3200 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3204 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3208 metric=(MetricType) option;
3211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3217 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3223 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3225 if (difference_image != (Image *) NULL)
3227 difference_image->error.mean_error_per_pixel=distortion;
3228 AddImageToRegistry(sv,difference_image);
3230 av_push(av,sv_bless(rv,hv));
3233 exception=DestroyExceptionInfo(exception);
3235 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3239 InheritPerlException(exception,perl_exception);
3240 exception=DestroyExceptionInfo(exception);
3241 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3242 SvPOK_on(perl_exception);
3243 ST(0)=sv_2mortal(perl_exception);
3248 ###############################################################################
3252 # C o m p a r e L a y e r s #
3256 ###############################################################################
3261 Image::Magick ref=NO_INIT
3263 CompareImagesLayers = 1
3265 compareimagelayers = 3
3302 PERL_UNUSED_VAR(ref);
3303 PERL_UNUSED_VAR(ix);
3304 exception=AcquireExceptionInfo();
3305 perl_exception=newSVpv("",0);
3307 if (sv_isobject(ST(0)) == 0)
3309 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3313 reference=SvRV(ST(0));
3314 hv=SvSTASH(reference);
3316 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3318 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3319 if (image == (Image *) NULL)
3321 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3325 method=CompareAnyLayer;
3326 for (i=2; i < items; i+=2)
3328 attribute=(char *) SvPV(ST(i-1),na);
3334 if (LocaleCompare(attribute,"method") == 0)
3336 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3340 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3344 method=(ImageLayerMethod) option;
3347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3353 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3359 image=CompareImagesLayers(image,method,exception);
3360 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3362 for ( ; image; image=image->next)
3364 AddImageToRegistry(sv,image);
3366 av_push(av,sv_bless(rv,hv));
3369 exception=DestroyExceptionInfo(exception);
3371 SvREFCNT_dec(perl_exception);
3375 InheritPerlException(exception,perl_exception);
3376 exception=DestroyExceptionInfo(exception);
3377 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3378 SvPOK_on(perl_exception);
3379 ST(0)=sv_2mortal(perl_exception);
3384 ###############################################################################
3392 ###############################################################################
3397 Image::Magick ref=NO_INIT
3403 PERL_UNUSED_VAR(ref);
3404 if (sv_isobject(ST(0)) == 0)
3405 croak("ReferenceIsNotMyType");
3406 reference=SvRV(ST(0));
3407 switch (SvTYPE(reference))
3412 message[MaxTextExtent];
3430 Array (AV *) reference
3432 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3433 XS_VERSION,reference);
3434 hv=gv_stashpv(PackageName, FALSE);
3437 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3441 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3443 info=(struct PackageInfo *) SvIV(sv);
3444 DestroyPackageInfo(info);
3446 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3456 Blessed scalar = (Image *) SvIV(reference)
3458 image=(Image *) SvIV(reference);
3459 if (image != (Image *) NULL)
3460 DeleteImageFromRegistry(reference,image);
3469 ###############################################################################
3477 ###############################################################################
3482 Image::Magick ref=NO_INIT
3506 PERL_UNUSED_VAR(ref);
3507 PERL_UNUSED_VAR(ix);
3508 exception=AcquireExceptionInfo();
3509 perl_exception=newSVpv("",0);
3510 package_info=(struct PackageInfo *) NULL;
3511 if (sv_isobject(ST(0)) == 0)
3513 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3517 reference=SvRV(ST(0));
3518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3519 if (image == (Image *) NULL)
3521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3525 package_info=ClonePackageInfo(info,exception);
3527 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3530 for (i=2; i < items; i+=2)
3531 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3533 (void) DisplayImages(package_info->image_info,image);
3534 (void) CatchImageException(image);
3535 InheritException(exception,&image->exception);
3538 if (package_info != (struct PackageInfo *) NULL)
3539 DestroyPackageInfo(package_info);
3540 InheritPerlException(exception,perl_exception);
3541 exception=DestroyExceptionInfo(exception);
3542 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3543 SvPOK_on(perl_exception);
3544 ST(0)=sv_2mortal(perl_exception);
3549 ###############################################################################
3553 # E v a l u a t e I m a g e s #
3557 ###############################################################################
3562 Image::Magick ref=NO_INIT
3584 MagickEvaluateOperator
3599 PERL_UNUSED_VAR(ref);
3600 PERL_UNUSED_VAR(ix);
3601 exception=AcquireExceptionInfo();
3602 perl_exception=newSVpv("",0);
3604 if (sv_isobject(ST(0)) == 0)
3606 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3610 reference=SvRV(ST(0));
3611 hv=SvSTASH(reference);
3612 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3613 if (image == (Image *) NULL)
3615 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3619 op=MeanEvaluateOperator;
3625 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3629 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3633 op=(MagickEvaluateOperator) in;
3636 for (i=2; i < items; i+=2)
3638 attribute=(char *) SvPV(ST(i-1),na);
3644 if (LocaleCompare(attribute,"operator") == 0)
3649 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3650 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3653 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3657 op=(MagickEvaluateOperator) in;
3660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3672 image=EvaluateImages(image,op,exception);
3673 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3676 Create blessed Perl array for the returned image.
3679 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3681 AddImageToRegistry(sv,image);
3683 av_push(av,sv_bless(rv,hv));
3685 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3686 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3687 "evaluate-%.*s",(int) (MaxTextExtent-9),
3688 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3689 (void) CopyMagickString(image->filename,info->image_info->filename,
3691 SetImageInfo(info->image_info,0,exception);
3692 exception=DestroyExceptionInfo(exception);
3693 SvREFCNT_dec(perl_exception);
3697 InheritPerlException(exception,perl_exception);
3698 exception=DestroyExceptionInfo(exception);
3699 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3700 SvPOK_on(perl_exception);
3701 ST(0)=sv_2mortal(perl_exception);
3706 ###############################################################################
3714 ###############################################################################
3719 Image::Magick ref=NO_INIT
3726 #define ChannelFeatures(channel,direction) \
3728 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3729 channel_features[channel].angular_second_moment[direction]); \
3730 PUSHs(sv_2mortal(newSVpv(message,0))); \
3731 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3732 channel_features[channel].contrast[direction]); \
3733 PUSHs(sv_2mortal(newSVpv(message,0))); \
3734 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3735 channel_features[channel].contrast[direction]); \
3736 PUSHs(sv_2mortal(newSVpv(message,0))); \
3737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3738 channel_features[channel].variance_sum_of_squares[direction]); \
3739 PUSHs(sv_2mortal(newSVpv(message,0))); \
3740 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3741 channel_features[channel].inverse_difference_moment[direction]); \
3742 PUSHs(sv_2mortal(newSVpv(message,0))); \
3743 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3744 channel_features[channel].sum_average[direction]); \
3745 PUSHs(sv_2mortal(newSVpv(message,0))); \
3746 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3747 channel_features[channel].sum_variance[direction]); \
3748 PUSHs(sv_2mortal(newSVpv(message,0))); \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].sum_entropy[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].entropy[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].difference_variance[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].difference_entropy[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].measure_of_correlation_1[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].measure_of_correlation_2[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].maximum_correlation_coefficient[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3777 message[MaxTextExtent];
3804 PERL_UNUSED_VAR(ref);
3805 PERL_UNUSED_VAR(ix);
3806 exception=AcquireExceptionInfo();
3807 perl_exception=newSVpv("",0);
3809 if (sv_isobject(ST(0)) == 0)
3811 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3815 reference=SvRV(ST(0));
3818 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3819 if (image == (Image *) NULL)
3821 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3825 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3827 for (i=2; i < items; i+=2)
3829 attribute=(char *) SvPV(ST(i-1),na);
3835 if (LocaleCompare(attribute,"distance") == 0)
3837 distance=StringToLong((char *) SvPV(ST(1),na));
3840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3846 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3853 for ( ; image; image=image->next)
3855 channel_features=GetImageFeatures(image,distance,
3857 if (channel_features == (ChannelFeatures *) NULL)
3860 EXTEND(sp,75*count);
3861 for (i=0; i < 4; i++)
3863 ChannelFeatures(RedChannel,i);
3864 ChannelFeatures(GreenChannel,i);
3865 ChannelFeatures(BlueChannel,i);
3866 if (image->colorspace == CMYKColorspace)
3867 ChannelFeatures(BlackChannel,i);
3868 if (image->matte != MagickFalse)
3869 ChannelFeatures(AlphaChannel,i);
3871 channel_features=(ChannelFeatures *)
3872 RelinquishMagickMemory(channel_features);
3876 InheritPerlException(exception,perl_exception);
3877 exception=DestroyExceptionInfo(exception);
3878 SvREFCNT_dec(perl_exception);
3882 ###############################################################################
3890 ###############################################################################
3895 Image::Magick ref=NO_INIT
3933 PERL_UNUSED_VAR(ref);
3934 PERL_UNUSED_VAR(ix);
3935 exception=AcquireExceptionInfo();
3936 perl_exception=newSVpv("",0);
3938 if (sv_isobject(ST(0)) == 0)
3940 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3944 reference=SvRV(ST(0));
3945 hv=SvSTASH(reference);
3946 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3947 if (image == (Image *) NULL)
3949 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3953 background_color=image->background_color;
3955 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3958 for (i=2; i < items; i+=2)
3960 attribute=(char *) SvPV(ST(i-1),na);
3966 if (LocaleCompare(attribute,"background") == 0)
3968 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3969 &background_color,exception);
3972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3984 image->background_color=background_color;
3985 image=MergeImageLayers(image,FlattenLayer,exception);
3986 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3989 Create blessed Perl array for the returned image.
3992 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3994 AddImageToRegistry(sv,image);
3996 av_push(av,sv_bless(rv,hv));
3998 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3999 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4000 "flatten-%.*s",(int) (MaxTextExtent-9),
4001 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4002 (void) CopyMagickString(image->filename,info->image_info->filename,
4004 SetImageInfo(info->image_info,0,exception);
4005 exception=DestroyExceptionInfo(exception);
4006 SvREFCNT_dec(perl_exception);
4010 InheritPerlException(exception,perl_exception);
4011 exception=DestroyExceptionInfo(exception);
4012 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4013 SvPOK_on(perl_exception); /* return messages in string context */
4014 ST(0)=sv_2mortal(perl_exception);
4019 ###############################################################################
4027 ###############################################################################
4032 Image::Magick ref=NO_INIT
4044 expression[MaxTextExtent];
4071 PERL_UNUSED_VAR(ref);
4072 PERL_UNUSED_VAR(ix);
4073 exception=AcquireExceptionInfo();
4074 perl_exception=newSVpv("",0);
4078 if (sv_isobject(ST(0)) == 0)
4080 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4084 reference=SvRV(ST(0));
4085 hv=SvSTASH(reference);
4087 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4089 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4090 if (image == (Image *) NULL)
4092 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4096 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4100 channel=DefaultChannels;
4101 (void) CopyMagickString(expression,"u",MaxTextExtent);
4103 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4105 for (i=2; i < items; i+=2)
4107 attribute=(char *) SvPV(ST(i-1),na);
4113 if (LocaleCompare(attribute,"channel") == 0)
4118 option=ParseChannelOption(SvPV(ST(i),na));
4121 ThrowPerlException(exception,OptionError,
4122 "UnrecognizedType",SvPV(ST(i),na));
4125 channel=(ChannelType) option;
4128 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4135 if (LocaleCompare(attribute,"expression") == 0)
4137 (void) CopyMagickString(expression,SvPV(ST(i),na),
4141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4153 PushPixelComponentMap(image,channel);
4154 image=FxImage(image,expression,exception);
4155 PopPixelComponentMap(image);
4156 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4158 for ( ; image; image=image->next)
4160 AddImageToRegistry(sv,image);
4162 av_push(av,sv_bless(rv,hv));
4165 exception=DestroyExceptionInfo(exception);
4167 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4171 InheritPerlException(exception,perl_exception);
4172 exception=DestroyExceptionInfo(exception);
4173 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4174 SvPOK_on(perl_exception);
4175 ST(0)=sv_2mortal(perl_exception);
4180 ###############################################################################
4188 ###############################################################################
4193 Image::Magick ref=NO_INIT
4204 color[MaxTextExtent];
4229 PERL_UNUSED_VAR(ref);
4230 PERL_UNUSED_VAR(ix);
4231 exception=AcquireExceptionInfo();
4232 perl_exception=newSVpv("",0);
4233 if (sv_isobject(ST(0)) == 0)
4235 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4239 reference=SvRV(ST(0));
4240 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4241 if (image == (Image *) NULL && !info)
4244 for (i=1; i < items; i++)
4246 attribute=(char *) SvPV(ST(i),na);
4253 if (LocaleCompare(attribute,"adjoin") == 0)
4256 s=newSViv((ssize_t) info->image_info->adjoin);
4257 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4260 if (LocaleCompare(attribute,"antialias") == 0)
4263 s=newSViv((ssize_t) info->image_info->antialias);
4264 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4267 if (LocaleCompare(attribute,"area") == 0)
4269 s=newSViv(GetMagickResource(AreaResource));
4270 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4273 if (LocaleCompare(attribute,"attenuate") == 0)
4278 value=GetImageProperty(image,attribute);
4279 if (value != (const char *) NULL)
4281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4284 if (LocaleCompare(attribute,"authenticate") == 0)
4287 s=newSVpv(info->image_info->authenticate,0);
4288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4291 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4298 if (LocaleCompare(attribute,"background") == 0)
4300 if (image == (Image *) NULL)
4302 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4303 QuantumFormat "," QuantumFormat "," QuantumFormat,
4304 image->background_color.red,image->background_color.green,
4305 image->background_color.blue,image->background_color.alpha);
4307 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4310 if (LocaleCompare(attribute,"base-columns") == 0)
4312 if (image != (Image *) NULL)
4313 s=newSViv((ssize_t) image->magick_columns);
4314 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4317 if (LocaleCompare(attribute,"base-filename") == 0)
4319 if (image != (Image *) NULL)
4320 s=newSVpv(image->magick_filename,0);
4321 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4324 if (LocaleCompare(attribute,"base-height") == 0)
4326 if (image != (Image *) NULL)
4327 s=newSViv((ssize_t) image->magick_rows);
4328 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4331 if (LocaleCompare(attribute,"base-rows") == 0)
4333 if (image != (Image *) NULL)
4334 s=newSViv((ssize_t) image->magick_rows);
4335 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4338 if (LocaleCompare(attribute,"base-width") == 0)
4340 if (image != (Image *) NULL)
4341 s=newSViv((ssize_t) image->magick_columns);
4342 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4345 if (LocaleCompare(attribute,"bias") == 0)
4347 if (image != (Image *) NULL)
4348 s=newSVnv(image->bias);
4349 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4352 if (LocaleCompare(attribute,"blue-primary") == 0)
4354 if (image == (Image *) NULL)
4356 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4357 image->chromaticity.blue_primary.x,
4358 image->chromaticity.blue_primary.y);
4360 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4363 if (LocaleCompare(attribute,"bordercolor") == 0)
4365 if (image == (Image *) NULL)
4367 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4368 QuantumFormat "," QuantumFormat "," QuantumFormat,
4369 image->border_color.red,image->border_color.green,
4370 image->border_color.blue,image->border_color.alpha);
4372 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4375 if (LocaleCompare(attribute,"bounding-box") == 0)
4378 geometry[MaxTextExtent];
4383 if (image == (Image *) NULL)
4385 page=GetImageBoundingBox(image,&image->exception);
4386 (void) FormatLocaleString(geometry,MaxTextExtent,
4387 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4388 page.height,(double) page.x,(double) page.y);
4389 s=newSVpv(geometry,0);
4390 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4393 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4400 if (LocaleCompare(attribute,"class") == 0)
4402 if (image == (Image *) NULL)
4404 s=newSViv(image->storage_class);
4405 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4406 image->storage_class));
4408 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4411 if (LocaleCompare(attribute,"clip-mask") == 0)
4413 if (image != (Image *) NULL)
4419 if (image->mask == (Image *) NULL)
4421 if (image->mask != (Image *) NULL)
4423 AddImageToRegistry(sv,image->mask);
4424 s=sv_bless(newRV(sv),SvSTASH(reference));
4427 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4430 if (LocaleCompare(attribute,"clip-path") == 0)
4432 if (image != (Image *) NULL)
4438 if (image->clip_mask == (Image *) NULL)
4440 if (image->clip_mask != (Image *) NULL)
4442 AddImageToRegistry(sv,image->clip_mask);
4443 s=sv_bless(newRV(sv),SvSTASH(reference));
4446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4449 if (LocaleCompare(attribute,"compression") == 0)
4451 j=info ? info->image_info->compression : image ?
4452 image->compression : UndefinedCompression;
4454 if (info->image_info->compression == UndefinedCompression)
4455 j=image->compression;
4457 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4460 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4463 if (LocaleCompare(attribute,"colorspace") == 0)
4465 j=image ? image->colorspace : RGBColorspace;
4467 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4470 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4473 if (LocaleCompare(attribute,"colors") == 0)
4475 if (image != (Image *) NULL)
4476 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4477 &image->exception));
4478 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4481 if (LocaleNCompare(attribute,"colormap",8) == 0)
4486 if (image == (Image *) NULL || !image->colormap)
4489 items=sscanf(attribute,"%*[^[][%ld",&j);
4491 if (j > (ssize_t) image->colors)
4493 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4494 QuantumFormat "," QuantumFormat "," QuantumFormat,
4495 image->colormap[j].red,image->colormap[j].green,
4496 image->colormap[j].blue,image->colormap[j].alpha);
4498 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4501 if (LocaleCompare(attribute,"columns") == 0)
4503 if (image != (Image *) NULL)
4504 s=newSViv((ssize_t) image->columns);
4505 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4508 if (LocaleCompare(attribute,"comment") == 0)
4513 value=GetImageProperty(image,attribute);
4514 if (value != (const char *) NULL)
4516 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4519 if (LocaleCompare(attribute,"copyright") == 0)
4521 s=newSVpv(GetMagickCopyright(),0);
4522 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4525 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4532 if (LocaleCompare(attribute,"density") == 0)
4535 geometry[MaxTextExtent];
4537 if (image == (Image *) NULL)
4539 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4540 image->x_resolution,image->y_resolution);
4541 s=newSVpv(geometry,0);
4542 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4545 if (LocaleCompare(attribute,"delay") == 0)
4547 if (image != (Image *) NULL)
4548 s=newSViv((ssize_t) image->delay);
4549 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4552 if (LocaleCompare(attribute,"depth") == 0)
4554 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4555 if (image != (Image *) NULL)
4556 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4560 if (LocaleCompare(attribute,"directory") == 0)
4562 if (image && image->directory)
4563 s=newSVpv(image->directory,0);
4564 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4567 if (LocaleCompare(attribute,"dispose") == 0)
4569 if (image == (Image *) NULL)
4572 s=newSViv(image->dispose);
4574 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4576 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4579 if (LocaleCompare(attribute,"disk") == 0)
4581 s=newSViv(GetMagickResource(DiskResource));
4582 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4585 if (LocaleCompare(attribute,"dither") == 0)
4588 s=newSViv((ssize_t) info->image_info->dither);
4589 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4592 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4594 if (info && info->image_info->server_name)
4595 s=newSVpv(info->image_info->server_name,0);
4596 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4599 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4606 if (LocaleCompare(attribute,"elapsed-time") == 0)
4608 if (image != (Image *) NULL)
4609 s=newSVnv(GetElapsedTime(&image->timer));
4610 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4613 if (LocaleCompare(attribute,"endian") == 0)
4615 j=info ? info->image_info->endian : image ? image->endian :
4618 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4623 if (LocaleCompare(attribute,"error") == 0)
4625 if (image != (Image *) NULL)
4626 s=newSVnv(image->error.mean_error_per_pixel);
4627 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4630 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4637 if (LocaleCompare(attribute,"filesize") == 0)
4639 if (image != (Image *) NULL)
4640 s=newSViv((ssize_t) GetBlobSize(image));
4641 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4644 if (LocaleCompare(attribute,"filename") == 0)
4646 if (info && info->image_info->filename &&
4647 *info->image_info->filename)
4648 s=newSVpv(info->image_info->filename,0);
4649 if (image != (Image *) NULL)
4650 s=newSVpv(image->filename,0);
4651 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4654 if (LocaleCompare(attribute,"filter") == 0)
4656 s=image ? newSViv(image->filter) : newSViv(0);
4657 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4660 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4663 if (LocaleCompare(attribute,"font") == 0)
4665 if (info && info->image_info->font)
4666 s=newSVpv(info->image_info->font,0);
4667 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4670 if (LocaleCompare(attribute,"foreground") == 0)
4672 if (LocaleCompare(attribute,"format") == 0)
4677 magick_info=(const MagickInfo *) NULL;
4678 if (info && (*info->image_info->magick != '\0'))
4679 magick_info=GetMagickInfo(info->image_info->magick,exception);
4680 if (image != (Image *) NULL)
4681 magick_info=GetMagickInfo(image->magick,&image->exception);
4682 if ((magick_info != (const MagickInfo *) NULL) &&
4683 (*magick_info->description != '\0'))
4684 s=newSVpv((char *) magick_info->description,0);
4685 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4688 if (LocaleCompare(attribute,"fuzz") == 0)
4691 s=newSVnv(info->image_info->fuzz);
4692 if (image != (Image *) NULL)
4693 s=newSVnv(image->fuzz);
4694 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4704 if (LocaleCompare(attribute,"gamma") == 0)
4706 if (image != (Image *) NULL)
4707 s=newSVnv(image->gamma);
4708 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4711 if (LocaleCompare(attribute,"geometry") == 0)
4713 if (image && image->geometry)
4714 s=newSVpv(image->geometry,0);
4715 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4718 if (LocaleCompare(attribute,"gravity") == 0)
4720 s=image ? newSViv(image->gravity) : newSViv(0);
4721 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4724 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4727 if (LocaleCompare(attribute,"green-primary") == 0)
4729 if (image == (Image *) NULL)
4731 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4732 image->chromaticity.green_primary.x,
4733 image->chromaticity.green_primary.y);
4735 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4738 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4745 if (LocaleCompare(attribute,"height") == 0)
4747 if (image != (Image *) NULL)
4748 s=newSViv((ssize_t) image->rows);
4749 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4752 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4759 if (LocaleCompare(attribute,"icc") == 0)
4761 if (image != (Image *) NULL)
4766 profile=GetImageProfile(image,"icc");
4767 if (profile != (StringInfo *) NULL)
4768 s=newSVpv((const char *) GetStringInfoDatum(profile),
4769 GetStringInfoLength(profile));
4771 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4774 if (LocaleCompare(attribute,"icm") == 0)
4776 if (image != (Image *) NULL)
4781 profile=GetImageProfile(image,"icm");
4782 if (profile != (const StringInfo *) NULL)
4783 s=newSVpv((const char *) GetStringInfoDatum(profile),
4784 GetStringInfoLength(profile));
4786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4789 if (LocaleCompare(attribute,"id") == 0)
4791 if (image != (Image *) NULL)
4802 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4804 status=SetImageRegistry(ImageRegistryType,key,image,
4809 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4812 if (LocaleNCompare(attribute,"index",5) == 0)
4815 name[MaxTextExtent];
4824 register const Quantum
4830 if (image == (Image *) NULL)
4832 if (image->storage_class != PseudoClass)
4836 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4838 image_view=AcquireCacheView(image);
4839 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4840 if (p != (const Quantum *) NULL)
4842 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4843 GetPixelIndex(image,p));
4845 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4847 image_view=DestroyCacheView(image_view);
4850 if (LocaleCompare(attribute,"iptc") == 0)
4852 if (image != (Image *) NULL)
4857 profile=GetImageProfile(image,"iptc");
4858 if (profile != (const StringInfo *) NULL)
4859 s=newSVpv((const char *) GetStringInfoDatum(profile),
4860 GetStringInfoLength(profile));
4862 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4865 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4867 if (image != (Image *) NULL)
4868 s=newSViv((ssize_t) image->iterations);
4869 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4872 if (LocaleCompare(attribute,"interlace") == 0)
4874 j=info ? info->image_info->interlace : image ? image->interlace :
4877 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4880 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4883 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4890 if (LocaleCompare(attribute,"label") == 0)
4895 if (image == (Image *) NULL)
4897 value=GetImageProperty(image,"Label");
4898 if (value != (const char *) NULL)
4900 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4903 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4905 if (image != (Image *) NULL)
4906 s=newSViv((ssize_t) image->iterations);
4907 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4910 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4917 if (LocaleCompare(attribute,"magick") == 0)
4919 if (info && *info->image_info->magick)
4920 s=newSVpv(info->image_info->magick,0);
4921 if (image != (Image *) NULL)
4922 s=newSVpv(image->magick,0);
4923 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4926 if (LocaleCompare(attribute,"map") == 0)
4928 s=newSViv(GetMagickResource(MapResource));
4929 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4932 if (LocaleCompare(attribute,"maximum-error") == 0)
4934 if (image != (Image *) NULL)
4935 s=newSVnv(image->error.normalized_maximum_error);
4936 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4939 if (LocaleCompare(attribute,"memory") == 0)
4941 s=newSViv(GetMagickResource(MemoryResource));
4942 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4945 if (LocaleCompare(attribute,"mean-error") == 0)
4947 if (image != (Image *) NULL)
4948 s=newSVnv(image->error.normalized_mean_error);
4949 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4952 if (LocaleCompare(attribute,"mime") == 0)
4954 if (info && *info->image_info->magick)
4955 s=newSVpv(MagickToMime(info->image_info->magick),0);
4956 if (image != (Image *) NULL)
4957 s=newSVpv(MagickToMime(image->magick),0);
4958 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4961 if (LocaleCompare(attribute,"mattecolor") == 0)
4963 if (image == (Image *) NULL)
4965 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4966 QuantumFormat "," QuantumFormat "," QuantumFormat,
4967 image->matte_color.red,image->matte_color.green,
4968 image->matte_color.blue,image->matte_color.alpha);
4970 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4973 if (LocaleCompare(attribute,"matte") == 0)
4975 if (image != (Image *) NULL)
4976 s=newSViv((ssize_t) image->matte);
4977 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4980 if (LocaleCompare(attribute,"mime") == 0)
4986 if (info && *info->image_info->magick)
4987 magick=info->image_info->magick;
4988 if (image != (Image *) NULL)
4989 magick=image->magick;
4995 mime=MagickToMime(magick);
4997 mime=(char *) RelinquishMagickMemory(mime);
4999 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5002 if (LocaleCompare(attribute,"monochrome") == 0)
5004 if (image == (Image *) NULL)
5006 j=info ? info->image_info->monochrome :
5007 IsImageMonochrome(image,&image->exception);
5009 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5012 if (LocaleCompare(attribute,"montage") == 0)
5014 if (image && image->montage)
5015 s=newSVpv(image->montage,0);
5016 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5026 if (LocaleCompare(attribute,"orientation") == 0)
5028 j=info ? info->image_info->orientation : image ?
5029 image->orientation : UndefinedOrientation;
5031 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5034 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5037 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5044 if (LocaleCompare(attribute,"page") == 0)
5046 if (info && info->image_info->page)
5047 s=newSVpv(info->image_info->page,0);
5048 if (image != (Image *) NULL)
5051 geometry[MaxTextExtent];
5053 (void) FormatLocaleString(geometry,MaxTextExtent,
5054 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5055 (double) image->page.height,(double) image->page.x,(double)
5057 s=newSVpv(geometry,0);
5059 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5062 if (LocaleCompare(attribute,"page.x") == 0)
5064 if (image != (Image *) NULL)
5065 s=newSViv((ssize_t) image->page.x);
5066 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5069 if (LocaleCompare(attribute,"page.y") == 0)
5071 if (image != (Image *) NULL)
5072 s=newSViv((ssize_t) image->page.y);
5073 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5076 if (LocaleNCompare(attribute,"pixel",5) == 0)
5079 tuple[MaxTextExtent];
5088 register const Quantum
5091 if (image == (Image *) NULL)
5095 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5097 p=GetVirtualPixels(image,x,y,1,1,exception);
5098 if (image->colorspace != CMYKColorspace)
5099 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5100 QuantumFormat "," QuantumFormat "," QuantumFormat,
5101 GetPixelRed(image,p),GetPixelGreen(image,p),
5102 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5104 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5105 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5106 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5107 GetPixelBlue(image,p),GetPixelBlack(image,p),
5108 GetPixelAlpha(image,p));
5110 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5113 if (LocaleCompare(attribute,"pointsize") == 0)
5116 s=newSViv((ssize_t) info->image_info->pointsize);
5117 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5120 if (LocaleCompare(attribute,"preview") == 0)
5122 s=newSViv(info->image_info->preview_type);
5123 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5124 info->image_info->preview_type));
5126 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5136 if (LocaleCompare(attribute,"quality") == 0)
5139 s=newSViv((ssize_t) info->image_info->quality);
5140 if (image != (Image *) NULL)
5141 s=newSViv((ssize_t) image->quality);
5142 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5145 if (LocaleCompare(attribute,"quantum") == 0)
5148 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5149 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5152 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5159 if (LocaleCompare(attribute,"rendering-intent") == 0)
5161 s=newSViv(image->rendering_intent);
5162 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5163 image->rendering_intent));
5165 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5168 if (LocaleCompare(attribute,"red-primary") == 0)
5170 if (image == (Image *) NULL)
5172 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5173 image->chromaticity.red_primary.x,
5174 image->chromaticity.red_primary.y);
5176 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5179 if (LocaleCompare(attribute,"rows") == 0)
5181 if (image != (Image *) NULL)
5182 s=newSViv((ssize_t) image->rows);
5183 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5193 if (LocaleCompare(attribute,"sampling-factor") == 0)
5195 if (info && info->image_info->sampling_factor)
5196 s=newSVpv(info->image_info->sampling_factor,0);
5197 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5200 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5202 if (info && info->image_info->server_name)
5203 s=newSVpv(info->image_info->server_name,0);
5204 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5207 if (LocaleCompare(attribute,"size") == 0)
5209 if (info && info->image_info->size)
5210 s=newSVpv(info->image_info->size,0);
5211 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5214 if (LocaleCompare(attribute,"scene") == 0)
5216 if (image != (Image *) NULL)
5217 s=newSViv((ssize_t) image->scene);
5218 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5221 if (LocaleCompare(attribute,"scenes") == 0)
5223 if (image != (Image *) NULL)
5224 s=newSViv((ssize_t) info->image_info->number_scenes);
5225 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5228 if (LocaleCompare(attribute,"signature") == 0)
5233 if (image == (Image *) NULL)
5235 (void) SignatureImage(image);
5236 value=GetImageProperty(image,"Signature");
5237 if (value != (const char *) NULL)
5239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5242 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5249 if (LocaleCompare(attribute,"taint") == 0)
5251 if (image != (Image *) NULL)
5252 s=newSViv((ssize_t) IsTaintImage(image));
5253 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5256 if (LocaleCompare(attribute,"texture") == 0)
5258 if (info && info->image_info->texture)
5259 s=newSVpv(info->image_info->texture,0);
5260 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5263 if (LocaleCompare(attribute,"total-ink-density") == 0)
5265 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5266 if (image != (Image *) NULL)
5267 s=newSVnv(GetImageTotalInkDensity(image));
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 if (LocaleCompare(attribute,"transparent-color") == 0)
5273 if (image == (Image *) NULL)
5275 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5276 QuantumFormat "," QuantumFormat "," QuantumFormat,
5277 image->transparent_color.red,image->transparent_color.green,
5278 image->transparent_color.blue,image->transparent_color.alpha);
5280 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5283 if (LocaleCompare(attribute,"type") == 0)
5285 if (image == (Image *) NULL)
5287 j=(ssize_t) GetImageType(image,&image->exception);
5289 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5291 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5294 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5301 if (LocaleCompare(attribute,"units") == 0)
5303 j=info ? info->image_info->units : image ? image->units :
5304 UndefinedResolution;
5305 if (info && (info->image_info->units == UndefinedResolution))
5308 if (j == UndefinedResolution)
5309 s=newSVpv("undefined units",0);
5311 if (j == PixelsPerInchResolution)
5312 s=newSVpv("pixels / inch",0);
5314 s=newSVpv("pixels / centimeter",0);
5315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5318 if (LocaleCompare(attribute,"user-time") == 0)
5320 if (image != (Image *) NULL)
5321 s=newSVnv(GetUserTime(&image->timer));
5322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5325 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5332 if (LocaleCompare(attribute,"verbose") == 0)
5335 s=newSViv((ssize_t) info->image_info->verbose);
5336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5339 if (LocaleCompare(attribute,"version") == 0)
5341 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5342 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5345 if (LocaleCompare(attribute,"view") == 0)
5347 if (info && info->image_info->view)
5348 s=newSVpv(info->image_info->view,0);
5349 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5352 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5354 if (image == (Image *) NULL)
5356 j=(ssize_t) GetImageVirtualPixelMethod(image);
5358 (void) sv_setpv(s,CommandOptionToMnemonic(
5359 MagickVirtualPixelOptions,j));
5361 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5364 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5371 if (LocaleCompare(attribute,"white-point") == 0)
5373 if (image == (Image *) NULL)
5375 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5376 image->chromaticity.white_point.x,
5377 image->chromaticity.white_point.y);
5379 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5382 if (LocaleCompare(attribute,"width") == 0)
5384 if (image != (Image *) NULL)
5385 s=newSViv((ssize_t) image->columns);
5386 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5389 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5396 if (LocaleCompare(attribute,"x-resolution") == 0)
5398 if (image != (Image *) NULL)
5399 s=newSVnv(image->x_resolution);
5400 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5410 if (LocaleCompare(attribute,"y-resolution") == 0)
5412 if (image != (Image *) NULL)
5413 s=newSVnv(image->y_resolution);
5414 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5417 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5424 if (image == (Image *) NULL)
5425 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5429 value=GetImageProperty(image,attribute);
5430 if (value != (const char *) NULL)
5433 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5436 if (*attribute != '%')
5437 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5444 meta=InterpretImageProperties(info ? info->image_info :
5445 (ImageInfo *) NULL,image,attribute);
5447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5448 meta=(char *) RelinquishMagickMemory(meta);
5452 exception=DestroyExceptionInfo(exception);
5453 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5457 ###############################################################################
5461 # G e t A u t h e n t i c P i x e l s #
5465 ###############################################################################
5469 GetAuthenticPixels(ref,...)
5470 Image::Magick ref = NO_INIT
5472 getauthenticpixels = 1
5502 PERL_UNUSED_VAR(ref);
5503 PERL_UNUSED_VAR(ix);
5504 exception=AcquireExceptionInfo();
5505 perl_exception=newSVpv("",0);
5506 if (sv_isobject(ST(0)) == 0)
5508 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5512 reference=SvRV(ST(0));
5514 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5515 if (image == (Image *) NULL)
5517 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5524 region.width=image->columns;
5527 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5528 for (i=2; i < items; i+=2)
5530 attribute=(char *) SvPV(ST(i-1),na);
5536 if (LocaleCompare(attribute,"geometry") == 0)
5538 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5548 if (LocaleCompare(attribute,"height") == 0)
5550 region.height=SvIV(ST(i));
5553 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5560 if (LocaleCompare(attribute,"x") == 0)
5562 region.x=SvIV(ST(i));
5565 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5572 if (LocaleCompare(attribute,"y") == 0)
5574 region.y=SvIV(ST(i));
5577 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5584 if (LocaleCompare(attribute,"width") == 0)
5586 region.width=SvIV(ST(i));
5589 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5595 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5596 region.height,exception);
5597 if (blob != (void *) NULL)
5601 InheritPerlException(exception,perl_exception);
5602 exception=DestroyExceptionInfo(exception);
5603 SvREFCNT_dec(perl_exception); /* throw away all errors */
5612 ###############################################################################
5616 # G e t V i r t u a l P i x e l s #
5620 ###############################################################################
5624 GetVirtualPixels(ref,...)
5625 Image::Magick ref = NO_INIT
5627 getvirtualpixels = 1
5628 AcquireImagePixels = 2
5629 acquireimagepixels = 3
5657 PERL_UNUSED_VAR(ref);
5658 PERL_UNUSED_VAR(ix);
5659 exception=AcquireExceptionInfo();
5660 perl_exception=newSVpv("",0);
5661 if (sv_isobject(ST(0)) == 0)
5663 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5667 reference=SvRV(ST(0));
5669 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5670 if (image == (Image *) NULL)
5672 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5679 region.width=image->columns;
5682 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5683 for (i=2; i < items; i+=2)
5685 attribute=(char *) SvPV(ST(i-1),na);
5691 if (LocaleCompare(attribute,"geometry") == 0)
5693 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5696 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5703 if (LocaleCompare(attribute,"height") == 0)
5705 region.height=SvIV(ST(i));
5708 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5715 if (LocaleCompare(attribute,"x") == 0)
5717 region.x=SvIV(ST(i));
5720 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5727 if (LocaleCompare(attribute,"y") == 0)
5729 region.y=SvIV(ST(i));
5732 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5739 if (LocaleCompare(attribute,"width") == 0)
5741 region.width=SvIV(ST(i));
5744 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5750 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5751 region.height,exception);
5752 if (blob != (void *) NULL)
5756 InheritPerlException(exception,perl_exception);
5757 exception=DestroyExceptionInfo(exception);
5758 SvREFCNT_dec(perl_exception); /* throw away all errors */
5761 RETVAL = (void *) blob;
5767 ###############################################################################
5771 # G e t A u t h e n t i c M e t a c o n t e n t #
5775 ###############################################################################
5779 GetAuthenticMetacontent(ref,...)
5780 Image::Magick ref = NO_INIT
5782 getauthenticmetacontent = 1
5803 PERL_UNUSED_VAR(ref);
5804 PERL_UNUSED_VAR(ix);
5805 exception=AcquireExceptionInfo();
5806 perl_exception=newSVpv("",0);
5807 if (sv_isobject(ST(0)) == 0)
5809 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5813 reference=SvRV(ST(0));
5815 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5816 if (image == (Image *) NULL)
5818 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5823 blob=(void *) GetAuthenticMetacontent(image);
5824 if (blob != (void *) NULL)
5828 InheritPerlException(exception,perl_exception);
5829 exception=DestroyExceptionInfo(exception);
5830 SvREFCNT_dec(perl_exception); /* throw away all errors */
5839 ###############################################################################
5843 # G e t V i r t u a l M e t a c o n t e n t #
5847 ###############################################################################
5851 GetVirtualMetacontent(ref,...)
5852 Image::Magick ref = NO_INIT
5854 getvirtualmetacontent = 1
5873 PERL_UNUSED_VAR(ref);
5874 PERL_UNUSED_VAR(ix);
5875 exception=AcquireExceptionInfo();
5876 perl_exception=newSVpv("",0);
5877 if (sv_isobject(ST(0)) == 0)
5879 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5883 reference=SvRV(ST(0));
5885 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5886 if (image == (Image *) NULL)
5888 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5893 blob=(void *) GetVirtualMetacontent(image);
5894 if (blob != (void *) NULL)
5898 InheritPerlException(exception,perl_exception);
5899 exception=DestroyExceptionInfo(exception);
5900 SvREFCNT_dec(perl_exception); /* throw away all errors */
5909 ###############################################################################
5913 # H i s t o g r a m #
5917 ###############################################################################
5922 Image::Magick ref=NO_INIT
5933 message[MaxTextExtent];
5960 PERL_UNUSED_VAR(ref);
5961 PERL_UNUSED_VAR(ix);
5962 exception=AcquireExceptionInfo();
5963 perl_exception=newSVpv("",0);
5965 if (sv_isobject(ST(0)) == 0)
5967 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5971 reference=SvRV(ST(0));
5974 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5975 if (image == (Image *) NULL)
5977 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5981 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5983 for ( ; image; image=image->next)
5985 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5986 if (histogram == (PixelPacket *) NULL)
5988 count+=(ssize_t) number_colors;
5990 for (i=0; i < (ssize_t) number_colors; i++)
5992 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5994 PUSHs(sv_2mortal(newSVpv(message,0)));
5995 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5996 histogram[i].green);
5997 PUSHs(sv_2mortal(newSVpv(message,0)));
5998 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6000 PUSHs(sv_2mortal(newSVpv(message,0)));
6001 if (image->colorspace == CMYKColorspace)
6003 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6004 histogram[i].black);
6005 PUSHs(sv_2mortal(newSVpv(message,0)));
6007 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6008 histogram[i].alpha);
6009 PUSHs(sv_2mortal(newSVpv(message,0)));
6010 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6011 histogram[i].count);
6012 PUSHs(sv_2mortal(newSVpv(message,0)));
6014 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6018 InheritPerlException(exception,perl_exception);
6019 exception=DestroyExceptionInfo(exception);
6020 SvREFCNT_dec(perl_exception);
6024 ###############################################################################
6032 ###############################################################################
6037 Image::Magick ref=NO_INIT
6061 register const Quantum
6075 *reference; /* reference is the SV* of ref=SvIV(reference) */
6077 PERL_UNUSED_VAR(ref);
6078 PERL_UNUSED_VAR(ix);
6079 exception=AcquireExceptionInfo();
6080 perl_exception=newSVpv("",0);
6081 reference=SvRV(ST(0));
6082 av=(AV *) reference;
6083 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6085 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6086 if (image == (Image *) NULL)
6088 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6092 normalize=MagickTrue;
6095 region.width=image->columns;
6098 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6099 for (i=2; i < items; i+=2)
6101 attribute=(char *) SvPV(ST(i-1),na);
6107 if (LocaleCompare(attribute,"channel") == 0)
6112 option=ParseChannelOption(SvPV(ST(i),na));
6115 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6119 SetPixelComponentMap(image,(ChannelType) option);
6122 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6129 if (LocaleCompare(attribute,"geometry") == 0)
6131 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6134 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6141 if (LocaleCompare(attribute,"normalize") == 0)
6143 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6147 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6151 normalize=option != 0 ? MagickTrue : MagickFalse;
6154 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6161 if (LocaleCompare(attribute,"x") == 0)
6163 region.x=SvIV(ST(i));
6166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6173 if (LocaleCompare(attribute,"y") == 0)
6175 region.y=SvIV(ST(i));
6178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6184 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6190 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6191 if (p == (const Quantum *) NULL)
6199 if (normalize != MagickFalse)
6200 scale=1.0/QuantumRange;
6201 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
6202 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6203 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
6204 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6205 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
6206 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6207 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
6208 (image->colorspace == CMYKColorspace))
6209 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6210 if ((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0)
6211 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6215 InheritPerlException(exception,perl_exception);
6216 exception=DestroyExceptionInfo(exception);
6217 SvREFCNT_dec(perl_exception);
6221 ###############################################################################
6225 # G e t P i x e l s #
6229 ###############################################################################
6234 Image::Magick ref=NO_INIT
6273 *reference; /* reference is the SV* of ref=SvIV(reference) */
6275 PERL_UNUSED_VAR(ref);
6276 PERL_UNUSED_VAR(ix);
6277 exception=AcquireExceptionInfo();
6278 perl_exception=newSVpv("",0);
6279 reference=SvRV(ST(0));
6280 av=(AV *) reference;
6281 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6283 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6284 if (image == (Image *) NULL)
6286 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6291 if (image->matte != MagickFalse)
6293 if (image->colorspace == CMYKColorspace)
6296 if (image->matte != MagickFalse)
6299 normalize=MagickFalse;
6302 region.width=image->columns;
6305 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6306 for (i=2; i < items; i+=2)
6308 attribute=(char *) SvPV(ST(i-1),na);
6314 if (LocaleCompare(attribute,"geometry") == 0)
6316 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6326 if (LocaleCompare(attribute,"height") == 0)
6328 region.height=SvIV(ST(i));
6331 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6338 if (LocaleCompare(attribute,"map") == 0)
6343 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6350 if (LocaleCompare(attribute,"normalize") == 0)
6352 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6356 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6360 normalize=option != 0 ? MagickTrue : MagickFalse;
6363 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6370 if (LocaleCompare(attribute,"width") == 0)
6372 region.width=SvIV(ST(i));
6375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6382 if (LocaleCompare(attribute,"x") == 0)
6384 region.x=SvIV(ST(i));
6387 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6394 if (LocaleCompare(attribute,"y") == 0)
6396 region.y=SvIV(ST(i));
6399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6411 if (normalize != MagickFalse)
6416 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6417 region.height*sizeof(*pixels));
6418 if (pixels == (float *) NULL)
6420 ThrowPerlException(exception,ResourceLimitError,
6421 "MemoryAllocationFailed",PackageName);
6424 status=ExportImagePixels(image,region.x,region.y,region.width,
6425 region.height,map,FloatPixel,pixels,exception);
6426 if (status == MagickFalse)
6430 EXTEND(sp,strlen(map)*region.width*region.height);
6431 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6432 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6434 pixels=(float *) RelinquishMagickMemory(pixels);
6441 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6442 region.height*sizeof(*pixels));
6443 if (pixels == (Quantum *) NULL)
6445 ThrowPerlException(exception,ResourceLimitError,
6446 "MemoryAllocationFailed",PackageName);
6449 status=ExportImagePixels(image,region.x,region.y,region.width,
6450 region.height,map,QuantumPixel,pixels,exception);
6451 if (status == MagickFalse)
6455 EXTEND(sp,strlen(map)*region.width*region.height);
6456 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6457 PUSHs(sv_2mortal(newSViv(pixels[i])));
6459 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6463 InheritPerlException(exception,perl_exception);
6464 exception=DestroyExceptionInfo(exception);
6465 SvREFCNT_dec(perl_exception);
6469 ###############################################################################
6473 # I m a g e T o B l o b #
6477 ###############################################################################
6481 ImageToBlob(ref,...)
6482 Image::Magick ref=NO_INIT
6491 filename[MaxTextExtent];
6520 PERL_UNUSED_VAR(ref);
6521 PERL_UNUSED_VAR(ix);
6522 exception=AcquireExceptionInfo();
6523 perl_exception=newSVpv("",0);
6524 package_info=(struct PackageInfo *) NULL;
6525 if (sv_isobject(ST(0)) == 0)
6527 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6531 reference=SvRV(ST(0));
6532 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6533 if (image == (Image *) NULL)
6535 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6539 package_info=ClonePackageInfo(info,exception);
6540 for (i=2; i < items; i+=2)
6541 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6542 (void) CopyMagickString(filename,package_info->image_info->filename,
6545 for (next=image; next; next=next->next)
6547 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6548 next->scene=scene++;
6550 SetImageInfo(package_info->image_info,(unsigned int)
6551 GetImageListLength(image),&image->exception);
6552 EXTEND(sp,(ssize_t) GetImageListLength(image));
6553 for ( ; image; image=image->next)
6556 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6557 if (blob != (char *) NULL)
6559 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6560 blob=(unsigned char *) RelinquishMagickMemory(blob);
6562 if (package_info->image_info->adjoin)
6567 if (package_info != (struct PackageInfo *) NULL)
6568 DestroyPackageInfo(package_info);
6569 InheritPerlException(exception,perl_exception);
6570 exception=DestroyExceptionInfo(exception);
6571 SvREFCNT_dec(perl_exception); /* throw away all errors */
6575 ###############################################################################
6583 ###############################################################################
6588 Image::Magick ref=NO_INIT
6592 OptimizeImageLayers = 3
6594 optimizeimagelayers = 5
6636 PERL_UNUSED_VAR(ref);
6637 PERL_UNUSED_VAR(ix);
6638 exception=AcquireExceptionInfo();
6639 perl_exception=newSVpv("",0);
6641 if (sv_isobject(ST(0)) == 0)
6643 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6647 reference=SvRV(ST(0));
6648 hv=SvSTASH(reference);
6650 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6652 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6653 if (image == (Image *) NULL)
6655 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6659 compose=image->compose;
6660 method=OptimizeLayer;
6661 for (i=2; i < items; i+=2)
6663 attribute=(char *) SvPV(ST(i-1),na);
6669 if (LocaleCompare(attribute,"compose") == 0)
6671 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6672 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6675 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6679 compose=(CompositeOperator) sp;
6682 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6689 if (LocaleCompare(attribute,"method") == 0)
6691 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6695 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6699 method=(ImageLayerMethod) option;
6702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6708 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6714 layers=(Image *) NULL;
6717 case CompareAnyLayer:
6718 case CompareClearLayer:
6719 case CompareOverlayLayer:
6722 layers=CompareImagesLayers(image,method,exception);
6729 layers=MergeImageLayers(image,method,exception);
6734 layers=DisposeImages(image,exception);
6737 case OptimizeImageLayer:
6739 layers=OptimizeImageLayers(image,exception);
6742 case OptimizePlusLayer:
6744 layers=OptimizePlusImageLayers(image,exception);
6747 case OptimizeTransLayer:
6749 OptimizeImageTransparency(image,exception);
6750 InheritException(&(image->exception),exception);
6753 case RemoveDupsLayer:
6755 RemoveDuplicateLayers(&image,exception);
6756 InheritException(&(image->exception),exception);
6759 case RemoveZeroLayer:
6761 RemoveZeroDelayLayers(&image,exception);
6762 InheritException(&(image->exception),exception);
6771 General Purpose, GIF Animation Optimizer.
6773 layers=CoalesceImages(image,exception);
6774 if (layers == (Image *) NULL)
6776 InheritException(&(layers->exception),exception);
6778 layers=OptimizeImageLayers(image,exception);
6779 if (layers == (Image *) NULL)
6781 InheritException(&(layers->exception),exception);
6782 image=DestroyImageList(image);
6784 layers=(Image *) NULL;
6785 OptimizeImageTransparency(image,exception);
6786 InheritException(&(image->exception),exception);
6787 quantize_info=AcquireQuantizeInfo(info->image_info);
6788 (void) RemapImages(quantize_info,image,(Image *) NULL);
6789 quantize_info=DestroyQuantizeInfo(quantize_info);
6792 case CompositeLayer:
6801 Split image sequence at the first 'NULL:' image.
6804 while (source != (Image *) NULL)
6806 source=GetNextImageInList(source);
6807 if ((source != (Image *) NULL) &&
6808 (LocaleCompare(source->magick,"NULL") == 0))
6811 if (source != (Image *) NULL)
6813 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6814 (GetNextImageInList(source) == (Image *) NULL))
6815 source=(Image *) NULL;
6819 Separate the two lists, junk the null: image.
6821 source=SplitImageList(source->previous);
6822 DeleteImageFromList(&source);
6825 if (source == (Image *) NULL)
6827 (void) ThrowMagickException(exception,GetMagickModule(),
6828 OptionError,"MissingNullSeparator","layers Composite");
6832 Adjust offset with gravity and virtual canvas.
6834 SetGeometry(image,&geometry);
6835 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6836 geometry.width=source->page.width != 0 ? source->page.width :
6838 geometry.height=source->page.height != 0 ? source->page.height :
6840 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6841 image->columns,image->page.height != 0 ? image->page.height :
6842 image->rows,image->gravity,&geometry);
6843 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6844 source=DestroyImageList(source);
6845 InheritException(&(image->exception),exception);
6849 if (layers != (Image *) NULL)
6851 InheritException(&(layers->exception),exception);
6854 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6856 for ( ; image; image=image->next)
6858 AddImageToRegistry(sv,image);
6860 av_push(av,sv_bless(rv,hv));
6863 exception=DestroyExceptionInfo(exception);
6865 SvREFCNT_dec(perl_exception);
6869 InheritPerlException(exception,perl_exception);
6870 exception=DestroyExceptionInfo(exception);
6871 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6872 SvPOK_on(perl_exception);
6873 ST(0)=sv_2mortal(perl_exception);
6878 ###############################################################################
6882 # M a g i c k T o M i m e #
6886 ###############################################################################
6890 MagickToMime(ref,name)
6891 Image::Magick ref=NO_INIT
6900 PERL_UNUSED_VAR(ref);
6901 PERL_UNUSED_VAR(ix);
6902 mime=MagickToMime(name);
6903 RETVAL=newSVpv(mime,0);
6904 mime=(char *) RelinquishMagickMemory(mime);
6910 ###############################################################################
6918 ###############################################################################
6923 Image::Magick ref=NO_INIT
6960 MedianFilterImage = 36
6966 ReduceNoiseImage = 42
6992 ColorFloodfillImage= 68
6998 CycleColormapImage = 74
7008 MatteFloodfillImage= 84
7016 NumberColorsImage = 92
7026 SignatureImage = 102
7036 TransparentImage = 112
7038 ThresholdImage = 114
7052 DeconstructImage = 130
7054 GaussianBlurImage = 132
7060 UnsharpMaskImage = 138
7062 MotionBlurImage = 140
7064 OrderedDitherImage = 142
7071 AffineTransform = 149
7072 AffineTransformImage = 150
7074 DifferenceImage = 152
7075 AdaptiveThreshold = 153
7076 AdaptiveThresholdImage = 154
7081 BlackThreshold = 159
7082 BlackThresholdImage= 160
7083 WhiteThreshold = 161
7084 WhiteThresholdImage= 162
7086 RadialBlurImage = 164
7088 ThumbnailImage = 166
7098 PosterizeImage = 176
7104 SepiaToneImage = 182
7105 SigmoidalContrast = 183
7106 SigmoidalContrastImage = 184
7111 ContrastStretch = 189
7112 ContrastStretchImage = 190
7117 AdaptiveSharpen = 195
7118 AdaptiveSharpenImage = 196
7120 TransposeImage = 198
7122 TransverseImage = 200
7124 AutoOrientImage = 202
7126 AdaptiveBlurImage = 204
7130 UniqueColorsImage = 208
7131 AdaptiveResize = 209
7132 AdaptiveResizeImage= 210
7136 LinearStretchImage = 214
7143 FloodfillPaint = 221
7144 FloodfillPaintImage= 222
7150 LiquidRescaleImage = 228
7160 SparseColorImage = 238
7164 SelectiveBlurImage = 242
7168 BlueShiftImage = 246
7169 ForwardFourierTransform = 247
7170 ForwardFourierTransformImage = 248
7171 InverseFourierTransform = 249
7172 InverseFourierTransformImage = 250
7173 ColorDecisionList = 251
7174 ColorDecisionListImage = 252
7176 AutoGammaImage = 254
7178 AutoLevelImage = 256
7180 LevelImageColors = 258
7185 BrightnessContrast = 263
7186 BrightnessContrastImage = 264
7188 MorphologyImage = 266
7190 ColorMatrixImage = 268
7196 StatisticImage = 274
7205 attribute_flag[MaxArguments],
7206 message[MaxTextExtent];
7266 argument_list[MaxArguments];
7268 PERL_UNUSED_VAR(ref);
7269 PERL_UNUSED_VAR(ix);
7270 exception=AcquireExceptionInfo();
7271 perl_exception=newSVpv("",0);
7272 reference_vector=NULL;
7276 if (sv_isobject(ST(0)) == 0)
7278 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7282 reference=SvRV(ST(0));
7283 region_info.width=0;
7284 region_info.height=0;
7287 region_image=(Image *) NULL;
7288 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7289 if (ix && (ix != 666))
7292 Called as Method(...)
7295 rp=(&Methods[ix-1]);
7301 Called as Mogrify("Method",...)
7303 attribute=(char *) SvPV(ST(1),na);
7306 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7307 attribute=(char *) SvPV(ST(2),na);
7310 for (rp=Methods; ; rp++)
7312 if (rp >= EndOf(Methods))
7314 ThrowPerlException(exception,OptionError,
7315 "UnrecognizedPerlMagickMethod",attribute);
7318 if (strEQcase(attribute,rp->name))
7324 if (image == (Image *) NULL)
7326 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7329 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7330 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7331 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7348 pp=(Arguments *) NULL;
7356 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7358 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7360 if (strEQcase(attribute,qq->method) > ssize_test)
7363 ssize_test=strEQcase(attribute,qq->method);
7366 if (pp == (Arguments *) NULL)
7368 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7370 goto continue_outer_loop;
7372 al=(&argument_list[pp-rp->arguments]);
7375 case ArrayReference:
7377 if (SvTYPE(sv) != SVt_RV)
7379 (void) FormatLocaleString(message,MaxTextExtent,
7380 "invalid %.60s value",pp->method);
7381 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7382 goto continue_outer_loop;
7384 al->array_reference=SvRV(sv);
7389 al->real_reference=SvNV(sv);
7394 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7397 case ImageReference:
7399 if (!sv_isobject(sv) ||
7400 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7401 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7403 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7409 case IntegerReference:
7411 al->integer_reference=SvIV(sv);
7414 case StringReference:
7416 al->string_reference=(char *) SvPV(sv,al->length);
7417 if (sv_isobject(sv))
7418 al->image_reference=SetupList(aTHX_ SvRV(sv),
7419 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7425 Is a string; look up name.
7427 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7429 al->string_reference=(char *) SvPV(sv,al->length);
7430 al->integer_reference=(-1);
7433 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7434 MagickFalse,SvPV(sv,na));
7435 if (pp->type == MagickChannelOptions)
7436 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7437 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7439 (void) FormatLocaleString(message,MaxTextExtent,
7440 "invalid %.60s value",pp->method);
7441 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7442 goto continue_outer_loop;
7447 attribute_flag[pp-rp->arguments]++;
7448 continue_outer_loop: ;
7450 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7451 pv=reference_vector;
7452 SetGeometryInfo(&geometry_info);
7453 channel=DefaultChannels;
7454 for (next=image; next; next=next->next)
7457 SetGeometry(image,&geometry);
7458 if ((region_info.width*region_info.height) != 0)
7461 image=CropImage(image,®ion_info,exception);
7467 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7468 ThrowPerlException(exception,OptionError,
7469 "UnrecognizedPerlMagickMethod",message);
7472 case 1: /* Comment */
7474 if (attribute_flag[0] == 0)
7475 argument_list[0].string_reference=(char *) NULL;
7476 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7477 info ? info->image_info : (ImageInfo *) NULL,image,
7478 argument_list[0].string_reference));
7483 if (attribute_flag[0] == 0)
7484 argument_list[0].string_reference=(char *) NULL;
7485 (void) SetImageProperty(image,"label",InterpretImageProperties(
7486 info ? info->image_info : (ImageInfo *) NULL,image,
7487 argument_list[0].string_reference));
7490 case 3: /* AddNoise */
7492 if (attribute_flag[0] == 0)
7493 argument_list[0].integer_reference=UniformNoise;
7494 if (attribute_flag[1] != 0)
7495 channel=(ChannelType) argument_list[1].integer_reference;
7496 PushPixelComponentMap(image,channel);
7497 image=AddNoiseImage(image,(NoiseType)
7498 argument_list[0].integer_reference,exception);
7499 PopPixelComponentMap(image);
7502 case 4: /* Colorize */
7507 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7508 if (attribute_flag[0] != 0)
7509 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7511 if (attribute_flag[1] == 0)
7512 argument_list[1].string_reference="100%";
7513 image=ColorizeImage(image,argument_list[1].string_reference,target,
7517 case 5: /* Border */
7521 if (attribute_flag[0] != 0)
7523 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7524 &geometry,exception);
7525 if ((flags & HeightValue) == 0)
7526 geometry.height=geometry.width;
7528 if (attribute_flag[1] != 0)
7529 geometry.width=argument_list[1].integer_reference;
7530 if (attribute_flag[2] != 0)
7531 geometry.height=argument_list[2].integer_reference;
7532 if (attribute_flag[3] != 0)
7533 QueryColorDatabase(argument_list[3].string_reference,
7534 &image->border_color,exception);
7535 if (attribute_flag[4] != 0)
7536 QueryColorDatabase(argument_list[4].string_reference,
7537 &image->border_color,exception);
7538 if (attribute_flag[5] != 0)
7539 QueryColorDatabase(argument_list[5].string_reference,
7540 &image->border_color,exception);
7541 if (attribute_flag[6] != 0)
7542 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7543 image=BorderImage(image,&geometry,exception);
7548 if (attribute_flag[0] != 0)
7550 flags=ParseGeometry(argument_list[0].string_reference,
7552 if ((flags & SigmaValue) == 0)
7553 geometry_info.sigma=1.0;
7555 if (attribute_flag[1] != 0)
7556 geometry_info.rho=argument_list[1].real_reference;
7557 if (attribute_flag[2] != 0)
7558 geometry_info.sigma=argument_list[2].real_reference;
7559 if (attribute_flag[3] != 0)
7560 channel=(ChannelType) argument_list[3].integer_reference;
7561 image=BlurImageChannel(image,channel,geometry_info.rho,
7562 geometry_info.sigma,exception);
7567 if (attribute_flag[0] != 0)
7568 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7569 &geometry,exception);
7570 if (attribute_flag[1] != 0)
7571 geometry.width=argument_list[1].integer_reference;
7572 if (attribute_flag[2] != 0)
7573 geometry.height=argument_list[2].integer_reference;
7574 if (attribute_flag[3] != 0)
7575 geometry.x=argument_list[3].integer_reference;
7576 if (attribute_flag[4] != 0)
7577 geometry.y=argument_list[4].integer_reference;
7578 image=ChopImage(image,&geometry,exception);
7583 if (attribute_flag[6] != 0)
7584 image->gravity=(GravityType) argument_list[6].integer_reference;
7585 if (attribute_flag[0] != 0)
7586 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7587 &geometry,exception);
7588 if (attribute_flag[1] != 0)
7589 geometry.width=argument_list[1].integer_reference;
7590 if (attribute_flag[2] != 0)
7591 geometry.height=argument_list[2].integer_reference;
7592 if (attribute_flag[3] != 0)
7593 geometry.x=argument_list[3].integer_reference;
7594 if (attribute_flag[4] != 0)
7595 geometry.y=argument_list[4].integer_reference;
7596 if (attribute_flag[5] != 0)
7598 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7599 image=CropImage(image,&geometry,exception);
7602 case 9: /* Despeckle */
7604 image=DespeckleImage(image,exception);
7609 if (attribute_flag[0] != 0)
7610 geometry_info.rho=argument_list[0].real_reference;
7611 image=EdgeImage(image,geometry_info.rho,exception);
7614 case 11: /* Emboss */
7616 if (attribute_flag[0] != 0)
7618 flags=ParseGeometry(argument_list[0].string_reference,
7620 if ((flags & SigmaValue) == 0)
7621 geometry_info.sigma=1.0;
7623 if (attribute_flag[1] != 0)
7624 geometry_info.rho=argument_list[1].real_reference;
7625 if (attribute_flag[2] != 0)
7626 geometry_info.sigma=argument_list[2].real_reference;
7627 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7631 case 12: /* Enhance */
7633 image=EnhanceImage(image,exception);
7638 image=FlipImage(image,exception);
7643 image=FlopImage(image,exception);
7646 case 15: /* Frame */
7651 if (attribute_flag[0] != 0)
7653 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7654 &geometry,exception);
7655 if ((flags & HeightValue) == 0)
7656 geometry.height=geometry.width;
7657 frame_info.width=geometry.width;
7658 frame_info.height=geometry.height;
7659 frame_info.outer_bevel=geometry.x;
7660 frame_info.inner_bevel=geometry.y;
7662 if (attribute_flag[1] != 0)
7663 frame_info.width=argument_list[1].integer_reference;
7664 if (attribute_flag[2] != 0)
7665 frame_info.height=argument_list[2].integer_reference;
7666 if (attribute_flag[3] != 0)
7667 frame_info.inner_bevel=argument_list[3].integer_reference;
7668 if (attribute_flag[4] != 0)
7669 frame_info.outer_bevel=argument_list[4].integer_reference;
7670 if (attribute_flag[5] != 0)
7671 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7673 if (attribute_flag[6] != 0)
7674 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7676 frame_info.x=(ssize_t) frame_info.width;
7677 frame_info.y=(ssize_t) frame_info.height;
7678 frame_info.width=image->columns+2*frame_info.x;
7679 frame_info.height=image->rows+2*frame_info.y;
7680 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7681 image->matte_color=fill_color;
7682 if (attribute_flag[7] != 0)
7683 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7684 image=FrameImage(image,&frame_info,exception);
7687 case 16: /* Implode */
7689 if (attribute_flag[0] == 0)
7690 argument_list[0].real_reference=0.5;
7691 if (attribute_flag[1] != 0)
7692 image->interpolate=(InterpolatePixelMethod)
7693 argument_list[1].integer_reference;
7694 image=ImplodeImage(image,argument_list[0].real_reference,
7698 case 17: /* Magnify */
7700 image=MagnifyImage(image,exception);
7703 case 18: /* MedianFilter */
7705 if (attribute_flag[0] != 0)
7707 flags=ParseGeometry(argument_list[0].string_reference,
7709 if ((flags & SigmaValue) == 0)
7710 geometry_info.sigma=1.0;
7712 if (attribute_flag[1] != 0)
7713 geometry_info.rho=argument_list[1].real_reference;
7714 if (attribute_flag[2] != 0)
7715 geometry_info.sigma=argument_list[2].real_reference;
7716 if (attribute_flag[3] != 0)
7717 channel=(ChannelType) argument_list[3].integer_reference;
7718 image=StatisticImageChannel(image,channel,MedianStatistic,
7719 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7722 case 19: /* Minify */
7724 image=MinifyImage(image,exception);
7727 case 20: /* OilPaint */
7729 if (attribute_flag[0] == 0)
7730 argument_list[0].real_reference=0.0;
7731 image=OilPaintImage(image,argument_list[0].real_reference,
7735 case 21: /* ReduceNoise */
7737 if (attribute_flag[0] != 0)
7739 flags=ParseGeometry(argument_list[0].string_reference,
7741 if ((flags & SigmaValue) == 0)
7742 geometry_info.sigma=1.0;
7744 if (attribute_flag[1] != 0)
7745 geometry_info.rho=argument_list[1].real_reference;
7746 if (attribute_flag[2] != 0)
7747 geometry_info.sigma=argument_list[2].real_reference;
7748 if (attribute_flag[3] != 0)
7749 channel=(ChannelType) argument_list[3].integer_reference;
7750 image=StatisticImageChannel(image,channel,NonpeakStatistic,
7751 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7756 if (attribute_flag[0] != 0)
7757 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7758 &geometry,exception);
7759 if (attribute_flag[1] != 0)
7760 geometry.x=argument_list[1].integer_reference;
7761 if (attribute_flag[2] != 0)
7762 geometry.y=argument_list[2].integer_reference;
7763 image=RollImage(image,geometry.x,geometry.y,exception);
7766 case 23: /* Rotate */
7768 if (attribute_flag[0] == 0)
7769 argument_list[0].real_reference=90.0;
7770 if (attribute_flag[1] != 0)
7771 QueryColorDatabase(argument_list[1].string_reference,
7772 &image->background_color,exception);
7773 if (attribute_flag[2] != 0)
7774 QueryColorDatabase(argument_list[2].string_reference,
7775 &image->background_color,exception);
7776 if (attribute_flag[3] != 0)
7777 QueryColorDatabase(argument_list[3].string_reference,
7778 &image->background_color,exception);
7779 image=RotateImage(image,argument_list[0].real_reference,exception);
7782 case 24: /* Sample */
7784 if (attribute_flag[0] != 0)
7785 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7786 &geometry,exception);
7787 if (attribute_flag[1] != 0)
7788 geometry.width=argument_list[1].integer_reference;
7789 if (attribute_flag[2] != 0)
7790 geometry.height=argument_list[2].integer_reference;
7791 image=SampleImage(image,geometry.width,geometry.height,exception);
7794 case 25: /* Scale */
7796 if (attribute_flag[0] != 0)
7797 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7798 &geometry,exception);
7799 if (attribute_flag[1] != 0)
7800 geometry.width=argument_list[1].integer_reference;
7801 if (attribute_flag[2] != 0)
7802 geometry.height=argument_list[2].integer_reference;
7803 image=ScaleImage(image,geometry.width,geometry.height,exception);
7806 case 26: /* Shade */
7808 if (attribute_flag[0] != 0)
7810 flags=ParseGeometry(argument_list[0].string_reference,
7812 if ((flags & SigmaValue) == 0)
7813 geometry_info.sigma=0.0;
7815 if (attribute_flag[1] != 0)
7816 geometry_info.rho=argument_list[1].real_reference;
7817 if (attribute_flag[2] != 0)
7818 geometry_info.sigma=argument_list[2].real_reference;
7819 image=ShadeImage(image,
7820 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7821 geometry_info.rho,geometry_info.sigma,exception);
7824 case 27: /* Sharpen */
7826 if (attribute_flag[0] != 0)
7828 flags=ParseGeometry(argument_list[0].string_reference,
7830 if ((flags & SigmaValue) == 0)
7831 geometry_info.sigma=1.0;
7833 if (attribute_flag[1] != 0)
7834 geometry_info.rho=argument_list[1].real_reference;
7835 if (attribute_flag[2] != 0)
7836 geometry_info.sigma=argument_list[2].real_reference;
7837 if (attribute_flag[3] != 0)
7838 channel=(ChannelType) argument_list[3].integer_reference;
7839 image=SharpenImageChannel(image,channel,geometry_info.rho,
7840 geometry_info.sigma,exception);
7843 case 28: /* Shear */
7845 if (attribute_flag[0] != 0)
7847 flags=ParseGeometry(argument_list[0].string_reference,
7849 if ((flags & SigmaValue) == 0)
7850 geometry_info.sigma=geometry_info.rho;
7852 if (attribute_flag[1] != 0)
7853 geometry_info.rho=argument_list[1].real_reference;
7854 if (attribute_flag[2] != 0)
7855 geometry_info.sigma=argument_list[2].real_reference;
7856 if (attribute_flag[3] != 0)
7857 QueryColorDatabase(argument_list[3].string_reference,
7858 &image->background_color,exception);
7859 if (attribute_flag[4] != 0)
7860 QueryColorDatabase(argument_list[4].string_reference,
7861 &image->background_color,exception);
7862 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7866 case 29: /* Spread */
7868 if (attribute_flag[0] == 0)
7869 argument_list[0].real_reference=1.0;
7870 image=SpreadImage(image,argument_list[0].real_reference,exception);
7873 case 30: /* Swirl */
7875 if (attribute_flag[0] == 0)
7876 argument_list[0].real_reference=50.0;
7877 if (attribute_flag[1] != 0)
7878 image->interpolate=(InterpolatePixelMethod)
7879 argument_list[1].integer_reference;
7880 image=SwirlImage(image,argument_list[0].real_reference,exception);
7883 case 31: /* Resize */
7886 if (attribute_flag[0] != 0)
7887 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7888 &geometry,exception);
7889 if (attribute_flag[1] != 0)
7890 geometry.width=argument_list[1].integer_reference;
7891 if (attribute_flag[2] != 0)
7892 geometry.height=argument_list[2].integer_reference;
7893 if (attribute_flag[3] == 0)
7894 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7895 if (attribute_flag[4] != 0)
7896 SetImageArtifact(image,"filter:support",
7897 argument_list[4].string_reference);
7898 if (attribute_flag[5] == 0)
7899 argument_list[5].real_reference=1.0;
7900 image=ResizeImage(image,geometry.width,geometry.height,
7901 (FilterTypes) argument_list[3].integer_reference,
7902 argument_list[5].real_reference,exception);
7905 case 33: /* Annotate */
7910 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7912 if (attribute_flag[0] != 0)
7917 text=InterpretImageProperties(info ? info->image_info :
7918 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7919 (void) CloneString(&draw_info->text,text);
7920 text=DestroyString(text);
7922 if (attribute_flag[1] != 0)
7923 (void) CloneString(&draw_info->font,
7924 argument_list[1].string_reference);
7925 if (attribute_flag[2] != 0)
7926 draw_info->pointsize=argument_list[2].real_reference;
7927 if (attribute_flag[3] != 0)
7928 (void) CloneString(&draw_info->density,
7929 argument_list[3].string_reference);
7930 if (attribute_flag[4] != 0)
7931 (void) QueryColorDatabase(argument_list[4].string_reference,
7932 &draw_info->undercolor,exception);
7933 if (attribute_flag[5] != 0)
7935 (void) QueryColorDatabase(argument_list[5].string_reference,
7936 &draw_info->stroke,exception);
7937 if (argument_list[5].image_reference != (Image *) NULL)
7938 draw_info->stroke_pattern=CloneImage(
7939 argument_list[5].image_reference,0,0,MagickTrue,exception);
7941 if (attribute_flag[6] != 0)
7943 (void) QueryColorDatabase(argument_list[6].string_reference,
7944 &draw_info->fill,exception);
7945 if (argument_list[6].image_reference != (Image *) NULL)
7946 draw_info->fill_pattern=CloneImage(
7947 argument_list[6].image_reference,0,0,MagickTrue,exception);
7949 if (attribute_flag[7] != 0)
7951 (void) CloneString(&draw_info->geometry,
7952 argument_list[7].string_reference);
7953 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7954 &geometry,exception);
7955 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7956 geometry_info.sigma=geometry_info.xi;
7958 if (attribute_flag[8] != 0)
7959 (void) QueryColorDatabase(argument_list[8].string_reference,
7960 &draw_info->fill,exception);
7961 if (attribute_flag[11] != 0)
7962 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7963 if (attribute_flag[25] != 0)
7968 av=(AV *) argument_list[25].array_reference;
7969 if ((av_len(av) != 3) && (av_len(av) != 5))
7971 ThrowPerlException(exception,OptionError,
7972 "affine matrix must have 4 or 6 elements",PackageName);
7975 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7976 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7977 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7978 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7979 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7980 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7982 ThrowPerlException(exception,OptionError,
7983 "affine matrix is singular",PackageName);
7986 if (av_len(av) == 5)
7988 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7989 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
7992 for (j=12; j < 17; j++)
7994 if (attribute_flag[j] == 0)
7996 value=argument_list[j].string_reference;
7997 angle=argument_list[j].real_reference;
7998 current=draw_info->affine;
7999 GetAffineMatrix(&affine);
8007 flags=ParseGeometry(value,&geometry_info);
8008 affine.tx=geometry_info.xi;
8009 affine.ty=geometry_info.psi;
8010 if ((flags & PsiValue) == 0)
8011 affine.ty=affine.tx;
8019 flags=ParseGeometry(value,&geometry_info);
8020 affine.sx=geometry_info.rho;
8021 affine.sy=geometry_info.sigma;
8022 if ((flags & SigmaValue) == 0)
8023 affine.sy=affine.sx;
8033 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8034 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8035 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8036 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8044 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8052 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8056 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8057 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8058 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8059 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8060 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8062 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8065 if (attribute_flag[9] == 0)
8066 argument_list[9].real_reference=0.0;
8067 if (attribute_flag[10] == 0)
8068 argument_list[10].real_reference=0.0;
8069 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8072 geometry[MaxTextExtent];
8074 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8075 (double) argument_list[9].real_reference+draw_info->affine.tx,
8076 (double) argument_list[10].real_reference+draw_info->affine.ty);
8077 (void) CloneString(&draw_info->geometry,geometry);
8079 if (attribute_flag[17] != 0)
8080 draw_info->stroke_width=argument_list[17].real_reference;
8081 if (attribute_flag[18] != 0)
8083 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8084 MagickTrue : MagickFalse;
8085 draw_info->stroke_antialias=draw_info->text_antialias;
8087 if (attribute_flag[19] != 0)
8088 (void) CloneString(&draw_info->family,
8089 argument_list[19].string_reference);
8090 if (attribute_flag[20] != 0)
8091 draw_info->style=(StyleType) argument_list[20].integer_reference;
8092 if (attribute_flag[21] != 0)
8093 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8094 if (attribute_flag[22] != 0)
8095 draw_info->weight=argument_list[22].integer_reference;
8096 if (attribute_flag[23] != 0)
8097 draw_info->align=(AlignType) argument_list[23].integer_reference;
8098 if (attribute_flag[24] != 0)
8099 (void) CloneString(&draw_info->encoding,
8100 argument_list[24].string_reference);
8101 if (attribute_flag[25] != 0)
8102 draw_info->fill_pattern=CloneImage(
8103 argument_list[25].image_reference,0,0,MagickTrue,exception);
8104 if (attribute_flag[26] != 0)
8105 draw_info->fill_pattern=CloneImage(
8106 argument_list[26].image_reference,0,0,MagickTrue,exception);
8107 if (attribute_flag[27] != 0)
8108 draw_info->stroke_pattern=CloneImage(
8109 argument_list[27].image_reference,0,0,MagickTrue,exception);
8110 if (attribute_flag[29] != 0)
8111 draw_info->kerning=argument_list[29].real_reference;
8112 if (attribute_flag[30] != 0)
8113 draw_info->interline_spacing=argument_list[30].real_reference;
8114 if (attribute_flag[31] != 0)
8115 draw_info->interword_spacing=argument_list[31].real_reference;
8116 if (attribute_flag[32] != 0)
8117 draw_info->direction=(DirectionType)
8118 argument_list[32].integer_reference;
8119 (void) AnnotateImage(image,draw_info);
8120 draw_info=DestroyDrawInfo(draw_info);
8123 case 34: /* ColorFloodfill */
8134 draw_info=CloneDrawInfo(info ? info->image_info :
8135 (ImageInfo *) NULL,(DrawInfo *) NULL);
8136 if (attribute_flag[0] != 0)
8137 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8138 &geometry,exception);
8139 if (attribute_flag[1] != 0)
8140 geometry.x=argument_list[1].integer_reference;
8141 if (attribute_flag[2] != 0)
8142 geometry.y=argument_list[2].integer_reference;
8143 if (attribute_flag[3] != 0)
8144 (void) QueryColorDatabase(argument_list[3].string_reference,
8145 &draw_info->fill,exception);
8146 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8149 if (attribute_flag[4] != 0)
8151 QueryMagickColor(argument_list[4].string_reference,&target,
8155 if (attribute_flag[5] != 0)
8156 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8158 if (attribute_flag[6] != 0)
8159 invert=(MagickBooleanType) argument_list[6].integer_reference;
8160 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8161 geometry.x,geometry.y,invert);
8162 draw_info=DestroyDrawInfo(draw_info);
8165 case 35: /* Composite */
8168 composite_geometry[MaxTextExtent];
8174 compose=OverCompositeOp;
8175 if (attribute_flag[0] != 0)
8176 composite_image=argument_list[0].image_reference;
8179 ThrowPerlException(exception,OptionError,
8180 "CompositeImageRequired",PackageName);
8184 Parameter Handling used for BOTH normal and tiled composition.
8186 if (attribute_flag[1] != 0) /* compose */
8187 compose=(CompositeOperator) argument_list[1].integer_reference;
8188 if (attribute_flag[6] != 0) /* opacity */
8190 if (compose != DissolveCompositeOp)
8191 (void) SetImageOpacity(composite_image,(Quantum)
8192 SiPrefixToDouble(argument_list[6].string_reference,
8215 Handle dissolve composite operator (patch by
8218 (void) CloneString(&image->geometry,
8219 argument_list[6].string_reference);
8220 opacity=(Quantum) SiPrefixToDouble(
8221 argument_list[6].string_reference,QuantumRange);
8222 if (composite_image->matte != MagickTrue)
8223 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8224 composite_view=AcquireCacheView(composite_image);
8225 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8227 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8228 composite_image->columns,1,exception);
8229 for (x=0; x < (ssize_t) composite_image->columns; x++)
8231 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8232 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8233 q+=GetPixelComponents(composite_image);
8235 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8236 if (sync == MagickFalse)
8239 composite_view=DestroyCacheView(composite_view);
8242 if (attribute_flag[9] != 0) /* "color=>" */
8243 QueryColorDatabase(argument_list[9].string_reference,
8244 &composite_image->background_color,exception);
8245 if (attribute_flag[12] != 0) /* "interpolate=>" */
8246 image->interpolate=(InterpolatePixelMethod)
8247 argument_list[12].integer_reference;
8248 if (attribute_flag[13] != 0) /* "args=>" */
8249 (void) SetImageArtifact(composite_image,"compose:args",
8250 argument_list[13].string_reference);
8251 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8252 (void) SetImageArtifact(composite_image,"compose:args",
8253 argument_list[14].string_reference);
8255 Tiling Composition (with orthogonal rotate).
8257 rotate_image=(Image *) NULL;
8258 if (attribute_flag[8] != 0) /* "rotate=>" */
8263 rotate_image=RotateImage(composite_image,
8264 argument_list[8].real_reference,exception);
8265 if (rotate_image == (Image *) NULL)
8268 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8275 Tile the composite image.
8277 if (attribute_flag[8] != 0) /* "tile=>" */
8278 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8281 (void) SetImageArtifact(composite_image,
8282 "compose:outside-overlay","false");
8283 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8284 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8286 if (attribute_flag[8] != 0) /* rotate */
8287 (void) CompositeImage(image,compose,rotate_image,x,y);
8289 (void) CompositeImage(image,compose,composite_image,x,y);
8291 if (attribute_flag[8] != 0) /* rotate */
8292 rotate_image=DestroyImage(rotate_image);
8296 Parameter Handling used used ONLY for normal composition.
8298 if (attribute_flag[5] != 0) /* gravity */
8299 image->gravity=(GravityType) argument_list[5].integer_reference;
8300 if (attribute_flag[2] != 0) /* geometry offset */
8302 SetGeometry(image,&geometry);
8303 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8305 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8308 if (attribute_flag[3] != 0) /* x offset */
8309 geometry.x=argument_list[3].integer_reference;
8310 if (attribute_flag[4] != 0) /* y offset */
8311 geometry.y=argument_list[4].integer_reference;
8312 if (attribute_flag[10] != 0) /* mask */
8314 if ((image->compose == DisplaceCompositeOp) ||
8315 (image->compose == DistortCompositeOp))
8318 Merge Y displacement into X displacement image.
8320 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8322 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8323 argument_list[10].image_reference,0,0);
8328 Set a blending mask for the composition.
8330 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8331 MagickTrue,&image->exception);
8332 (void) NegateImage(image->mask,MagickFalse);
8335 if (attribute_flag[11] != 0) /* channel */
8336 channel=(ChannelType) argument_list[11].integer_reference;
8338 Composite two images (normal composition).
8340 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8341 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8342 (double) composite_image->rows,(double) geometry.x,(double)
8344 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8346 if (attribute_flag[8] == 0) /* no rotate */
8347 CompositeImageChannel(image,channel,compose,composite_image,
8348 geometry.x,geometry.y);
8352 Position adjust rotated image then composite.
8354 geometry.x-=(ssize_t) (rotate_image->columns-
8355 composite_image->columns)/2;
8356 geometry.y-=(ssize_t) (rotate_image->rows-
8357 composite_image->rows)/2;
8358 CompositeImageChannel(image,channel,compose,rotate_image,
8359 geometry.x,geometry.y);
8360 rotate_image=DestroyImage(rotate_image);
8362 if (attribute_flag[10] != 0) /* mask */
8364 if ((image->compose == DisplaceCompositeOp) ||
8365 (image->compose == DistortCompositeOp))
8366 composite_image=DestroyImage(composite_image);
8368 image->mask=DestroyImage(image->mask);
8372 case 36: /* Contrast */
8374 if (attribute_flag[0] == 0)
8375 argument_list[0].integer_reference=0;
8376 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8377 MagickTrue : MagickFalse);
8380 case 37: /* CycleColormap */
8382 if (attribute_flag[0] == 0)
8383 argument_list[0].integer_reference=6;
8384 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8392 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8394 (void) CloneString(&draw_info->primitive,"point");
8395 if (attribute_flag[0] != 0)
8397 if (argument_list[0].integer_reference < 0)
8398 (void) CloneString(&draw_info->primitive,
8399 argument_list[0].string_reference);
8401 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8402 MagickPrimitiveOptions,argument_list[0].integer_reference));
8404 if (attribute_flag[1] != 0)
8406 if (LocaleCompare(draw_info->primitive,"path") == 0)
8408 (void) ConcatenateString(&draw_info->primitive," '");
8409 ConcatenateString(&draw_info->primitive,
8410 argument_list[1].string_reference);
8411 (void) ConcatenateString(&draw_info->primitive,"'");
8415 (void) ConcatenateString(&draw_info->primitive," ");
8416 ConcatenateString(&draw_info->primitive,
8417 argument_list[1].string_reference);
8420 if (attribute_flag[2] != 0)
8422 (void) ConcatenateString(&draw_info->primitive," ");
8423 (void) ConcatenateString(&draw_info->primitive,
8424 CommandOptionToMnemonic(MagickMethodOptions,
8425 argument_list[2].integer_reference));
8427 if (attribute_flag[3] != 0)
8429 (void) QueryColorDatabase(argument_list[3].string_reference,
8430 &draw_info->stroke,exception);
8431 if (argument_list[3].image_reference != (Image *) NULL)
8432 draw_info->stroke_pattern=CloneImage(
8433 argument_list[3].image_reference,0,0,MagickTrue,exception);
8435 if (attribute_flag[4] != 0)
8437 (void) QueryColorDatabase(argument_list[4].string_reference,
8438 &draw_info->fill,exception);
8439 if (argument_list[4].image_reference != (Image *) NULL)
8440 draw_info->fill_pattern=CloneImage(
8441 argument_list[4].image_reference,0,0,MagickTrue,exception);
8443 if (attribute_flag[5] != 0)
8444 draw_info->stroke_width=argument_list[5].real_reference;
8445 if (attribute_flag[6] != 0)
8446 (void) CloneString(&draw_info->font,
8447 argument_list[6].string_reference);
8448 if (attribute_flag[7] != 0)
8449 (void) QueryColorDatabase(argument_list[7].string_reference,
8450 &draw_info->border_color,exception);
8451 if (attribute_flag[8] != 0)
8452 draw_info->affine.tx=argument_list[8].real_reference;
8453 if (attribute_flag[9] != 0)
8454 draw_info->affine.ty=argument_list[9].real_reference;
8455 if (attribute_flag[20] != 0)
8460 av=(AV *) argument_list[20].array_reference;
8461 if ((av_len(av) != 3) && (av_len(av) != 5))
8463 ThrowPerlException(exception,OptionError,
8464 "affine matrix must have 4 or 6 elements",PackageName);
8467 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8468 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8469 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8470 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8471 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8472 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8474 ThrowPerlException(exception,OptionError,
8475 "affine matrix is singular",PackageName);
8478 if (av_len(av) == 5)
8480 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8481 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8484 for (j=10; j < 15; j++)
8486 if (attribute_flag[j] == 0)
8488 value=argument_list[j].string_reference;
8489 angle=argument_list[j].real_reference;
8490 current=draw_info->affine;
8491 GetAffineMatrix(&affine);
8499 flags=ParseGeometry(value,&geometry_info);
8500 affine.tx=geometry_info.xi;
8501 affine.ty=geometry_info.psi;
8502 if ((flags & PsiValue) == 0)
8503 affine.ty=affine.tx;
8511 flags=ParseGeometry(value,&geometry_info);
8512 affine.sx=geometry_info.rho;
8513 affine.sy=geometry_info.sigma;
8514 if ((flags & SigmaValue) == 0)
8515 affine.sy=affine.sx;
8525 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8526 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8527 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8528 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8536 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8544 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8548 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8549 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8550 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8551 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8552 draw_info->affine.tx=
8553 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8554 draw_info->affine.ty=
8555 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8557 if (attribute_flag[15] != 0)
8558 draw_info->fill_pattern=CloneImage(
8559 argument_list[15].image_reference,0,0,MagickTrue,exception);
8560 if (attribute_flag[16] != 0)
8561 draw_info->pointsize=argument_list[16].real_reference;
8562 if (attribute_flag[17] != 0)
8564 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8565 ? MagickTrue : MagickFalse;
8566 draw_info->text_antialias=draw_info->stroke_antialias;
8568 if (attribute_flag[18] != 0)
8569 (void) CloneString(&draw_info->density,
8570 argument_list[18].string_reference);
8571 if (attribute_flag[19] != 0)
8572 draw_info->stroke_width=argument_list[19].real_reference;
8573 if (attribute_flag[21] != 0)
8574 draw_info->dash_offset=argument_list[21].real_reference;
8575 if (attribute_flag[22] != 0)
8580 av=(AV *) argument_list[22].array_reference;
8581 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8582 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8583 if (draw_info->dash_pattern != (double *) NULL)
8585 for (i=0; i <= av_len(av); i++)
8586 draw_info->dash_pattern[i]=(double)
8587 SvNV(*(av_fetch(av,i,0)));
8588 draw_info->dash_pattern[i]=0.0;
8591 if (attribute_flag[23] != 0)
8592 image->interpolate=(InterpolatePixelMethod)
8593 argument_list[23].integer_reference;
8594 if ((attribute_flag[24] != 0) &&
8595 (draw_info->fill_pattern != (Image *) NULL))
8596 flags=ParsePageGeometry(draw_info->fill_pattern,
8597 argument_list[24].string_reference,
8598 &draw_info->fill_pattern->tile_offset,exception);
8599 if (attribute_flag[25] != 0)
8601 (void) ConcatenateString(&draw_info->primitive," '");
8602 (void) ConcatenateString(&draw_info->primitive,
8603 argument_list[25].string_reference);
8604 (void) ConcatenateString(&draw_info->primitive,"'");
8606 if (attribute_flag[26] != 0)
8607 draw_info->fill_pattern=CloneImage(
8608 argument_list[26].image_reference,0,0,MagickTrue,exception);
8609 if (attribute_flag[27] != 0)
8610 draw_info->stroke_pattern=CloneImage(
8611 argument_list[27].image_reference,0,0,MagickTrue,exception);
8612 if (attribute_flag[28] != 0)
8613 (void) CloneString(&draw_info->primitive,
8614 argument_list[28].string_reference);
8615 if (attribute_flag[29] != 0)
8616 draw_info->kerning=argument_list[29].real_reference;
8617 if (attribute_flag[30] != 0)
8618 draw_info->interline_spacing=argument_list[30].real_reference;
8619 if (attribute_flag[31] != 0)
8620 draw_info->interword_spacing=argument_list[31].real_reference;
8621 if (attribute_flag[32] != 0)
8622 draw_info->direction=(DirectionType)
8623 argument_list[32].integer_reference;
8624 DrawImage(image,draw_info);
8625 draw_info=DestroyDrawInfo(draw_info);
8628 case 39: /* Equalize */
8630 if (attribute_flag[0] != 0)
8631 channel=(ChannelType) argument_list[0].integer_reference;
8632 PushPixelComponentMap(image,channel);
8633 EqualizeImage(image);
8634 PopPixelComponentMap(image);
8637 case 40: /* Gamma */
8639 if (attribute_flag[1] != 0)
8640 channel=(ChannelType) argument_list[1].integer_reference;
8641 if (attribute_flag[2] == 0)
8642 argument_list[2].real_reference=1.0;
8643 if (attribute_flag[3] == 0)
8644 argument_list[3].real_reference=1.0;
8645 if (attribute_flag[4] == 0)
8646 argument_list[4].real_reference=1.0;
8647 if (attribute_flag[0] == 0)
8649 (void) FormatLocaleString(message,MaxTextExtent,
8650 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8651 (double) argument_list[3].real_reference,
8652 (double) argument_list[4].real_reference);
8653 argument_list[0].string_reference=message;
8655 (void) GammaImage(image,InterpretLocaleValue(
8656 argument_list[0].string_reference,(char **) NULL));
8664 if (attribute_flag[0] == 0)
8666 ThrowPerlException(exception,OptionError,"MapImageRequired",
8670 quantize_info=AcquireQuantizeInfo(info->image_info);
8671 if (attribute_flag[1] != 0)
8672 quantize_info->dither=(MagickBooleanType)
8673 argument_list[1].integer_reference;
8674 if (attribute_flag[2] != 0)
8675 quantize_info->dither_method=(DitherMethod)
8676 argument_list[2].integer_reference;
8677 (void) RemapImages(quantize_info,image,
8678 argument_list[0].image_reference);
8679 quantize_info=DestroyQuantizeInfo(quantize_info);
8682 case 42: /* MatteFloodfill */
8693 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8695 if (attribute_flag[0] != 0)
8696 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8697 &geometry,exception);
8698 if (attribute_flag[1] != 0)
8699 geometry.x=argument_list[1].integer_reference;
8700 if (attribute_flag[2] != 0)
8701 geometry.y=argument_list[2].integer_reference;
8702 if (image->matte == MagickFalse)
8703 (void) SetImageOpacity(image,OpaqueAlpha);
8704 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8706 if (attribute_flag[4] != 0)
8707 QueryMagickColor(argument_list[4].string_reference,&target,
8709 if (attribute_flag[3] != 0)
8710 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8712 if (attribute_flag[5] != 0)
8713 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8716 if (attribute_flag[6] != 0)
8717 invert=(MagickBooleanType) argument_list[6].integer_reference;
8718 PushPixelComponentMap(image,AlphaChannel);
8719 (void) FloodfillPaintImage(image,AlphaChannel,draw_info,&target,
8720 geometry.x,geometry.y,invert);
8721 PopPixelComponentMap(image);
8722 StandardPixelComponentMap(image);
8723 draw_info=DestroyDrawInfo(draw_info);
8726 case 43: /* Modulate */
8729 modulate[MaxTextExtent];
8731 geometry_info.rho=100.0;
8732 geometry_info.sigma=100.0;
8733 geometry_info.xi=100.0;
8734 if (attribute_flag[0] != 0)
8735 (void)ParseGeometry(argument_list[0].string_reference,
8737 if (attribute_flag[1] != 0)
8738 geometry_info.xi=argument_list[1].real_reference;
8739 if (attribute_flag[2] != 0)
8740 geometry_info.sigma=argument_list[2].real_reference;
8741 if (attribute_flag[3] != 0)
8743 geometry_info.sigma=argument_list[3].real_reference;
8744 SetImageArtifact(image,"modulate:colorspace","HWB");
8746 if (attribute_flag[4] != 0)
8748 geometry_info.rho=argument_list[4].real_reference;
8749 SetImageArtifact(image,"modulate:colorspace","HSB");
8751 if (attribute_flag[5] != 0)
8753 geometry_info.sigma=argument_list[5].real_reference;
8754 SetImageArtifact(image,"modulate:colorspace","HSL");
8756 if (attribute_flag[6] != 0)
8758 geometry_info.rho=argument_list[6].real_reference;
8759 SetImageArtifact(image,"modulate:colorspace","HWB");
8761 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8762 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8763 (void) ModulateImage(image,modulate);
8766 case 44: /* Negate */
8768 if (attribute_flag[0] == 0)
8769 argument_list[0].integer_reference=0;
8770 if (attribute_flag[1] != 0)
8771 channel=(ChannelType) argument_list[1].integer_reference;
8772 PushPixelComponentMap(image,channel);
8773 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8774 MagickTrue : MagickFalse);
8775 PopPixelComponentMap(image);
8778 case 45: /* Normalize */
8780 if (attribute_flag[0] != 0)
8781 channel=(ChannelType) argument_list[0].integer_reference;
8782 PushPixelComponentMap(image,channel);
8783 NormalizeImage(image);
8784 PopPixelComponentMap(image);
8787 case 46: /* NumberColors */
8789 case 47: /* Opaque */
8798 (void) QueryMagickColor("none",&target,exception);
8799 (void) QueryMagickColor("none",&fill_color,exception);
8800 if (attribute_flag[0] != 0)
8801 (void) QueryMagickColor(argument_list[0].string_reference,
8803 if (attribute_flag[1] != 0)
8804 (void) QueryMagickColor(argument_list[1].string_reference,
8805 &fill_color,exception);
8806 if (attribute_flag[2] != 0)
8807 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8809 if (attribute_flag[3] != 0)
8810 channel=(ChannelType) argument_list[3].integer_reference;
8812 if (attribute_flag[4] != 0)
8813 invert=(MagickBooleanType) argument_list[4].integer_reference;
8814 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8818 case 48: /* Quantize */
8823 quantize_info=AcquireQuantizeInfo(info->image_info);
8824 if (attribute_flag[0] != 0)
8825 quantize_info->number_colors=(size_t)
8826 argument_list[0].integer_reference;
8827 if (attribute_flag[1] != 0)
8828 quantize_info->tree_depth=(size_t)
8829 argument_list[1].integer_reference;
8830 if (attribute_flag[2] != 0)
8831 quantize_info->colorspace=(ColorspaceType)
8832 argument_list[2].integer_reference;
8833 if (attribute_flag[3] != 0)
8834 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8835 MagickTrue : MagickFalse;
8836 if (attribute_flag[4] != 0)
8837 quantize_info->measure_error=
8838 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8839 if (attribute_flag[5] != 0)
8840 (void) QueryColorDatabase(argument_list[5].string_reference,
8841 &image->transparent_color,exception);
8842 if (attribute_flag[5] && argument_list[5].integer_reference)
8844 (void) QuantizeImages(quantize_info,image);
8847 if (attribute_flag[6] != 0)
8848 quantize_info->dither_method=(DitherMethod)
8849 argument_list[6].integer_reference;
8850 if ((image->storage_class == DirectClass) ||
8851 (image->colors > quantize_info->number_colors) ||
8852 (quantize_info->colorspace == GRAYColorspace))
8853 (void) QuantizeImage(quantize_info,image);
8855 CompressImageColormap(image);
8856 quantize_info=DestroyQuantizeInfo(quantize_info);
8859 case 49: /* Raise */
8861 if (attribute_flag[0] != 0)
8862 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8863 &geometry,exception);
8864 if (attribute_flag[1] != 0)
8865 geometry.width=argument_list[1].integer_reference;
8866 if (attribute_flag[2] != 0)
8867 geometry.height=argument_list[2].integer_reference;
8868 if (attribute_flag[3] == 0)
8869 argument_list[3].integer_reference=1;
8870 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8871 0 ? MagickTrue : MagickFalse);
8874 case 50: /* Segment */
8881 smoothing_threshold;
8886 cluster_threshold=1.0;
8887 smoothing_threshold=1.5;
8888 colorspace=RGBColorspace;
8889 verbose=MagickFalse;
8890 if (attribute_flag[0] != 0)
8892 flags=ParseGeometry(argument_list[0].string_reference,
8894 cluster_threshold=geometry_info.rho;
8895 if (flags & SigmaValue)
8896 smoothing_threshold=geometry_info.sigma;
8898 if (attribute_flag[1] != 0)
8899 cluster_threshold=argument_list[1].real_reference;
8900 if (attribute_flag[2] != 0)
8901 smoothing_threshold=argument_list[2].real_reference;
8902 if (attribute_flag[3] != 0)
8903 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8904 if (attribute_flag[4] != 0)
8905 verbose=argument_list[4].integer_reference != 0 ?
8906 MagickTrue : MagickFalse;
8907 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8908 smoothing_threshold);
8911 case 51: /* Signature */
8913 (void) SignatureImage(image);
8916 case 52: /* Solarize */
8918 geometry_info.rho=QuantumRange/2.0;
8919 if (attribute_flag[0] != 0)
8920 flags=ParseGeometry(argument_list[0].string_reference,
8922 if (attribute_flag[1] != 0)
8923 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8925 (void) SolarizeImage(image,geometry_info.rho);
8930 (void) SyncImage(image);
8933 case 54: /* Texture */
8935 if (attribute_flag[0] == 0)
8937 TextureImage(image,argument_list[0].image_reference);
8940 case 55: /* Evalute */
8942 MagickEvaluateOperator
8945 op=SetEvaluateOperator;
8946 if (attribute_flag[0] == MagickFalse)
8947 argument_list[0].real_reference=0.0;
8948 if (attribute_flag[1] != MagickFalse)
8949 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8950 if (attribute_flag[2] != MagickFalse)
8951 channel=(ChannelType) argument_list[2].integer_reference;
8952 (void) EvaluateImageChannel(image,channel,op,
8953 argument_list[0].real_reference,exception);
8956 case 56: /* Transparent */
8967 (void) QueryMagickColor("none",&target,exception);
8968 if (attribute_flag[0] != 0)
8969 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8971 opacity=TransparentAlpha;
8972 if (attribute_flag[1] != 0)
8973 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8975 if (attribute_flag[2] != 0)
8976 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8978 if (attribute_flag[3] == 0)
8979 argument_list[3].integer_reference=0;
8981 if (attribute_flag[3] != 0)
8982 invert=(MagickBooleanType) argument_list[3].integer_reference;
8983 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
8987 case 57: /* Threshold */
8992 if (attribute_flag[0] == 0)
8993 argument_list[0].string_reference="50%";
8994 if (attribute_flag[1] != 0)
8995 channel=(ChannelType) argument_list[1].integer_reference;
8996 threshold=SiPrefixToDouble(argument_list[0].string_reference,
8998 (void) BilevelImageChannel(image,channel,threshold);
9001 case 58: /* Charcoal */
9003 if (attribute_flag[0] != 0)
9005 flags=ParseGeometry(argument_list[0].string_reference,
9007 if ((flags & SigmaValue) == 0)
9008 geometry_info.sigma=1.0;
9010 if (attribute_flag[1] != 0)
9011 geometry_info.rho=argument_list[1].real_reference;
9012 if (attribute_flag[2] != 0)
9013 geometry_info.sigma=argument_list[2].real_reference;
9014 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9020 if (attribute_flag[0] != 0)
9021 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9023 image=TrimImage(image,exception);
9028 if (attribute_flag[0] != 0)
9030 flags=ParseGeometry(argument_list[0].string_reference,
9032 if ((flags & SigmaValue) == 0)
9033 geometry_info.sigma=1.0;
9035 if (attribute_flag[1] != 0)
9036 geometry_info.rho=argument_list[1].real_reference;
9037 if (attribute_flag[2] != 0)
9038 geometry_info.sigma=argument_list[2].real_reference;
9039 if (attribute_flag[3] != 0)
9040 image->interpolate=(InterpolatePixelMethod)
9041 argument_list[3].integer_reference;
9042 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9046 case 61: /* Separate */
9048 if (attribute_flag[0] != 0)
9049 channel=(ChannelType) argument_list[0].integer_reference;
9050 PushPixelComponentMap(image,channel);
9051 (void) SeparateImage(image);
9052 PopPixelComponentMap(image);
9055 case 63: /* Stereo */
9057 if (attribute_flag[0] == 0)
9059 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9063 if (attribute_flag[1] != 0)
9064 geometry.x=argument_list[1].integer_reference;
9065 if (attribute_flag[2] != 0)
9066 geometry.y=argument_list[2].integer_reference;
9067 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9068 geometry.x,geometry.y,exception);
9071 case 64: /* Stegano */
9073 if (attribute_flag[0] == 0)
9075 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9079 if (attribute_flag[1] == 0)
9080 argument_list[1].integer_reference=0;
9081 image->offset=argument_list[1].integer_reference;
9082 image=SteganoImage(image,argument_list[0].image_reference,exception);
9085 case 65: /* Deconstruct */
9087 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9090 case 66: /* GaussianBlur */
9092 if (attribute_flag[0] != 0)
9094 flags=ParseGeometry(argument_list[0].string_reference,
9096 if ((flags & SigmaValue) == 0)
9097 geometry_info.sigma=1.0;
9099 if (attribute_flag[1] != 0)
9100 geometry_info.rho=argument_list[1].real_reference;
9101 if (attribute_flag[2] != 0)
9102 geometry_info.sigma=argument_list[2].real_reference;
9103 if (attribute_flag[3] != 0)
9104 channel=(ChannelType) argument_list[3].integer_reference;
9105 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9106 geometry_info.sigma,exception);
9109 case 67: /* Convolve */
9120 if (attribute_flag[0] == 0)
9122 if (attribute_flag[1] != 0)
9123 channel=(ChannelType) argument_list[1].integer_reference;
9124 if (attribute_flag[2] != 0)
9125 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9127 av=(AV *) argument_list[0].array_reference;
9128 order=(size_t) sqrt(av_len(av)+1);
9129 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9130 if (kernel == (double *) NULL)
9132 ThrowPerlException(exception,ResourceLimitFatalError,
9133 "MemoryAllocationFailed",PackageName);
9136 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9137 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9138 for ( ; j < (ssize_t) (order*order); j++)
9140 image=ConvolveImageChannel(image,channel,order,kernel,exception);
9141 kernel=(double *) RelinquishMagickMemory(kernel);
9144 case 68: /* Profile */
9159 if (attribute_flag[0] != 0)
9160 name=argument_list[0].string_reference;
9161 if (attribute_flag[2] != 0)
9162 image->rendering_intent=(RenderingIntent)
9163 argument_list[2].integer_reference;
9164 if (attribute_flag[3] != 0)
9165 image->black_point_compensation=
9166 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9167 if (attribute_flag[1] != 0)
9169 if (argument_list[1].length == 0)
9172 Remove a profile from the image.
9174 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9179 Associate user supplied profile with the image.
9181 profile=AcquireStringInfo(argument_list[1].length);
9182 SetStringInfoDatum(profile,(const unsigned char *)
9183 argument_list[1].string_reference);
9184 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9185 (size_t) GetStringInfoLength(profile),MagickFalse);
9186 profile=DestroyStringInfo(profile);
9190 Associate a profile with the image.
9193 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9194 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9195 profile_image=ReadImages(profile_info,&image->exception);
9196 if (profile_image == (Image *) NULL)
9198 ResetImageProfileIterator(profile_image);
9199 name=GetNextImageProfile(profile_image);
9200 while (name != (const char *) NULL)
9205 profile=GetImageProfile(profile_image,name);
9206 if (profile != (const StringInfo *) NULL)
9207 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9208 (size_t) GetStringInfoLength(profile),MagickFalse);
9209 name=GetNextImageProfile(profile_image);
9211 profile_image=DestroyImage(profile_image);
9212 profile_info=DestroyImageInfo(profile_info);
9215 case 69: /* UnsharpMask */
9217 if (attribute_flag[0] != 0)
9219 flags=ParseGeometry(argument_list[0].string_reference,
9221 if ((flags & SigmaValue) == 0)
9222 geometry_info.sigma=1.0;
9223 if ((flags & XiValue) == 0)
9224 geometry_info.xi=1.0;
9225 if ((flags & PsiValue) == 0)
9226 geometry_info.psi=0.5;
9228 if (attribute_flag[1] != 0)
9229 geometry_info.rho=argument_list[1].real_reference;
9230 if (attribute_flag[2] != 0)
9231 geometry_info.sigma=argument_list[2].real_reference;
9232 if (attribute_flag[3] != 0)
9233 geometry_info.xi=argument_list[3].real_reference;
9234 if (attribute_flag[4] != 0)
9235 geometry_info.psi=argument_list[4].real_reference;
9236 if (attribute_flag[5] != 0)
9237 channel=(ChannelType) argument_list[5].integer_reference;
9238 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9239 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9242 case 70: /* MotionBlur */
9244 if (attribute_flag[0] != 0)
9246 flags=ParseGeometry(argument_list[0].string_reference,
9248 if ((flags & SigmaValue) == 0)
9249 geometry_info.sigma=1.0;
9250 if ((flags & XiValue) == 0)
9251 geometry_info.xi=1.0;
9253 if (attribute_flag[1] != 0)
9254 geometry_info.rho=argument_list[1].real_reference;
9255 if (attribute_flag[2] != 0)
9256 geometry_info.sigma=argument_list[2].real_reference;
9257 if (attribute_flag[3] != 0)
9258 geometry_info.xi=argument_list[3].real_reference;
9259 if (attribute_flag[4] != 0)
9260 channel=(ChannelType) argument_list[4].integer_reference;
9261 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9262 geometry_info.sigma,geometry_info.xi,exception);
9265 case 71: /* OrderedDither */
9267 if (attribute_flag[0] == 0)
9268 argument_list[0].string_reference="o8x8";
9269 if (attribute_flag[1] != 0)
9270 channel=(ChannelType) argument_list[1].integer_reference;
9271 (void) OrderedPosterizeImageChannel(image,channel,
9272 argument_list[0].string_reference,exception);
9275 case 72: /* Shave */
9277 if (attribute_flag[0] != 0)
9278 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9279 &geometry,exception);
9280 if (attribute_flag[1] != 0)
9281 geometry.width=argument_list[1].integer_reference;
9282 if (attribute_flag[2] != 0)
9283 geometry.height=argument_list[2].integer_reference;
9284 image=ShaveImage(image,&geometry,exception);
9287 case 73: /* Level */
9295 white_point=(MagickRealType) image->columns*image->rows;
9297 if (attribute_flag[0] != 0)
9299 flags=ParseGeometry(argument_list[0].string_reference,
9301 black_point=geometry_info.rho;
9302 if ((flags & SigmaValue) != 0)
9303 white_point=geometry_info.sigma;
9304 if ((flags & XiValue) != 0)
9305 gamma=geometry_info.xi;
9306 if ((flags & PercentValue) != 0)
9308 black_point*=(double) (QuantumRange/100.0);
9309 white_point*=(double) (QuantumRange/100.0);
9311 if ((flags & SigmaValue) == 0)
9312 white_point=(double) QuantumRange-black_point;
9314 if (attribute_flag[1] != 0)
9315 black_point=argument_list[1].real_reference;
9316 if (attribute_flag[2] != 0)
9317 white_point=argument_list[2].real_reference;
9318 if (attribute_flag[3] != 0)
9319 gamma=argument_list[3].real_reference;
9320 if (attribute_flag[4] != 0)
9321 channel=(ChannelType) argument_list[4].integer_reference;
9322 if (attribute_flag[5] != 0)
9324 argument_list[0].real_reference=argument_list[5].real_reference;
9325 attribute_flag[0]=attribute_flag[5];
9327 PushPixelComponentMap(image,channel);
9328 (void) LevelImage(image,black_point,white_point,gamma);
9329 PopPixelComponentMap(image);
9334 if (attribute_flag[0] == 0)
9335 argument_list[0].string_reference="#1";
9336 if (attribute_flag[1] == 0)
9337 argument_list[1].integer_reference=MagickTrue;
9338 (void) ClipImagePath(image,argument_list[0].string_reference,
9339 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9342 case 75: /* AffineTransform */
9347 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9349 if (attribute_flag[0] != 0)
9354 av=(AV *) argument_list[0].array_reference;
9355 if ((av_len(av) != 3) && (av_len(av) != 5))
9357 ThrowPerlException(exception,OptionError,
9358 "affine matrix must have 4 or 6 elements",PackageName);
9361 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9362 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9363 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9364 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9365 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9366 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9368 ThrowPerlException(exception,OptionError,
9369 "affine matrix is singular",PackageName);
9372 if (av_len(av) == 5)
9374 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9375 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9378 for (j=1; j < 6; j++)
9380 if (attribute_flag[j] == 0)
9382 value=argument_list[j].string_reference;
9383 angle=argument_list[j].real_reference;
9384 current=draw_info->affine;
9385 GetAffineMatrix(&affine);
9393 flags=ParseGeometry(value,&geometry_info);
9394 affine.tx=geometry_info.xi;
9395 affine.ty=geometry_info.psi;
9396 if ((flags & PsiValue) == 0)
9397 affine.ty=affine.tx;
9405 flags=ParseGeometry(value,&geometry_info);
9406 affine.sx=geometry_info.rho;
9407 affine.sy=geometry_info.sigma;
9408 if ((flags & SigmaValue) == 0)
9409 affine.sy=affine.sx;
9419 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9420 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9421 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9422 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9430 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9438 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9442 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9443 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9444 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9445 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9446 draw_info->affine.tx=
9447 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9448 draw_info->affine.ty=
9449 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9451 if (attribute_flag[6] != 0)
9452 image->interpolate=(InterpolatePixelMethod)
9453 argument_list[6].integer_reference;
9454 if (attribute_flag[7] != 0)
9455 QueryColorDatabase(argument_list[7].string_reference,
9456 &image->background_color,exception);
9457 image=AffineTransformImage(image,&draw_info->affine,exception);
9458 draw_info=DestroyDrawInfo(draw_info);
9461 case 76: /* Difference */
9463 if (attribute_flag[0] == 0)
9465 ThrowPerlException(exception,OptionError,
9466 "ReferenceImageRequired",PackageName);
9469 if (attribute_flag[1] != 0)
9470 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9472 (void) IsImagesEqual(image,argument_list[0].image_reference);
9475 case 77: /* AdaptiveThreshold */
9477 if (attribute_flag[0] != 0)
9479 flags=ParseGeometry(argument_list[0].string_reference,
9481 if ((flags & PercentValue) != 0)
9482 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9484 if (attribute_flag[1] != 0)
9485 geometry_info.rho=argument_list[1].integer_reference;
9486 if (attribute_flag[2] != 0)
9487 geometry_info.sigma=argument_list[2].integer_reference;
9488 if (attribute_flag[3] != 0)
9489 geometry_info.xi=argument_list[3].integer_reference;;
9490 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9491 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9495 case 78: /* Resample */
9501 if (attribute_flag[0] != 0)
9503 flags=ParseGeometry(argument_list[0].string_reference,
9505 if ((flags & SigmaValue) == 0)
9506 geometry_info.sigma=geometry_info.rho;
9508 if (attribute_flag[1] != 0)
9509 geometry_info.rho=argument_list[1].real_reference;
9510 if (attribute_flag[2] != 0)
9511 geometry_info.sigma=argument_list[2].real_reference;
9512 if (attribute_flag[3] == 0)
9513 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9514 if (attribute_flag[4] == 0)
9515 SetImageArtifact(image,"filter:support",
9516 argument_list[4].string_reference);
9517 if (attribute_flag[5] != 0)
9518 argument_list[5].real_reference=1.0;
9519 width=(size_t) (geometry_info.rho*image->columns/
9520 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9521 height=(size_t) (geometry_info.sigma*image->rows/
9522 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9523 image=ResizeImage(image,width,height,(FilterTypes)
9524 argument_list[3].integer_reference,argument_list[5].real_reference,
9526 if (image != (Image *) NULL)
9528 image->x_resolution=geometry_info.rho;
9529 image->y_resolution=geometry_info.sigma;
9533 case 79: /* Describe */
9535 if (attribute_flag[0] == 0)
9536 argument_list[0].file_reference=(FILE *) NULL;
9537 if (attribute_flag[1] != 0)
9538 (void) SetImageArtifact(image,"identify:features",
9539 argument_list[1].string_reference);
9540 (void) IdentifyImage(image,argument_list[0].file_reference,
9544 case 80: /* BlackThreshold */
9546 if (attribute_flag[0] == 0)
9547 argument_list[0].string_reference="50%";
9548 if (attribute_flag[2] != 0)
9549 channel=(ChannelType) argument_list[2].integer_reference;
9550 BlackThresholdImageChannel(image,channel,
9551 argument_list[0].string_reference,exception);
9554 case 81: /* WhiteThreshold */
9556 if (attribute_flag[0] == 0)
9557 argument_list[0].string_reference="50%";
9558 if (attribute_flag[2] != 0)
9559 channel=(ChannelType) argument_list[2].integer_reference;
9560 WhiteThresholdImageChannel(image,channel,
9561 argument_list[0].string_reference,exception);
9564 case 82: /* RadialBlur */
9566 if (attribute_flag[0] != 0)
9568 flags=ParseGeometry(argument_list[0].string_reference,
9570 if ((flags & SigmaValue) == 0)
9571 geometry_info.sigma=1.0;
9573 if (attribute_flag[1] != 0)
9574 geometry_info.rho=argument_list[1].real_reference;
9575 if (attribute_flag[2] != 0)
9576 channel=(ChannelType) argument_list[2].integer_reference;
9577 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9581 case 83: /* Thumbnail */
9583 if (attribute_flag[0] != 0)
9584 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9585 &geometry,exception);
9586 if (attribute_flag[1] != 0)
9587 geometry.width=argument_list[1].integer_reference;
9588 if (attribute_flag[2] != 0)
9589 geometry.height=argument_list[2].integer_reference;
9590 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9593 case 84: /* Strip */
9595 (void) StripImage(image);
9603 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9604 if (attribute_flag[0] != 0)
9605 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9607 if (attribute_flag[1] == 0)
9608 argument_list[1].string_reference="100";
9609 image=TintImage(image,argument_list[1].string_reference,target,
9613 case 86: /* Channel */
9615 if (attribute_flag[0] != 0)
9616 channel=(ChannelType) argument_list[0].integer_reference;
9617 PushPixelComponentMap(image,channel);
9618 (void) SeparateImage(image);
9619 PopPixelComponentMap(image);
9622 case 87: /* Splice */
9624 if (attribute_flag[0] != 0)
9625 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9626 &geometry,exception);
9627 if (attribute_flag[1] != 0)
9628 geometry.width=argument_list[1].integer_reference;
9629 if (attribute_flag[2] != 0)
9630 geometry.height=argument_list[2].integer_reference;
9631 if (attribute_flag[3] != 0)
9632 geometry.x=argument_list[3].integer_reference;
9633 if (attribute_flag[4] != 0)
9634 geometry.y=argument_list[4].integer_reference;
9635 if (attribute_flag[5] != 0)
9636 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9638 if (attribute_flag[6] != 0)
9639 (void) QueryColorDatabase(argument_list[6].string_reference,
9640 &image->background_color,exception);
9641 if (attribute_flag[7] != 0)
9642 image->gravity=(GravityType) argument_list[7].integer_reference;
9643 image=SpliceImage(image,&geometry,exception);
9646 case 88: /* Posterize */
9648 if (attribute_flag[0] == 0)
9649 argument_list[0].integer_reference=3;
9650 if (attribute_flag[1] == 0)
9651 argument_list[1].integer_reference=0;
9652 (void) PosterizeImage(image,argument_list[0].integer_reference,
9653 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9656 case 89: /* Shadow */
9658 if (attribute_flag[0] != 0)
9660 flags=ParseGeometry(argument_list[0].string_reference,
9662 if ((flags & SigmaValue) == 0)
9663 geometry_info.sigma=1.0;
9664 if ((flags & XiValue) == 0)
9665 geometry_info.xi=4.0;
9666 if ((flags & PsiValue) == 0)
9667 geometry_info.psi=4.0;
9669 if (attribute_flag[1] != 0)
9670 geometry_info.rho=argument_list[1].real_reference;
9671 if (attribute_flag[2] != 0)
9672 geometry_info.sigma=argument_list[2].real_reference;
9673 if (attribute_flag[3] != 0)
9674 geometry_info.xi=argument_list[3].integer_reference;
9675 if (attribute_flag[4] != 0)
9676 geometry_info.psi=argument_list[4].integer_reference;
9677 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9678 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9682 case 90: /* Identify */
9684 if (attribute_flag[0] == 0)
9685 argument_list[0].file_reference=(FILE *) NULL;
9686 if (attribute_flag[1] != 0)
9687 (void) SetImageArtifact(image,"identify:features",
9688 argument_list[1].string_reference);
9689 if ((attribute_flag[2] != 0) &&
9690 (argument_list[2].integer_reference != 0))
9691 (void) SetImageArtifact(image,"identify:unique","true");
9692 (void) IdentifyImage(image,argument_list[0].file_reference,
9696 case 91: /* SepiaTone */
9698 if (attribute_flag[0] == 0)
9699 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9700 image=SepiaToneImage(image,argument_list[0].real_reference,
9704 case 92: /* SigmoidalContrast */
9709 if (attribute_flag[0] != 0)
9711 flags=ParseGeometry(argument_list[0].string_reference,
9713 if ((flags & SigmaValue) == 0)
9714 geometry_info.sigma=QuantumRange/2.0;
9715 if ((flags & PercentValue) != 0)
9716 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9718 if (attribute_flag[1] != 0)
9719 geometry_info.rho=argument_list[1].real_reference;
9720 if (attribute_flag[2] != 0)
9721 geometry_info.sigma=argument_list[2].real_reference;
9722 if (attribute_flag[3] != 0)
9723 channel=(ChannelType) argument_list[3].integer_reference;
9725 if (attribute_flag[4] != 0)
9726 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9728 PushPixelComponentMap(image,channel);
9729 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9730 geometry_info.sigma);
9731 PopPixelComponentMap(image);
9734 case 93: /* Extent */
9736 if (attribute_flag[7] != 0)
9737 image->gravity=(GravityType) argument_list[7].integer_reference;
9738 if (attribute_flag[0] != 0)
9743 flags=ParseGravityGeometry(image,
9744 argument_list[0].string_reference,&geometry,exception);
9746 if (geometry.width == 0)
9747 geometry.width=image->columns;
9748 if (geometry.height == 0)
9749 geometry.height=image->rows;
9751 if (attribute_flag[1] != 0)
9752 geometry.width=argument_list[1].integer_reference;
9753 if (attribute_flag[2] != 0)
9754 geometry.height=argument_list[2].integer_reference;
9755 if (attribute_flag[3] != 0)
9756 geometry.x=argument_list[3].integer_reference;
9757 if (attribute_flag[4] != 0)
9758 geometry.y=argument_list[4].integer_reference;
9759 if (attribute_flag[5] != 0)
9760 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9762 if (attribute_flag[6] != 0)
9763 (void) QueryColorDatabase(argument_list[6].string_reference,
9764 &image->background_color,exception);
9765 image=ExtentImage(image,&geometry,exception);
9768 case 94: /* Vignette */
9770 if (attribute_flag[0] != 0)
9772 flags=ParseGeometry(argument_list[0].string_reference,
9774 if ((flags & SigmaValue) == 0)
9775 geometry_info.sigma=1.0;
9776 if ((flags & XiValue) == 0)
9777 geometry_info.xi=0.1*image->columns;
9778 if ((flags & PsiValue) == 0)
9779 geometry_info.psi=0.1*image->rows;
9781 if (attribute_flag[1] != 0)
9782 geometry_info.rho=argument_list[1].real_reference;
9783 if (attribute_flag[2] != 0)
9784 geometry_info.sigma=argument_list[2].real_reference;
9785 if (attribute_flag[3] != 0)
9786 geometry_info.xi=argument_list[3].integer_reference;
9787 if (attribute_flag[4] != 0)
9788 geometry_info.psi=argument_list[4].integer_reference;
9789 if (attribute_flag[5] != 0)
9790 (void) QueryColorDatabase(argument_list[5].string_reference,
9791 &image->background_color,exception);
9792 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9793 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9797 case 95: /* ContrastStretch */
9804 white_point=(MagickRealType) image->columns*image->rows;
9805 if (attribute_flag[0] != 0)
9807 flags=ParseGeometry(argument_list[0].string_reference,
9809 black_point=geometry_info.rho;
9810 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9812 if ((flags & PercentValue) != 0)
9814 black_point*=(double) image->columns*image->rows/100.0;
9815 white_point*=(double) image->columns*image->rows/100.0;
9817 white_point=(MagickRealType) image->columns*image->rows-
9820 if (attribute_flag[1] != 0)
9821 black_point=argument_list[1].real_reference;
9822 if (attribute_flag[2] != 0)
9823 white_point=argument_list[2].real_reference;
9824 if (attribute_flag[4] != 0)
9825 channel=(ChannelType) argument_list[4].integer_reference;
9826 PushPixelComponentMap(image,channel);
9827 (void) ContrastStretchImage(image,black_point,white_point);
9828 PopPixelComponentMap(image);
9831 case 96: /* Sans0 */
9835 case 97: /* Sans1 */
9839 case 98: /* AdaptiveSharpen */
9841 if (attribute_flag[0] != 0)
9843 flags=ParseGeometry(argument_list[0].string_reference,
9845 if ((flags & SigmaValue) == 0)
9846 geometry_info.sigma=1.0;
9848 if (attribute_flag[1] != 0)
9849 geometry_info.rho=argument_list[1].real_reference;
9850 if (attribute_flag[2] != 0)
9851 geometry_info.sigma=argument_list[2].real_reference;
9852 if (attribute_flag[3] != 0)
9853 channel=(ChannelType) argument_list[3].integer_reference;
9854 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9855 geometry_info.sigma,exception);
9858 case 99: /* Transpose */
9860 image=TransposeImage(image,exception);
9863 case 100: /* Tranverse */
9865 image=TransverseImage(image,exception);
9868 case 101: /* AutoOrient */
9870 switch (image->orientation)
9872 case TopRightOrientation:
9874 image=FlopImage(image,exception);
9877 case BottomRightOrientation:
9879 image=RotateImage(image,180.0,exception);
9882 case BottomLeftOrientation:
9884 image=FlipImage(image,exception);
9887 case LeftTopOrientation:
9889 image=TransposeImage(image,exception);
9892 case RightTopOrientation:
9894 image=RotateImage(image,90.0,exception);
9897 case RightBottomOrientation:
9899 image=TransverseImage(image,exception);
9902 case LeftBottomOrientation:
9904 image=RotateImage(image,270.0,exception);
9912 case 102: /* AdaptiveBlur */
9914 if (attribute_flag[0] != 0)
9916 flags=ParseGeometry(argument_list[0].string_reference,
9918 if ((flags & SigmaValue) == 0)
9919 geometry_info.sigma=1.0;
9921 if (attribute_flag[1] != 0)
9922 geometry_info.rho=argument_list[1].real_reference;
9923 if (attribute_flag[2] != 0)
9924 geometry_info.sigma=argument_list[2].real_reference;
9925 if (attribute_flag[3] != 0)
9926 channel=(ChannelType) argument_list[3].integer_reference;
9927 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
9928 geometry_info.sigma,exception);
9931 case 103: /* Sketch */
9933 if (attribute_flag[0] != 0)
9935 flags=ParseGeometry(argument_list[0].string_reference,
9937 if ((flags & SigmaValue) == 0)
9938 geometry_info.sigma=1.0;
9939 if ((flags & XiValue) == 0)
9940 geometry_info.xi=1.0;
9942 if (attribute_flag[1] != 0)
9943 geometry_info.rho=argument_list[1].real_reference;
9944 if (attribute_flag[2] != 0)
9945 geometry_info.sigma=argument_list[2].real_reference;
9946 if (attribute_flag[3] != 0)
9947 geometry_info.xi=argument_list[3].real_reference;
9948 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9949 geometry_info.xi,exception);
9952 case 104: /* UniqueColors */
9954 image=UniqueImageColors(image,exception);
9957 case 105: /* AdaptiveResize */
9959 if (attribute_flag[0] != 0)
9960 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9961 &geometry,exception);
9962 if (attribute_flag[1] != 0)
9963 geometry.width=argument_list[1].integer_reference;
9964 if (attribute_flag[2] != 0)
9965 geometry.height=argument_list[2].integer_reference;
9966 if (attribute_flag[3] != 0)
9967 image->filter=(FilterTypes) argument_list[4].integer_reference;
9968 if (attribute_flag[4] != 0)
9969 SetImageArtifact(image,"filter:support",
9970 argument_list[4].string_reference);
9971 if (attribute_flag[5] != 0)
9972 image->blur=argument_list[5].real_reference;
9973 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
9977 case 106: /* ClipMask */
9979 if (attribute_flag[0] == 0)
9981 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9985 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
9986 MagickTrue,exception);
9987 (void) NegateImage(image->clip_mask,MagickFalse);
9990 case 107: /* LinearStretch */
9997 white_point=(MagickRealType) image->columns*image->rows;
9998 if (attribute_flag[0] != 0)
10000 flags=ParseGeometry(argument_list[0].string_reference,
10002 if ((flags & SigmaValue) != 0)
10003 white_point=geometry_info.sigma;
10004 if ((flags & PercentValue) != 0)
10006 black_point*=(double) image->columns*image->rows/100.0;
10007 white_point*=(double) image->columns*image->rows/100.0;
10009 if ((flags & SigmaValue) == 0)
10010 white_point=(double) image->columns*image->rows-black_point;
10012 if (attribute_flag[1] != 0)
10013 black_point=argument_list[1].real_reference;
10014 if (attribute_flag[2] != 0)
10015 white_point=argument_list[2].real_reference;
10016 (void) LinearStretchImage(image,black_point,white_point);
10019 case 109: /* Mask */
10021 if (attribute_flag[0] == 0)
10023 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10025 goto PerlException;
10027 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10028 MagickTrue,exception);
10029 (void) NegateImage(image->mask,MagickFalse);
10032 case 110: /* Polaroid */
10040 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10041 (DrawInfo *) NULL);
10042 if (attribute_flag[0] != 0)
10043 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10044 info ? info->image_info : (ImageInfo *) NULL,image,
10045 argument_list[0].string_reference));
10047 if (attribute_flag[1] != 0)
10048 angle=argument_list[1].real_reference;
10049 if (attribute_flag[2] != 0)
10050 (void) CloneString(&draw_info->font,
10051 argument_list[2].string_reference);
10052 if (attribute_flag[3] != 0)
10053 (void) QueryColorDatabase(argument_list[3].string_reference,
10054 &draw_info->stroke,exception);
10055 if (attribute_flag[4] != 0)
10056 (void) QueryColorDatabase(argument_list[4].string_reference,
10057 &draw_info->fill,exception);
10058 if (attribute_flag[5] != 0)
10059 draw_info->stroke_width=argument_list[5].real_reference;
10060 if (attribute_flag[6] != 0)
10061 draw_info->pointsize=argument_list[6].real_reference;
10062 if (attribute_flag[7] != 0)
10063 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10064 if (attribute_flag[8] != 0)
10065 (void) QueryColorDatabase(argument_list[8].string_reference,
10066 &image->background_color,exception);
10067 image=PolaroidImage(image,draw_info,angle,exception);
10068 draw_info=DestroyDrawInfo(draw_info);
10071 case 111: /* FloodfillPaint */
10082 draw_info=CloneDrawInfo(info ? info->image_info :
10083 (ImageInfo *) NULL,(DrawInfo *) NULL);
10084 if (attribute_flag[0] != 0)
10085 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10086 &geometry,exception);
10087 if (attribute_flag[1] != 0)
10088 geometry.x=argument_list[1].integer_reference;
10089 if (attribute_flag[2] != 0)
10090 geometry.y=argument_list[2].integer_reference;
10091 if (attribute_flag[3] != 0)
10092 (void) QueryColorDatabase(argument_list[3].string_reference,
10093 &draw_info->fill,exception);
10094 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10096 if (attribute_flag[4] != 0)
10097 QueryMagickColor(argument_list[4].string_reference,&target,
10099 if (attribute_flag[5] != 0)
10100 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10102 if (attribute_flag[6] != 0)
10103 channel=(ChannelType) argument_list[6].integer_reference;
10104 invert=MagickFalse;
10105 if (attribute_flag[7] != 0)
10106 invert=(MagickBooleanType) argument_list[7].integer_reference;
10107 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10108 geometry.y,invert);
10109 draw_info=DestroyDrawInfo(draw_info);
10112 case 112: /* Distort */
10124 number_coordinates;
10129 if (attribute_flag[0] == 0)
10131 method=UndefinedDistortion;
10132 if (attribute_flag[1] != 0)
10133 method=(DistortImageMethod) argument_list[1].integer_reference;
10134 av=(AV *) argument_list[0].array_reference;
10135 number_coordinates=(size_t) av_len(av)+1;
10136 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10137 sizeof(*coordinates));
10138 if (coordinates == (double *) NULL)
10140 ThrowPerlException(exception,ResourceLimitFatalError,
10141 "MemoryAllocationFailed",PackageName);
10142 goto PerlException;
10144 for (j=0; j < (ssize_t) number_coordinates; j++)
10145 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10146 virtual_pixel=UndefinedVirtualPixelMethod;
10147 if (attribute_flag[2] != 0)
10148 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10149 argument_list[2].integer_reference);
10150 image=DistortImage(image,method,number_coordinates,coordinates,
10151 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10153 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10154 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10155 coordinates=(double *) RelinquishMagickMemory(coordinates);
10158 case 113: /* Clut */
10160 if (attribute_flag[0] == 0)
10162 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10164 goto PerlException;
10166 if (attribute_flag[1] != 0)
10167 channel=(ChannelType) argument_list[1].integer_reference;
10168 PushPixelComponentMap(image,channel);
10169 (void) ClutImage(image,argument_list[0].image_reference);
10170 PopPixelComponentMap(image);
10173 case 114: /* LiquidRescale */
10175 if (attribute_flag[0] != 0)
10176 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10177 &geometry,exception);
10178 if (attribute_flag[1] != 0)
10179 geometry.width=argument_list[1].integer_reference;
10180 if (attribute_flag[2] != 0)
10181 geometry.height=argument_list[2].integer_reference;
10182 if (attribute_flag[3] == 0)
10183 argument_list[3].real_reference=1.0;
10184 if (attribute_flag[4] == 0)
10185 argument_list[4].real_reference=0.0;
10186 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10187 argument_list[3].real_reference,argument_list[4].real_reference,
10191 case 115: /* EncipherImage */
10193 (void) EncipherImage(image,argument_list[0].string_reference,
10197 case 116: /* DecipherImage */
10199 (void) DecipherImage(image,argument_list[0].string_reference,
10203 case 117: /* Deskew */
10205 geometry_info.rho=QuantumRange/2.0;
10206 if (attribute_flag[0] != 0)
10207 flags=ParseGeometry(argument_list[0].string_reference,
10209 if (attribute_flag[1] != 0)
10210 geometry_info.rho=SiPrefixToDouble(
10211 argument_list[1].string_reference,QuantumRange);
10212 image=DeskewImage(image,geometry_info.rho,exception);
10215 case 118: /* Remap */
10220 if (attribute_flag[0] == 0)
10222 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10224 goto PerlException;
10226 quantize_info=AcquireQuantizeInfo(info->image_info);
10227 if (attribute_flag[1] != 0)
10228 quantize_info->dither=(MagickBooleanType)
10229 argument_list[1].integer_reference;
10230 if (attribute_flag[2] != 0)
10231 quantize_info->dither_method=(DitherMethod)
10232 argument_list[2].integer_reference;
10233 (void) RemapImages(quantize_info,image,
10234 argument_list[0].image_reference);
10235 quantize_info=DestroyQuantizeInfo(quantize_info);
10238 case 119: /* SparseColor */
10250 number_coordinates;
10255 if (attribute_flag[0] == 0)
10257 method=UndefinedColorInterpolate;
10258 if (attribute_flag[1] != 0)
10259 method=(SparseColorMethod) argument_list[1].integer_reference;
10260 av=(AV *) argument_list[0].array_reference;
10261 number_coordinates=(size_t) av_len(av)+1;
10262 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10263 sizeof(*coordinates));
10264 if (coordinates == (double *) NULL)
10266 ThrowPerlException(exception,ResourceLimitFatalError,
10267 "MemoryAllocationFailed",PackageName);
10268 goto PerlException;
10270 for (j=0; j < (ssize_t) number_coordinates; j++)
10271 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10272 virtual_pixel=UndefinedVirtualPixelMethod;
10273 if (attribute_flag[2] != 0)
10274 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10275 argument_list[2].integer_reference);
10276 if (attribute_flag[3] != 0)
10277 channel=(ChannelType) argument_list[3].integer_reference;
10278 image=SparseColorImage(image,channel,method,number_coordinates,
10279 coordinates,exception);
10280 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10281 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10282 coordinates=(double *) RelinquishMagickMemory(coordinates);
10285 case 120: /* Function */
10302 if (attribute_flag[0] == 0)
10304 function=UndefinedFunction;
10305 if (attribute_flag[1] != 0)
10306 function=(MagickFunction) argument_list[1].integer_reference;
10307 av=(AV *) argument_list[0].array_reference;
10308 number_parameters=(size_t) av_len(av)+1;
10309 parameters=(double *) AcquireQuantumMemory(number_parameters,
10310 sizeof(*parameters));
10311 if (parameters == (double *) NULL)
10313 ThrowPerlException(exception,ResourceLimitFatalError,
10314 "MemoryAllocationFailed",PackageName);
10315 goto PerlException;
10317 for (j=0; j < (ssize_t) number_parameters; j++)
10318 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10319 virtual_pixel=UndefinedVirtualPixelMethod;
10320 if (attribute_flag[2] != 0)
10321 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10322 argument_list[2].integer_reference);
10323 (void) FunctionImage(image,function,number_parameters,parameters,
10325 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10326 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10327 parameters=(double *) RelinquishMagickMemory(parameters);
10330 case 121: /* SelectiveBlur */
10332 if (attribute_flag[0] != 0)
10334 flags=ParseGeometry(argument_list[0].string_reference,
10336 if ((flags & SigmaValue) == 0)
10337 geometry_info.sigma=1.0;
10338 if ((flags & PercentValue) != 0)
10339 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10341 if (attribute_flag[1] != 0)
10342 geometry_info.rho=argument_list[1].real_reference;
10343 if (attribute_flag[2] != 0)
10344 geometry_info.sigma=argument_list[2].real_reference;
10345 if (attribute_flag[3] != 0)
10346 geometry_info.xi=argument_list[3].integer_reference;;
10347 if (attribute_flag[4] != 0)
10348 channel=(ChannelType) argument_list[4].integer_reference;
10349 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10350 geometry_info.sigma,geometry_info.xi,exception);
10353 case 122: /* HaldClut */
10355 if (attribute_flag[0] == 0)
10357 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10359 goto PerlException;
10361 if (attribute_flag[1] != 0)
10362 channel=(ChannelType) argument_list[1].integer_reference;
10363 PushPixelComponentMap(image,channel);
10364 (void) HaldClutImage(image,argument_list[0].image_reference);
10365 PopPixelComponentMap(image);
10368 case 123: /* BlueShift */
10370 if (attribute_flag[0] != 0)
10371 (void) ParseGeometry(argument_list[0].string_reference,
10373 image=BlueShiftImage(image,geometry_info.rho,exception);
10376 case 124: /* ForwardFourierTransformImage */
10378 image=ForwardFourierTransformImage(image,
10379 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10383 case 125: /* InverseFourierTransformImage */
10385 image=InverseFourierTransformImage(image,image->next,
10386 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10390 case 126: /* ColorDecisionList */
10392 if (attribute_flag[0] == 0)
10393 argument_list[0].string_reference=(char *) NULL;
10394 (void) ColorDecisionListImage(image,
10395 argument_list[0].string_reference);
10398 case 127: /* AutoGamma */
10400 if (attribute_flag[0] != 0)
10401 channel=(ChannelType) argument_list[0].integer_reference;
10402 PushPixelComponentMap(image,channel);
10403 (void) AutoGammaImage(image);
10404 PopPixelComponentMap(image);
10407 case 128: /* AutoLevel */
10409 if (attribute_flag[0] != 0)
10410 channel=(ChannelType) argument_list[0].integer_reference;
10411 PushPixelComponentMap(image,channel);
10412 (void) AutoLevelImage(image);
10413 PopPixelComponentMap(image);
10416 case 129: /* LevelColors */
10422 (void) QueryMagickColor("#000000",&black_point,exception);
10423 (void) QueryMagickColor("#ffffff",&white_point,exception);
10424 if (attribute_flag[1] != 0)
10425 (void) QueryMagickColor(argument_list[1].string_reference,
10426 &black_point,exception);
10427 if (attribute_flag[2] != 0)
10428 (void) QueryMagickColor(argument_list[2].string_reference,
10429 &white_point,exception);
10430 if (attribute_flag[3] != 0)
10431 channel=(ChannelType) argument_list[3].integer_reference;
10432 PushPixelComponentMap(image,channel);
10433 (void) LevelImageColors(image,&black_point,&white_point,
10434 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
10435 PopPixelComponentMap(image);
10438 case 130: /* Clamp */
10440 if (attribute_flag[0] != 0)
10441 channel=(ChannelType) argument_list[0].integer_reference;
10442 (void) ClampImageChannel(image,channel);
10445 case 131: /* Filter */
10450 if (attribute_flag[0] == 0)
10452 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10453 if (kernel == (KernelInfo *) NULL)
10455 if (attribute_flag[1] != 0)
10456 channel=(ChannelType) argument_list[1].integer_reference;
10457 if (attribute_flag[2] != 0)
10458 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10460 image=FilterImageChannel(image,channel,kernel,exception);
10461 kernel=DestroyKernelInfo(kernel);
10464 case 132: /* BrightnessContrast */
10472 if (attribute_flag[0] != 0)
10474 flags=ParseGeometry(argument_list[0].string_reference,
10476 brightness=geometry_info.rho;
10477 if ((flags & SigmaValue) == 0)
10478 contrast=geometry_info.sigma;
10480 if (attribute_flag[1] != 0)
10481 brightness=argument_list[1].real_reference;
10482 if (attribute_flag[2] != 0)
10483 contrast=argument_list[2].real_reference;
10484 if (attribute_flag[4] != 0)
10485 channel=(ChannelType) argument_list[4].integer_reference;
10486 PushPixelComponentMap(image,channel);
10487 (void) BrightnessContrastImage(image,brightness,contrast);
10488 PopPixelComponentMap(image);
10491 case 133: /* Morphology */
10502 if (attribute_flag[0] == 0)
10504 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10505 if (kernel == (KernelInfo *) NULL)
10507 if (attribute_flag[1] != 0)
10508 channel=(ChannelType) argument_list[1].integer_reference;
10509 method=UndefinedMorphology;
10510 if (attribute_flag[2] != 0)
10511 method=argument_list[2].integer_reference;
10513 if (attribute_flag[3] != 0)
10514 iterations=argument_list[4].integer_reference;
10515 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10517 kernel=DestroyKernelInfo(kernel);
10520 case 108: /* Recolor */
10521 case 134: /* ColorMatrix */
10535 if (attribute_flag[0] == 0)
10537 av=(AV *) argument_list[0].array_reference;
10538 order=(size_t) sqrt(av_len(av)+1);
10539 color_matrix=(double *) AcquireQuantumMemory(order,order*
10540 sizeof(*color_matrix));
10541 if (color_matrix == (double *) NULL)
10543 ThrowPerlException(exception,ResourceLimitFatalError,
10544 "MemoryAllocationFailed",PackageName);
10545 goto PerlException;
10547 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10548 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10549 for ( ; j < (ssize_t) (order*order); j++)
10550 color_matrix[j]=0.0;
10551 kernel_info=AcquireKernelInfo("1");
10552 if (kernel_info == (KernelInfo *) NULL)
10554 kernel_info->width=order;
10555 kernel_info->height=order;
10556 kernel_info->values=color_matrix;
10557 image=ColorMatrixImage(image,kernel_info,exception);
10558 kernel_info->values=(double *) NULL;
10559 kernel_info=DestroyKernelInfo(kernel_info);
10560 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10563 case 135: /* Color */
10568 (void) QueryMagickColor("none",&color,exception);
10569 if (attribute_flag[0] != 0)
10570 (void) QueryMagickColor(argument_list[0].string_reference,
10572 (void) SetImageColor(image,&color);
10575 case 136: /* Mode */
10577 if (attribute_flag[0] != 0)
10579 flags=ParseGeometry(argument_list[0].string_reference,
10581 if ((flags & SigmaValue) == 0)
10582 geometry_info.sigma=1.0;
10584 if (attribute_flag[1] != 0)
10585 geometry_info.rho=argument_list[1].real_reference;
10586 if (attribute_flag[2] != 0)
10587 geometry_info.sigma=argument_list[2].real_reference;
10588 if (attribute_flag[3] != 0)
10589 channel=(ChannelType) argument_list[3].integer_reference;
10590 image=StatisticImageChannel(image,channel,ModeStatistic,
10591 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10594 case 137: /* Statistic */
10599 statistic=UndefinedStatistic;
10600 if (attribute_flag[0] != 0)
10602 flags=ParseGeometry(argument_list[0].string_reference,
10604 if ((flags & SigmaValue) == 0)
10605 geometry_info.sigma=1.0;
10607 if (attribute_flag[1] != 0)
10608 geometry_info.rho=argument_list[1].real_reference;
10609 if (attribute_flag[2] != 0)
10610 geometry_info.sigma=argument_list[2].real_reference;
10611 if (attribute_flag[3] != 0)
10612 channel=(ChannelType) argument_list[3].integer_reference;
10613 if (attribute_flag[4] != 0)
10614 statistic=(StatisticType) argument_list[4].integer_reference;
10615 image=StatisticImageChannel(image,channel,statistic,
10616 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10620 if (next != (Image *) NULL)
10621 (void) CatchImageException(next);
10622 if (region_image != (Image *) NULL)
10627 status=CompositeImage(region_image,CopyCompositeOp,image,
10628 region_info.x,region_info.y);
10630 (void) CatchImageException(region_image);
10631 image=DestroyImage(image);
10632 image=region_image;
10634 if (image != (Image *) NULL)
10637 if (next && (next != image))
10639 image->next=next->next;
10640 DeleteImageFromRegistry(*pv,next);
10642 sv_setiv(*pv,(IV) image);
10650 if (reference_vector)
10651 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10652 InheritPerlException(exception,perl_exception);
10653 exception=DestroyExceptionInfo(exception);
10654 sv_setiv(perl_exception,(IV) number_images);
10655 SvPOK_on(perl_exception);
10656 ST(0)=sv_2mortal(perl_exception);
10661 ###############################################################################
10669 ###############################################################################
10674 Image::Magick ref=NO_INIT
10719 PERL_UNUSED_VAR(ref);
10720 PERL_UNUSED_VAR(ix);
10721 exception=AcquireExceptionInfo();
10722 perl_exception=newSVpv("",0);
10725 if (sv_isobject(ST(0)) == 0)
10727 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10729 goto PerlException;
10731 reference=SvRV(ST(0));
10732 hv=SvSTASH(reference);
10734 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10736 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10737 if (image == (Image *) NULL)
10739 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10741 goto PerlException;
10746 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10747 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10748 (void) QueryMagickColor("none",&transparent_color,exception);
10749 for (i=2; i < items; i+=2)
10751 attribute=(char *) SvPV(ST(i-1),na);
10752 switch (*attribute)
10757 if (LocaleCompare(attribute,"background") == 0)
10759 (void) QueryColorDatabase(SvPV(ST(i),na),
10760 &montage_info->background_color,exception);
10761 for (next=image; next; next=next->next)
10762 next->background_color=montage_info->background_color;
10765 if (LocaleCompare(attribute,"border") == 0)
10767 montage_info->border_width=SvIV(ST(i));
10770 if (LocaleCompare(attribute,"bordercolor") == 0)
10772 (void) QueryColorDatabase(SvPV(ST(i),na),
10773 &montage_info->border_color,exception);
10774 for (next=image; next; next=next->next)
10775 next->border_color=montage_info->border_color;
10778 if (LocaleCompare(attribute,"borderwidth") == 0)
10780 montage_info->border_width=SvIV(ST(i));
10783 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10790 if (LocaleCompare(attribute,"compose") == 0)
10792 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10793 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10796 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10800 for (next=image; next; next=next->next)
10801 next->compose=(CompositeOperator) sp;
10804 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10811 if (LocaleCompare(attribute,"fill") == 0)
10813 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10817 if (LocaleCompare(attribute,"font") == 0)
10819 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10822 if (LocaleCompare(attribute,"frame") == 0)
10828 if (IsGeometry(p) == MagickFalse)
10830 ThrowPerlException(exception,OptionError,"MissingGeometry",
10834 (void) CloneString(&montage_info->frame,p);
10836 montage_info->frame=(char *) NULL;
10839 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10846 if (LocaleCompare(attribute,"geometry") == 0)
10852 if (IsGeometry(p) == MagickFalse)
10854 ThrowPerlException(exception,OptionError,"MissingGeometry",
10858 (void) CloneString(&montage_info->geometry,p);
10860 montage_info->geometry=(char *) NULL;
10863 if (LocaleCompare(attribute,"gravity") == 0)
10868 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10869 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10872 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10876 montage_info->gravity=(GravityType) in;
10877 for (next=image; next; next=next->next)
10878 next->gravity=(GravityType) in;
10881 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10888 if (LocaleCompare(attribute,"label") == 0)
10890 for (next=image; next; next=next->next)
10891 (void) SetImageProperty(next,"label",InterpretImageProperties(
10892 info ? info->image_info : (ImageInfo *) NULL,next,
10896 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10903 if (LocaleCompare(attribute,"mattecolor") == 0)
10905 (void) QueryColorDatabase(SvPV(ST(i),na),
10906 &montage_info->matte_color,exception);
10907 for (next=image; next; next=next->next)
10908 next->matte_color=montage_info->matte_color;
10911 if (LocaleCompare(attribute,"mode") == 0)
10916 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10917 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10922 ThrowPerlException(exception,OptionError,
10923 "UnrecognizedModeType",SvPV(ST(i),na));
10928 (void) CloneString(&montage_info->frame,"15x15+3+3");
10929 montage_info->shadow=MagickTrue;
10934 montage_info->frame=(char *) NULL;
10935 montage_info->shadow=MagickFalse;
10936 montage_info->border_width=0;
10939 case ConcatenateMode:
10941 montage_info->frame=(char *) NULL;
10942 montage_info->shadow=MagickFalse;
10943 (void) CloneString(&montage_info->geometry,"+0+0");
10944 montage_info->border_width=0;
10949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10956 if (LocaleCompare(attribute,"pointsize") == 0)
10958 montage_info->pointsize=SvIV(ST(i));
10961 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10968 if (LocaleCompare(attribute,"shadow") == 0)
10970 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10971 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
10974 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10978 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
10981 if (LocaleCompare(attribute,"stroke") == 0)
10983 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
10987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10994 if (LocaleCompare(attribute,"texture") == 0)
10996 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
10999 if (LocaleCompare(attribute,"tile") == 0)
11001 char *p=SvPV(ST(i),na);
11002 if (IsGeometry(p) == MagickFalse)
11004 ThrowPerlException(exception,OptionError,"MissingGeometry",
11008 (void) CloneString(&montage_info->tile,p);
11010 montage_info->tile=(char *) NULL;
11013 if (LocaleCompare(attribute,"title") == 0)
11015 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11018 if (LocaleCompare(attribute,"transparent") == 0)
11023 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11024 for (next=image; next; next=next->next)
11025 (void) TransparentPaintImage(next,&transparent_color,
11026 TransparentAlpha,MagickFalse);
11029 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11035 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11041 image=MontageImageList(info->image_info,montage_info,image,exception);
11042 montage_info=DestroyMontageInfo(montage_info);
11043 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11044 goto PerlException;
11045 if (transparent_color.alpha != TransparentAlpha)
11046 for (next=image; next; next=next->next)
11047 (void) TransparentPaintImage(next,&transparent_color,
11048 TransparentAlpha,MagickFalse);
11049 for ( ; image; image=image->next)
11051 AddImageToRegistry(sv,image);
11053 av_push(av,sv_bless(rv,hv));
11056 exception=DestroyExceptionInfo(exception);
11057 ST(0)=av_reference;
11058 SvREFCNT_dec(perl_exception);
11062 InheritPerlException(exception,perl_exception);
11063 exception=DestroyExceptionInfo(exception);
11064 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11065 SvPOK_on(perl_exception);
11066 ST(0)=sv_2mortal(perl_exception);
11071 ###############################################################################
11079 ###############################################################################
11084 Image::Magick ref=NO_INIT
11122 PERL_UNUSED_VAR(ref);
11123 PERL_UNUSED_VAR(ix);
11124 exception=AcquireExceptionInfo();
11125 perl_exception=newSVpv("",0);
11129 if (sv_isobject(ST(0)) == 0)
11131 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11133 goto PerlException;
11135 reference=SvRV(ST(0));
11136 hv=SvSTASH(reference);
11138 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11140 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11141 if (image == (Image *) NULL)
11143 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11145 goto PerlException;
11147 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11152 for (i=2; i < items; i+=2)
11154 attribute=(char *) SvPV(ST(i-1),na);
11155 switch (*attribute)
11160 if (LocaleCompare(attribute,"frames") == 0)
11162 number_frames=SvIV(ST(i));
11165 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11171 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11177 image=MorphImages(image,number_frames,exception);
11178 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11179 goto PerlException;
11180 for ( ; image; image=image->next)
11182 AddImageToRegistry(sv,image);
11184 av_push(av,sv_bless(rv,hv));
11187 exception=DestroyExceptionInfo(exception);
11188 ST(0)=av_reference;
11189 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11193 InheritPerlException(exception,perl_exception);
11194 exception=DestroyExceptionInfo(exception);
11195 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11196 SvPOK_on(perl_exception);
11197 ST(0)=sv_2mortal(perl_exception);
11202 ###############################################################################
11210 ###############################################################################
11215 Image::Magick ref=NO_INIT
11243 PERL_UNUSED_VAR(ref);
11244 PERL_UNUSED_VAR(ix);
11245 exception=AcquireExceptionInfo();
11246 perl_exception=newSVpv("",0);
11248 if (sv_isobject(ST(0)) == 0)
11250 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11252 goto PerlException;
11254 reference=SvRV(ST(0));
11255 hv=SvSTASH(reference);
11256 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11257 if (image == (Image *) NULL)
11259 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11261 goto PerlException;
11263 image=MergeImageLayers(image,MosaicLayer,exception);
11265 Create blessed Perl array for the returned image.
11268 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11270 AddImageToRegistry(sv,image);
11272 av_push(av,sv_bless(rv,hv));
11274 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11275 (void) CopyMagickString(image->filename,info->image_info->filename,
11277 SetImageInfo(info->image_info,0,&image->exception);
11278 exception=DestroyExceptionInfo(exception);
11279 SvREFCNT_dec(perl_exception);
11283 InheritPerlException(exception,perl_exception);
11284 exception=DestroyExceptionInfo(exception);
11285 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11286 SvPOK_on(perl_exception); /* return messages in string context */
11287 ST(0)=sv_2mortal(perl_exception);
11292 ###############################################################################
11300 ###############################################################################
11305 Image::Magick ref=NO_INIT
11355 PERL_UNUSED_VAR(ref);
11356 PERL_UNUSED_VAR(ix);
11357 exception=AcquireExceptionInfo();
11358 perl_exception=newSVpv("",0);
11359 package_info=(struct PackageInfo *) NULL;
11360 ac=(items < 2) ? 1 : items-1;
11361 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11363 length=(STRLEN *) NULL;
11364 if (list == (char **) NULL)
11366 ThrowPerlException(exception,ResourceLimitError,
11367 "MemoryAllocationFailed",PackageName);
11368 goto PerlException;
11371 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11372 if (length == (STRLEN *) NULL)
11374 ThrowPerlException(exception,ResourceLimitError,
11375 "MemoryAllocationFailed",PackageName);
11376 goto PerlException;
11378 if (sv_isobject(ST(0)) == 0)
11380 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11382 goto PerlException;
11384 reference=SvRV(ST(0));
11385 if (SvTYPE(reference) != SVt_PVAV)
11387 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11389 goto PerlException;
11391 av=(AV *) reference;
11392 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11394 package_info=ClonePackageInfo(info,exception);
11397 *list=(char *) (*package_info->image_info->filename ?
11398 package_info->image_info->filename : "XC:black");
11400 for (n=0, i=0; i < ac; i++)
11402 list[n]=(char *) SvPV(ST(i+1),length[n]);
11403 if ((items >= 3) && strEQcase(list[n],"blob"))
11409 blob=(void *) (SvPV(ST(i+1),length[n]));
11410 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11412 if ((items >= 3) && strEQcase(list[n],"filename"))
11414 if ((items >= 3) && strEQcase(list[n],"file"))
11423 io_info=IoIFP(sv_2io(ST(i+1)));
11424 if (io_info == (PerlIO *) NULL)
11426 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11430 file=PerlIO_findFILE(io_info);
11431 if (file == (FILE *) NULL)
11433 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11437 SetImageInfoFile(package_info->image_info,file);
11439 if ((items >= 3) && strEQcase(list[n],"magick"))
11443 list[n]=(char *) NULL;
11445 status=ExpandFilenames(&n,&list);
11446 if (status == MagickFalse)
11448 ThrowPerlException(exception,ResourceLimitError,
11449 "MemoryAllocationFailed",PackageName);
11450 goto PerlException;
11453 for (i=0; i < n; i++)
11455 (void) CopyMagickString(package_info->image_info->filename,list[i],
11457 image=PingImage(package_info->image_info,exception);
11458 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11460 if ((package_info->image_info->file != (FILE *) NULL) ||
11461 (package_info->image_info->blob != (void *) NULL))
11462 DisassociateImageStream(image);
11463 count+=GetImageListLength(image);
11464 EXTEND(sp,4*count);
11465 for (next=image; next; next=next->next)
11467 PUSHs(sv_2mortal(newSViv(next->columns)));
11468 PUSHs(sv_2mortal(newSViv(next->rows)));
11469 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11470 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11472 image=DestroyImageList(image);
11477 for (i=0; i < n; i++)
11478 if (list[i] != (char *) NULL)
11479 for (p=keep; list[i] != *p++; )
11482 list[i]=(char *) RelinquishMagickMemory(list[i]);
11487 if (package_info != (struct PackageInfo *) NULL)
11488 DestroyPackageInfo(package_info);
11489 if (list && (list != keep))
11490 list=(char **) RelinquishMagickMemory(list);
11492 keep=(char **) RelinquishMagickMemory(keep);
11494 length=(STRLEN *) RelinquishMagickMemory(length);
11495 InheritPerlException(exception,perl_exception);
11496 exception=DestroyExceptionInfo(exception);
11497 SvREFCNT_dec(perl_exception); /* throw away all errors */
11501 ###############################################################################
11509 ###############################################################################
11514 Image::Magick ref=NO_INIT
11547 PERL_UNUSED_VAR(ref);
11548 PERL_UNUSED_VAR(ix);
11549 exception=AcquireExceptionInfo();
11550 perl_exception=newSVpv("",0);
11553 if (sv_isobject(ST(0)) == 0)
11555 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11557 goto PerlException;
11559 reference=SvRV(ST(0));
11560 hv=SvSTASH(reference);
11562 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11564 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11565 if (image == (Image *) NULL)
11567 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11569 goto PerlException;
11571 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11572 preview_type=GammaPreview;
11574 preview_type=(PreviewType)
11575 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11576 for ( ; image; image=image->next)
11578 preview_image=PreviewImage(image,preview_type,exception);
11579 if (preview_image == (Image *) NULL)
11580 goto PerlException;
11581 AddImageToRegistry(sv,preview_image);
11583 av_push(av,sv_bless(rv,hv));
11586 exception=DestroyExceptionInfo(exception);
11587 ST(0)=av_reference;
11588 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11592 InheritPerlException(exception,perl_exception);
11593 exception=DestroyExceptionInfo(exception);
11594 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11595 SvPOK_on(perl_exception);
11596 ST(0)=sv_2mortal(perl_exception);
11601 ###############################################################################
11605 # Q u e r y C o l o r #
11609 ###############################################################################
11613 QueryColor(ref,...)
11614 Image::Magick ref=NO_INIT
11634 PERL_UNUSED_VAR(ref);
11635 PERL_UNUSED_VAR(ix);
11636 exception=AcquireExceptionInfo();
11637 perl_exception=newSVpv("",0);
11646 colorlist=GetColorInfoList("*",&colors,exception);
11648 for (i=0; i < (ssize_t) colors; i++)
11650 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11652 colorlist=(const ColorInfo **)
11653 RelinquishMagickMemory((ColorInfo **) colorlist);
11654 goto PerlException;
11656 EXTEND(sp,5*items);
11657 for (i=1; i < items; i++)
11659 name=(char *) SvPV(ST(i),na);
11660 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11665 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11666 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11667 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11668 if (color.colorspace == CMYKColorspace)
11669 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11670 if (color.matte != MagickFalse)
11671 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11675 InheritPerlException(exception,perl_exception);
11676 exception=DestroyExceptionInfo(exception);
11677 SvREFCNT_dec(perl_exception);
11681 ###############################################################################
11685 # Q u e r y C o l o r N a m e #
11689 ###############################################################################
11693 QueryColorname(ref,...)
11694 Image::Magick ref=NO_INIT
11703 message[MaxTextExtent];
11722 *reference; /* reference is the SV* of ref=SvIV(reference) */
11724 PERL_UNUSED_VAR(ref);
11725 PERL_UNUSED_VAR(ix);
11726 exception=AcquireExceptionInfo();
11727 perl_exception=newSVpv("",0);
11728 reference=SvRV(ST(0));
11729 av=(AV *) reference;
11730 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11732 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11733 if (image == (Image *) NULL)
11735 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11737 goto PerlException;
11740 for (i=1; i < items; i++)
11742 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11743 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11745 PUSHs(sv_2mortal(newSVpv(message,0)));
11749 InheritPerlException(exception,perl_exception);
11750 exception=DestroyExceptionInfo(exception);
11751 SvREFCNT_dec(perl_exception);
11755 ###############################################################################
11759 # Q u e r y F o n t #
11763 ###############################################################################
11768 Image::Magick ref=NO_INIT
11775 message[MaxTextExtent];
11786 volatile const TypeInfo
11789 PERL_UNUSED_VAR(ref);
11790 PERL_UNUSED_VAR(ix);
11791 exception=AcquireExceptionInfo();
11792 perl_exception=newSVpv("",0);
11801 typelist=GetTypeInfoList("*",&types,exception);
11803 for (i=0; i < (ssize_t) types; i++)
11805 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11807 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11809 goto PerlException;
11811 EXTEND(sp,10*items);
11812 for (i=1; i < items; i++)
11814 name=(char *) SvPV(ST(i),na);
11815 type_info=GetTypeInfo(name,exception);
11816 if (type_info == (TypeInfo *) NULL)
11821 if (type_info->name == (char *) NULL)
11824 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11825 if (type_info->description == (char *) NULL)
11828 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11829 if (type_info->family == (char *) NULL)
11832 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11833 if (type_info->style == UndefinedStyle)
11836 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11837 type_info->style),0)));
11838 if (type_info->stretch == UndefinedStretch)
11841 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11842 type_info->stretch),0)));
11843 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11844 type_info->weight);
11845 PUSHs(sv_2mortal(newSVpv(message,0)));
11846 if (type_info->encoding == (char *) NULL)
11849 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11850 if (type_info->foundry == (char *) NULL)
11853 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11854 if (type_info->format == (char *) NULL)
11857 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11858 if (type_info->metrics == (char *) NULL)
11861 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11862 if (type_info->glyphs == (char *) NULL)
11865 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11869 InheritPerlException(exception,perl_exception);
11870 exception=DestroyExceptionInfo(exception);
11871 SvREFCNT_dec(perl_exception);
11875 ###############################################################################
11879 # Q u e r y F o n t M e t r i c s #
11883 ###############################################################################
11887 QueryFontMetrics(ref,...)
11888 Image::Magick ref=NO_INIT
11890 queryfontmetrics = 1
11937 *reference; /* reference is the SV* of ref=SvIV(reference) */
11942 PERL_UNUSED_VAR(ref);
11943 PERL_UNUSED_VAR(ix);
11944 exception=AcquireExceptionInfo();
11945 package_info=(struct PackageInfo *) NULL;
11946 perl_exception=newSVpv("",0);
11947 reference=SvRV(ST(0));
11948 av=(AV *) reference;
11949 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11951 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11952 if (image == (Image *) NULL)
11954 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11956 goto PerlException;
11958 package_info=ClonePackageInfo(info,exception);
11959 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
11960 CloneString(&draw_info->text,"");
11961 current=draw_info->affine;
11962 GetAffineMatrix(&affine);
11965 EXTEND(sp,7*items);
11966 for (i=2; i < items; i+=2)
11968 attribute=(char *) SvPV(ST(i-1),na);
11969 switch (*attribute)
11974 if (LocaleCompare(attribute,"antialias") == 0)
11976 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
11980 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11984 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
11987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11994 if (LocaleCompare(attribute,"density") == 0)
11996 CloneString(&draw_info->density,SvPV(ST(i),na));
11999 if (LocaleCompare(attribute,"direction") == 0)
12001 draw_info->direction=(DirectionType) ParseCommandOption(
12002 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12012 if (LocaleCompare(attribute,"encoding") == 0)
12014 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12017 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12024 if (LocaleCompare(attribute,"family") == 0)
12026 CloneString(&draw_info->family,SvPV(ST(i),na));
12029 if (LocaleCompare(attribute,"fill") == 0)
12032 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12033 &image->exception);
12036 if (LocaleCompare(attribute,"font") == 0)
12038 CloneString(&draw_info->font,SvPV(ST(i),na));
12041 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12048 if (LocaleCompare(attribute,"geometry") == 0)
12050 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12053 if (LocaleCompare(attribute,"gravity") == 0)
12055 draw_info->gravity=(GravityType) ParseCommandOption(
12056 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12066 if (LocaleCompare(attribute,"interline-spacing") == 0)
12068 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12069 draw_info->interline_spacing=geometry_info.rho;
12072 if (LocaleCompare(attribute,"interword-spacing") == 0)
12074 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12075 draw_info->interword_spacing=geometry_info.rho;
12078 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12085 if (LocaleCompare(attribute,"kerning") == 0)
12087 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12088 draw_info->kerning=geometry_info.rho;
12091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12098 if (LocaleCompare(attribute,"pointsize") == 0)
12100 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12101 draw_info->pointsize=geometry_info.rho;
12104 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12111 if (LocaleCompare(attribute,"rotate") == 0)
12113 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12114 affine.rx=geometry_info.rho;
12115 affine.ry=geometry_info.sigma;
12116 if ((flags & SigmaValue) == 0)
12117 affine.ry=affine.rx;
12120 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12127 if (LocaleCompare(attribute,"scale") == 0)
12129 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12130 affine.sx=geometry_info.rho;
12131 affine.sy=geometry_info.sigma;
12132 if ((flags & SigmaValue) == 0)
12133 affine.sy=affine.sx;
12136 if (LocaleCompare(attribute,"skew") == 0)
12142 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12143 x_angle=geometry_info.rho;
12144 y_angle=geometry_info.sigma;
12145 if ((flags & SigmaValue) == 0)
12147 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12148 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12151 if (LocaleCompare(attribute,"stroke") == 0)
12154 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12155 &image->exception);
12158 if (LocaleCompare(attribute,"style") == 0)
12160 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12164 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12168 draw_info->style=(StyleType) type;
12171 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12178 if (LocaleCompare(attribute,"text") == 0)
12180 CloneString(&draw_info->text,SvPV(ST(i),na));
12183 if (LocaleCompare(attribute,"translate") == 0)
12185 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12186 affine.tx=geometry_info.rho;
12187 affine.ty=geometry_info.sigma;
12188 if ((flags & SigmaValue) == 0)
12189 affine.ty=affine.tx;
12192 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12199 if (LocaleCompare(attribute,"weight") == 0)
12201 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12202 draw_info->weight=(size_t) geometry_info.rho;
12205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12212 if (LocaleCompare(attribute,"x") == 0)
12214 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12215 x=geometry_info.rho;
12218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12225 if (LocaleCompare(attribute,"y") == 0)
12227 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12228 y=geometry_info.rho;
12231 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12237 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12243 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12244 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12245 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12246 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12247 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12248 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12249 if (draw_info->geometry == (char *) NULL)
12251 draw_info->geometry=AcquireString((char *) NULL);
12252 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12253 "%.15g,%.15g",x,y);
12255 status=GetTypeMetrics(image,draw_info,&metrics);
12256 (void) CatchImageException(image);
12257 if (status == MagickFalse)
12261 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12262 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12263 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12264 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12265 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12266 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12267 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12268 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12269 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12270 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12271 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12272 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12273 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12275 draw_info=DestroyDrawInfo(draw_info);
12278 if (package_info != (struct PackageInfo *) NULL)
12279 DestroyPackageInfo(package_info);
12280 InheritPerlException(exception,perl_exception);
12281 exception=DestroyExceptionInfo(exception);
12282 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12286 ###############################################################################
12290 # 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 #
12294 ###############################################################################
12298 QueryMultilineFontMetrics(ref,...)
12299 Image::Magick ref=NO_INIT
12301 querymultilinefontmetrics = 1
12348 *reference; /* reference is the SV* of ref=SvIV(reference) */
12353 PERL_UNUSED_VAR(ref);
12354 PERL_UNUSED_VAR(ix);
12355 exception=AcquireExceptionInfo();
12356 package_info=(struct PackageInfo *) NULL;
12357 perl_exception=newSVpv("",0);
12358 reference=SvRV(ST(0));
12359 av=(AV *) reference;
12360 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12362 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12363 if (image == (Image *) NULL)
12365 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12367 goto PerlException;
12369 package_info=ClonePackageInfo(info,exception);
12370 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12371 CloneString(&draw_info->text,"");
12372 current=draw_info->affine;
12373 GetAffineMatrix(&affine);
12376 EXTEND(sp,7*items);
12377 for (i=2; i < items; i+=2)
12379 attribute=(char *) SvPV(ST(i-1),na);
12380 switch (*attribute)
12385 if (LocaleCompare(attribute,"antialias") == 0)
12387 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12391 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12395 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12398 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12405 if (LocaleCompare(attribute,"density") == 0)
12407 CloneString(&draw_info->density,SvPV(ST(i),na));
12410 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12417 if (LocaleCompare(attribute,"encoding") == 0)
12419 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12422 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12429 if (LocaleCompare(attribute,"family") == 0)
12431 CloneString(&draw_info->family,SvPV(ST(i),na));
12434 if (LocaleCompare(attribute,"fill") == 0)
12437 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12438 &image->exception);
12441 if (LocaleCompare(attribute,"font") == 0)
12443 CloneString(&draw_info->font,SvPV(ST(i),na));
12446 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12453 if (LocaleCompare(attribute,"geometry") == 0)
12455 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12458 if (LocaleCompare(attribute,"gravity") == 0)
12460 draw_info->gravity=(GravityType) ParseCommandOption(
12461 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12464 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12471 if (LocaleCompare(attribute,"pointsize") == 0)
12473 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12474 draw_info->pointsize=geometry_info.rho;
12477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12484 if (LocaleCompare(attribute,"rotate") == 0)
12486 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12487 affine.rx=geometry_info.rho;
12488 affine.ry=geometry_info.sigma;
12489 if ((flags & SigmaValue) == 0)
12490 affine.ry=affine.rx;
12493 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12500 if (LocaleCompare(attribute,"scale") == 0)
12502 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12503 affine.sx=geometry_info.rho;
12504 affine.sy=geometry_info.sigma;
12505 if ((flags & SigmaValue) == 0)
12506 affine.sy=affine.sx;
12509 if (LocaleCompare(attribute,"skew") == 0)
12515 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12516 x_angle=geometry_info.rho;
12517 y_angle=geometry_info.sigma;
12518 if ((flags & SigmaValue) == 0)
12520 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12521 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12524 if (LocaleCompare(attribute,"stroke") == 0)
12527 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12528 &image->exception);
12531 if (LocaleCompare(attribute,"style") == 0)
12533 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12537 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12541 draw_info->style=(StyleType) type;
12544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12551 if (LocaleCompare(attribute,"text") == 0)
12553 CloneString(&draw_info->text,SvPV(ST(i),na));
12556 if (LocaleCompare(attribute,"translate") == 0)
12558 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12559 affine.tx=geometry_info.rho;
12560 affine.ty=geometry_info.sigma;
12561 if ((flags & SigmaValue) == 0)
12562 affine.ty=affine.tx;
12565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12572 if (LocaleCompare(attribute,"weight") == 0)
12574 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12575 draw_info->weight=(size_t) geometry_info.rho;
12578 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12585 if (LocaleCompare(attribute,"x") == 0)
12587 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12588 x=geometry_info.rho;
12591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12598 if (LocaleCompare(attribute,"y") == 0)
12600 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12601 y=geometry_info.rho;
12604 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12610 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12616 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12617 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12618 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12619 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12620 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12621 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12622 if (draw_info->geometry == (char *) NULL)
12624 draw_info->geometry=AcquireString((char *) NULL);
12625 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12626 "%.15g,%.15g",x,y);
12628 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12629 (void) CatchImageException(image);
12630 if (status == MagickFalse)
12634 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12635 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12636 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12637 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12638 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12639 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12640 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12641 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12642 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12643 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12644 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12645 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12646 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12648 draw_info=DestroyDrawInfo(draw_info);
12651 if (package_info != (struct PackageInfo *) NULL)
12652 DestroyPackageInfo(package_info);
12653 InheritPerlException(exception,perl_exception);
12654 exception=DestroyExceptionInfo(exception);
12655 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12659 ###############################################################################
12663 # Q u e r y F o r m a t #
12667 ###############################################################################
12671 QueryFormat(ref,...)
12672 Image::Magick ref=NO_INIT
12689 volatile const MagickInfo
12692 PERL_UNUSED_VAR(ref);
12693 PERL_UNUSED_VAR(ix);
12694 exception=AcquireExceptionInfo();
12695 perl_exception=newSVpv("",0);
12699 format[MaxTextExtent];
12707 format_list=GetMagickInfoList("*",&types,exception);
12709 for (i=0; i < (ssize_t) types; i++)
12711 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12712 LocaleLower(format);
12713 PUSHs(sv_2mortal(newSVpv(format,0)));
12715 format_list=(const MagickInfo **)
12716 RelinquishMagickMemory((MagickInfo *) format_list);
12717 goto PerlException;
12719 EXTEND(sp,8*items);
12720 for (i=1; i < items; i++)
12722 name=(char *) SvPV(ST(i),na);
12723 magick_info=GetMagickInfo(name,exception);
12724 if (magick_info == (const MagickInfo *) NULL)
12729 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12730 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12731 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12732 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12733 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12734 if (magick_info->description == (char *) NULL)
12737 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12738 if (magick_info->module == (char *) NULL)
12741 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12745 InheritPerlException(exception,perl_exception);
12746 exception=DestroyExceptionInfo(exception);
12747 SvREFCNT_dec(perl_exception);
12751 ###############################################################################
12755 # Q u e r y O p t i o n #
12759 ###############################################################################
12763 QueryOption(ref,...)
12764 Image::Magick ref=NO_INIT
12785 PERL_UNUSED_VAR(ref);
12786 PERL_UNUSED_VAR(ix);
12787 exception=AcquireExceptionInfo();
12788 perl_exception=newSVpv("",0);
12789 EXTEND(sp,8*items);
12790 for (i=1; i < items; i++)
12792 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12794 options=GetCommandOptions((CommandOption) option);
12795 if (options == (char **) NULL)
12799 for (j=0; options[j] != (char *) NULL; j++)
12800 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12801 options=DestroyStringList(options);
12805 InheritPerlException(exception,perl_exception);
12806 exception=DestroyExceptionInfo(exception);
12807 SvREFCNT_dec(perl_exception);
12811 ###############################################################################
12819 ###############################################################################
12824 Image::Magick ref=NO_INIT
12871 *perl_exception, /* Perl variable for storing messages */
12876 PERL_UNUSED_VAR(ref);
12877 PERL_UNUSED_VAR(ix);
12878 exception=AcquireExceptionInfo();
12879 perl_exception=newSVpv("",0);
12881 package_info=(struct PackageInfo *) NULL;
12883 ac=(items < 2) ? 1 : items-1;
12884 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12886 length=(STRLEN *) NULL;
12887 if (list == (char **) NULL)
12889 ThrowPerlException(exception,ResourceLimitError,
12890 "MemoryAllocationFailed",PackageName);
12891 goto PerlException;
12893 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12894 if (length == (STRLEN *) NULL)
12896 ThrowPerlException(exception,ResourceLimitError,
12897 "MemoryAllocationFailed",PackageName);
12898 goto PerlException;
12900 if (sv_isobject(ST(0)) == 0)
12902 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12904 goto PerlException;
12906 reference=SvRV(ST(0));
12907 hv=SvSTASH(reference);
12908 if (SvTYPE(reference) != SVt_PVAV)
12910 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12912 goto PerlException;
12914 av=(AV *) reference;
12915 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12917 package_info=ClonePackageInfo(info,exception);
12920 *list=(char *) (*package_info->image_info->filename ?
12921 package_info->image_info->filename : "XC:black");
12923 for (n=0, i=0; i < ac; i++)
12925 list[n]=(char *) SvPV(ST(i+1),length[n]);
12926 if ((items >= 3) && strEQcase(list[n],"blob"))
12932 blob=(void *) (SvPV(ST(i+1),length[n]));
12933 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12935 if ((items >= 3) && strEQcase(list[n],"filename"))
12937 if ((items >= 3) && strEQcase(list[n],"file"))
12946 io_info=IoIFP(sv_2io(ST(i+1)));
12947 if (io_info == (PerlIO *) NULL)
12949 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12953 file=PerlIO_findFILE(io_info);
12954 if (file == (FILE *) NULL)
12956 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12960 SetImageInfoFile(package_info->image_info,file);
12962 if ((items >= 3) && strEQcase(list[n],"magick"))
12966 list[n]=(char *) NULL;
12968 status=ExpandFilenames(&n,&list);
12969 if (status == MagickFalse)
12971 ThrowPerlException(exception,ResourceLimitError,
12972 "MemoryAllocationFailed",PackageName);
12973 goto PerlException;
12976 for (i=0; i < n; i++)
12978 if ((package_info->image_info->file != (FILE *) NULL) ||
12979 (package_info->image_info->blob != (void *) NULL))
12981 image=ReadImages(package_info->image_info,exception);
12982 if (image != (Image *) NULL)
12983 DisassociateImageStream(image);
12987 (void) CopyMagickString(package_info->image_info->filename,list[i],
12989 image=ReadImages(package_info->image_info,exception);
12991 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
12993 for ( ; image; image=image->next)
12995 AddImageToRegistry(sv,image);
12997 av_push(av,sv_bless(rv,hv));
13005 for (i=0; i < n; i++)
13006 if (list[i] != (char *) NULL)
13007 for (p=keep; list[i] != *p++; )
13008 if (*p == (char *) NULL)
13010 list[i]=(char *) RelinquishMagickMemory(list[i]);
13015 if (package_info != (struct PackageInfo *) NULL)
13016 DestroyPackageInfo(package_info);
13017 if (list && (list != keep))
13018 list=(char **) RelinquishMagickMemory(list);
13020 keep=(char **) RelinquishMagickMemory(keep);
13022 length=(STRLEN *) RelinquishMagickMemory(length);
13023 InheritPerlException(exception,perl_exception);
13024 exception=DestroyExceptionInfo(exception);
13025 sv_setiv(perl_exception,(IV) number_images);
13026 SvPOK_on(perl_exception);
13027 ST(0)=sv_2mortal(perl_exception);
13032 ###############################################################################
13040 ###############################################################################
13045 Image::Magick ref=NO_INIT
13068 PERL_UNUSED_VAR(ref);
13069 PERL_UNUSED_VAR(ix);
13070 exception=AcquireExceptionInfo();
13071 perl_exception=newSVpv("",0);
13072 reference=SvRV(ST(0));
13073 av=(AV *) reference;
13074 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13076 for (i=1; i < items; i++)
13077 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13078 SvPV(ST(i),na),exception);
13079 InheritPerlException(exception,perl_exception);
13080 exception=DestroyExceptionInfo(exception);
13081 SvREFCNT_dec(perl_exception); /* throw away all errors */
13085 ###############################################################################
13093 ###############################################################################
13098 Image::Magick ref=NO_INIT
13121 *reference; /* reference is the SV* of ref=SvIV(reference) */
13123 PERL_UNUSED_VAR(ref);
13124 PERL_UNUSED_VAR(ix);
13125 exception=AcquireExceptionInfo();
13126 perl_exception=newSVpv("",0);
13127 if (sv_isobject(ST(0)) == 0)
13129 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13131 goto PerlException;
13133 reference=SvRV(ST(0));
13134 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13136 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13138 for (i=2; i < items; i+=2)
13139 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13142 InheritPerlException(exception,perl_exception);
13143 exception=DestroyExceptionInfo(exception);
13144 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13145 SvPOK_on(perl_exception);
13146 ST(0)=sv_2mortal(perl_exception);
13151 ###############################################################################
13155 # S e t P i x e l #
13159 ###############################################################################
13164 Image::Magick ref=NO_INIT
13205 *reference; /* reference is the SV* of ref=SvIV(reference) */
13207 PERL_UNUSED_VAR(ref);
13208 PERL_UNUSED_VAR(ix);
13209 exception=AcquireExceptionInfo();
13210 perl_exception=newSVpv("",0);
13211 reference=SvRV(ST(0));
13212 av=(AV *) reference;
13213 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13215 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13216 if (image == (Image *) NULL)
13218 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13220 goto PerlException;
13223 normalize=MagickTrue;
13226 region.width=image->columns;
13229 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13230 channel=DefaultChannels;
13231 for (i=2; i < items; i+=2)
13233 attribute=(char *) SvPV(ST(i-1),na);
13234 switch (*attribute)
13239 if (LocaleCompare(attribute,"channel") == 0)
13244 option=ParseChannelOption(SvPV(ST(i),na));
13247 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13251 channel=(ChannelType) option;
13254 if (LocaleCompare(attribute,"color") == 0)
13256 if (SvTYPE(ST(i)) != SVt_RV)
13259 message[MaxTextExtent];
13261 (void) FormatLocaleString(message,MaxTextExtent,
13262 "invalid %.60s value",attribute);
13263 ThrowPerlException(exception,OptionError,message,
13266 av=(AV *) SvRV(ST(i));
13269 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13276 if (LocaleCompare(attribute,"geometry") == 0)
13278 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13281 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13288 if (LocaleCompare(attribute,"normalize") == 0)
13290 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13294 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13298 normalize=option != 0 ? MagickTrue : MagickFalse;
13301 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13308 if (LocaleCompare(attribute,"x") == 0)
13310 region.x=SvIV(ST(i));
13313 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13320 if (LocaleCompare(attribute,"y") == 0)
13322 region.y=SvIV(ST(i));
13325 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13331 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13337 (void) SetImageStorageClass(image,DirectClass);
13338 PushPixelComponentMap(image,channel);
13339 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13340 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13341 (SvTYPE(av) != SVt_PVAV))
13353 if (normalize != MagickFalse)
13354 scale=QuantumRange;
13355 if (((GetPixelRedTraits(image) & ActivePixelTrait) != 0) &&
13358 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13359 av_fetch(av,i,0)))),q);
13362 if (((GetPixelGreenTraits(image) & ActivePixelTrait) != 0) &&
13365 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13366 av_fetch(av,i,0)))),q);
13369 if (((GetPixelBlueTraits(image) & ActivePixelTrait) != 0) &&
13372 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13373 av_fetch(av,i,0)))),q);
13376 if ((((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
13377 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13379 SetPixelBlack(image,ClampToQuantum(scale*
13380 SvNV(*(av_fetch(av,i,0)))),q);
13383 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) &&
13386 SetPixelAlpha(image,ClampToQuantum(scale*
13387 SvNV(*(av_fetch(av,i,0)))),q);
13390 (void) SyncAuthenticPixels(image,exception);
13392 PopPixelComponentMap(image);
13395 InheritPerlException(exception,perl_exception);
13396 exception=DestroyExceptionInfo(exception);
13397 SvREFCNT_dec(perl_exception);
13401 ###############################################################################
13409 ###############################################################################
13414 Image::Magick ref=NO_INIT
13453 PERL_UNUSED_VAR(ref);
13454 PERL_UNUSED_VAR(ix);
13455 exception=AcquireExceptionInfo();
13456 perl_exception=newSVpv("",0);
13460 if (sv_isobject(ST(0)) == 0)
13462 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13464 goto PerlException;
13466 reference=SvRV(ST(0));
13467 hv=SvSTASH(reference);
13469 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13471 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13472 if (image == (Image *) NULL)
13474 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13476 goto PerlException;
13478 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13484 for (i=2; i < items; i+=2)
13486 attribute=(char *) SvPV(ST(i-1),na);
13487 switch (*attribute)
13492 if (LocaleCompare(attribute,"offset") == 0)
13494 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13497 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13504 if (LocaleCompare(attribute,"stack") == 0)
13506 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13510 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13516 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13522 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13528 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13530 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13531 goto PerlException;
13532 for ( ; image; image=image->next)
13534 AddImageToRegistry(sv,image);
13536 av_push(av,sv_bless(rv,hv));
13539 exception=DestroyExceptionInfo(exception);
13540 ST(0)=av_reference;
13541 SvREFCNT_dec(perl_exception);
13545 InheritPerlException(exception,perl_exception);
13546 exception=DestroyExceptionInfo(exception);
13547 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13548 SvPOK_on(perl_exception);
13549 ST(0)=sv_2mortal(perl_exception);
13554 ###############################################################################
13558 # S t a t i s t i c s #
13562 ###############################################################################
13566 Statistics(ref,...)
13567 Image::Magick ref=NO_INIT
13569 StatisticsImage = 1
13571 statisticsimage = 3
13574 #define ChannelStatistics(channel) \
13576 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13577 (double) channel_statistics[channel].depth); \
13578 PUSHs(sv_2mortal(newSVpv(message,0))); \
13579 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13580 channel_statistics[channel].minima/scale); \
13581 PUSHs(sv_2mortal(newSVpv(message,0))); \
13582 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13583 channel_statistics[channel].maxima/scale); \
13584 PUSHs(sv_2mortal(newSVpv(message,0))); \
13585 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13586 channel_statistics[channel].mean/scale); \
13587 PUSHs(sv_2mortal(newSVpv(message,0))); \
13588 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13589 channel_statistics[channel].standard_deviation/scale); \
13590 PUSHs(sv_2mortal(newSVpv(message,0))); \
13591 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13592 channel_statistics[channel].kurtosis); \
13593 PUSHs(sv_2mortal(newSVpv(message,0))); \
13594 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13595 channel_statistics[channel].skewness); \
13596 PUSHs(sv_2mortal(newSVpv(message,0))); \
13603 message[MaxTextExtent];
13606 *channel_statistics;
13627 PERL_UNUSED_VAR(ref);
13628 PERL_UNUSED_VAR(ix);
13629 exception=AcquireExceptionInfo();
13630 perl_exception=newSVpv("",0);
13632 if (sv_isobject(ST(0)) == 0)
13634 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13636 goto PerlException;
13638 reference=SvRV(ST(0));
13641 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13642 if (image == (Image *) NULL)
13644 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13646 goto PerlException;
13648 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13650 for ( ; image; image=image->next)
13652 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13653 if (channel_statistics == (ChannelStatistics *) NULL)
13656 EXTEND(sp,35*count);
13657 scale=(double) QuantumRange;
13658 ChannelStatistics(RedChannel);
13659 ChannelStatistics(GreenChannel);
13660 ChannelStatistics(BlueChannel);
13661 if (image->colorspace == CMYKColorspace)
13662 ChannelStatistics(BlackChannel);
13663 if (image->matte != MagickFalse)
13664 ChannelStatistics(AlphaChannel);
13665 channel_statistics=(ChannelStatistics *)
13666 RelinquishMagickMemory(channel_statistics);
13670 InheritPerlException(exception,perl_exception);
13671 exception=DestroyExceptionInfo(exception);
13672 SvREFCNT_dec(perl_exception);
13676 ###############################################################################
13680 # S y n c A u t h e n t i c P i x e l s #
13684 ###############################################################################
13688 SyncAuthenticPixels(ref,...)
13689 Image::Magick ref = NO_INIT
13691 Syncauthenticpixels = 1
13692 SyncImagePixels = 2
13693 syncimagepixels = 3
13712 PERL_UNUSED_VAR(ref);
13713 PERL_UNUSED_VAR(ix);
13714 exception=AcquireExceptionInfo();
13715 perl_exception=newSVpv("",0);
13716 if (sv_isobject(ST(0)) == 0)
13718 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13720 goto PerlException;
13723 reference=SvRV(ST(0));
13724 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13725 if (image == (Image *) NULL)
13727 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13729 goto PerlException;
13732 status=SyncAuthenticPixels(image,exception);
13733 if (status != MagickFalse)
13735 InheritException(exception,&image->exception);
13738 InheritPerlException(exception,perl_exception);
13739 exception=DestroyExceptionInfo(exception);
13740 SvREFCNT_dec(perl_exception); /* throw away all errors */
13744 ###############################################################################
13748 # T r a n s f o r m #
13752 ###############################################################################
13757 Image::Magick ref=NO_INIT
13795 PERL_UNUSED_VAR(ref);
13796 PERL_UNUSED_VAR(ix);
13797 exception=AcquireExceptionInfo();
13798 perl_exception=newSVpv("",0);
13802 if (sv_isobject(ST(0)) == 0)
13804 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13806 goto PerlException;
13808 reference=SvRV(ST(0));
13809 hv=SvSTASH(reference);
13811 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13813 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13814 if (image == (Image *) NULL)
13816 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13818 goto PerlException;
13820 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13824 crop_geometry=(char *) NULL;
13825 geometry=(char *) NULL;
13826 for (i=2; i < items; i+=2)
13828 attribute=(char *) SvPV(ST(i-1),na);
13829 switch (*attribute)
13834 if (LocaleCompare(attribute,"crop") == 0)
13836 crop_geometry=SvPV(ST(i),na);
13839 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13846 if (LocaleCompare(attribute,"geometry") == 0)
13848 geometry=SvPV(ST(i),na);
13851 if (LocaleCompare(attribute,"gravity") == 0)
13859 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13860 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13863 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13867 for (next=image; next; next=next->next)
13868 next->gravity=(GravityType) in;
13871 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13877 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13883 for ( ; image; image=image->next)
13885 clone=CloneImage(image,0,0,MagickTrue,exception);
13886 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13887 goto PerlException;
13888 TransformImage(&clone,crop_geometry,geometry);
13889 for ( ; clone; clone=clone->next)
13891 AddImageToRegistry(sv,clone);
13893 av_push(av,sv_bless(rv,hv));
13897 exception=DestroyExceptionInfo(exception);
13898 ST(0)=av_reference;
13899 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13903 InheritPerlException(exception,perl_exception);
13904 exception=DestroyExceptionInfo(exception);
13905 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13906 SvPOK_on(perl_exception);
13907 ST(0)=sv_2mortal(perl_exception);
13912 ###############################################################################
13920 ###############################################################################
13925 Image::Magick ref=NO_INIT
13933 filename[MaxTextExtent];
13957 PERL_UNUSED_VAR(ref);
13958 PERL_UNUSED_VAR(ix);
13959 exception=AcquireExceptionInfo();
13960 perl_exception=newSVpv("",0);
13962 package_info=(struct PackageInfo *) NULL;
13963 if (sv_isobject(ST(0)) == 0)
13965 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13967 goto PerlException;
13969 reference=SvRV(ST(0));
13970 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13971 if (image == (Image *) NULL)
13973 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13975 goto PerlException;
13977 package_info=ClonePackageInfo(info,exception);
13979 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
13982 for (i=2; i < items; i+=2)
13983 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
13985 (void) CopyMagickString(filename,package_info->image_info->filename,
13988 for (next=image; next; next=next->next)
13990 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
13991 next->scene=scene++;
13993 SetImageInfo(package_info->image_info,(unsigned int)
13994 GetImageListLength(image),&image->exception);
13995 for (next=image; next; next=next->next)
13997 (void) WriteImage(package_info->image_info,next);
13998 if (next->exception.severity >= ErrorException)
13999 InheritException(exception,&next->exception);
14000 GetImageException(next,exception);
14002 if (package_info->image_info->adjoin)
14007 if (package_info != (struct PackageInfo *) NULL)
14008 DestroyPackageInfo(package_info);
14009 InheritPerlException(exception,perl_exception);
14010 exception=DestroyExceptionInfo(exception);
14011 sv_setiv(perl_exception,(IV) number_images);
14012 SvPOK_on(perl_exception);
14013 ST(0)=sv_2mortal(perl_exception);