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 PushPixelComponentMap(image,channel);
7562 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7564 PopPixelComponentMap(image);
7569 if (attribute_flag[0] != 0)
7570 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7571 &geometry,exception);
7572 if (attribute_flag[1] != 0)
7573 geometry.width=argument_list[1].integer_reference;
7574 if (attribute_flag[2] != 0)
7575 geometry.height=argument_list[2].integer_reference;
7576 if (attribute_flag[3] != 0)
7577 geometry.x=argument_list[3].integer_reference;
7578 if (attribute_flag[4] != 0)
7579 geometry.y=argument_list[4].integer_reference;
7580 image=ChopImage(image,&geometry,exception);
7585 if (attribute_flag[6] != 0)
7586 image->gravity=(GravityType) argument_list[6].integer_reference;
7587 if (attribute_flag[0] != 0)
7588 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7589 &geometry,exception);
7590 if (attribute_flag[1] != 0)
7591 geometry.width=argument_list[1].integer_reference;
7592 if (attribute_flag[2] != 0)
7593 geometry.height=argument_list[2].integer_reference;
7594 if (attribute_flag[3] != 0)
7595 geometry.x=argument_list[3].integer_reference;
7596 if (attribute_flag[4] != 0)
7597 geometry.y=argument_list[4].integer_reference;
7598 if (attribute_flag[5] != 0)
7600 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7601 image=CropImage(image,&geometry,exception);
7604 case 9: /* Despeckle */
7606 image=DespeckleImage(image,exception);
7611 if (attribute_flag[0] != 0)
7612 geometry_info.rho=argument_list[0].real_reference;
7613 image=EdgeImage(image,geometry_info.rho,exception);
7616 case 11: /* Emboss */
7618 if (attribute_flag[0] != 0)
7620 flags=ParseGeometry(argument_list[0].string_reference,
7622 if ((flags & SigmaValue) == 0)
7623 geometry_info.sigma=1.0;
7625 if (attribute_flag[1] != 0)
7626 geometry_info.rho=argument_list[1].real_reference;
7627 if (attribute_flag[2] != 0)
7628 geometry_info.sigma=argument_list[2].real_reference;
7629 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7633 case 12: /* Enhance */
7635 image=EnhanceImage(image,exception);
7640 image=FlipImage(image,exception);
7645 image=FlopImage(image,exception);
7648 case 15: /* Frame */
7653 if (attribute_flag[0] != 0)
7655 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7656 &geometry,exception);
7657 if ((flags & HeightValue) == 0)
7658 geometry.height=geometry.width;
7659 frame_info.width=geometry.width;
7660 frame_info.height=geometry.height;
7661 frame_info.outer_bevel=geometry.x;
7662 frame_info.inner_bevel=geometry.y;
7664 if (attribute_flag[1] != 0)
7665 frame_info.width=argument_list[1].integer_reference;
7666 if (attribute_flag[2] != 0)
7667 frame_info.height=argument_list[2].integer_reference;
7668 if (attribute_flag[3] != 0)
7669 frame_info.inner_bevel=argument_list[3].integer_reference;
7670 if (attribute_flag[4] != 0)
7671 frame_info.outer_bevel=argument_list[4].integer_reference;
7672 if (attribute_flag[5] != 0)
7673 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7675 if (attribute_flag[6] != 0)
7676 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7678 frame_info.x=(ssize_t) frame_info.width;
7679 frame_info.y=(ssize_t) frame_info.height;
7680 frame_info.width=image->columns+2*frame_info.x;
7681 frame_info.height=image->rows+2*frame_info.y;
7682 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7683 image->matte_color=fill_color;
7684 if (attribute_flag[7] != 0)
7685 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7686 image=FrameImage(image,&frame_info,exception);
7689 case 16: /* Implode */
7691 if (attribute_flag[0] == 0)
7692 argument_list[0].real_reference=0.5;
7693 if (attribute_flag[1] != 0)
7694 image->interpolate=(InterpolatePixelMethod)
7695 argument_list[1].integer_reference;
7696 image=ImplodeImage(image,argument_list[0].real_reference,
7700 case 17: /* Magnify */
7702 image=MagnifyImage(image,exception);
7705 case 18: /* MedianFilter */
7707 if (attribute_flag[0] != 0)
7709 flags=ParseGeometry(argument_list[0].string_reference,
7711 if ((flags & SigmaValue) == 0)
7712 geometry_info.sigma=1.0;
7714 if (attribute_flag[1] != 0)
7715 geometry_info.rho=argument_list[1].real_reference;
7716 if (attribute_flag[2] != 0)
7717 geometry_info.sigma=argument_list[2].real_reference;
7718 if (attribute_flag[3] != 0)
7719 channel=(ChannelType) argument_list[3].integer_reference;
7720 PushPixelComponentMap(image,channel);
7721 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7722 (size_t) geometry_info.sigma,exception);
7723 PopPixelComponentMap(image);
7726 case 19: /* Minify */
7728 image=MinifyImage(image,exception);
7731 case 20: /* OilPaint */
7733 if (attribute_flag[0] == 0)
7734 argument_list[0].real_reference=0.0;
7735 image=OilPaintImage(image,argument_list[0].real_reference,
7739 case 21: /* ReduceNoise */
7741 if (attribute_flag[0] != 0)
7743 flags=ParseGeometry(argument_list[0].string_reference,
7745 if ((flags & SigmaValue) == 0)
7746 geometry_info.sigma=1.0;
7748 if (attribute_flag[1] != 0)
7749 geometry_info.rho=argument_list[1].real_reference;
7750 if (attribute_flag[2] != 0)
7751 geometry_info.sigma=argument_list[2].real_reference;
7752 if (attribute_flag[3] != 0)
7753 channel=(ChannelType) argument_list[3].integer_reference;
7754 PushPixelComponentMap(image,channel);
7755 image=StatisticImage(image,NonpeakStatistic,(size_t)
7756 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7757 PopPixelComponentMap(image);
7762 if (attribute_flag[0] != 0)
7763 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7764 &geometry,exception);
7765 if (attribute_flag[1] != 0)
7766 geometry.x=argument_list[1].integer_reference;
7767 if (attribute_flag[2] != 0)
7768 geometry.y=argument_list[2].integer_reference;
7769 image=RollImage(image,geometry.x,geometry.y,exception);
7772 case 23: /* Rotate */
7774 if (attribute_flag[0] == 0)
7775 argument_list[0].real_reference=90.0;
7776 if (attribute_flag[1] != 0)
7777 QueryColorDatabase(argument_list[1].string_reference,
7778 &image->background_color,exception);
7779 if (attribute_flag[2] != 0)
7780 QueryColorDatabase(argument_list[2].string_reference,
7781 &image->background_color,exception);
7782 if (attribute_flag[3] != 0)
7783 QueryColorDatabase(argument_list[3].string_reference,
7784 &image->background_color,exception);
7785 image=RotateImage(image,argument_list[0].real_reference,exception);
7788 case 24: /* Sample */
7790 if (attribute_flag[0] != 0)
7791 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7792 &geometry,exception);
7793 if (attribute_flag[1] != 0)
7794 geometry.width=argument_list[1].integer_reference;
7795 if (attribute_flag[2] != 0)
7796 geometry.height=argument_list[2].integer_reference;
7797 image=SampleImage(image,geometry.width,geometry.height,exception);
7800 case 25: /* Scale */
7802 if (attribute_flag[0] != 0)
7803 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7804 &geometry,exception);
7805 if (attribute_flag[1] != 0)
7806 geometry.width=argument_list[1].integer_reference;
7807 if (attribute_flag[2] != 0)
7808 geometry.height=argument_list[2].integer_reference;
7809 image=ScaleImage(image,geometry.width,geometry.height,exception);
7812 case 26: /* Shade */
7814 if (attribute_flag[0] != 0)
7816 flags=ParseGeometry(argument_list[0].string_reference,
7818 if ((flags & SigmaValue) == 0)
7819 geometry_info.sigma=0.0;
7821 if (attribute_flag[1] != 0)
7822 geometry_info.rho=argument_list[1].real_reference;
7823 if (attribute_flag[2] != 0)
7824 geometry_info.sigma=argument_list[2].real_reference;
7825 image=ShadeImage(image,
7826 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7827 geometry_info.rho,geometry_info.sigma,exception);
7830 case 27: /* Sharpen */
7832 if (attribute_flag[0] != 0)
7834 flags=ParseGeometry(argument_list[0].string_reference,
7836 if ((flags & SigmaValue) == 0)
7837 geometry_info.sigma=1.0;
7839 if (attribute_flag[1] != 0)
7840 geometry_info.rho=argument_list[1].real_reference;
7841 if (attribute_flag[2] != 0)
7842 geometry_info.sigma=argument_list[2].real_reference;
7843 if (attribute_flag[3] != 0)
7844 channel=(ChannelType) argument_list[3].integer_reference;
7845 PushPixelComponentMap(image,channel);
7846 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7848 PopPixelComponentMap(image);
7851 case 28: /* Shear */
7853 if (attribute_flag[0] != 0)
7855 flags=ParseGeometry(argument_list[0].string_reference,
7857 if ((flags & SigmaValue) == 0)
7858 geometry_info.sigma=geometry_info.rho;
7860 if (attribute_flag[1] != 0)
7861 geometry_info.rho=argument_list[1].real_reference;
7862 if (attribute_flag[2] != 0)
7863 geometry_info.sigma=argument_list[2].real_reference;
7864 if (attribute_flag[3] != 0)
7865 QueryColorDatabase(argument_list[3].string_reference,
7866 &image->background_color,exception);
7867 if (attribute_flag[4] != 0)
7868 QueryColorDatabase(argument_list[4].string_reference,
7869 &image->background_color,exception);
7870 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7874 case 29: /* Spread */
7876 if (attribute_flag[0] == 0)
7877 argument_list[0].real_reference=1.0;
7878 image=SpreadImage(image,argument_list[0].real_reference,exception);
7881 case 30: /* Swirl */
7883 if (attribute_flag[0] == 0)
7884 argument_list[0].real_reference=50.0;
7885 if (attribute_flag[1] != 0)
7886 image->interpolate=(InterpolatePixelMethod)
7887 argument_list[1].integer_reference;
7888 image=SwirlImage(image,argument_list[0].real_reference,exception);
7891 case 31: /* Resize */
7894 if (attribute_flag[0] != 0)
7895 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7896 &geometry,exception);
7897 if (attribute_flag[1] != 0)
7898 geometry.width=argument_list[1].integer_reference;
7899 if (attribute_flag[2] != 0)
7900 geometry.height=argument_list[2].integer_reference;
7901 if (attribute_flag[3] == 0)
7902 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7903 if (attribute_flag[4] != 0)
7904 SetImageArtifact(image,"filter:support",
7905 argument_list[4].string_reference);
7906 if (attribute_flag[5] == 0)
7907 argument_list[5].real_reference=1.0;
7908 image=ResizeImage(image,geometry.width,geometry.height,
7909 (FilterTypes) argument_list[3].integer_reference,
7910 argument_list[5].real_reference,exception);
7913 case 33: /* Annotate */
7918 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7920 if (attribute_flag[0] != 0)
7925 text=InterpretImageProperties(info ? info->image_info :
7926 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7927 (void) CloneString(&draw_info->text,text);
7928 text=DestroyString(text);
7930 if (attribute_flag[1] != 0)
7931 (void) CloneString(&draw_info->font,
7932 argument_list[1].string_reference);
7933 if (attribute_flag[2] != 0)
7934 draw_info->pointsize=argument_list[2].real_reference;
7935 if (attribute_flag[3] != 0)
7936 (void) CloneString(&draw_info->density,
7937 argument_list[3].string_reference);
7938 if (attribute_flag[4] != 0)
7939 (void) QueryColorDatabase(argument_list[4].string_reference,
7940 &draw_info->undercolor,exception);
7941 if (attribute_flag[5] != 0)
7943 (void) QueryColorDatabase(argument_list[5].string_reference,
7944 &draw_info->stroke,exception);
7945 if (argument_list[5].image_reference != (Image *) NULL)
7946 draw_info->stroke_pattern=CloneImage(
7947 argument_list[5].image_reference,0,0,MagickTrue,exception);
7949 if (attribute_flag[6] != 0)
7951 (void) QueryColorDatabase(argument_list[6].string_reference,
7952 &draw_info->fill,exception);
7953 if (argument_list[6].image_reference != (Image *) NULL)
7954 draw_info->fill_pattern=CloneImage(
7955 argument_list[6].image_reference,0,0,MagickTrue,exception);
7957 if (attribute_flag[7] != 0)
7959 (void) CloneString(&draw_info->geometry,
7960 argument_list[7].string_reference);
7961 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7962 &geometry,exception);
7963 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7964 geometry_info.sigma=geometry_info.xi;
7966 if (attribute_flag[8] != 0)
7967 (void) QueryColorDatabase(argument_list[8].string_reference,
7968 &draw_info->fill,exception);
7969 if (attribute_flag[11] != 0)
7970 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7971 if (attribute_flag[25] != 0)
7976 av=(AV *) argument_list[25].array_reference;
7977 if ((av_len(av) != 3) && (av_len(av) != 5))
7979 ThrowPerlException(exception,OptionError,
7980 "affine matrix must have 4 or 6 elements",PackageName);
7983 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7984 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7985 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7986 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7987 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7988 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7990 ThrowPerlException(exception,OptionError,
7991 "affine matrix is singular",PackageName);
7994 if (av_len(av) == 5)
7996 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7997 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8000 for (j=12; j < 17; j++)
8002 if (attribute_flag[j] == 0)
8004 value=argument_list[j].string_reference;
8005 angle=argument_list[j].real_reference;
8006 current=draw_info->affine;
8007 GetAffineMatrix(&affine);
8015 flags=ParseGeometry(value,&geometry_info);
8016 affine.tx=geometry_info.xi;
8017 affine.ty=geometry_info.psi;
8018 if ((flags & PsiValue) == 0)
8019 affine.ty=affine.tx;
8027 flags=ParseGeometry(value,&geometry_info);
8028 affine.sx=geometry_info.rho;
8029 affine.sy=geometry_info.sigma;
8030 if ((flags & SigmaValue) == 0)
8031 affine.sy=affine.sx;
8041 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8042 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8043 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8044 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8052 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8060 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8064 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8065 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8066 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8067 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8068 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8070 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8073 if (attribute_flag[9] == 0)
8074 argument_list[9].real_reference=0.0;
8075 if (attribute_flag[10] == 0)
8076 argument_list[10].real_reference=0.0;
8077 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8080 geometry[MaxTextExtent];
8082 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8083 (double) argument_list[9].real_reference+draw_info->affine.tx,
8084 (double) argument_list[10].real_reference+draw_info->affine.ty);
8085 (void) CloneString(&draw_info->geometry,geometry);
8087 if (attribute_flag[17] != 0)
8088 draw_info->stroke_width=argument_list[17].real_reference;
8089 if (attribute_flag[18] != 0)
8091 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8092 MagickTrue : MagickFalse;
8093 draw_info->stroke_antialias=draw_info->text_antialias;
8095 if (attribute_flag[19] != 0)
8096 (void) CloneString(&draw_info->family,
8097 argument_list[19].string_reference);
8098 if (attribute_flag[20] != 0)
8099 draw_info->style=(StyleType) argument_list[20].integer_reference;
8100 if (attribute_flag[21] != 0)
8101 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8102 if (attribute_flag[22] != 0)
8103 draw_info->weight=argument_list[22].integer_reference;
8104 if (attribute_flag[23] != 0)
8105 draw_info->align=(AlignType) argument_list[23].integer_reference;
8106 if (attribute_flag[24] != 0)
8107 (void) CloneString(&draw_info->encoding,
8108 argument_list[24].string_reference);
8109 if (attribute_flag[25] != 0)
8110 draw_info->fill_pattern=CloneImage(
8111 argument_list[25].image_reference,0,0,MagickTrue,exception);
8112 if (attribute_flag[26] != 0)
8113 draw_info->fill_pattern=CloneImage(
8114 argument_list[26].image_reference,0,0,MagickTrue,exception);
8115 if (attribute_flag[27] != 0)
8116 draw_info->stroke_pattern=CloneImage(
8117 argument_list[27].image_reference,0,0,MagickTrue,exception);
8118 if (attribute_flag[29] != 0)
8119 draw_info->kerning=argument_list[29].real_reference;
8120 if (attribute_flag[30] != 0)
8121 draw_info->interline_spacing=argument_list[30].real_reference;
8122 if (attribute_flag[31] != 0)
8123 draw_info->interword_spacing=argument_list[31].real_reference;
8124 if (attribute_flag[32] != 0)
8125 draw_info->direction=(DirectionType)
8126 argument_list[32].integer_reference;
8127 (void) AnnotateImage(image,draw_info);
8128 draw_info=DestroyDrawInfo(draw_info);
8131 case 34: /* ColorFloodfill */
8142 draw_info=CloneDrawInfo(info ? info->image_info :
8143 (ImageInfo *) NULL,(DrawInfo *) NULL);
8144 if (attribute_flag[0] != 0)
8145 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8146 &geometry,exception);
8147 if (attribute_flag[1] != 0)
8148 geometry.x=argument_list[1].integer_reference;
8149 if (attribute_flag[2] != 0)
8150 geometry.y=argument_list[2].integer_reference;
8151 if (attribute_flag[3] != 0)
8152 (void) QueryColorDatabase(argument_list[3].string_reference,
8153 &draw_info->fill,exception);
8154 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8157 if (attribute_flag[4] != 0)
8159 QueryMagickColor(argument_list[4].string_reference,&target,
8163 if (attribute_flag[5] != 0)
8164 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8166 if (attribute_flag[6] != 0)
8167 invert=(MagickBooleanType) argument_list[6].integer_reference;
8168 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8170 draw_info=DestroyDrawInfo(draw_info);
8173 case 35: /* Composite */
8176 composite_geometry[MaxTextExtent];
8182 compose=OverCompositeOp;
8183 if (attribute_flag[0] != 0)
8184 composite_image=argument_list[0].image_reference;
8187 ThrowPerlException(exception,OptionError,
8188 "CompositeImageRequired",PackageName);
8192 Parameter Handling used for BOTH normal and tiled composition.
8194 if (attribute_flag[1] != 0) /* compose */
8195 compose=(CompositeOperator) argument_list[1].integer_reference;
8196 if (attribute_flag[6] != 0) /* opacity */
8198 if (compose != DissolveCompositeOp)
8199 (void) SetImageOpacity(composite_image,(Quantum)
8200 SiPrefixToDouble(argument_list[6].string_reference,
8223 Handle dissolve composite operator (patch by
8226 (void) CloneString(&image->geometry,
8227 argument_list[6].string_reference);
8228 opacity=(Quantum) SiPrefixToDouble(
8229 argument_list[6].string_reference,QuantumRange);
8230 if (composite_image->matte != MagickTrue)
8231 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8232 composite_view=AcquireCacheView(composite_image);
8233 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8235 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8236 composite_image->columns,1,exception);
8237 for (x=0; x < (ssize_t) composite_image->columns; x++)
8239 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8240 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8241 q+=GetPixelComponents(composite_image);
8243 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8244 if (sync == MagickFalse)
8247 composite_view=DestroyCacheView(composite_view);
8250 if (attribute_flag[9] != 0) /* "color=>" */
8251 QueryColorDatabase(argument_list[9].string_reference,
8252 &composite_image->background_color,exception);
8253 if (attribute_flag[12] != 0) /* "interpolate=>" */
8254 image->interpolate=(InterpolatePixelMethod)
8255 argument_list[12].integer_reference;
8256 if (attribute_flag[13] != 0) /* "args=>" */
8257 (void) SetImageArtifact(composite_image,"compose:args",
8258 argument_list[13].string_reference);
8259 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8260 (void) SetImageArtifact(composite_image,"compose:args",
8261 argument_list[14].string_reference);
8263 Tiling Composition (with orthogonal rotate).
8265 rotate_image=(Image *) NULL;
8266 if (attribute_flag[8] != 0) /* "rotate=>" */
8271 rotate_image=RotateImage(composite_image,
8272 argument_list[8].real_reference,exception);
8273 if (rotate_image == (Image *) NULL)
8276 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8283 Tile the composite image.
8285 if (attribute_flag[8] != 0) /* "tile=>" */
8286 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8289 (void) SetImageArtifact(composite_image,
8290 "compose:outside-overlay","false");
8291 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8292 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8294 if (attribute_flag[8] != 0) /* rotate */
8295 (void) CompositeImage(image,compose,rotate_image,x,y);
8297 (void) CompositeImage(image,compose,composite_image,x,y);
8299 if (attribute_flag[8] != 0) /* rotate */
8300 rotate_image=DestroyImage(rotate_image);
8304 Parameter Handling used used ONLY for normal composition.
8306 if (attribute_flag[5] != 0) /* gravity */
8307 image->gravity=(GravityType) argument_list[5].integer_reference;
8308 if (attribute_flag[2] != 0) /* geometry offset */
8310 SetGeometry(image,&geometry);
8311 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8313 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8316 if (attribute_flag[3] != 0) /* x offset */
8317 geometry.x=argument_list[3].integer_reference;
8318 if (attribute_flag[4] != 0) /* y offset */
8319 geometry.y=argument_list[4].integer_reference;
8320 if (attribute_flag[10] != 0) /* mask */
8322 if ((image->compose == DisplaceCompositeOp) ||
8323 (image->compose == DistortCompositeOp))
8326 Merge Y displacement into X displacement image.
8328 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8330 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8331 argument_list[10].image_reference,0,0);
8336 Set a blending mask for the composition.
8338 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8339 MagickTrue,&image->exception);
8340 (void) NegateImage(image->mask,MagickFalse);
8343 if (attribute_flag[11] != 0) /* channel */
8344 channel=(ChannelType) argument_list[11].integer_reference;
8346 Composite two images (normal composition).
8348 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8349 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8350 (double) composite_image->rows,(double) geometry.x,(double)
8352 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8354 PushPixelComponentMap(image,channel);
8355 if (attribute_flag[8] == 0) /* no rotate */
8356 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8360 Position adjust rotated image then composite.
8362 geometry.x-=(ssize_t) (rotate_image->columns-
8363 composite_image->columns)/2;
8364 geometry.y-=(ssize_t) (rotate_image->rows-
8365 composite_image->rows)/2;
8366 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8367 rotate_image=DestroyImage(rotate_image);
8369 if (attribute_flag[10] != 0) /* mask */
8371 if ((image->compose == DisplaceCompositeOp) ||
8372 (image->compose == DistortCompositeOp))
8373 composite_image=DestroyImage(composite_image);
8375 image->mask=DestroyImage(image->mask);
8377 PopPixelComponentMap(image);
8380 case 36: /* Contrast */
8382 if (attribute_flag[0] == 0)
8383 argument_list[0].integer_reference=0;
8384 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8385 MagickTrue : MagickFalse);
8388 case 37: /* CycleColormap */
8390 if (attribute_flag[0] == 0)
8391 argument_list[0].integer_reference=6;
8392 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8400 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8402 (void) CloneString(&draw_info->primitive,"point");
8403 if (attribute_flag[0] != 0)
8405 if (argument_list[0].integer_reference < 0)
8406 (void) CloneString(&draw_info->primitive,
8407 argument_list[0].string_reference);
8409 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8410 MagickPrimitiveOptions,argument_list[0].integer_reference));
8412 if (attribute_flag[1] != 0)
8414 if (LocaleCompare(draw_info->primitive,"path") == 0)
8416 (void) ConcatenateString(&draw_info->primitive," '");
8417 ConcatenateString(&draw_info->primitive,
8418 argument_list[1].string_reference);
8419 (void) ConcatenateString(&draw_info->primitive,"'");
8423 (void) ConcatenateString(&draw_info->primitive," ");
8424 ConcatenateString(&draw_info->primitive,
8425 argument_list[1].string_reference);
8428 if (attribute_flag[2] != 0)
8430 (void) ConcatenateString(&draw_info->primitive," ");
8431 (void) ConcatenateString(&draw_info->primitive,
8432 CommandOptionToMnemonic(MagickMethodOptions,
8433 argument_list[2].integer_reference));
8435 if (attribute_flag[3] != 0)
8437 (void) QueryColorDatabase(argument_list[3].string_reference,
8438 &draw_info->stroke,exception);
8439 if (argument_list[3].image_reference != (Image *) NULL)
8440 draw_info->stroke_pattern=CloneImage(
8441 argument_list[3].image_reference,0,0,MagickTrue,exception);
8443 if (attribute_flag[4] != 0)
8445 (void) QueryColorDatabase(argument_list[4].string_reference,
8446 &draw_info->fill,exception);
8447 if (argument_list[4].image_reference != (Image *) NULL)
8448 draw_info->fill_pattern=CloneImage(
8449 argument_list[4].image_reference,0,0,MagickTrue,exception);
8451 if (attribute_flag[5] != 0)
8452 draw_info->stroke_width=argument_list[5].real_reference;
8453 if (attribute_flag[6] != 0)
8454 (void) CloneString(&draw_info->font,
8455 argument_list[6].string_reference);
8456 if (attribute_flag[7] != 0)
8457 (void) QueryColorDatabase(argument_list[7].string_reference,
8458 &draw_info->border_color,exception);
8459 if (attribute_flag[8] != 0)
8460 draw_info->affine.tx=argument_list[8].real_reference;
8461 if (attribute_flag[9] != 0)
8462 draw_info->affine.ty=argument_list[9].real_reference;
8463 if (attribute_flag[20] != 0)
8468 av=(AV *) argument_list[20].array_reference;
8469 if ((av_len(av) != 3) && (av_len(av) != 5))
8471 ThrowPerlException(exception,OptionError,
8472 "affine matrix must have 4 or 6 elements",PackageName);
8475 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8476 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8477 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8478 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8479 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8480 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8482 ThrowPerlException(exception,OptionError,
8483 "affine matrix is singular",PackageName);
8486 if (av_len(av) == 5)
8488 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8489 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8492 for (j=10; j < 15; j++)
8494 if (attribute_flag[j] == 0)
8496 value=argument_list[j].string_reference;
8497 angle=argument_list[j].real_reference;
8498 current=draw_info->affine;
8499 GetAffineMatrix(&affine);
8507 flags=ParseGeometry(value,&geometry_info);
8508 affine.tx=geometry_info.xi;
8509 affine.ty=geometry_info.psi;
8510 if ((flags & PsiValue) == 0)
8511 affine.ty=affine.tx;
8519 flags=ParseGeometry(value,&geometry_info);
8520 affine.sx=geometry_info.rho;
8521 affine.sy=geometry_info.sigma;
8522 if ((flags & SigmaValue) == 0)
8523 affine.sy=affine.sx;
8533 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8534 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8535 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8536 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8544 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8552 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8556 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8557 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8558 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8559 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8560 draw_info->affine.tx=
8561 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8562 draw_info->affine.ty=
8563 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8565 if (attribute_flag[15] != 0)
8566 draw_info->fill_pattern=CloneImage(
8567 argument_list[15].image_reference,0,0,MagickTrue,exception);
8568 if (attribute_flag[16] != 0)
8569 draw_info->pointsize=argument_list[16].real_reference;
8570 if (attribute_flag[17] != 0)
8572 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8573 ? MagickTrue : MagickFalse;
8574 draw_info->text_antialias=draw_info->stroke_antialias;
8576 if (attribute_flag[18] != 0)
8577 (void) CloneString(&draw_info->density,
8578 argument_list[18].string_reference);
8579 if (attribute_flag[19] != 0)
8580 draw_info->stroke_width=argument_list[19].real_reference;
8581 if (attribute_flag[21] != 0)
8582 draw_info->dash_offset=argument_list[21].real_reference;
8583 if (attribute_flag[22] != 0)
8588 av=(AV *) argument_list[22].array_reference;
8589 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8590 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8591 if (draw_info->dash_pattern != (double *) NULL)
8593 for (i=0; i <= av_len(av); i++)
8594 draw_info->dash_pattern[i]=(double)
8595 SvNV(*(av_fetch(av,i,0)));
8596 draw_info->dash_pattern[i]=0.0;
8599 if (attribute_flag[23] != 0)
8600 image->interpolate=(InterpolatePixelMethod)
8601 argument_list[23].integer_reference;
8602 if ((attribute_flag[24] != 0) &&
8603 (draw_info->fill_pattern != (Image *) NULL))
8604 flags=ParsePageGeometry(draw_info->fill_pattern,
8605 argument_list[24].string_reference,
8606 &draw_info->fill_pattern->tile_offset,exception);
8607 if (attribute_flag[25] != 0)
8609 (void) ConcatenateString(&draw_info->primitive," '");
8610 (void) ConcatenateString(&draw_info->primitive,
8611 argument_list[25].string_reference);
8612 (void) ConcatenateString(&draw_info->primitive,"'");
8614 if (attribute_flag[26] != 0)
8615 draw_info->fill_pattern=CloneImage(
8616 argument_list[26].image_reference,0,0,MagickTrue,exception);
8617 if (attribute_flag[27] != 0)
8618 draw_info->stroke_pattern=CloneImage(
8619 argument_list[27].image_reference,0,0,MagickTrue,exception);
8620 if (attribute_flag[28] != 0)
8621 (void) CloneString(&draw_info->primitive,
8622 argument_list[28].string_reference);
8623 if (attribute_flag[29] != 0)
8624 draw_info->kerning=argument_list[29].real_reference;
8625 if (attribute_flag[30] != 0)
8626 draw_info->interline_spacing=argument_list[30].real_reference;
8627 if (attribute_flag[31] != 0)
8628 draw_info->interword_spacing=argument_list[31].real_reference;
8629 if (attribute_flag[32] != 0)
8630 draw_info->direction=(DirectionType)
8631 argument_list[32].integer_reference;
8632 DrawImage(image,draw_info);
8633 draw_info=DestroyDrawInfo(draw_info);
8636 case 39: /* Equalize */
8638 if (attribute_flag[0] != 0)
8639 channel=(ChannelType) argument_list[0].integer_reference;
8640 PushPixelComponentMap(image,channel);
8641 EqualizeImage(image);
8642 PopPixelComponentMap(image);
8645 case 40: /* Gamma */
8647 if (attribute_flag[1] != 0)
8648 channel=(ChannelType) argument_list[1].integer_reference;
8649 if (attribute_flag[2] == 0)
8650 argument_list[2].real_reference=1.0;
8651 if (attribute_flag[3] == 0)
8652 argument_list[3].real_reference=1.0;
8653 if (attribute_flag[4] == 0)
8654 argument_list[4].real_reference=1.0;
8655 if (attribute_flag[0] == 0)
8657 (void) FormatLocaleString(message,MaxTextExtent,
8658 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8659 (double) argument_list[3].real_reference,
8660 (double) argument_list[4].real_reference);
8661 argument_list[0].string_reference=message;
8663 (void) GammaImage(image,InterpretLocaleValue(
8664 argument_list[0].string_reference,(char **) NULL));
8672 if (attribute_flag[0] == 0)
8674 ThrowPerlException(exception,OptionError,"MapImageRequired",
8678 quantize_info=AcquireQuantizeInfo(info->image_info);
8679 if (attribute_flag[1] != 0)
8680 quantize_info->dither=(MagickBooleanType)
8681 argument_list[1].integer_reference;
8682 if (attribute_flag[2] != 0)
8683 quantize_info->dither_method=(DitherMethod)
8684 argument_list[2].integer_reference;
8685 (void) RemapImages(quantize_info,image,
8686 argument_list[0].image_reference);
8687 quantize_info=DestroyQuantizeInfo(quantize_info);
8690 case 42: /* MatteFloodfill */
8701 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8703 if (attribute_flag[0] != 0)
8704 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8705 &geometry,exception);
8706 if (attribute_flag[1] != 0)
8707 geometry.x=argument_list[1].integer_reference;
8708 if (attribute_flag[2] != 0)
8709 geometry.y=argument_list[2].integer_reference;
8710 if (image->matte == MagickFalse)
8711 (void) SetImageOpacity(image,OpaqueAlpha);
8712 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8714 if (attribute_flag[4] != 0)
8715 QueryMagickColor(argument_list[4].string_reference,&target,
8717 if (attribute_flag[3] != 0)
8718 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8720 if (attribute_flag[5] != 0)
8721 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8724 if (attribute_flag[6] != 0)
8725 invert=(MagickBooleanType) argument_list[6].integer_reference;
8726 PushPixelComponentMap(image,AlphaChannel);
8727 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8729 PopPixelComponentMap(image);
8730 StandardPixelComponentMap(image);
8731 draw_info=DestroyDrawInfo(draw_info);
8734 case 43: /* Modulate */
8737 modulate[MaxTextExtent];
8739 geometry_info.rho=100.0;
8740 geometry_info.sigma=100.0;
8741 geometry_info.xi=100.0;
8742 if (attribute_flag[0] != 0)
8743 (void)ParseGeometry(argument_list[0].string_reference,
8745 if (attribute_flag[1] != 0)
8746 geometry_info.xi=argument_list[1].real_reference;
8747 if (attribute_flag[2] != 0)
8748 geometry_info.sigma=argument_list[2].real_reference;
8749 if (attribute_flag[3] != 0)
8751 geometry_info.sigma=argument_list[3].real_reference;
8752 SetImageArtifact(image,"modulate:colorspace","HWB");
8754 if (attribute_flag[4] != 0)
8756 geometry_info.rho=argument_list[4].real_reference;
8757 SetImageArtifact(image,"modulate:colorspace","HSB");
8759 if (attribute_flag[5] != 0)
8761 geometry_info.sigma=argument_list[5].real_reference;
8762 SetImageArtifact(image,"modulate:colorspace","HSL");
8764 if (attribute_flag[6] != 0)
8766 geometry_info.rho=argument_list[6].real_reference;
8767 SetImageArtifact(image,"modulate:colorspace","HWB");
8769 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8770 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8771 (void) ModulateImage(image,modulate);
8774 case 44: /* Negate */
8776 if (attribute_flag[0] == 0)
8777 argument_list[0].integer_reference=0;
8778 if (attribute_flag[1] != 0)
8779 channel=(ChannelType) argument_list[1].integer_reference;
8780 PushPixelComponentMap(image,channel);
8781 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8782 MagickTrue : MagickFalse);
8783 PopPixelComponentMap(image);
8786 case 45: /* Normalize */
8788 if (attribute_flag[0] != 0)
8789 channel=(ChannelType) argument_list[0].integer_reference;
8790 PushPixelComponentMap(image,channel);
8791 NormalizeImage(image);
8792 PopPixelComponentMap(image);
8795 case 46: /* NumberColors */
8797 case 47: /* Opaque */
8806 (void) QueryMagickColor("none",&target,exception);
8807 (void) QueryMagickColor("none",&fill_color,exception);
8808 if (attribute_flag[0] != 0)
8809 (void) QueryMagickColor(argument_list[0].string_reference,
8811 if (attribute_flag[1] != 0)
8812 (void) QueryMagickColor(argument_list[1].string_reference,
8813 &fill_color,exception);
8814 if (attribute_flag[2] != 0)
8815 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8817 if (attribute_flag[3] != 0)
8818 channel=(ChannelType) argument_list[3].integer_reference;
8820 if (attribute_flag[4] != 0)
8821 invert=(MagickBooleanType) argument_list[4].integer_reference;
8822 PushPixelComponentMap(image,channel);
8823 (void) OpaquePaintImage(image,&target,&fill_color,invert);
8824 PopPixelComponentMap(image);
8827 case 48: /* Quantize */
8832 quantize_info=AcquireQuantizeInfo(info->image_info);
8833 if (attribute_flag[0] != 0)
8834 quantize_info->number_colors=(size_t)
8835 argument_list[0].integer_reference;
8836 if (attribute_flag[1] != 0)
8837 quantize_info->tree_depth=(size_t)
8838 argument_list[1].integer_reference;
8839 if (attribute_flag[2] != 0)
8840 quantize_info->colorspace=(ColorspaceType)
8841 argument_list[2].integer_reference;
8842 if (attribute_flag[3] != 0)
8843 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8844 MagickTrue : MagickFalse;
8845 if (attribute_flag[4] != 0)
8846 quantize_info->measure_error=
8847 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8848 if (attribute_flag[5] != 0)
8849 (void) QueryColorDatabase(argument_list[5].string_reference,
8850 &image->transparent_color,exception);
8851 if (attribute_flag[5] && argument_list[5].integer_reference)
8853 (void) QuantizeImages(quantize_info,image);
8856 if (attribute_flag[6] != 0)
8857 quantize_info->dither_method=(DitherMethod)
8858 argument_list[6].integer_reference;
8859 if ((image->storage_class == DirectClass) ||
8860 (image->colors > quantize_info->number_colors) ||
8861 (quantize_info->colorspace == GRAYColorspace))
8862 (void) QuantizeImage(quantize_info,image);
8864 CompressImageColormap(image);
8865 quantize_info=DestroyQuantizeInfo(quantize_info);
8868 case 49: /* Raise */
8870 if (attribute_flag[0] != 0)
8871 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8872 &geometry,exception);
8873 if (attribute_flag[1] != 0)
8874 geometry.width=argument_list[1].integer_reference;
8875 if (attribute_flag[2] != 0)
8876 geometry.height=argument_list[2].integer_reference;
8877 if (attribute_flag[3] == 0)
8878 argument_list[3].integer_reference=1;
8879 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8880 0 ? MagickTrue : MagickFalse);
8883 case 50: /* Segment */
8890 smoothing_threshold;
8895 cluster_threshold=1.0;
8896 smoothing_threshold=1.5;
8897 colorspace=RGBColorspace;
8898 verbose=MagickFalse;
8899 if (attribute_flag[0] != 0)
8901 flags=ParseGeometry(argument_list[0].string_reference,
8903 cluster_threshold=geometry_info.rho;
8904 if (flags & SigmaValue)
8905 smoothing_threshold=geometry_info.sigma;
8907 if (attribute_flag[1] != 0)
8908 cluster_threshold=argument_list[1].real_reference;
8909 if (attribute_flag[2] != 0)
8910 smoothing_threshold=argument_list[2].real_reference;
8911 if (attribute_flag[3] != 0)
8912 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8913 if (attribute_flag[4] != 0)
8914 verbose=argument_list[4].integer_reference != 0 ?
8915 MagickTrue : MagickFalse;
8916 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8917 smoothing_threshold);
8920 case 51: /* Signature */
8922 (void) SignatureImage(image);
8925 case 52: /* Solarize */
8927 geometry_info.rho=QuantumRange/2.0;
8928 if (attribute_flag[0] != 0)
8929 flags=ParseGeometry(argument_list[0].string_reference,
8931 if (attribute_flag[1] != 0)
8932 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8934 (void) SolarizeImage(image,geometry_info.rho);
8939 (void) SyncImage(image);
8942 case 54: /* Texture */
8944 if (attribute_flag[0] == 0)
8946 TextureImage(image,argument_list[0].image_reference);
8949 case 55: /* Evalute */
8951 MagickEvaluateOperator
8954 op=SetEvaluateOperator;
8955 if (attribute_flag[0] == MagickFalse)
8956 argument_list[0].real_reference=0.0;
8957 if (attribute_flag[1] != MagickFalse)
8958 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8959 if (attribute_flag[2] != MagickFalse)
8960 channel=(ChannelType) argument_list[2].integer_reference;
8961 PushPixelComponentMap(image,channel);
8962 (void) EvaluateImage(image,op,argument_list[0].real_reference,
8964 PopPixelComponentMap(image);
8967 case 56: /* Transparent */
8978 (void) QueryMagickColor("none",&target,exception);
8979 if (attribute_flag[0] != 0)
8980 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8982 opacity=TransparentAlpha;
8983 if (attribute_flag[1] != 0)
8984 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8986 if (attribute_flag[2] != 0)
8987 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8989 if (attribute_flag[3] == 0)
8990 argument_list[3].integer_reference=0;
8992 if (attribute_flag[3] != 0)
8993 invert=(MagickBooleanType) argument_list[3].integer_reference;
8994 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
8998 case 57: /* Threshold */
9003 if (attribute_flag[0] == 0)
9004 argument_list[0].string_reference="50%";
9005 if (attribute_flag[1] != 0)
9006 channel=(ChannelType) argument_list[1].integer_reference;
9007 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9009 PushPixelComponentMap(image,channel);
9010 (void) BilevelImage(image,threshold);
9011 PopPixelComponentMap(image);
9014 case 58: /* Charcoal */
9016 if (attribute_flag[0] != 0)
9018 flags=ParseGeometry(argument_list[0].string_reference,
9020 if ((flags & SigmaValue) == 0)
9021 geometry_info.sigma=1.0;
9023 if (attribute_flag[1] != 0)
9024 geometry_info.rho=argument_list[1].real_reference;
9025 if (attribute_flag[2] != 0)
9026 geometry_info.sigma=argument_list[2].real_reference;
9027 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9033 if (attribute_flag[0] != 0)
9034 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9036 image=TrimImage(image,exception);
9041 if (attribute_flag[0] != 0)
9043 flags=ParseGeometry(argument_list[0].string_reference,
9045 if ((flags & SigmaValue) == 0)
9046 geometry_info.sigma=1.0;
9048 if (attribute_flag[1] != 0)
9049 geometry_info.rho=argument_list[1].real_reference;
9050 if (attribute_flag[2] != 0)
9051 geometry_info.sigma=argument_list[2].real_reference;
9052 if (attribute_flag[3] != 0)
9053 image->interpolate=(InterpolatePixelMethod)
9054 argument_list[3].integer_reference;
9055 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9059 case 61: /* Separate */
9061 if (attribute_flag[0] != 0)
9062 channel=(ChannelType) argument_list[0].integer_reference;
9063 PushPixelComponentMap(image,channel);
9064 (void) SeparateImage(image);
9065 PopPixelComponentMap(image);
9068 case 63: /* Stereo */
9070 if (attribute_flag[0] == 0)
9072 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9076 if (attribute_flag[1] != 0)
9077 geometry.x=argument_list[1].integer_reference;
9078 if (attribute_flag[2] != 0)
9079 geometry.y=argument_list[2].integer_reference;
9080 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9081 geometry.x,geometry.y,exception);
9084 case 64: /* Stegano */
9086 if (attribute_flag[0] == 0)
9088 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9092 if (attribute_flag[1] == 0)
9093 argument_list[1].integer_reference=0;
9094 image->offset=argument_list[1].integer_reference;
9095 image=SteganoImage(image,argument_list[0].image_reference,exception);
9098 case 65: /* Deconstruct */
9100 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9103 case 66: /* GaussianBlur */
9105 if (attribute_flag[0] != 0)
9107 flags=ParseGeometry(argument_list[0].string_reference,
9109 if ((flags & SigmaValue) == 0)
9110 geometry_info.sigma=1.0;
9112 if (attribute_flag[1] != 0)
9113 geometry_info.rho=argument_list[1].real_reference;
9114 if (attribute_flag[2] != 0)
9115 geometry_info.sigma=argument_list[2].real_reference;
9116 if (attribute_flag[3] != 0)
9117 channel=(ChannelType) argument_list[3].integer_reference;
9118 PushPixelComponentMap(image,channel);
9119 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9121 PopPixelComponentMap(image);
9124 case 67: /* Convolve */
9135 if (attribute_flag[0] == 0)
9137 if (attribute_flag[1] != 0)
9138 channel=(ChannelType) argument_list[1].integer_reference;
9139 if (attribute_flag[2] != 0)
9140 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9142 av=(AV *) argument_list[0].array_reference;
9143 order=(size_t) sqrt(av_len(av)+1);
9144 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9145 if (kernel == (double *) NULL)
9147 ThrowPerlException(exception,ResourceLimitFatalError,
9148 "MemoryAllocationFailed",PackageName);
9151 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9152 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9153 for ( ; j < (ssize_t) (order*order); j++)
9155 PushPixelComponentMap(image,channel);
9156 image=ConvolveImage(image,order,kernel,exception);
9157 PopPixelComponentMap(image);
9158 kernel=(double *) RelinquishMagickMemory(kernel);
9161 case 68: /* Profile */
9176 if (attribute_flag[0] != 0)
9177 name=argument_list[0].string_reference;
9178 if (attribute_flag[2] != 0)
9179 image->rendering_intent=(RenderingIntent)
9180 argument_list[2].integer_reference;
9181 if (attribute_flag[3] != 0)
9182 image->black_point_compensation=
9183 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9184 if (attribute_flag[1] != 0)
9186 if (argument_list[1].length == 0)
9189 Remove a profile from the image.
9191 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9196 Associate user supplied profile with the image.
9198 profile=AcquireStringInfo(argument_list[1].length);
9199 SetStringInfoDatum(profile,(const unsigned char *)
9200 argument_list[1].string_reference);
9201 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9202 (size_t) GetStringInfoLength(profile),MagickFalse);
9203 profile=DestroyStringInfo(profile);
9207 Associate a profile with the image.
9210 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9211 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9212 profile_image=ReadImages(profile_info,&image->exception);
9213 if (profile_image == (Image *) NULL)
9215 ResetImageProfileIterator(profile_image);
9216 name=GetNextImageProfile(profile_image);
9217 while (name != (const char *) NULL)
9222 profile=GetImageProfile(profile_image,name);
9223 if (profile != (const StringInfo *) NULL)
9224 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9225 (size_t) GetStringInfoLength(profile),MagickFalse);
9226 name=GetNextImageProfile(profile_image);
9228 profile_image=DestroyImage(profile_image);
9229 profile_info=DestroyImageInfo(profile_info);
9232 case 69: /* UnsharpMask */
9234 if (attribute_flag[0] != 0)
9236 flags=ParseGeometry(argument_list[0].string_reference,
9238 if ((flags & SigmaValue) == 0)
9239 geometry_info.sigma=1.0;
9240 if ((flags & XiValue) == 0)
9241 geometry_info.xi=1.0;
9242 if ((flags & PsiValue) == 0)
9243 geometry_info.psi=0.5;
9245 if (attribute_flag[1] != 0)
9246 geometry_info.rho=argument_list[1].real_reference;
9247 if (attribute_flag[2] != 0)
9248 geometry_info.sigma=argument_list[2].real_reference;
9249 if (attribute_flag[3] != 0)
9250 geometry_info.xi=argument_list[3].real_reference;
9251 if (attribute_flag[4] != 0)
9252 geometry_info.psi=argument_list[4].real_reference;
9253 if (attribute_flag[5] != 0)
9254 channel=(ChannelType) argument_list[5].integer_reference;
9255 PushPixelComponentMap(image,channel);
9256 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9257 geometry_info.xi,geometry_info.psi,exception);
9258 PopPixelComponentMap(image);
9261 case 70: /* MotionBlur */
9263 if (attribute_flag[0] != 0)
9265 flags=ParseGeometry(argument_list[0].string_reference,
9267 if ((flags & SigmaValue) == 0)
9268 geometry_info.sigma=1.0;
9269 if ((flags & XiValue) == 0)
9270 geometry_info.xi=1.0;
9272 if (attribute_flag[1] != 0)
9273 geometry_info.rho=argument_list[1].real_reference;
9274 if (attribute_flag[2] != 0)
9275 geometry_info.sigma=argument_list[2].real_reference;
9276 if (attribute_flag[3] != 0)
9277 geometry_info.xi=argument_list[3].real_reference;
9278 if (attribute_flag[4] != 0)
9279 channel=(ChannelType) argument_list[4].integer_reference;
9280 PushPixelComponentMap(image,channel);
9281 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9282 geometry_info.xi,exception);
9283 PopPixelComponentMap(image);
9286 case 71: /* OrderedDither */
9288 if (attribute_flag[0] == 0)
9289 argument_list[0].string_reference="o8x8";
9290 if (attribute_flag[1] != 0)
9291 channel=(ChannelType) argument_list[1].integer_reference;
9292 PushPixelComponentMap(image,channel);
9293 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9295 PopPixelComponentMap(image);
9298 case 72: /* Shave */
9300 if (attribute_flag[0] != 0)
9301 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9302 &geometry,exception);
9303 if (attribute_flag[1] != 0)
9304 geometry.width=argument_list[1].integer_reference;
9305 if (attribute_flag[2] != 0)
9306 geometry.height=argument_list[2].integer_reference;
9307 image=ShaveImage(image,&geometry,exception);
9310 case 73: /* Level */
9318 white_point=(MagickRealType) image->columns*image->rows;
9320 if (attribute_flag[0] != 0)
9322 flags=ParseGeometry(argument_list[0].string_reference,
9324 black_point=geometry_info.rho;
9325 if ((flags & SigmaValue) != 0)
9326 white_point=geometry_info.sigma;
9327 if ((flags & XiValue) != 0)
9328 gamma=geometry_info.xi;
9329 if ((flags & PercentValue) != 0)
9331 black_point*=(double) (QuantumRange/100.0);
9332 white_point*=(double) (QuantumRange/100.0);
9334 if ((flags & SigmaValue) == 0)
9335 white_point=(double) QuantumRange-black_point;
9337 if (attribute_flag[1] != 0)
9338 black_point=argument_list[1].real_reference;
9339 if (attribute_flag[2] != 0)
9340 white_point=argument_list[2].real_reference;
9341 if (attribute_flag[3] != 0)
9342 gamma=argument_list[3].real_reference;
9343 if (attribute_flag[4] != 0)
9344 channel=(ChannelType) argument_list[4].integer_reference;
9345 if (attribute_flag[5] != 0)
9347 argument_list[0].real_reference=argument_list[5].real_reference;
9348 attribute_flag[0]=attribute_flag[5];
9350 PushPixelComponentMap(image,channel);
9351 (void) LevelImage(image,black_point,white_point,gamma);
9352 PopPixelComponentMap(image);
9357 if (attribute_flag[0] == 0)
9358 argument_list[0].string_reference="#1";
9359 if (attribute_flag[1] == 0)
9360 argument_list[1].integer_reference=MagickTrue;
9361 (void) ClipImagePath(image,argument_list[0].string_reference,
9362 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9365 case 75: /* AffineTransform */
9370 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9372 if (attribute_flag[0] != 0)
9377 av=(AV *) argument_list[0].array_reference;
9378 if ((av_len(av) != 3) && (av_len(av) != 5))
9380 ThrowPerlException(exception,OptionError,
9381 "affine matrix must have 4 or 6 elements",PackageName);
9384 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9385 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9386 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9387 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9388 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9389 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9391 ThrowPerlException(exception,OptionError,
9392 "affine matrix is singular",PackageName);
9395 if (av_len(av) == 5)
9397 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9398 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9401 for (j=1; j < 6; j++)
9403 if (attribute_flag[j] == 0)
9405 value=argument_list[j].string_reference;
9406 angle=argument_list[j].real_reference;
9407 current=draw_info->affine;
9408 GetAffineMatrix(&affine);
9416 flags=ParseGeometry(value,&geometry_info);
9417 affine.tx=geometry_info.xi;
9418 affine.ty=geometry_info.psi;
9419 if ((flags & PsiValue) == 0)
9420 affine.ty=affine.tx;
9428 flags=ParseGeometry(value,&geometry_info);
9429 affine.sx=geometry_info.rho;
9430 affine.sy=geometry_info.sigma;
9431 if ((flags & SigmaValue) == 0)
9432 affine.sy=affine.sx;
9442 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9443 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9444 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9445 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9453 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9461 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9465 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9466 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9467 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9468 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9469 draw_info->affine.tx=
9470 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9471 draw_info->affine.ty=
9472 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9474 if (attribute_flag[6] != 0)
9475 image->interpolate=(InterpolatePixelMethod)
9476 argument_list[6].integer_reference;
9477 if (attribute_flag[7] != 0)
9478 QueryColorDatabase(argument_list[7].string_reference,
9479 &image->background_color,exception);
9480 image=AffineTransformImage(image,&draw_info->affine,exception);
9481 draw_info=DestroyDrawInfo(draw_info);
9484 case 76: /* Difference */
9486 if (attribute_flag[0] == 0)
9488 ThrowPerlException(exception,OptionError,
9489 "ReferenceImageRequired",PackageName);
9492 if (attribute_flag[1] != 0)
9493 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9495 (void) IsImagesEqual(image,argument_list[0].image_reference);
9498 case 77: /* AdaptiveThreshold */
9500 if (attribute_flag[0] != 0)
9502 flags=ParseGeometry(argument_list[0].string_reference,
9504 if ((flags & PercentValue) != 0)
9505 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9507 if (attribute_flag[1] != 0)
9508 geometry_info.rho=argument_list[1].integer_reference;
9509 if (attribute_flag[2] != 0)
9510 geometry_info.sigma=argument_list[2].integer_reference;
9511 if (attribute_flag[3] != 0)
9512 geometry_info.xi=argument_list[3].integer_reference;;
9513 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9514 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9518 case 78: /* Resample */
9524 if (attribute_flag[0] != 0)
9526 flags=ParseGeometry(argument_list[0].string_reference,
9528 if ((flags & SigmaValue) == 0)
9529 geometry_info.sigma=geometry_info.rho;
9531 if (attribute_flag[1] != 0)
9532 geometry_info.rho=argument_list[1].real_reference;
9533 if (attribute_flag[2] != 0)
9534 geometry_info.sigma=argument_list[2].real_reference;
9535 if (attribute_flag[3] == 0)
9536 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9537 if (attribute_flag[4] == 0)
9538 SetImageArtifact(image,"filter:support",
9539 argument_list[4].string_reference);
9540 if (attribute_flag[5] != 0)
9541 argument_list[5].real_reference=1.0;
9542 width=(size_t) (geometry_info.rho*image->columns/
9543 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9544 height=(size_t) (geometry_info.sigma*image->rows/
9545 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9546 image=ResizeImage(image,width,height,(FilterTypes)
9547 argument_list[3].integer_reference,argument_list[5].real_reference,
9549 if (image != (Image *) NULL)
9551 image->x_resolution=geometry_info.rho;
9552 image->y_resolution=geometry_info.sigma;
9556 case 79: /* Describe */
9558 if (attribute_flag[0] == 0)
9559 argument_list[0].file_reference=(FILE *) NULL;
9560 if (attribute_flag[1] != 0)
9561 (void) SetImageArtifact(image,"identify:features",
9562 argument_list[1].string_reference);
9563 (void) IdentifyImage(image,argument_list[0].file_reference,
9567 case 80: /* BlackThreshold */
9569 if (attribute_flag[0] == 0)
9570 argument_list[0].string_reference="50%";
9571 if (attribute_flag[2] != 0)
9572 channel=(ChannelType) argument_list[2].integer_reference;
9573 PushPixelComponentMap(image,channel);
9574 BlackThresholdImage(image,argument_list[0].string_reference,
9576 PopPixelComponentMap(image);
9579 case 81: /* WhiteThreshold */
9581 if (attribute_flag[0] == 0)
9582 argument_list[0].string_reference="50%";
9583 if (attribute_flag[2] != 0)
9584 channel=(ChannelType) argument_list[2].integer_reference;
9585 PushPixelComponentMap(image,channel);
9586 WhiteThresholdImage(image,argument_list[0].string_reference,
9588 PopPixelComponentMap(image);
9591 case 82: /* RadialBlur */
9593 if (attribute_flag[0] != 0)
9595 flags=ParseGeometry(argument_list[0].string_reference,
9597 if ((flags & SigmaValue) == 0)
9598 geometry_info.sigma=1.0;
9600 if (attribute_flag[1] != 0)
9601 geometry_info.rho=argument_list[1].real_reference;
9602 if (attribute_flag[2] != 0)
9603 channel=(ChannelType) argument_list[2].integer_reference;
9604 PushPixelComponentMap(image,channel);
9605 image=RadialBlurImage(image,geometry_info.rho,exception);
9606 PopPixelComponentMap(image);
9609 case 83: /* Thumbnail */
9611 if (attribute_flag[0] != 0)
9612 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9613 &geometry,exception);
9614 if (attribute_flag[1] != 0)
9615 geometry.width=argument_list[1].integer_reference;
9616 if (attribute_flag[2] != 0)
9617 geometry.height=argument_list[2].integer_reference;
9618 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9621 case 84: /* Strip */
9623 (void) StripImage(image);
9631 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9632 if (attribute_flag[0] != 0)
9633 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9635 if (attribute_flag[1] == 0)
9636 argument_list[1].string_reference="100";
9637 image=TintImage(image,argument_list[1].string_reference,target,
9641 case 86: /* Channel */
9643 if (attribute_flag[0] != 0)
9644 channel=(ChannelType) argument_list[0].integer_reference;
9645 PushPixelComponentMap(image,channel);
9646 (void) SeparateImage(image);
9647 PopPixelComponentMap(image);
9650 case 87: /* Splice */
9652 if (attribute_flag[0] != 0)
9653 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9654 &geometry,exception);
9655 if (attribute_flag[1] != 0)
9656 geometry.width=argument_list[1].integer_reference;
9657 if (attribute_flag[2] != 0)
9658 geometry.height=argument_list[2].integer_reference;
9659 if (attribute_flag[3] != 0)
9660 geometry.x=argument_list[3].integer_reference;
9661 if (attribute_flag[4] != 0)
9662 geometry.y=argument_list[4].integer_reference;
9663 if (attribute_flag[5] != 0)
9664 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9666 if (attribute_flag[6] != 0)
9667 (void) QueryColorDatabase(argument_list[6].string_reference,
9668 &image->background_color,exception);
9669 if (attribute_flag[7] != 0)
9670 image->gravity=(GravityType) argument_list[7].integer_reference;
9671 image=SpliceImage(image,&geometry,exception);
9674 case 88: /* Posterize */
9676 if (attribute_flag[0] == 0)
9677 argument_list[0].integer_reference=3;
9678 if (attribute_flag[1] == 0)
9679 argument_list[1].integer_reference=0;
9680 (void) PosterizeImage(image,argument_list[0].integer_reference,
9681 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9684 case 89: /* Shadow */
9686 if (attribute_flag[0] != 0)
9688 flags=ParseGeometry(argument_list[0].string_reference,
9690 if ((flags & SigmaValue) == 0)
9691 geometry_info.sigma=1.0;
9692 if ((flags & XiValue) == 0)
9693 geometry_info.xi=4.0;
9694 if ((flags & PsiValue) == 0)
9695 geometry_info.psi=4.0;
9697 if (attribute_flag[1] != 0)
9698 geometry_info.rho=argument_list[1].real_reference;
9699 if (attribute_flag[2] != 0)
9700 geometry_info.sigma=argument_list[2].real_reference;
9701 if (attribute_flag[3] != 0)
9702 geometry_info.xi=argument_list[3].integer_reference;
9703 if (attribute_flag[4] != 0)
9704 geometry_info.psi=argument_list[4].integer_reference;
9705 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9706 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9710 case 90: /* Identify */
9712 if (attribute_flag[0] == 0)
9713 argument_list[0].file_reference=(FILE *) NULL;
9714 if (attribute_flag[1] != 0)
9715 (void) SetImageArtifact(image,"identify:features",
9716 argument_list[1].string_reference);
9717 if ((attribute_flag[2] != 0) &&
9718 (argument_list[2].integer_reference != 0))
9719 (void) SetImageArtifact(image,"identify:unique","true");
9720 (void) IdentifyImage(image,argument_list[0].file_reference,
9724 case 91: /* SepiaTone */
9726 if (attribute_flag[0] == 0)
9727 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9728 image=SepiaToneImage(image,argument_list[0].real_reference,
9732 case 92: /* SigmoidalContrast */
9737 if (attribute_flag[0] != 0)
9739 flags=ParseGeometry(argument_list[0].string_reference,
9741 if ((flags & SigmaValue) == 0)
9742 geometry_info.sigma=QuantumRange/2.0;
9743 if ((flags & PercentValue) != 0)
9744 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9746 if (attribute_flag[1] != 0)
9747 geometry_info.rho=argument_list[1].real_reference;
9748 if (attribute_flag[2] != 0)
9749 geometry_info.sigma=argument_list[2].real_reference;
9750 if (attribute_flag[3] != 0)
9751 channel=(ChannelType) argument_list[3].integer_reference;
9753 if (attribute_flag[4] != 0)
9754 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9756 PushPixelComponentMap(image,channel);
9757 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9758 geometry_info.sigma);
9759 PopPixelComponentMap(image);
9762 case 93: /* Extent */
9764 if (attribute_flag[7] != 0)
9765 image->gravity=(GravityType) argument_list[7].integer_reference;
9766 if (attribute_flag[0] != 0)
9771 flags=ParseGravityGeometry(image,
9772 argument_list[0].string_reference,&geometry,exception);
9774 if (geometry.width == 0)
9775 geometry.width=image->columns;
9776 if (geometry.height == 0)
9777 geometry.height=image->rows;
9779 if (attribute_flag[1] != 0)
9780 geometry.width=argument_list[1].integer_reference;
9781 if (attribute_flag[2] != 0)
9782 geometry.height=argument_list[2].integer_reference;
9783 if (attribute_flag[3] != 0)
9784 geometry.x=argument_list[3].integer_reference;
9785 if (attribute_flag[4] != 0)
9786 geometry.y=argument_list[4].integer_reference;
9787 if (attribute_flag[5] != 0)
9788 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9790 if (attribute_flag[6] != 0)
9791 (void) QueryColorDatabase(argument_list[6].string_reference,
9792 &image->background_color,exception);
9793 image=ExtentImage(image,&geometry,exception);
9796 case 94: /* Vignette */
9798 if (attribute_flag[0] != 0)
9800 flags=ParseGeometry(argument_list[0].string_reference,
9802 if ((flags & SigmaValue) == 0)
9803 geometry_info.sigma=1.0;
9804 if ((flags & XiValue) == 0)
9805 geometry_info.xi=0.1*image->columns;
9806 if ((flags & PsiValue) == 0)
9807 geometry_info.psi=0.1*image->rows;
9809 if (attribute_flag[1] != 0)
9810 geometry_info.rho=argument_list[1].real_reference;
9811 if (attribute_flag[2] != 0)
9812 geometry_info.sigma=argument_list[2].real_reference;
9813 if (attribute_flag[3] != 0)
9814 geometry_info.xi=argument_list[3].integer_reference;
9815 if (attribute_flag[4] != 0)
9816 geometry_info.psi=argument_list[4].integer_reference;
9817 if (attribute_flag[5] != 0)
9818 (void) QueryColorDatabase(argument_list[5].string_reference,
9819 &image->background_color,exception);
9820 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9821 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9825 case 95: /* ContrastStretch */
9832 white_point=(MagickRealType) image->columns*image->rows;
9833 if (attribute_flag[0] != 0)
9835 flags=ParseGeometry(argument_list[0].string_reference,
9837 black_point=geometry_info.rho;
9838 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9840 if ((flags & PercentValue) != 0)
9842 black_point*=(double) image->columns*image->rows/100.0;
9843 white_point*=(double) image->columns*image->rows/100.0;
9845 white_point=(MagickRealType) image->columns*image->rows-
9848 if (attribute_flag[1] != 0)
9849 black_point=argument_list[1].real_reference;
9850 if (attribute_flag[2] != 0)
9851 white_point=argument_list[2].real_reference;
9852 if (attribute_flag[4] != 0)
9853 channel=(ChannelType) argument_list[4].integer_reference;
9854 PushPixelComponentMap(image,channel);
9855 (void) ContrastStretchImage(image,black_point,white_point);
9856 PopPixelComponentMap(image);
9859 case 96: /* Sans0 */
9863 case 97: /* Sans1 */
9867 case 98: /* AdaptiveSharpen */
9869 if (attribute_flag[0] != 0)
9871 flags=ParseGeometry(argument_list[0].string_reference,
9873 if ((flags & SigmaValue) == 0)
9874 geometry_info.sigma=1.0;
9876 if (attribute_flag[1] != 0)
9877 geometry_info.rho=argument_list[1].real_reference;
9878 if (attribute_flag[2] != 0)
9879 geometry_info.sigma=argument_list[2].real_reference;
9880 if (attribute_flag[3] != 0)
9881 channel=(ChannelType) argument_list[3].integer_reference;
9882 PushPixelComponentMap(image,channel);
9883 image=AdaptiveSharpenImage(image,geometry_info.rho,
9884 geometry_info.sigma,exception);
9885 PopPixelComponentMap(image);
9888 case 99: /* Transpose */
9890 image=TransposeImage(image,exception);
9893 case 100: /* Tranverse */
9895 image=TransverseImage(image,exception);
9898 case 101: /* AutoOrient */
9900 switch (image->orientation)
9902 case TopRightOrientation:
9904 image=FlopImage(image,exception);
9907 case BottomRightOrientation:
9909 image=RotateImage(image,180.0,exception);
9912 case BottomLeftOrientation:
9914 image=FlipImage(image,exception);
9917 case LeftTopOrientation:
9919 image=TransposeImage(image,exception);
9922 case RightTopOrientation:
9924 image=RotateImage(image,90.0,exception);
9927 case RightBottomOrientation:
9929 image=TransverseImage(image,exception);
9932 case LeftBottomOrientation:
9934 image=RotateImage(image,270.0,exception);
9942 case 102: /* AdaptiveBlur */
9944 if (attribute_flag[0] != 0)
9946 flags=ParseGeometry(argument_list[0].string_reference,
9948 if ((flags & SigmaValue) == 0)
9949 geometry_info.sigma=1.0;
9951 if (attribute_flag[1] != 0)
9952 geometry_info.rho=argument_list[1].real_reference;
9953 if (attribute_flag[2] != 0)
9954 geometry_info.sigma=argument_list[2].real_reference;
9955 if (attribute_flag[3] != 0)
9956 channel=(ChannelType) argument_list[3].integer_reference;
9957 PushPixelComponentMap(image,channel);
9958 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
9960 PopPixelComponentMap(image);
9963 case 103: /* Sketch */
9965 if (attribute_flag[0] != 0)
9967 flags=ParseGeometry(argument_list[0].string_reference,
9969 if ((flags & SigmaValue) == 0)
9970 geometry_info.sigma=1.0;
9971 if ((flags & XiValue) == 0)
9972 geometry_info.xi=1.0;
9974 if (attribute_flag[1] != 0)
9975 geometry_info.rho=argument_list[1].real_reference;
9976 if (attribute_flag[2] != 0)
9977 geometry_info.sigma=argument_list[2].real_reference;
9978 if (attribute_flag[3] != 0)
9979 geometry_info.xi=argument_list[3].real_reference;
9980 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9981 geometry_info.xi,exception);
9984 case 104: /* UniqueColors */
9986 image=UniqueImageColors(image,exception);
9989 case 105: /* AdaptiveResize */
9991 if (attribute_flag[0] != 0)
9992 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9993 &geometry,exception);
9994 if (attribute_flag[1] != 0)
9995 geometry.width=argument_list[1].integer_reference;
9996 if (attribute_flag[2] != 0)
9997 geometry.height=argument_list[2].integer_reference;
9998 if (attribute_flag[3] != 0)
9999 image->filter=(FilterTypes) argument_list[4].integer_reference;
10000 if (attribute_flag[4] != 0)
10001 SetImageArtifact(image,"filter:support",
10002 argument_list[4].string_reference);
10003 if (attribute_flag[5] != 0)
10004 image->blur=argument_list[5].real_reference;
10005 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10009 case 106: /* ClipMask */
10011 if (attribute_flag[0] == 0)
10013 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10015 goto PerlException;
10017 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10018 MagickTrue,exception);
10019 (void) NegateImage(image->clip_mask,MagickFalse);
10022 case 107: /* LinearStretch */
10029 white_point=(MagickRealType) image->columns*image->rows;
10030 if (attribute_flag[0] != 0)
10032 flags=ParseGeometry(argument_list[0].string_reference,
10034 if ((flags & SigmaValue) != 0)
10035 white_point=geometry_info.sigma;
10036 if ((flags & PercentValue) != 0)
10038 black_point*=(double) image->columns*image->rows/100.0;
10039 white_point*=(double) image->columns*image->rows/100.0;
10041 if ((flags & SigmaValue) == 0)
10042 white_point=(double) image->columns*image->rows-black_point;
10044 if (attribute_flag[1] != 0)
10045 black_point=argument_list[1].real_reference;
10046 if (attribute_flag[2] != 0)
10047 white_point=argument_list[2].real_reference;
10048 (void) LinearStretchImage(image,black_point,white_point);
10051 case 109: /* Mask */
10053 if (attribute_flag[0] == 0)
10055 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10057 goto PerlException;
10059 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10060 MagickTrue,exception);
10061 (void) NegateImage(image->mask,MagickFalse);
10064 case 110: /* Polaroid */
10072 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10073 (DrawInfo *) NULL);
10074 if (attribute_flag[0] != 0)
10075 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10076 info ? info->image_info : (ImageInfo *) NULL,image,
10077 argument_list[0].string_reference));
10079 if (attribute_flag[1] != 0)
10080 angle=argument_list[1].real_reference;
10081 if (attribute_flag[2] != 0)
10082 (void) CloneString(&draw_info->font,
10083 argument_list[2].string_reference);
10084 if (attribute_flag[3] != 0)
10085 (void) QueryColorDatabase(argument_list[3].string_reference,
10086 &draw_info->stroke,exception);
10087 if (attribute_flag[4] != 0)
10088 (void) QueryColorDatabase(argument_list[4].string_reference,
10089 &draw_info->fill,exception);
10090 if (attribute_flag[5] != 0)
10091 draw_info->stroke_width=argument_list[5].real_reference;
10092 if (attribute_flag[6] != 0)
10093 draw_info->pointsize=argument_list[6].real_reference;
10094 if (attribute_flag[7] != 0)
10095 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10096 if (attribute_flag[8] != 0)
10097 (void) QueryColorDatabase(argument_list[8].string_reference,
10098 &image->background_color,exception);
10099 image=PolaroidImage(image,draw_info,angle,exception);
10100 draw_info=DestroyDrawInfo(draw_info);
10103 case 111: /* FloodfillPaint */
10114 draw_info=CloneDrawInfo(info ? info->image_info :
10115 (ImageInfo *) NULL,(DrawInfo *) NULL);
10116 if (attribute_flag[0] != 0)
10117 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10118 &geometry,exception);
10119 if (attribute_flag[1] != 0)
10120 geometry.x=argument_list[1].integer_reference;
10121 if (attribute_flag[2] != 0)
10122 geometry.y=argument_list[2].integer_reference;
10123 if (attribute_flag[3] != 0)
10124 (void) QueryColorDatabase(argument_list[3].string_reference,
10125 &draw_info->fill,exception);
10126 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10128 if (attribute_flag[4] != 0)
10129 QueryMagickColor(argument_list[4].string_reference,&target,
10131 if (attribute_flag[5] != 0)
10132 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10134 if (attribute_flag[6] != 0)
10135 channel=(ChannelType) argument_list[6].integer_reference;
10136 invert=MagickFalse;
10137 if (attribute_flag[7] != 0)
10138 invert=(MagickBooleanType) argument_list[7].integer_reference;
10139 PushPixelComponentMap(image,channel);
10140 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10141 geometry.y,invert);
10142 PopPixelComponentMap(image);
10143 draw_info=DestroyDrawInfo(draw_info);
10146 case 112: /* Distort */
10158 number_coordinates;
10163 if (attribute_flag[0] == 0)
10165 method=UndefinedDistortion;
10166 if (attribute_flag[1] != 0)
10167 method=(DistortImageMethod) argument_list[1].integer_reference;
10168 av=(AV *) argument_list[0].array_reference;
10169 number_coordinates=(size_t) av_len(av)+1;
10170 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10171 sizeof(*coordinates));
10172 if (coordinates == (double *) NULL)
10174 ThrowPerlException(exception,ResourceLimitFatalError,
10175 "MemoryAllocationFailed",PackageName);
10176 goto PerlException;
10178 for (j=0; j < (ssize_t) number_coordinates; j++)
10179 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10180 virtual_pixel=UndefinedVirtualPixelMethod;
10181 if (attribute_flag[2] != 0)
10182 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10183 argument_list[2].integer_reference);
10184 image=DistortImage(image,method,number_coordinates,coordinates,
10185 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10187 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10188 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10189 coordinates=(double *) RelinquishMagickMemory(coordinates);
10192 case 113: /* Clut */
10194 if (attribute_flag[0] == 0)
10196 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10198 goto PerlException;
10200 if (attribute_flag[1] != 0)
10201 channel=(ChannelType) argument_list[1].integer_reference;
10202 PushPixelComponentMap(image,channel);
10203 (void) ClutImage(image,argument_list[0].image_reference);
10204 PopPixelComponentMap(image);
10207 case 114: /* LiquidRescale */
10209 if (attribute_flag[0] != 0)
10210 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10211 &geometry,exception);
10212 if (attribute_flag[1] != 0)
10213 geometry.width=argument_list[1].integer_reference;
10214 if (attribute_flag[2] != 0)
10215 geometry.height=argument_list[2].integer_reference;
10216 if (attribute_flag[3] == 0)
10217 argument_list[3].real_reference=1.0;
10218 if (attribute_flag[4] == 0)
10219 argument_list[4].real_reference=0.0;
10220 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10221 argument_list[3].real_reference,argument_list[4].real_reference,
10225 case 115: /* EncipherImage */
10227 (void) EncipherImage(image,argument_list[0].string_reference,
10231 case 116: /* DecipherImage */
10233 (void) DecipherImage(image,argument_list[0].string_reference,
10237 case 117: /* Deskew */
10239 geometry_info.rho=QuantumRange/2.0;
10240 if (attribute_flag[0] != 0)
10241 flags=ParseGeometry(argument_list[0].string_reference,
10243 if (attribute_flag[1] != 0)
10244 geometry_info.rho=SiPrefixToDouble(
10245 argument_list[1].string_reference,QuantumRange);
10246 image=DeskewImage(image,geometry_info.rho,exception);
10249 case 118: /* Remap */
10254 if (attribute_flag[0] == 0)
10256 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10258 goto PerlException;
10260 quantize_info=AcquireQuantizeInfo(info->image_info);
10261 if (attribute_flag[1] != 0)
10262 quantize_info->dither=(MagickBooleanType)
10263 argument_list[1].integer_reference;
10264 if (attribute_flag[2] != 0)
10265 quantize_info->dither_method=(DitherMethod)
10266 argument_list[2].integer_reference;
10267 (void) RemapImages(quantize_info,image,
10268 argument_list[0].image_reference);
10269 quantize_info=DestroyQuantizeInfo(quantize_info);
10272 case 119: /* SparseColor */
10284 number_coordinates;
10289 if (attribute_flag[0] == 0)
10291 method=UndefinedColorInterpolate;
10292 if (attribute_flag[1] != 0)
10293 method=(SparseColorMethod) argument_list[1].integer_reference;
10294 av=(AV *) argument_list[0].array_reference;
10295 number_coordinates=(size_t) av_len(av)+1;
10296 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10297 sizeof(*coordinates));
10298 if (coordinates == (double *) NULL)
10300 ThrowPerlException(exception,ResourceLimitFatalError,
10301 "MemoryAllocationFailed",PackageName);
10302 goto PerlException;
10304 for (j=0; j < (ssize_t) number_coordinates; j++)
10305 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10306 virtual_pixel=UndefinedVirtualPixelMethod;
10307 if (attribute_flag[2] != 0)
10308 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10309 argument_list[2].integer_reference);
10310 if (attribute_flag[3] != 0)
10311 channel=(ChannelType) argument_list[3].integer_reference;
10312 PushPixelComponentMap(image,channel);
10313 image=SparseColorImage(image,method,number_coordinates,coordinates,
10315 PopPixelComponentMap(image);
10316 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10317 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10318 coordinates=(double *) RelinquishMagickMemory(coordinates);
10321 case 120: /* Function */
10338 if (attribute_flag[0] == 0)
10340 function=UndefinedFunction;
10341 if (attribute_flag[1] != 0)
10342 function=(MagickFunction) argument_list[1].integer_reference;
10343 av=(AV *) argument_list[0].array_reference;
10344 number_parameters=(size_t) av_len(av)+1;
10345 parameters=(double *) AcquireQuantumMemory(number_parameters,
10346 sizeof(*parameters));
10347 if (parameters == (double *) NULL)
10349 ThrowPerlException(exception,ResourceLimitFatalError,
10350 "MemoryAllocationFailed",PackageName);
10351 goto PerlException;
10353 for (j=0; j < (ssize_t) number_parameters; j++)
10354 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10355 virtual_pixel=UndefinedVirtualPixelMethod;
10356 if (attribute_flag[2] != 0)
10357 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10358 argument_list[2].integer_reference);
10359 (void) FunctionImage(image,function,number_parameters,parameters,
10361 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10362 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10363 parameters=(double *) RelinquishMagickMemory(parameters);
10366 case 121: /* SelectiveBlur */
10368 if (attribute_flag[0] != 0)
10370 flags=ParseGeometry(argument_list[0].string_reference,
10372 if ((flags & SigmaValue) == 0)
10373 geometry_info.sigma=1.0;
10374 if ((flags & PercentValue) != 0)
10375 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10377 if (attribute_flag[1] != 0)
10378 geometry_info.rho=argument_list[1].real_reference;
10379 if (attribute_flag[2] != 0)
10380 geometry_info.sigma=argument_list[2].real_reference;
10381 if (attribute_flag[3] != 0)
10382 geometry_info.xi=argument_list[3].integer_reference;;
10383 if (attribute_flag[4] != 0)
10384 channel=(ChannelType) argument_list[4].integer_reference;
10385 PushPixelComponentMap(image,channel);
10386 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10387 geometry_info.xi,exception);
10388 PopPixelComponentMap(image);
10391 case 122: /* HaldClut */
10393 if (attribute_flag[0] == 0)
10395 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10397 goto PerlException;
10399 if (attribute_flag[1] != 0)
10400 channel=(ChannelType) argument_list[1].integer_reference;
10401 PushPixelComponentMap(image,channel);
10402 (void) HaldClutImage(image,argument_list[0].image_reference);
10403 PopPixelComponentMap(image);
10406 case 123: /* BlueShift */
10408 if (attribute_flag[0] != 0)
10409 (void) ParseGeometry(argument_list[0].string_reference,
10411 image=BlueShiftImage(image,geometry_info.rho,exception);
10414 case 124: /* ForwardFourierTransformImage */
10416 image=ForwardFourierTransformImage(image,
10417 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10421 case 125: /* InverseFourierTransformImage */
10423 image=InverseFourierTransformImage(image,image->next,
10424 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10428 case 126: /* ColorDecisionList */
10430 if (attribute_flag[0] == 0)
10431 argument_list[0].string_reference=(char *) NULL;
10432 (void) ColorDecisionListImage(image,
10433 argument_list[0].string_reference);
10436 case 127: /* AutoGamma */
10438 if (attribute_flag[0] != 0)
10439 channel=(ChannelType) argument_list[0].integer_reference;
10440 PushPixelComponentMap(image,channel);
10441 (void) AutoGammaImage(image);
10442 PopPixelComponentMap(image);
10445 case 128: /* AutoLevel */
10447 if (attribute_flag[0] != 0)
10448 channel=(ChannelType) argument_list[0].integer_reference;
10449 PushPixelComponentMap(image,channel);
10450 (void) AutoLevelImage(image);
10451 PopPixelComponentMap(image);
10454 case 129: /* LevelColors */
10460 (void) QueryMagickColor("#000000",&black_point,exception);
10461 (void) QueryMagickColor("#ffffff",&white_point,exception);
10462 if (attribute_flag[1] != 0)
10463 (void) QueryMagickColor(argument_list[1].string_reference,
10464 &black_point,exception);
10465 if (attribute_flag[2] != 0)
10466 (void) QueryMagickColor(argument_list[2].string_reference,
10467 &white_point,exception);
10468 if (attribute_flag[3] != 0)
10469 channel=(ChannelType) argument_list[3].integer_reference;
10470 PushPixelComponentMap(image,channel);
10471 (void) LevelImageColors(image,&black_point,&white_point,
10472 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
10473 PopPixelComponentMap(image);
10476 case 130: /* Clamp */
10478 if (attribute_flag[0] != 0)
10479 channel=(ChannelType) argument_list[0].integer_reference;
10480 PushPixelComponentMap(image,channel);
10481 (void) ClampImage(image);
10482 PopPixelComponentMap(image);
10485 case 131: /* Filter */
10490 if (attribute_flag[0] == 0)
10492 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10493 if (kernel == (KernelInfo *) NULL)
10495 if (attribute_flag[1] != 0)
10496 channel=(ChannelType) argument_list[1].integer_reference;
10497 if (attribute_flag[2] != 0)
10498 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10500 PushPixelComponentMap(image,channel);
10501 image=FilterImage(image,kernel,exception);
10502 PopPixelComponentMap(image);
10503 kernel=DestroyKernelInfo(kernel);
10506 case 132: /* BrightnessContrast */
10514 if (attribute_flag[0] != 0)
10516 flags=ParseGeometry(argument_list[0].string_reference,
10518 brightness=geometry_info.rho;
10519 if ((flags & SigmaValue) == 0)
10520 contrast=geometry_info.sigma;
10522 if (attribute_flag[1] != 0)
10523 brightness=argument_list[1].real_reference;
10524 if (attribute_flag[2] != 0)
10525 contrast=argument_list[2].real_reference;
10526 if (attribute_flag[4] != 0)
10527 channel=(ChannelType) argument_list[4].integer_reference;
10528 PushPixelComponentMap(image,channel);
10529 (void) BrightnessContrastImage(image,brightness,contrast);
10530 PopPixelComponentMap(image);
10533 case 133: /* Morphology */
10544 if (attribute_flag[0] == 0)
10546 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10547 if (kernel == (KernelInfo *) NULL)
10549 if (attribute_flag[1] != 0)
10550 channel=(ChannelType) argument_list[1].integer_reference;
10551 method=UndefinedMorphology;
10552 if (attribute_flag[2] != 0)
10553 method=argument_list[2].integer_reference;
10555 if (attribute_flag[3] != 0)
10556 iterations=argument_list[4].integer_reference;
10557 PushPixelComponentMap(image,channel);
10558 image=MorphologyImage(image,method,iterations,kernel,exception);
10559 PopPixelComponentMap(image);
10560 kernel=DestroyKernelInfo(kernel);
10563 case 108: /* Recolor */
10564 case 134: /* ColorMatrix */
10578 if (attribute_flag[0] == 0)
10580 av=(AV *) argument_list[0].array_reference;
10581 order=(size_t) sqrt(av_len(av)+1);
10582 color_matrix=(double *) AcquireQuantumMemory(order,order*
10583 sizeof(*color_matrix));
10584 if (color_matrix == (double *) NULL)
10586 ThrowPerlException(exception,ResourceLimitFatalError,
10587 "MemoryAllocationFailed",PackageName);
10588 goto PerlException;
10590 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10591 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10592 for ( ; j < (ssize_t) (order*order); j++)
10593 color_matrix[j]=0.0;
10594 kernel_info=AcquireKernelInfo("1");
10595 if (kernel_info == (KernelInfo *) NULL)
10597 kernel_info->width=order;
10598 kernel_info->height=order;
10599 kernel_info->values=color_matrix;
10600 image=ColorMatrixImage(image,kernel_info,exception);
10601 kernel_info->values=(double *) NULL;
10602 kernel_info=DestroyKernelInfo(kernel_info);
10603 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10606 case 135: /* Color */
10611 (void) QueryMagickColor("none",&color,exception);
10612 if (attribute_flag[0] != 0)
10613 (void) QueryMagickColor(argument_list[0].string_reference,
10615 (void) SetImageColor(image,&color);
10618 case 136: /* Mode */
10620 if (attribute_flag[0] != 0)
10622 flags=ParseGeometry(argument_list[0].string_reference,
10624 if ((flags & SigmaValue) == 0)
10625 geometry_info.sigma=1.0;
10627 if (attribute_flag[1] != 0)
10628 geometry_info.rho=argument_list[1].real_reference;
10629 if (attribute_flag[2] != 0)
10630 geometry_info.sigma=argument_list[2].real_reference;
10631 if (attribute_flag[3] != 0)
10632 channel=(ChannelType) argument_list[3].integer_reference;
10633 PushPixelComponentMap(image,channel);
10634 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10635 (size_t) geometry_info.sigma,exception);
10636 PopPixelComponentMap(image);
10639 case 137: /* Statistic */
10644 statistic=UndefinedStatistic;
10645 if (attribute_flag[0] != 0)
10647 flags=ParseGeometry(argument_list[0].string_reference,
10649 if ((flags & SigmaValue) == 0)
10650 geometry_info.sigma=1.0;
10652 if (attribute_flag[1] != 0)
10653 geometry_info.rho=argument_list[1].real_reference;
10654 if (attribute_flag[2] != 0)
10655 geometry_info.sigma=argument_list[2].real_reference;
10656 if (attribute_flag[3] != 0)
10657 channel=(ChannelType) argument_list[3].integer_reference;
10658 if (attribute_flag[4] != 0)
10659 statistic=(StatisticType) argument_list[4].integer_reference;
10660 PushPixelComponentMap(image,channel);
10661 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10662 (size_t) geometry_info.sigma,exception);
10663 PopPixelComponentMap(image);
10667 if (next != (Image *) NULL)
10668 (void) CatchImageException(next);
10669 if (region_image != (Image *) NULL)
10674 status=CompositeImage(region_image,CopyCompositeOp,image,
10675 region_info.x,region_info.y);
10677 (void) CatchImageException(region_image);
10678 image=DestroyImage(image);
10679 image=region_image;
10681 if (image != (Image *) NULL)
10684 if (next && (next != image))
10686 image->next=next->next;
10687 DeleteImageFromRegistry(*pv,next);
10689 sv_setiv(*pv,(IV) image);
10697 if (reference_vector)
10698 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10699 InheritPerlException(exception,perl_exception);
10700 exception=DestroyExceptionInfo(exception);
10701 sv_setiv(perl_exception,(IV) number_images);
10702 SvPOK_on(perl_exception);
10703 ST(0)=sv_2mortal(perl_exception);
10708 ###############################################################################
10716 ###############################################################################
10721 Image::Magick ref=NO_INIT
10766 PERL_UNUSED_VAR(ref);
10767 PERL_UNUSED_VAR(ix);
10768 exception=AcquireExceptionInfo();
10769 perl_exception=newSVpv("",0);
10772 if (sv_isobject(ST(0)) == 0)
10774 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10776 goto PerlException;
10778 reference=SvRV(ST(0));
10779 hv=SvSTASH(reference);
10781 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10783 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10784 if (image == (Image *) NULL)
10786 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10788 goto PerlException;
10793 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10794 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10795 (void) QueryMagickColor("none",&transparent_color,exception);
10796 for (i=2; i < items; i+=2)
10798 attribute=(char *) SvPV(ST(i-1),na);
10799 switch (*attribute)
10804 if (LocaleCompare(attribute,"background") == 0)
10806 (void) QueryColorDatabase(SvPV(ST(i),na),
10807 &montage_info->background_color,exception);
10808 for (next=image; next; next=next->next)
10809 next->background_color=montage_info->background_color;
10812 if (LocaleCompare(attribute,"border") == 0)
10814 montage_info->border_width=SvIV(ST(i));
10817 if (LocaleCompare(attribute,"bordercolor") == 0)
10819 (void) QueryColorDatabase(SvPV(ST(i),na),
10820 &montage_info->border_color,exception);
10821 for (next=image; next; next=next->next)
10822 next->border_color=montage_info->border_color;
10825 if (LocaleCompare(attribute,"borderwidth") == 0)
10827 montage_info->border_width=SvIV(ST(i));
10830 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10837 if (LocaleCompare(attribute,"compose") == 0)
10839 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10840 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10843 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10847 for (next=image; next; next=next->next)
10848 next->compose=(CompositeOperator) sp;
10851 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10858 if (LocaleCompare(attribute,"fill") == 0)
10860 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10864 if (LocaleCompare(attribute,"font") == 0)
10866 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10869 if (LocaleCompare(attribute,"frame") == 0)
10875 if (IsGeometry(p) == MagickFalse)
10877 ThrowPerlException(exception,OptionError,"MissingGeometry",
10881 (void) CloneString(&montage_info->frame,p);
10883 montage_info->frame=(char *) NULL;
10886 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10893 if (LocaleCompare(attribute,"geometry") == 0)
10899 if (IsGeometry(p) == MagickFalse)
10901 ThrowPerlException(exception,OptionError,"MissingGeometry",
10905 (void) CloneString(&montage_info->geometry,p);
10907 montage_info->geometry=(char *) NULL;
10910 if (LocaleCompare(attribute,"gravity") == 0)
10915 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10916 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10919 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10923 montage_info->gravity=(GravityType) in;
10924 for (next=image; next; next=next->next)
10925 next->gravity=(GravityType) in;
10928 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10935 if (LocaleCompare(attribute,"label") == 0)
10937 for (next=image; next; next=next->next)
10938 (void) SetImageProperty(next,"label",InterpretImageProperties(
10939 info ? info->image_info : (ImageInfo *) NULL,next,
10943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10950 if (LocaleCompare(attribute,"mattecolor") == 0)
10952 (void) QueryColorDatabase(SvPV(ST(i),na),
10953 &montage_info->matte_color,exception);
10954 for (next=image; next; next=next->next)
10955 next->matte_color=montage_info->matte_color;
10958 if (LocaleCompare(attribute,"mode") == 0)
10963 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10964 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10969 ThrowPerlException(exception,OptionError,
10970 "UnrecognizedModeType",SvPV(ST(i),na));
10975 (void) CloneString(&montage_info->frame,"15x15+3+3");
10976 montage_info->shadow=MagickTrue;
10981 montage_info->frame=(char *) NULL;
10982 montage_info->shadow=MagickFalse;
10983 montage_info->border_width=0;
10986 case ConcatenateMode:
10988 montage_info->frame=(char *) NULL;
10989 montage_info->shadow=MagickFalse;
10990 (void) CloneString(&montage_info->geometry,"+0+0");
10991 montage_info->border_width=0;
10996 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11003 if (LocaleCompare(attribute,"pointsize") == 0)
11005 montage_info->pointsize=SvIV(ST(i));
11008 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11015 if (LocaleCompare(attribute,"shadow") == 0)
11017 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11018 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11021 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11025 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11028 if (LocaleCompare(attribute,"stroke") == 0)
11030 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11041 if (LocaleCompare(attribute,"texture") == 0)
11043 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11046 if (LocaleCompare(attribute,"tile") == 0)
11048 char *p=SvPV(ST(i),na);
11049 if (IsGeometry(p) == MagickFalse)
11051 ThrowPerlException(exception,OptionError,"MissingGeometry",
11055 (void) CloneString(&montage_info->tile,p);
11057 montage_info->tile=(char *) NULL;
11060 if (LocaleCompare(attribute,"title") == 0)
11062 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11065 if (LocaleCompare(attribute,"transparent") == 0)
11070 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11071 for (next=image; next; next=next->next)
11072 (void) TransparentPaintImage(next,&transparent_color,
11073 TransparentAlpha,MagickFalse);
11076 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11088 image=MontageImageList(info->image_info,montage_info,image,exception);
11089 montage_info=DestroyMontageInfo(montage_info);
11090 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11091 goto PerlException;
11092 if (transparent_color.alpha != TransparentAlpha)
11093 for (next=image; next; next=next->next)
11094 (void) TransparentPaintImage(next,&transparent_color,
11095 TransparentAlpha,MagickFalse);
11096 for ( ; image; image=image->next)
11098 AddImageToRegistry(sv,image);
11100 av_push(av,sv_bless(rv,hv));
11103 exception=DestroyExceptionInfo(exception);
11104 ST(0)=av_reference;
11105 SvREFCNT_dec(perl_exception);
11109 InheritPerlException(exception,perl_exception);
11110 exception=DestroyExceptionInfo(exception);
11111 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11112 SvPOK_on(perl_exception);
11113 ST(0)=sv_2mortal(perl_exception);
11118 ###############################################################################
11126 ###############################################################################
11131 Image::Magick ref=NO_INIT
11169 PERL_UNUSED_VAR(ref);
11170 PERL_UNUSED_VAR(ix);
11171 exception=AcquireExceptionInfo();
11172 perl_exception=newSVpv("",0);
11176 if (sv_isobject(ST(0)) == 0)
11178 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11180 goto PerlException;
11182 reference=SvRV(ST(0));
11183 hv=SvSTASH(reference);
11185 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11187 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11188 if (image == (Image *) NULL)
11190 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11192 goto PerlException;
11194 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11199 for (i=2; i < items; i+=2)
11201 attribute=(char *) SvPV(ST(i-1),na);
11202 switch (*attribute)
11207 if (LocaleCompare(attribute,"frames") == 0)
11209 number_frames=SvIV(ST(i));
11212 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11224 image=MorphImages(image,number_frames,exception);
11225 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11226 goto PerlException;
11227 for ( ; image; image=image->next)
11229 AddImageToRegistry(sv,image);
11231 av_push(av,sv_bless(rv,hv));
11234 exception=DestroyExceptionInfo(exception);
11235 ST(0)=av_reference;
11236 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11240 InheritPerlException(exception,perl_exception);
11241 exception=DestroyExceptionInfo(exception);
11242 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11243 SvPOK_on(perl_exception);
11244 ST(0)=sv_2mortal(perl_exception);
11249 ###############################################################################
11257 ###############################################################################
11262 Image::Magick ref=NO_INIT
11290 PERL_UNUSED_VAR(ref);
11291 PERL_UNUSED_VAR(ix);
11292 exception=AcquireExceptionInfo();
11293 perl_exception=newSVpv("",0);
11295 if (sv_isobject(ST(0)) == 0)
11297 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11299 goto PerlException;
11301 reference=SvRV(ST(0));
11302 hv=SvSTASH(reference);
11303 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11304 if (image == (Image *) NULL)
11306 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11308 goto PerlException;
11310 image=MergeImageLayers(image,MosaicLayer,exception);
11312 Create blessed Perl array for the returned image.
11315 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11317 AddImageToRegistry(sv,image);
11319 av_push(av,sv_bless(rv,hv));
11321 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11322 (void) CopyMagickString(image->filename,info->image_info->filename,
11324 SetImageInfo(info->image_info,0,&image->exception);
11325 exception=DestroyExceptionInfo(exception);
11326 SvREFCNT_dec(perl_exception);
11330 InheritPerlException(exception,perl_exception);
11331 exception=DestroyExceptionInfo(exception);
11332 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11333 SvPOK_on(perl_exception); /* return messages in string context */
11334 ST(0)=sv_2mortal(perl_exception);
11339 ###############################################################################
11347 ###############################################################################
11352 Image::Magick ref=NO_INIT
11402 PERL_UNUSED_VAR(ref);
11403 PERL_UNUSED_VAR(ix);
11404 exception=AcquireExceptionInfo();
11405 perl_exception=newSVpv("",0);
11406 package_info=(struct PackageInfo *) NULL;
11407 ac=(items < 2) ? 1 : items-1;
11408 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11410 length=(STRLEN *) NULL;
11411 if (list == (char **) NULL)
11413 ThrowPerlException(exception,ResourceLimitError,
11414 "MemoryAllocationFailed",PackageName);
11415 goto PerlException;
11418 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11419 if (length == (STRLEN *) NULL)
11421 ThrowPerlException(exception,ResourceLimitError,
11422 "MemoryAllocationFailed",PackageName);
11423 goto PerlException;
11425 if (sv_isobject(ST(0)) == 0)
11427 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11429 goto PerlException;
11431 reference=SvRV(ST(0));
11432 if (SvTYPE(reference) != SVt_PVAV)
11434 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11436 goto PerlException;
11438 av=(AV *) reference;
11439 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11441 package_info=ClonePackageInfo(info,exception);
11444 *list=(char *) (*package_info->image_info->filename ?
11445 package_info->image_info->filename : "XC:black");
11447 for (n=0, i=0; i < ac; i++)
11449 list[n]=(char *) SvPV(ST(i+1),length[n]);
11450 if ((items >= 3) && strEQcase(list[n],"blob"))
11456 blob=(void *) (SvPV(ST(i+1),length[n]));
11457 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11459 if ((items >= 3) && strEQcase(list[n],"filename"))
11461 if ((items >= 3) && strEQcase(list[n],"file"))
11470 io_info=IoIFP(sv_2io(ST(i+1)));
11471 if (io_info == (PerlIO *) NULL)
11473 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11477 file=PerlIO_findFILE(io_info);
11478 if (file == (FILE *) NULL)
11480 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11484 SetImageInfoFile(package_info->image_info,file);
11486 if ((items >= 3) && strEQcase(list[n],"magick"))
11490 list[n]=(char *) NULL;
11492 status=ExpandFilenames(&n,&list);
11493 if (status == MagickFalse)
11495 ThrowPerlException(exception,ResourceLimitError,
11496 "MemoryAllocationFailed",PackageName);
11497 goto PerlException;
11500 for (i=0; i < n; i++)
11502 (void) CopyMagickString(package_info->image_info->filename,list[i],
11504 image=PingImage(package_info->image_info,exception);
11505 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11507 if ((package_info->image_info->file != (FILE *) NULL) ||
11508 (package_info->image_info->blob != (void *) NULL))
11509 DisassociateImageStream(image);
11510 count+=GetImageListLength(image);
11511 EXTEND(sp,4*count);
11512 for (next=image; next; next=next->next)
11514 PUSHs(sv_2mortal(newSViv(next->columns)));
11515 PUSHs(sv_2mortal(newSViv(next->rows)));
11516 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11517 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11519 image=DestroyImageList(image);
11524 for (i=0; i < n; i++)
11525 if (list[i] != (char *) NULL)
11526 for (p=keep; list[i] != *p++; )
11529 list[i]=(char *) RelinquishMagickMemory(list[i]);
11534 if (package_info != (struct PackageInfo *) NULL)
11535 DestroyPackageInfo(package_info);
11536 if (list && (list != keep))
11537 list=(char **) RelinquishMagickMemory(list);
11539 keep=(char **) RelinquishMagickMemory(keep);
11541 length=(STRLEN *) RelinquishMagickMemory(length);
11542 InheritPerlException(exception,perl_exception);
11543 exception=DestroyExceptionInfo(exception);
11544 SvREFCNT_dec(perl_exception); /* throw away all errors */
11548 ###############################################################################
11556 ###############################################################################
11561 Image::Magick ref=NO_INIT
11594 PERL_UNUSED_VAR(ref);
11595 PERL_UNUSED_VAR(ix);
11596 exception=AcquireExceptionInfo();
11597 perl_exception=newSVpv("",0);
11600 if (sv_isobject(ST(0)) == 0)
11602 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11604 goto PerlException;
11606 reference=SvRV(ST(0));
11607 hv=SvSTASH(reference);
11609 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11611 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11612 if (image == (Image *) NULL)
11614 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11616 goto PerlException;
11618 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11619 preview_type=GammaPreview;
11621 preview_type=(PreviewType)
11622 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11623 for ( ; image; image=image->next)
11625 preview_image=PreviewImage(image,preview_type,exception);
11626 if (preview_image == (Image *) NULL)
11627 goto PerlException;
11628 AddImageToRegistry(sv,preview_image);
11630 av_push(av,sv_bless(rv,hv));
11633 exception=DestroyExceptionInfo(exception);
11634 ST(0)=av_reference;
11635 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11639 InheritPerlException(exception,perl_exception);
11640 exception=DestroyExceptionInfo(exception);
11641 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11642 SvPOK_on(perl_exception);
11643 ST(0)=sv_2mortal(perl_exception);
11648 ###############################################################################
11652 # Q u e r y C o l o r #
11656 ###############################################################################
11660 QueryColor(ref,...)
11661 Image::Magick ref=NO_INIT
11681 PERL_UNUSED_VAR(ref);
11682 PERL_UNUSED_VAR(ix);
11683 exception=AcquireExceptionInfo();
11684 perl_exception=newSVpv("",0);
11693 colorlist=GetColorInfoList("*",&colors,exception);
11695 for (i=0; i < (ssize_t) colors; i++)
11697 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11699 colorlist=(const ColorInfo **)
11700 RelinquishMagickMemory((ColorInfo **) colorlist);
11701 goto PerlException;
11703 EXTEND(sp,5*items);
11704 for (i=1; i < items; i++)
11706 name=(char *) SvPV(ST(i),na);
11707 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11712 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11713 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11714 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11715 if (color.colorspace == CMYKColorspace)
11716 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11717 if (color.matte != MagickFalse)
11718 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11722 InheritPerlException(exception,perl_exception);
11723 exception=DestroyExceptionInfo(exception);
11724 SvREFCNT_dec(perl_exception);
11728 ###############################################################################
11732 # Q u e r y C o l o r N a m e #
11736 ###############################################################################
11740 QueryColorname(ref,...)
11741 Image::Magick ref=NO_INIT
11750 message[MaxTextExtent];
11769 *reference; /* reference is the SV* of ref=SvIV(reference) */
11771 PERL_UNUSED_VAR(ref);
11772 PERL_UNUSED_VAR(ix);
11773 exception=AcquireExceptionInfo();
11774 perl_exception=newSVpv("",0);
11775 reference=SvRV(ST(0));
11776 av=(AV *) reference;
11777 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11779 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11780 if (image == (Image *) NULL)
11782 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11784 goto PerlException;
11787 for (i=1; i < items; i++)
11789 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11790 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11792 PUSHs(sv_2mortal(newSVpv(message,0)));
11796 InheritPerlException(exception,perl_exception);
11797 exception=DestroyExceptionInfo(exception);
11798 SvREFCNT_dec(perl_exception);
11802 ###############################################################################
11806 # Q u e r y F o n t #
11810 ###############################################################################
11815 Image::Magick ref=NO_INIT
11822 message[MaxTextExtent];
11833 volatile const TypeInfo
11836 PERL_UNUSED_VAR(ref);
11837 PERL_UNUSED_VAR(ix);
11838 exception=AcquireExceptionInfo();
11839 perl_exception=newSVpv("",0);
11848 typelist=GetTypeInfoList("*",&types,exception);
11850 for (i=0; i < (ssize_t) types; i++)
11852 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11854 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11856 goto PerlException;
11858 EXTEND(sp,10*items);
11859 for (i=1; i < items; i++)
11861 name=(char *) SvPV(ST(i),na);
11862 type_info=GetTypeInfo(name,exception);
11863 if (type_info == (TypeInfo *) NULL)
11868 if (type_info->name == (char *) NULL)
11871 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11872 if (type_info->description == (char *) NULL)
11875 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11876 if (type_info->family == (char *) NULL)
11879 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11880 if (type_info->style == UndefinedStyle)
11883 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11884 type_info->style),0)));
11885 if (type_info->stretch == UndefinedStretch)
11888 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11889 type_info->stretch),0)));
11890 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11891 type_info->weight);
11892 PUSHs(sv_2mortal(newSVpv(message,0)));
11893 if (type_info->encoding == (char *) NULL)
11896 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11897 if (type_info->foundry == (char *) NULL)
11900 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11901 if (type_info->format == (char *) NULL)
11904 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11905 if (type_info->metrics == (char *) NULL)
11908 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11909 if (type_info->glyphs == (char *) NULL)
11912 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11916 InheritPerlException(exception,perl_exception);
11917 exception=DestroyExceptionInfo(exception);
11918 SvREFCNT_dec(perl_exception);
11922 ###############################################################################
11926 # Q u e r y F o n t M e t r i c s #
11930 ###############################################################################
11934 QueryFontMetrics(ref,...)
11935 Image::Magick ref=NO_INIT
11937 queryfontmetrics = 1
11984 *reference; /* reference is the SV* of ref=SvIV(reference) */
11989 PERL_UNUSED_VAR(ref);
11990 PERL_UNUSED_VAR(ix);
11991 exception=AcquireExceptionInfo();
11992 package_info=(struct PackageInfo *) NULL;
11993 perl_exception=newSVpv("",0);
11994 reference=SvRV(ST(0));
11995 av=(AV *) reference;
11996 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11998 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11999 if (image == (Image *) NULL)
12001 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12003 goto PerlException;
12005 package_info=ClonePackageInfo(info,exception);
12006 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12007 CloneString(&draw_info->text,"");
12008 current=draw_info->affine;
12009 GetAffineMatrix(&affine);
12012 EXTEND(sp,7*items);
12013 for (i=2; i < items; i+=2)
12015 attribute=(char *) SvPV(ST(i-1),na);
12016 switch (*attribute)
12021 if (LocaleCompare(attribute,"antialias") == 0)
12023 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12027 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12031 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12041 if (LocaleCompare(attribute,"density") == 0)
12043 CloneString(&draw_info->density,SvPV(ST(i),na));
12046 if (LocaleCompare(attribute,"direction") == 0)
12048 draw_info->direction=(DirectionType) ParseCommandOption(
12049 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12052 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12059 if (LocaleCompare(attribute,"encoding") == 0)
12061 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12064 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12071 if (LocaleCompare(attribute,"family") == 0)
12073 CloneString(&draw_info->family,SvPV(ST(i),na));
12076 if (LocaleCompare(attribute,"fill") == 0)
12079 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12080 &image->exception);
12083 if (LocaleCompare(attribute,"font") == 0)
12085 CloneString(&draw_info->font,SvPV(ST(i),na));
12088 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12095 if (LocaleCompare(attribute,"geometry") == 0)
12097 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12100 if (LocaleCompare(attribute,"gravity") == 0)
12102 draw_info->gravity=(GravityType) ParseCommandOption(
12103 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12106 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12113 if (LocaleCompare(attribute,"interline-spacing") == 0)
12115 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12116 draw_info->interline_spacing=geometry_info.rho;
12119 if (LocaleCompare(attribute,"interword-spacing") == 0)
12121 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12122 draw_info->interword_spacing=geometry_info.rho;
12125 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12132 if (LocaleCompare(attribute,"kerning") == 0)
12134 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12135 draw_info->kerning=geometry_info.rho;
12138 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12145 if (LocaleCompare(attribute,"pointsize") == 0)
12147 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12148 draw_info->pointsize=geometry_info.rho;
12151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12158 if (LocaleCompare(attribute,"rotate") == 0)
12160 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12161 affine.rx=geometry_info.rho;
12162 affine.ry=geometry_info.sigma;
12163 if ((flags & SigmaValue) == 0)
12164 affine.ry=affine.rx;
12167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12174 if (LocaleCompare(attribute,"scale") == 0)
12176 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12177 affine.sx=geometry_info.rho;
12178 affine.sy=geometry_info.sigma;
12179 if ((flags & SigmaValue) == 0)
12180 affine.sy=affine.sx;
12183 if (LocaleCompare(attribute,"skew") == 0)
12189 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12190 x_angle=geometry_info.rho;
12191 y_angle=geometry_info.sigma;
12192 if ((flags & SigmaValue) == 0)
12194 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12195 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12198 if (LocaleCompare(attribute,"stroke") == 0)
12201 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12202 &image->exception);
12205 if (LocaleCompare(attribute,"style") == 0)
12207 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12211 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12215 draw_info->style=(StyleType) type;
12218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12225 if (LocaleCompare(attribute,"text") == 0)
12227 CloneString(&draw_info->text,SvPV(ST(i),na));
12230 if (LocaleCompare(attribute,"translate") == 0)
12232 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12233 affine.tx=geometry_info.rho;
12234 affine.ty=geometry_info.sigma;
12235 if ((flags & SigmaValue) == 0)
12236 affine.ty=affine.tx;
12239 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12246 if (LocaleCompare(attribute,"weight") == 0)
12248 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12249 draw_info->weight=(size_t) geometry_info.rho;
12252 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12259 if (LocaleCompare(attribute,"x") == 0)
12261 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12262 x=geometry_info.rho;
12265 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12272 if (LocaleCompare(attribute,"y") == 0)
12274 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12275 y=geometry_info.rho;
12278 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12284 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12290 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12291 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12292 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12293 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12294 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12295 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12296 if (draw_info->geometry == (char *) NULL)
12298 draw_info->geometry=AcquireString((char *) NULL);
12299 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12300 "%.15g,%.15g",x,y);
12302 status=GetTypeMetrics(image,draw_info,&metrics);
12303 (void) CatchImageException(image);
12304 if (status == MagickFalse)
12308 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12309 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12310 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12311 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12312 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12313 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12314 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12315 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12316 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12317 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12318 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12319 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12320 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12322 draw_info=DestroyDrawInfo(draw_info);
12325 if (package_info != (struct PackageInfo *) NULL)
12326 DestroyPackageInfo(package_info);
12327 InheritPerlException(exception,perl_exception);
12328 exception=DestroyExceptionInfo(exception);
12329 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12333 ###############################################################################
12337 # 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 #
12341 ###############################################################################
12345 QueryMultilineFontMetrics(ref,...)
12346 Image::Magick ref=NO_INIT
12348 querymultilinefontmetrics = 1
12395 *reference; /* reference is the SV* of ref=SvIV(reference) */
12400 PERL_UNUSED_VAR(ref);
12401 PERL_UNUSED_VAR(ix);
12402 exception=AcquireExceptionInfo();
12403 package_info=(struct PackageInfo *) NULL;
12404 perl_exception=newSVpv("",0);
12405 reference=SvRV(ST(0));
12406 av=(AV *) reference;
12407 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12409 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12410 if (image == (Image *) NULL)
12412 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12414 goto PerlException;
12416 package_info=ClonePackageInfo(info,exception);
12417 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12418 CloneString(&draw_info->text,"");
12419 current=draw_info->affine;
12420 GetAffineMatrix(&affine);
12423 EXTEND(sp,7*items);
12424 for (i=2; i < items; i+=2)
12426 attribute=(char *) SvPV(ST(i-1),na);
12427 switch (*attribute)
12432 if (LocaleCompare(attribute,"antialias") == 0)
12434 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12438 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12442 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12445 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12452 if (LocaleCompare(attribute,"density") == 0)
12454 CloneString(&draw_info->density,SvPV(ST(i),na));
12457 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12464 if (LocaleCompare(attribute,"encoding") == 0)
12466 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12469 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12476 if (LocaleCompare(attribute,"family") == 0)
12478 CloneString(&draw_info->family,SvPV(ST(i),na));
12481 if (LocaleCompare(attribute,"fill") == 0)
12484 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12485 &image->exception);
12488 if (LocaleCompare(attribute,"font") == 0)
12490 CloneString(&draw_info->font,SvPV(ST(i),na));
12493 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12500 if (LocaleCompare(attribute,"geometry") == 0)
12502 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12505 if (LocaleCompare(attribute,"gravity") == 0)
12507 draw_info->gravity=(GravityType) ParseCommandOption(
12508 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12511 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12518 if (LocaleCompare(attribute,"pointsize") == 0)
12520 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12521 draw_info->pointsize=geometry_info.rho;
12524 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12531 if (LocaleCompare(attribute,"rotate") == 0)
12533 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12534 affine.rx=geometry_info.rho;
12535 affine.ry=geometry_info.sigma;
12536 if ((flags & SigmaValue) == 0)
12537 affine.ry=affine.rx;
12540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12547 if (LocaleCompare(attribute,"scale") == 0)
12549 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12550 affine.sx=geometry_info.rho;
12551 affine.sy=geometry_info.sigma;
12552 if ((flags & SigmaValue) == 0)
12553 affine.sy=affine.sx;
12556 if (LocaleCompare(attribute,"skew") == 0)
12562 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12563 x_angle=geometry_info.rho;
12564 y_angle=geometry_info.sigma;
12565 if ((flags & SigmaValue) == 0)
12567 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12568 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12571 if (LocaleCompare(attribute,"stroke") == 0)
12574 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12575 &image->exception);
12578 if (LocaleCompare(attribute,"style") == 0)
12580 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12584 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12588 draw_info->style=(StyleType) type;
12591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12598 if (LocaleCompare(attribute,"text") == 0)
12600 CloneString(&draw_info->text,SvPV(ST(i),na));
12603 if (LocaleCompare(attribute,"translate") == 0)
12605 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12606 affine.tx=geometry_info.rho;
12607 affine.ty=geometry_info.sigma;
12608 if ((flags & SigmaValue) == 0)
12609 affine.ty=affine.tx;
12612 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12619 if (LocaleCompare(attribute,"weight") == 0)
12621 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12622 draw_info->weight=(size_t) geometry_info.rho;
12625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12632 if (LocaleCompare(attribute,"x") == 0)
12634 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12635 x=geometry_info.rho;
12638 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12645 if (LocaleCompare(attribute,"y") == 0)
12647 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12648 y=geometry_info.rho;
12651 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12657 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12663 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12664 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12665 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12666 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12667 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12668 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12669 if (draw_info->geometry == (char *) NULL)
12671 draw_info->geometry=AcquireString((char *) NULL);
12672 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12673 "%.15g,%.15g",x,y);
12675 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12676 (void) CatchImageException(image);
12677 if (status == MagickFalse)
12681 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12682 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12683 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12684 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12685 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12686 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12687 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12688 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12689 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12690 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12691 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12692 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12693 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12695 draw_info=DestroyDrawInfo(draw_info);
12698 if (package_info != (struct PackageInfo *) NULL)
12699 DestroyPackageInfo(package_info);
12700 InheritPerlException(exception,perl_exception);
12701 exception=DestroyExceptionInfo(exception);
12702 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12706 ###############################################################################
12710 # Q u e r y F o r m a t #
12714 ###############################################################################
12718 QueryFormat(ref,...)
12719 Image::Magick ref=NO_INIT
12736 volatile const MagickInfo
12739 PERL_UNUSED_VAR(ref);
12740 PERL_UNUSED_VAR(ix);
12741 exception=AcquireExceptionInfo();
12742 perl_exception=newSVpv("",0);
12746 format[MaxTextExtent];
12754 format_list=GetMagickInfoList("*",&types,exception);
12756 for (i=0; i < (ssize_t) types; i++)
12758 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12759 LocaleLower(format);
12760 PUSHs(sv_2mortal(newSVpv(format,0)));
12762 format_list=(const MagickInfo **)
12763 RelinquishMagickMemory((MagickInfo *) format_list);
12764 goto PerlException;
12766 EXTEND(sp,8*items);
12767 for (i=1; i < items; i++)
12769 name=(char *) SvPV(ST(i),na);
12770 magick_info=GetMagickInfo(name,exception);
12771 if (magick_info == (const MagickInfo *) NULL)
12776 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12777 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12778 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12779 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12780 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12781 if (magick_info->description == (char *) NULL)
12784 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12785 if (magick_info->module == (char *) NULL)
12788 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12792 InheritPerlException(exception,perl_exception);
12793 exception=DestroyExceptionInfo(exception);
12794 SvREFCNT_dec(perl_exception);
12798 ###############################################################################
12802 # Q u e r y O p t i o n #
12806 ###############################################################################
12810 QueryOption(ref,...)
12811 Image::Magick ref=NO_INIT
12832 PERL_UNUSED_VAR(ref);
12833 PERL_UNUSED_VAR(ix);
12834 exception=AcquireExceptionInfo();
12835 perl_exception=newSVpv("",0);
12836 EXTEND(sp,8*items);
12837 for (i=1; i < items; i++)
12839 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12841 options=GetCommandOptions((CommandOption) option);
12842 if (options == (char **) NULL)
12846 for (j=0; options[j] != (char *) NULL; j++)
12847 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12848 options=DestroyStringList(options);
12852 InheritPerlException(exception,perl_exception);
12853 exception=DestroyExceptionInfo(exception);
12854 SvREFCNT_dec(perl_exception);
12858 ###############################################################################
12866 ###############################################################################
12871 Image::Magick ref=NO_INIT
12918 *perl_exception, /* Perl variable for storing messages */
12923 PERL_UNUSED_VAR(ref);
12924 PERL_UNUSED_VAR(ix);
12925 exception=AcquireExceptionInfo();
12926 perl_exception=newSVpv("",0);
12928 package_info=(struct PackageInfo *) NULL;
12930 ac=(items < 2) ? 1 : items-1;
12931 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12933 length=(STRLEN *) NULL;
12934 if (list == (char **) NULL)
12936 ThrowPerlException(exception,ResourceLimitError,
12937 "MemoryAllocationFailed",PackageName);
12938 goto PerlException;
12940 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12941 if (length == (STRLEN *) NULL)
12943 ThrowPerlException(exception,ResourceLimitError,
12944 "MemoryAllocationFailed",PackageName);
12945 goto PerlException;
12947 if (sv_isobject(ST(0)) == 0)
12949 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12951 goto PerlException;
12953 reference=SvRV(ST(0));
12954 hv=SvSTASH(reference);
12955 if (SvTYPE(reference) != SVt_PVAV)
12957 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12959 goto PerlException;
12961 av=(AV *) reference;
12962 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12964 package_info=ClonePackageInfo(info,exception);
12967 *list=(char *) (*package_info->image_info->filename ?
12968 package_info->image_info->filename : "XC:black");
12970 for (n=0, i=0; i < ac; i++)
12972 list[n]=(char *) SvPV(ST(i+1),length[n]);
12973 if ((items >= 3) && strEQcase(list[n],"blob"))
12979 blob=(void *) (SvPV(ST(i+1),length[n]));
12980 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12982 if ((items >= 3) && strEQcase(list[n],"filename"))
12984 if ((items >= 3) && strEQcase(list[n],"file"))
12993 io_info=IoIFP(sv_2io(ST(i+1)));
12994 if (io_info == (PerlIO *) NULL)
12996 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13000 file=PerlIO_findFILE(io_info);
13001 if (file == (FILE *) NULL)
13003 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13007 SetImageInfoFile(package_info->image_info,file);
13009 if ((items >= 3) && strEQcase(list[n],"magick"))
13013 list[n]=(char *) NULL;
13015 status=ExpandFilenames(&n,&list);
13016 if (status == MagickFalse)
13018 ThrowPerlException(exception,ResourceLimitError,
13019 "MemoryAllocationFailed",PackageName);
13020 goto PerlException;
13023 for (i=0; i < n; i++)
13025 if ((package_info->image_info->file != (FILE *) NULL) ||
13026 (package_info->image_info->blob != (void *) NULL))
13028 image=ReadImages(package_info->image_info,exception);
13029 if (image != (Image *) NULL)
13030 DisassociateImageStream(image);
13034 (void) CopyMagickString(package_info->image_info->filename,list[i],
13036 image=ReadImages(package_info->image_info,exception);
13038 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13040 for ( ; image; image=image->next)
13042 AddImageToRegistry(sv,image);
13044 av_push(av,sv_bless(rv,hv));
13052 for (i=0; i < n; i++)
13053 if (list[i] != (char *) NULL)
13054 for (p=keep; list[i] != *p++; )
13055 if (*p == (char *) NULL)
13057 list[i]=(char *) RelinquishMagickMemory(list[i]);
13062 if (package_info != (struct PackageInfo *) NULL)
13063 DestroyPackageInfo(package_info);
13064 if (list && (list != keep))
13065 list=(char **) RelinquishMagickMemory(list);
13067 keep=(char **) RelinquishMagickMemory(keep);
13069 length=(STRLEN *) RelinquishMagickMemory(length);
13070 InheritPerlException(exception,perl_exception);
13071 exception=DestroyExceptionInfo(exception);
13072 sv_setiv(perl_exception,(IV) number_images);
13073 SvPOK_on(perl_exception);
13074 ST(0)=sv_2mortal(perl_exception);
13079 ###############################################################################
13087 ###############################################################################
13092 Image::Magick ref=NO_INIT
13115 PERL_UNUSED_VAR(ref);
13116 PERL_UNUSED_VAR(ix);
13117 exception=AcquireExceptionInfo();
13118 perl_exception=newSVpv("",0);
13119 reference=SvRV(ST(0));
13120 av=(AV *) reference;
13121 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13123 for (i=1; i < items; i++)
13124 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13125 SvPV(ST(i),na),exception);
13126 InheritPerlException(exception,perl_exception);
13127 exception=DestroyExceptionInfo(exception);
13128 SvREFCNT_dec(perl_exception); /* throw away all errors */
13132 ###############################################################################
13140 ###############################################################################
13145 Image::Magick ref=NO_INIT
13168 *reference; /* reference is the SV* of ref=SvIV(reference) */
13170 PERL_UNUSED_VAR(ref);
13171 PERL_UNUSED_VAR(ix);
13172 exception=AcquireExceptionInfo();
13173 perl_exception=newSVpv("",0);
13174 if (sv_isobject(ST(0)) == 0)
13176 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13178 goto PerlException;
13180 reference=SvRV(ST(0));
13181 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13183 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13185 for (i=2; i < items; i+=2)
13186 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13189 InheritPerlException(exception,perl_exception);
13190 exception=DestroyExceptionInfo(exception);
13191 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13192 SvPOK_on(perl_exception);
13193 ST(0)=sv_2mortal(perl_exception);
13198 ###############################################################################
13202 # S e t P i x e l #
13206 ###############################################################################
13211 Image::Magick ref=NO_INIT
13252 *reference; /* reference is the SV* of ref=SvIV(reference) */
13254 PERL_UNUSED_VAR(ref);
13255 PERL_UNUSED_VAR(ix);
13256 exception=AcquireExceptionInfo();
13257 perl_exception=newSVpv("",0);
13258 reference=SvRV(ST(0));
13259 av=(AV *) reference;
13260 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13262 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13263 if (image == (Image *) NULL)
13265 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13267 goto PerlException;
13270 normalize=MagickTrue;
13273 region.width=image->columns;
13276 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13277 channel=DefaultChannels;
13278 for (i=2; i < items; i+=2)
13280 attribute=(char *) SvPV(ST(i-1),na);
13281 switch (*attribute)
13286 if (LocaleCompare(attribute,"channel") == 0)
13291 option=ParseChannelOption(SvPV(ST(i),na));
13294 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13298 channel=(ChannelType) option;
13301 if (LocaleCompare(attribute,"color") == 0)
13303 if (SvTYPE(ST(i)) != SVt_RV)
13306 message[MaxTextExtent];
13308 (void) FormatLocaleString(message,MaxTextExtent,
13309 "invalid %.60s value",attribute);
13310 ThrowPerlException(exception,OptionError,message,
13313 av=(AV *) SvRV(ST(i));
13316 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13323 if (LocaleCompare(attribute,"geometry") == 0)
13325 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13328 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13335 if (LocaleCompare(attribute,"normalize") == 0)
13337 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13341 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13345 normalize=option != 0 ? MagickTrue : MagickFalse;
13348 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13355 if (LocaleCompare(attribute,"x") == 0)
13357 region.x=SvIV(ST(i));
13360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13367 if (LocaleCompare(attribute,"y") == 0)
13369 region.y=SvIV(ST(i));
13372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13378 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13384 (void) SetImageStorageClass(image,DirectClass);
13385 PushPixelComponentMap(image,channel);
13386 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13387 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13388 (SvTYPE(av) != SVt_PVAV))
13400 if (normalize != MagickFalse)
13401 scale=QuantumRange;
13402 if (((GetPixelRedTraits(image) & ActivePixelTrait) != 0) &&
13405 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13406 av_fetch(av,i,0)))),q);
13409 if (((GetPixelGreenTraits(image) & ActivePixelTrait) != 0) &&
13412 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13413 av_fetch(av,i,0)))),q);
13416 if (((GetPixelBlueTraits(image) & ActivePixelTrait) != 0) &&
13419 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13420 av_fetch(av,i,0)))),q);
13423 if ((((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
13424 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13426 SetPixelBlack(image,ClampToQuantum(scale*
13427 SvNV(*(av_fetch(av,i,0)))),q);
13430 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) &&
13433 SetPixelAlpha(image,ClampToQuantum(scale*
13434 SvNV(*(av_fetch(av,i,0)))),q);
13437 (void) SyncAuthenticPixels(image,exception);
13439 PopPixelComponentMap(image);
13442 InheritPerlException(exception,perl_exception);
13443 exception=DestroyExceptionInfo(exception);
13444 SvREFCNT_dec(perl_exception);
13448 ###############################################################################
13456 ###############################################################################
13461 Image::Magick ref=NO_INIT
13500 PERL_UNUSED_VAR(ref);
13501 PERL_UNUSED_VAR(ix);
13502 exception=AcquireExceptionInfo();
13503 perl_exception=newSVpv("",0);
13507 if (sv_isobject(ST(0)) == 0)
13509 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13511 goto PerlException;
13513 reference=SvRV(ST(0));
13514 hv=SvSTASH(reference);
13516 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13519 if (image == (Image *) NULL)
13521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13523 goto PerlException;
13525 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13531 for (i=2; i < items; i+=2)
13533 attribute=(char *) SvPV(ST(i-1),na);
13534 switch (*attribute)
13539 if (LocaleCompare(attribute,"offset") == 0)
13541 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13551 if (LocaleCompare(attribute,"stack") == 0)
13553 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13557 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13563 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13569 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13575 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13577 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13578 goto PerlException;
13579 for ( ; image; image=image->next)
13581 AddImageToRegistry(sv,image);
13583 av_push(av,sv_bless(rv,hv));
13586 exception=DestroyExceptionInfo(exception);
13587 ST(0)=av_reference;
13588 SvREFCNT_dec(perl_exception);
13592 InheritPerlException(exception,perl_exception);
13593 exception=DestroyExceptionInfo(exception);
13594 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13595 SvPOK_on(perl_exception);
13596 ST(0)=sv_2mortal(perl_exception);
13601 ###############################################################################
13605 # S t a t i s t i c s #
13609 ###############################################################################
13613 Statistics(ref,...)
13614 Image::Magick ref=NO_INIT
13616 StatisticsImage = 1
13618 statisticsimage = 3
13621 #define ChannelStatistics(channel) \
13623 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13624 (double) channel_statistics[channel].depth); \
13625 PUSHs(sv_2mortal(newSVpv(message,0))); \
13626 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13627 channel_statistics[channel].minima/scale); \
13628 PUSHs(sv_2mortal(newSVpv(message,0))); \
13629 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13630 channel_statistics[channel].maxima/scale); \
13631 PUSHs(sv_2mortal(newSVpv(message,0))); \
13632 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13633 channel_statistics[channel].mean/scale); \
13634 PUSHs(sv_2mortal(newSVpv(message,0))); \
13635 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13636 channel_statistics[channel].standard_deviation/scale); \
13637 PUSHs(sv_2mortal(newSVpv(message,0))); \
13638 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13639 channel_statistics[channel].kurtosis); \
13640 PUSHs(sv_2mortal(newSVpv(message,0))); \
13641 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13642 channel_statistics[channel].skewness); \
13643 PUSHs(sv_2mortal(newSVpv(message,0))); \
13650 message[MaxTextExtent];
13653 *channel_statistics;
13674 PERL_UNUSED_VAR(ref);
13675 PERL_UNUSED_VAR(ix);
13676 exception=AcquireExceptionInfo();
13677 perl_exception=newSVpv("",0);
13679 if (sv_isobject(ST(0)) == 0)
13681 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13683 goto PerlException;
13685 reference=SvRV(ST(0));
13688 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13689 if (image == (Image *) NULL)
13691 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13693 goto PerlException;
13695 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13697 for ( ; image; image=image->next)
13699 channel_statistics=GetImageStatistics(image,&image->exception);
13700 if (channel_statistics == (ChannelStatistics *) NULL)
13703 EXTEND(sp,35*count);
13704 scale=(double) QuantumRange;
13705 ChannelStatistics(RedChannel);
13706 ChannelStatistics(GreenChannel);
13707 ChannelStatistics(BlueChannel);
13708 if (image->colorspace == CMYKColorspace)
13709 ChannelStatistics(BlackChannel);
13710 if (image->matte != MagickFalse)
13711 ChannelStatistics(AlphaChannel);
13712 channel_statistics=(ChannelStatistics *)
13713 RelinquishMagickMemory(channel_statistics);
13717 InheritPerlException(exception,perl_exception);
13718 exception=DestroyExceptionInfo(exception);
13719 SvREFCNT_dec(perl_exception);
13723 ###############################################################################
13727 # S y n c A u t h e n t i c P i x e l s #
13731 ###############################################################################
13735 SyncAuthenticPixels(ref,...)
13736 Image::Magick ref = NO_INIT
13738 Syncauthenticpixels = 1
13739 SyncImagePixels = 2
13740 syncimagepixels = 3
13759 PERL_UNUSED_VAR(ref);
13760 PERL_UNUSED_VAR(ix);
13761 exception=AcquireExceptionInfo();
13762 perl_exception=newSVpv("",0);
13763 if (sv_isobject(ST(0)) == 0)
13765 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13767 goto PerlException;
13770 reference=SvRV(ST(0));
13771 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13772 if (image == (Image *) NULL)
13774 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13776 goto PerlException;
13779 status=SyncAuthenticPixels(image,exception);
13780 if (status != MagickFalse)
13782 InheritException(exception,&image->exception);
13785 InheritPerlException(exception,perl_exception);
13786 exception=DestroyExceptionInfo(exception);
13787 SvREFCNT_dec(perl_exception); /* throw away all errors */
13791 ###############################################################################
13795 # T r a n s f o r m #
13799 ###############################################################################
13804 Image::Magick ref=NO_INIT
13842 PERL_UNUSED_VAR(ref);
13843 PERL_UNUSED_VAR(ix);
13844 exception=AcquireExceptionInfo();
13845 perl_exception=newSVpv("",0);
13849 if (sv_isobject(ST(0)) == 0)
13851 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13853 goto PerlException;
13855 reference=SvRV(ST(0));
13856 hv=SvSTASH(reference);
13858 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13860 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13861 if (image == (Image *) NULL)
13863 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13865 goto PerlException;
13867 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13871 crop_geometry=(char *) NULL;
13872 geometry=(char *) NULL;
13873 for (i=2; i < items; i+=2)
13875 attribute=(char *) SvPV(ST(i-1),na);
13876 switch (*attribute)
13881 if (LocaleCompare(attribute,"crop") == 0)
13883 crop_geometry=SvPV(ST(i),na);
13886 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13893 if (LocaleCompare(attribute,"geometry") == 0)
13895 geometry=SvPV(ST(i),na);
13898 if (LocaleCompare(attribute,"gravity") == 0)
13906 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13907 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13910 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13914 for (next=image; next; next=next->next)
13915 next->gravity=(GravityType) in;
13918 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13924 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13930 for ( ; image; image=image->next)
13932 clone=CloneImage(image,0,0,MagickTrue,exception);
13933 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13934 goto PerlException;
13935 TransformImage(&clone,crop_geometry,geometry);
13936 for ( ; clone; clone=clone->next)
13938 AddImageToRegistry(sv,clone);
13940 av_push(av,sv_bless(rv,hv));
13944 exception=DestroyExceptionInfo(exception);
13945 ST(0)=av_reference;
13946 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13950 InheritPerlException(exception,perl_exception);
13951 exception=DestroyExceptionInfo(exception);
13952 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13953 SvPOK_on(perl_exception);
13954 ST(0)=sv_2mortal(perl_exception);
13959 ###############################################################################
13967 ###############################################################################
13972 Image::Magick ref=NO_INIT
13980 filename[MaxTextExtent];
14004 PERL_UNUSED_VAR(ref);
14005 PERL_UNUSED_VAR(ix);
14006 exception=AcquireExceptionInfo();
14007 perl_exception=newSVpv("",0);
14009 package_info=(struct PackageInfo *) NULL;
14010 if (sv_isobject(ST(0)) == 0)
14012 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14014 goto PerlException;
14016 reference=SvRV(ST(0));
14017 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14018 if (image == (Image *) NULL)
14020 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14022 goto PerlException;
14024 package_info=ClonePackageInfo(info,exception);
14026 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14029 for (i=2; i < items; i+=2)
14030 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14032 (void) CopyMagickString(filename,package_info->image_info->filename,
14035 for (next=image; next; next=next->next)
14037 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14038 next->scene=scene++;
14040 SetImageInfo(package_info->image_info,(unsigned int)
14041 GetImageListLength(image),&image->exception);
14042 for (next=image; next; next=next->next)
14044 (void) WriteImage(package_info->image_info,next);
14045 if (next->exception.severity >= ErrorException)
14046 InheritException(exception,&next->exception);
14047 GetImageException(next,exception);
14049 if (package_info->image_info->adjoin)
14054 if (package_info != (struct PackageInfo *) NULL)
14055 DestroyPackageInfo(package_info);
14056 InheritPerlException(exception,perl_exception);
14057 exception=DestroyExceptionInfo(exception);
14058 sv_setiv(perl_exception,(IV) number_images);
14059 SvPOK_on(perl_exception);
14060 ST(0)=sv_2mortal(perl_exception);