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-2013 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.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv(PTR2IV(image)); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
218 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
219 {"height", IntegerReference}, {"x", IntegerReference},
220 {"y", IntegerReference} } },
221 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
222 {"height", IntegerReference}, {"x", IntegerReference},
223 {"y", IntegerReference}, {"fuzz", StringReference},
224 {"gravity", MagickGravityOptions} } },
226 { "Edge", { {"radius", RealReference} } },
227 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
228 {"sigma", RealReference} } },
232 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
233 {"height", IntegerReference}, {"inner", IntegerReference},
234 {"outer", IntegerReference}, {"fill", StringReference},
235 {"color", StringReference}, {"compose", MagickComposeOptions} } },
236 { "Implode", { {"amount", RealReference},
237 {"interpolate", MagickInterpolateOptions} } },
239 { "MedianFilter", { {"geometry", StringReference},
240 {"width", IntegerReference}, {"height", IntegerReference},
241 {"channel", MagickChannelOptions} } },
243 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
244 { "ReduceNoise", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
247 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
248 {"y", IntegerReference} } },
249 { "Rotate", { {"degrees", RealReference},
250 {"background", StringReference} } },
251 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
252 {"height", IntegerReference} } },
253 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
254 {"height", IntegerReference} } },
255 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
256 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
257 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
258 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
259 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
260 {"y", RealReference}, { "fill", StringReference},
261 {"color", StringReference} } },
262 { "Spread", { {"radius", RealReference},
263 {"interpolate", MagickInterpolateOptions} } },
264 { "Swirl", { {"degrees", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
267 {"height", IntegerReference}, {"filter", MagickFilterOptions},
268 {"support", StringReference } } },
269 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", RealReference } } },
272 { "Annotate", { {"text", StringReference}, {"font", StringReference},
273 {"pointsize", RealReference}, {"density", StringReference},
274 {"undercolor", StringReference}, {"stroke", StringReference},
275 {"fill", StringReference}, {"geometry", StringReference},
276 {"sans", StringReference}, {"x", RealReference},
277 {"y", RealReference}, {"gravity", MagickGravityOptions},
278 {"translate", StringReference}, {"scale", StringReference},
279 {"rotate", RealReference}, {"skewX", RealReference},
280 {"skewY", RealReference}, {"strokewidth", RealReference},
281 {"antialias", MagickBooleanOptions}, {"family", StringReference},
282 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
283 {"weight", IntegerReference}, {"align", MagickAlignOptions},
284 {"encoding", StringReference}, {"affine", ArrayReference},
285 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
286 {"tile", ImageReference}, {"kerning", RealReference},
287 {"interline-spacing", RealReference},
288 {"interword-spacing", RealReference},
289 {"direction", MagickDirectionOptions} } },
290 { "ColorFloodfill", { {"geometry", StringReference},
291 {"x", IntegerReference}, {"y", IntegerReference},
292 {"fill", StringReference}, {"bordercolor", StringReference},
293 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
294 { "Composite", { {"image", ImageReference},
295 {"compose", MagickComposeOptions}, {"geometry", StringReference},
296 {"x", IntegerReference}, {"y", IntegerReference},
297 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
298 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
299 {"color", StringReference}, {"mask", ImageReference},
300 {"channel", MagickChannelOptions},
301 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
302 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
303 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
304 { "CycleColormap", { {"display", IntegerReference} } },
305 { "Draw", { {"primitive", MagickPrimitiveOptions},
306 {"points", StringReference}, {"method", MagickMethodOptions},
307 {"stroke", StringReference}, {"fill", StringReference},
308 {"strokewidth", RealReference}, {"font", StringReference},
309 {"bordercolor", StringReference}, {"x", RealReference},
310 {"y", RealReference}, {"translate", StringReference},
311 {"scale", StringReference}, {"rotate", RealReference},
312 {"skewX", RealReference}, {"skewY", RealReference},
313 {"tile", ImageReference}, {"pointsize", RealReference},
314 {"antialias", MagickBooleanOptions}, {"density", StringReference},
315 {"linewidth", RealReference}, {"affine", ArrayReference},
316 {"stroke-dashoffset", RealReference},
317 {"stroke-dasharray", ArrayReference},
318 {"interpolate", MagickInterpolateOptions},
319 {"origin", StringReference}, {"text", StringReference},
320 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
321 {"vector-graphics", StringReference}, {"kerning", RealReference},
322 {"interline-spacing", RealReference},
323 {"interword-spacing", RealReference},
324 {"direction", MagickDirectionOptions} } },
325 { "Equalize", { {"channel", MagickChannelOptions} } },
326 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
327 {"red", RealReference}, {"green", RealReference},
328 {"blue", RealReference} } },
329 { "Map", { {"image", ImageReference},
330 {"dither-method", MagickDitherOptions} } },
331 { "MatteFloodfill", { {"geometry", StringReference},
332 {"x", IntegerReference}, {"y", IntegerReference},
333 {"opacity", StringReference}, {"bordercolor", StringReference},
334 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
335 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
336 {"saturation", RealReference}, {"whiteness", RealReference},
337 {"brightness", RealReference}, {"lightness", RealReference},
338 {"blackness", RealReference} } },
339 { "Negate", { {"gray", MagickBooleanOptions},
340 {"channel", MagickChannelOptions} } },
341 { "Normalize", { {"channel", MagickChannelOptions} } },
343 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
344 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
345 {"invert", MagickBooleanOptions} } },
346 { "Quantize", { {"colors", IntegerReference},
347 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
348 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
349 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
350 {"dither-method", MagickDitherOptions} } },
351 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
352 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
353 { "Segment", { {"geometry", StringReference},
354 {"cluster-threshold", RealReference},
355 {"smoothing-threshold", RealReference},
356 {"colorspace", MagickColorspaceOptions},
357 {"verbose", MagickBooleanOptions} } },
359 { "Solarize", { {"geometry", StringReference},
360 {"threshold", StringReference} } },
362 { "Texture", { {"texture", ImageReference} } },
363 { "Evaluate", { {"value", RealReference},
364 {"operator", MagickEvaluateOptions},
365 {"channel", MagickChannelOptions} } },
366 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
367 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
368 { "Threshold", { {"threshold", StringReference},
369 {"channel", MagickChannelOptions} } },
370 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
371 {"sigma", RealReference} } },
372 { "Trim", { {"fuzz", StringReference} } },
373 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
374 {"wavelength", RealReference},
375 {"interpolate", MagickInterpolateOptions} } },
376 { "Separate", { {"channel", MagickChannelOptions} } },
378 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
379 {"y", IntegerReference} } },
380 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
382 { "GaussianBlur", { {"geometry", StringReference},
383 {"radius", RealReference}, {"sigma", RealReference},
384 {"channel", MagickChannelOptions} } },
385 { "Convolve", { {"coefficients", ArrayReference},
386 {"channel", MagickChannelOptions}, {"bias", StringReference},
387 {"kernel", StringReference} } },
388 { "Profile", { {"name", StringReference}, {"profile", StringReference},
389 { "rendering-intent", MagickIntentOptions},
390 { "black-point-compensation", MagickBooleanOptions} } },
391 { "UnsharpMask", { {"geometry", StringReference},
392 {"radius", RealReference}, {"sigma", RealReference},
393 {"amount", RealReference}, {"threshold", RealReference},
394 {"channel", MagickChannelOptions} } },
395 { "MotionBlur", { {"geometry", StringReference},
396 {"radius", RealReference}, {"sigma", RealReference},
397 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
398 { "OrderedDither", { {"threshold", StringReference},
399 {"channel", MagickChannelOptions} } },
400 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
401 {"height", IntegerReference} } },
402 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
403 {"white-point", RealReference}, {"gamma", RealReference},
404 {"channel", MagickChannelOptions}, {"level", StringReference} } },
405 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
406 { "AffineTransform", { {"affine", ArrayReference},
407 {"translate", StringReference}, {"scale", StringReference},
408 {"rotate", RealReference}, {"skewX", RealReference},
409 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
410 {"background", StringReference} } },
411 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
412 { "AdaptiveThreshold", { {"geometry", StringReference},
413 {"width", IntegerReference}, {"height", IntegerReference} } },
414 { "Resample", { {"density", StringReference}, {"x", RealReference},
415 {"y", RealReference}, {"filter", MagickFilterOptions},
416 {"support", RealReference } } },
417 { "Describe", { {"file", FileReference} } },
418 { "BlackThreshold", { {"threshold", StringReference},
419 {"channel", MagickChannelOptions} } },
420 { "WhiteThreshold", { {"threshold", StringReference},
421 {"channel", MagickChannelOptions} } },
422 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
423 {"channel", MagickChannelOptions} } },
424 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
425 {"height", IntegerReference} } },
427 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
428 { "Channel", { {"channel", MagickChannelOptions} } },
429 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
430 {"height", IntegerReference}, {"x", IntegerReference},
431 {"y", IntegerReference}, {"fuzz", StringReference},
432 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
433 { "Posterize", { {"levels", IntegerReference},
434 {"dither", MagickBooleanOptions} } },
435 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
436 {"sigma", RealReference}, {"x", IntegerReference},
437 {"y", IntegerReference} } },
438 { "Identify", { {"file", FileReference}, {"features", StringReference},
439 {"unique", MagickBooleanOptions} } },
440 { "SepiaTone", { {"threshold", RealReference} } },
441 { "SigmoidalContrast", { {"geometry", StringReference},
442 {"contrast", RealReference}, {"mid-point", RealReference},
443 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
444 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
445 {"height", IntegerReference}, {"x", IntegerReference},
446 {"y", IntegerReference}, {"fuzz", StringReference},
447 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
448 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
449 {"sigma", RealReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"background", StringReference} } },
451 { "ContrastStretch", { {"levels", StringReference},
452 {"black-point", RealReference},{"white-point", RealReference},
453 {"channel", MagickChannelOptions} } },
456 { "AdaptiveSharpen", { {"geometry", StringReference},
457 {"radius", RealReference}, {"sigma", RealReference},
458 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
462 { "AdaptiveBlur", { {"geometry", StringReference},
463 {"radius", RealReference}, {"sigma", RealReference},
464 {"channel", MagickChannelOptions} } },
465 { "Sketch", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"angle", RealReference} } },
469 { "AdaptiveResize", { {"geometry", StringReference},
470 {"width", IntegerReference}, {"height", IntegerReference},
471 {"filter", MagickFilterOptions}, {"support", StringReference },
472 {"blur", RealReference } } },
473 { "ClipMask", { {"mask", ImageReference} } },
474 { "LinearStretch", { {"levels", StringReference},
475 {"black-point", RealReference},{"white-point", RealReference} } },
476 { "ColorMatrix", { {"matrix", ArrayReference} } },
477 { "Mask", { {"mask", ImageReference} } },
478 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
479 {"font", StringReference}, {"stroke", StringReference},
480 {"fill", StringReference}, {"strokewidth", RealReference},
481 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
482 {"background", StringReference},
483 {"interpolate", MagickInterpolateOptions} } },
484 { "FloodfillPaint", { {"geometry", StringReference},
485 {"x", IntegerReference}, {"y", IntegerReference},
486 {"fill", StringReference}, {"bordercolor", StringReference},
487 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
488 {"invert", MagickBooleanOptions} } },
489 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
490 {"virtual-pixel", MagickVirtualPixelOptions},
491 {"best-fit", MagickBooleanOptions} } },
492 { "Clut", { {"image", ImageReference},
493 {"interpolate", MagickInterpolateOptions},
494 {"channel", MagickChannelOptions} } },
495 { "LiquidRescale", { {"geometry", StringReference},
496 {"width", IntegerReference}, {"height", IntegerReference},
497 {"delta-x", RealReference}, {"rigidity", RealReference } } },
498 { "Encipher", { {"passphrase", StringReference} } },
499 { "Decipher", { {"passphrase", StringReference} } },
500 { "Deskew", { {"geometry", StringReference},
501 {"threshold", StringReference} } },
502 { "Remap", { {"image", ImageReference},
503 {"dither-method", MagickDitherOptions} } },
504 { "SparseColor", { {"points", ArrayReference},
505 {"method", MagickSparseColorOptions},
506 {"virtual-pixel", MagickVirtualPixelOptions},
507 {"channel", MagickChannelOptions} } },
508 { "Function", { {"parameters", ArrayReference},
509 {"function", MagickFunctionOptions},
510 {"virtual-pixel", MagickVirtualPixelOptions} } },
511 { "SelectiveBlur", { {"geometry", StringReference},
512 {"radius", RealReference}, {"sigma", RealReference},
513 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
514 { "HaldClut", { {"image", ImageReference},
515 {"channel", MagickChannelOptions} } },
516 { "BlueShift", { {"factor", StringReference} } },
517 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
518 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "ColorDecisionList", {
520 {"color-correction-collection", StringReference} } },
521 { "AutoGamma", { {"channel", MagickChannelOptions} } },
522 { "AutoLevel", { {"channel", MagickChannelOptions} } },
523 { "LevelColors", { {"invert", MagickBooleanOptions},
524 {"black-point", StringReference}, {"white-point", StringReference},
525 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
526 { "Clamp", { {"channel", MagickChannelOptions} } },
527 { "BrightnessContrast", { {"levels", StringReference},
528 {"brightness", RealReference},{"contrast", RealReference},
529 {"channel", MagickChannelOptions} } },
530 { "Morphology", { {"kernel", StringReference},
531 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
532 {"iterations", IntegerReference} } },
533 { "Sans", { {"matrix", ArrayReference} } },
534 { "Color", { {"color", StringReference} } },
535 { "Mode", { {"geometry", StringReference},
536 {"width", IntegerReference},{"height", IntegerReference},
537 {"channel", MagickChannelOptions} } },
538 { "Statistic", { {"geometry", StringReference},
539 {"width", IntegerReference},{"height", IntegerReference},
540 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
541 { "Perceptible", { {"epsilon", RealReference},
542 {"channel", MagickChannelOptions} } },
543 { "Poly", { {"terms", ArrayReference},
544 {"channel", MagickChannelOptions} } }
548 *magick_registry = (SplayTreeInfo *) NULL;
551 Forward declarations.
554 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
557 strEQcase(const char *,const char *);
560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 % C l o n e P a c k a g e I n f o %
568 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
573 % The format of the ClonePackageInfo routine is:
575 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
578 % A description of each parameter follows:
580 % o info: a structure of type info.
582 % o exception: Return any errors or warnings in this structure.
585 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
586 ExceptionInfo *exception)
591 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
592 if (clone_info == (struct PackageInfo *) NULL)
594 ThrowPerlException(exception,ResourceLimitError,
595 "UnableToClonePackageInfo",PackageName);
596 return((struct PackageInfo *) NULL);
598 if (info == (struct PackageInfo *) NULL)
600 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
604 clone_info->image_info=CloneImageInfo(info->image_info);
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 % constant() returns a double value for the specified name.
621 % The format of the constant routine is:
623 % double constant(char *name,ssize_t sans)
625 % A description of each parameter follows:
627 % o value: Method constant returns a double value for the specified name.
629 % o name: The name of the constant.
631 % o sans: This integer value is not used.
634 static double constant(char *name,ssize_t sans)
642 if (strEQ(name,"BlobError"))
644 if (strEQ(name,"BlobWarning"))
650 if (strEQ(name,"CacheError"))
652 if (strEQ(name,"CacheWarning"))
653 return(CacheWarning);
654 if (strEQ(name,"CoderError"))
656 if (strEQ(name,"CoderWarning"))
657 return(CoderWarning);
658 if (strEQ(name,"ConfigureError"))
659 return(ConfigureError);
660 if (strEQ(name,"ConfigureWarning"))
661 return(ConfigureWarning);
662 if (strEQ(name,"CorruptImageError"))
663 return(CorruptImageError);
664 if (strEQ(name,"CorruptImageWarning"))
665 return(CorruptImageWarning);
670 if (strEQ(name,"DelegateError"))
671 return(DelegateError);
672 if (strEQ(name,"DelegateWarning"))
673 return(DelegateWarning);
674 if (strEQ(name,"DrawError"))
676 if (strEQ(name,"DrawWarning"))
682 if (strEQ(name,"ErrorException"))
683 return(ErrorException);
684 if (strEQ(name,"ExceptionError"))
686 if (strEQ(name,"ExceptionWarning"))
687 return(CoderWarning);
692 if (strEQ(name,"FatalErrorException"))
693 return(FatalErrorException);
694 if (strEQ(name,"FileOpenError"))
695 return(FileOpenError);
696 if (strEQ(name,"FileOpenWarning"))
697 return(FileOpenWarning);
702 if (strEQ(name,"ImageError"))
704 if (strEQ(name,"ImageWarning"))
705 return(ImageWarning);
710 if (strEQ(name,"MaxRGB"))
711 return(QuantumRange);
712 if (strEQ(name,"MissingDelegateError"))
713 return(MissingDelegateError);
714 if (strEQ(name,"MissingDelegateWarning"))
715 return(MissingDelegateWarning);
716 if (strEQ(name,"ModuleError"))
718 if (strEQ(name,"ModuleWarning"))
719 return(ModuleWarning);
724 if (strEQ(name,"Opaque"))
726 if (strEQ(name,"OptionError"))
728 if (strEQ(name,"OptionWarning"))
729 return(OptionWarning);
734 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
735 return(MAGICKCORE_QUANTUM_DEPTH);
736 if (strEQ(name,"QuantumDepth"))
737 return(MAGICKCORE_QUANTUM_DEPTH);
738 if (strEQ(name,"QuantumRange"))
739 return(QuantumRange);
744 if (strEQ(name,"ResourceLimitError"))
745 return(ResourceLimitError);
746 if (strEQ(name,"ResourceLimitWarning"))
747 return(ResourceLimitWarning);
748 if (strEQ(name,"RegistryError"))
749 return(RegistryError);
750 if (strEQ(name,"RegistryWarning"))
751 return(RegistryWarning);
756 if (strEQ(name,"StreamError"))
758 if (strEQ(name,"StreamWarning"))
759 return(StreamWarning);
760 if (strEQ(name,"Success"))
766 if (strEQ(name,"Transparent"))
767 return(TransparentAlpha);
768 if (strEQ(name,"TypeError"))
770 if (strEQ(name,"TypeWarning"))
776 if (strEQ(name,"WarningException"))
777 return(WarningException);
782 if (strEQ(name,"XServerError"))
783 return(XServerError);
784 if (strEQ(name,"XServerWarning"))
785 return(XServerWarning);
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 % D e s t r o y P a c k a g e I n f o %
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804 % Method DestroyPackageInfo frees a previously created info structure.
806 % The format of the DestroyPackageInfo routine is:
808 % DestroyPackageInfo(struct PackageInfo *info)
810 % A description of each parameter follows:
812 % o info: a structure of type info.
815 static void DestroyPackageInfo(struct PackageInfo *info)
817 info->image_info=DestroyImageInfo(info->image_info);
818 info=(struct PackageInfo *) RelinquishMagickMemory(info);
822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % Method GetList is recursively called by SetupList to traverse the
833 % Image__Magick reference. If building an reference_vector (see SetupList),
834 % *current is the current position in *reference_vector and *last is the final
835 % entry in *reference_vector.
837 % The format of the GetList routine is:
841 % A description of each parameter follows:
843 % o info: a structure of type info.
846 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
847 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
852 if (reference == (SV *) NULL)
854 switch (SvTYPE(reference))
874 previous=(Image *) NULL;
878 for (i=0; i <= n; i++)
884 if (rv && *rv && sv_isobject(*rv))
886 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
888 if (image == (Image *) NULL)
890 if (image == previous)
892 image=CloneImage(image,0,0,MagickTrue,exception);
893 if (image == (Image *) NULL)
896 image->previous=previous;
897 *(previous ? &previous->next : &head)=image;
898 for (previous=image; previous->next; previous=previous->next) ;
906 Blessed scalar, one image.
908 image=INT2PTR(Image *,SvIV(reference));
909 if (image == (Image *) NULL)
911 image->previous=(Image *) NULL;
912 image->next=(Image *) NULL;
913 if (reference_vector)
915 if (*current == *last)
918 if (*reference_vector == (SV **) NULL)
919 *reference_vector=(SV **) AcquireQuantumMemory(*last,
920 sizeof(*reference_vector));
922 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
923 *last,sizeof(*reference_vector));
925 if (*reference_vector == (SV **) NULL)
927 ThrowPerlException(exception,ResourceLimitError,
928 "MemoryAllocationFailed",PackageName);
929 return((Image *) NULL);
931 (*reference_vector)[*current]=reference;
932 (*reference_vector)[++(*current)]=NULL;
939 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
940 (double) SvTYPE(reference));
941 return((Image *) NULL);
945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
949 % G e t P a c k a g e I n f o %
953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
955 % Method GetPackageInfo looks up or creates an info structure for the given
956 % Image__Magick reference. If it does create a new one, the information in
957 % package_info is used to initialize it.
959 % The format of the GetPackageInfo routine is:
961 % struct PackageInfo *GetPackageInfo(void *reference,
962 % struct PackageInfo *package_info,ExceptionInfo *exception)
964 % A description of each parameter follows:
966 % o info: a structure of type info.
968 % o exception: Return any errors or warnings in this structure.
971 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
972 struct PackageInfo *package_info,ExceptionInfo *exception)
975 message[MaxTextExtent];
983 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
984 PackageName,XS_VERSION,reference);
985 sv=perl_get_sv(message,(TRUE | 0x02));
986 if (sv == (SV *) NULL)
988 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
990 return(package_info);
992 if (SvREFCNT(sv) == 0)
993 (void) SvREFCNT_inc(sv);
994 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
996 clone_info=ClonePackageInfo(package_info,exception);
997 sv_setiv(sv,PTR2IV(clone_info));
1002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 % S e t A t t r i b u t e %
1010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 % SetAttribute() sets the attribute to the value in sval. This can change
1013 % either or both of image or info.
1015 % The format of the SetAttribute routine is:
1017 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1018 % SV *sval,ExceptionInfo *exception)
1020 % A description of each parameter follows:
1022 % o list: a list of strings.
1024 % o string: a character string.
1028 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1036 value=InterpretSiPrefixValue(string,&q);
1038 value*=interval/100.0;
1042 static inline double StringToDouble(const char *string,char **sentinal)
1044 return(InterpretLocaleValue(string,sentinal));
1047 static double StringToDoubleInterval(const char *string,const double interval)
1055 value=InterpretLocaleValue(string,&q);
1057 value*=interval/100.0;
1061 static inline ssize_t StringToLong(const char *value)
1063 return(strtol(value,(char **) NULL,10));
1066 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1067 const char *attribute,SV *sval,ExceptionInfo *exception)
1094 if (LocaleCompare(attribute,"adjoin") == 0)
1096 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1097 SvPV(sval,na)) : SvIV(sval);
1100 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1105 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1108 if (LocaleCompare(attribute,"alpha") == 0)
1110 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1111 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1114 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1118 for ( ; image; image=image->next)
1119 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1123 if (LocaleCompare(attribute,"antialias") == 0)
1125 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1126 SvPV(sval,na)) : SvIV(sval);
1129 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1134 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1137 if (LocaleCompare(attribute,"area-limit") == 0)
1142 limit=MagickResourceInfinity;
1143 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1144 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1146 (void) SetMagickResourceLimit(AreaResource,limit);
1149 if (LocaleCompare(attribute,"attenuate") == 0)
1152 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1155 if (LocaleCompare(attribute,"authenticate") == 0)
1158 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1162 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1163 for ( ; image; image=image->next)
1164 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1170 if (LocaleCompare(attribute,"background") == 0)
1172 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1175 info->image_info->background_color=target_color;
1176 for ( ; image; image=image->next)
1177 image->background_color=target_color;
1180 if (LocaleCompare(attribute,"blue-primary") == 0)
1182 for ( ; image; image=image->next)
1184 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1185 image->chromaticity.blue_primary.x=geometry_info.rho;
1186 image->chromaticity.blue_primary.y=geometry_info.sigma;
1187 if ((flags & SigmaValue) == 0)
1188 image->chromaticity.blue_primary.y=
1189 image->chromaticity.blue_primary.x;
1193 if (LocaleCompare(attribute,"bordercolor") == 0)
1195 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1198 info->image_info->border_color=target_color;
1199 for ( ; image; image=image->next)
1200 image->border_color=target_color;
1204 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1205 for ( ; image; image=image->next)
1206 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1212 if (LocaleCompare(attribute,"cache-threshold") == 0)
1214 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1215 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1216 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1217 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1220 if (LocaleCompare(attribute,"clip-mask") == 0)
1225 clip_mask=(Image *) NULL;
1227 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1228 for ( ; image; image=image->next)
1229 SetImageMask(image,clip_mask,exception);
1232 if (LocaleNCompare(attribute,"colormap",8) == 0)
1234 for ( ; image; image=image->next)
1242 if (image->storage_class == DirectClass)
1245 items=sscanf(attribute,"%*[^[][%ld",&i);
1247 if (i > (ssize_t) image->colors)
1249 if ((strchr(SvPV(sval,na),',') == 0) ||
1250 (strchr(SvPV(sval,na),')') != 0))
1251 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1252 image->colormap+i,exception);
1255 color=image->colormap+i;
1256 pixel.red=color->red;
1257 pixel.green=color->green;
1258 pixel.blue=color->blue;
1259 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1260 pixel.red=geometry_info.rho;
1261 pixel.green=geometry_info.sigma;
1262 pixel.blue=geometry_info.xi;
1263 color->red=ClampToQuantum(pixel.red);
1264 color->green=ClampToQuantum(pixel.green);
1265 color->blue=ClampToQuantum(pixel.blue);
1270 if (LocaleCompare(attribute,"colorspace") == 0)
1272 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1273 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1276 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1280 for ( ; image; image=image->next)
1281 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1285 if (LocaleCompare(attribute,"comment") == 0)
1287 for ( ; image; image=image->next)
1288 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1289 info ? info->image_info : (ImageInfo *) NULL,image,
1290 SvPV(sval,na),exception),exception);
1293 if (LocaleCompare(attribute,"compression") == 0)
1295 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1296 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1299 ThrowPerlException(exception,OptionError,
1300 "UnrecognizedImageCompression",SvPV(sval,na));
1304 info->image_info->compression=(CompressionType) sp;
1305 for ( ; image; image=image->next)
1306 image->compression=(CompressionType) sp;
1310 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1311 for ( ; image; image=image->next)
1312 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1318 if (LocaleCompare(attribute,"debug") == 0)
1320 SetLogEventMask(SvPV(sval,na));
1323 if (LocaleCompare(attribute,"delay") == 0)
1325 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1326 for ( ; image; image=image->next)
1328 image->delay=(size_t) floor(geometry_info.rho+0.5);
1329 if ((flags & SigmaValue) != 0)
1330 image->ticks_per_second=(ssize_t)
1331 floor(geometry_info.sigma+0.5);
1335 if (LocaleCompare(attribute,"disk-limit") == 0)
1340 limit=MagickResourceInfinity;
1341 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1342 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1344 (void) SetMagickResourceLimit(DiskResource,limit);
1347 if (LocaleCompare(attribute,"density") == 0)
1349 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1351 ThrowPerlException(exception,OptionError,"MissingGeometry",
1356 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1357 for ( ; image; image=image->next)
1359 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1360 image->resolution.x=geometry_info.rho;
1361 image->resolution.y=geometry_info.sigma;
1362 if ((flags & SigmaValue) == 0)
1363 image->resolution.y=image->resolution.x;
1367 if (LocaleCompare(attribute,"depth") == 0)
1370 info->image_info->depth=SvIV(sval);
1371 for ( ; image; image=image->next)
1372 (void) SetImageDepth(image,SvIV(sval),exception);
1375 if (LocaleCompare(attribute,"dispose") == 0)
1377 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1378 SvPV(sval,na)) : SvIV(sval);
1381 ThrowPerlException(exception,OptionError,
1382 "UnrecognizedDisposeMethod",SvPV(sval,na));
1385 for ( ; image; image=image->next)
1386 image->dispose=(DisposeType) sp;
1389 if (LocaleCompare(attribute,"dither") == 0)
1393 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1394 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1397 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1401 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1405 if (LocaleCompare(attribute,"display") == 0)
1409 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1413 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1414 for ( ; image; image=image->next)
1415 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1421 if (LocaleCompare(attribute,"endian") == 0)
1423 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1424 SvPV(sval,na)) : SvIV(sval);
1427 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1432 info->image_info->endian=(EndianType) sp;
1433 for ( ; image; image=image->next)
1434 image->endian=(EndianType) sp;
1437 if (LocaleCompare(attribute,"extract") == 0)
1440 Set image extract geometry.
1442 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1446 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1447 for ( ; image; image=image->next)
1448 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1454 if (LocaleCompare(attribute,"filename") == 0)
1457 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1459 for ( ; image; image=image->next)
1460 (void) CopyMagickString(image->filename,SvPV(sval,na),
1464 if (LocaleCompare(attribute,"file") == 0)
1472 if (info == (struct PackageInfo *) NULL)
1474 io_info=IoIFP(sv_2io(sval));
1475 if (io_info == (PerlIO *) NULL)
1477 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1481 file=PerlIO_findFILE(io_info);
1482 if (file == (FILE *) NULL)
1484 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1488 SetImageInfoFile(info->image_info,file);
1491 if (LocaleCompare(attribute,"fill") == 0)
1494 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1497 if (LocaleCompare(attribute,"font") == 0)
1500 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1503 if (LocaleCompare(attribute,"foreground") == 0)
1505 if (LocaleCompare(attribute,"fuzz") == 0)
1508 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1510 for ( ; image; image=image->next)
1511 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1516 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1517 for ( ; image; image=image->next)
1518 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1524 if (LocaleCompare(attribute,"gamma") == 0)
1526 for ( ; image; image=image->next)
1527 image->gamma=SvNV(sval);
1530 if (LocaleCompare(attribute,"gravity") == 0)
1532 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1533 SvPV(sval,na)) : SvIV(sval);
1536 ThrowPerlException(exception,OptionError,
1537 "UnrecognizedGravityType",SvPV(sval,na));
1541 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1542 for ( ; image; image=image->next)
1543 image->gravity=(GravityType) sp;
1546 if (LocaleCompare(attribute,"green-primary") == 0)
1548 for ( ; image; image=image->next)
1550 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1551 image->chromaticity.green_primary.x=geometry_info.rho;
1552 image->chromaticity.green_primary.y=geometry_info.sigma;
1553 if ((flags & SigmaValue) == 0)
1554 image->chromaticity.green_primary.y=
1555 image->chromaticity.green_primary.x;
1560 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1561 for ( ; image; image=image->next)
1562 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1568 if (LocaleNCompare(attribute,"index",5) == 0)
1582 for ( ; image; image=image->next)
1584 if (image->storage_class != PseudoClass)
1588 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1590 image_view=AcquireAuthenticCacheView(image,exception);
1591 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1592 if (q != (Quantum *) NULL)
1594 items=sscanf(SvPV(sval,na),"%ld",&index);
1595 if ((index >= 0) && (index < (ssize_t) image->colors))
1596 SetPixelIndex(image,index,q);
1597 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1599 image_view=DestroyCacheView(image_view);
1603 if (LocaleCompare(attribute,"iterations") == 0)
1606 for ( ; image; image=image->next)
1607 image->iterations=SvIV(sval);
1610 if (LocaleCompare(attribute,"interlace") == 0)
1612 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1613 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1616 ThrowPerlException(exception,OptionError,
1617 "UnrecognizedInterlaceType",SvPV(sval,na));
1621 info->image_info->interlace=(InterlaceType) sp;
1622 for ( ; image; image=image->next)
1623 image->interlace=(InterlaceType) sp;
1627 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1628 for ( ; image; image=image->next)
1629 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1635 if (LocaleCompare(attribute,"label") == 0)
1637 for ( ; image; image=image->next)
1638 (void) SetImageProperty(image,"label",InterpretImageProperties(
1639 info ? info->image_info : (ImageInfo *) NULL,image,
1640 SvPV(sval,na),exception),exception);
1643 if (LocaleCompare(attribute,"loop") == 0)
1646 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1647 for ( ; image; image=image->next)
1648 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1654 if (LocaleCompare(attribute,"magick") == 0)
1657 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1658 "%s:",SvPV(sval,na));
1659 for ( ; image; image=image->next)
1660 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1663 if (LocaleCompare(attribute,"map-limit") == 0)
1668 limit=MagickResourceInfinity;
1669 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1670 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1672 (void) SetMagickResourceLimit(MapResource,limit);
1675 if (LocaleCompare(attribute,"mask") == 0)
1680 mask=(Image *) NULL;
1682 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1683 for ( ; image; image=image->next)
1684 SetImageMask(image,mask,exception);
1687 if (LocaleCompare(attribute,"mattecolor") == 0)
1689 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1692 info->image_info->matte_color=target_color;
1693 for ( ; image; image=image->next)
1694 image->matte_color=target_color;
1697 if (LocaleCompare(attribute,"matte") == 0)
1699 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1700 SvPV(sval,na)) : SvIV(sval);
1703 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1707 for ( ; image; image=image->next)
1708 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1711 if (LocaleCompare(attribute,"memory-limit") == 0)
1716 limit=MagickResourceInfinity;
1717 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1718 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1720 (void) SetMagickResourceLimit(MemoryResource,limit);
1723 if (LocaleCompare(attribute,"monochrome") == 0)
1725 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1726 SvPV(sval,na)) : SvIV(sval);
1729 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1734 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1735 for ( ; image; image=image->next)
1736 (void) SetImageType(image,BilevelType,exception);
1740 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1741 for ( ; image; image=image->next)
1742 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1748 if (LocaleCompare(attribute,"option") == 0)
1751 DefineImageOption(info->image_info,SvPV(sval,na));
1754 if (LocaleCompare(attribute,"orientation") == 0)
1756 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1757 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1760 ThrowPerlException(exception,OptionError,
1761 "UnrecognizedOrientationType",SvPV(sval,na));
1765 info->image_info->orientation=(OrientationType) sp;
1766 for ( ; image; image=image->next)
1767 image->orientation=(OrientationType) sp;
1771 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1772 for ( ; image; image=image->next)
1773 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1779 if (LocaleCompare(attribute,"page") == 0)
1784 geometry=GetPageGeometry(SvPV(sval,na));
1786 (void) CloneString(&info->image_info->page,geometry);
1787 for ( ; image; image=image->next)
1788 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1789 geometry=(char *) RelinquishMagickMemory(geometry);
1792 if (LocaleNCompare(attribute,"pixel",5) == 0)
1806 for ( ; image; image=image->next)
1808 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1812 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1814 image_view=AcquireVirtualCacheView(image,exception);
1815 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1816 if (q != (Quantum *) NULL)
1818 if ((strchr(SvPV(sval,na),',') == 0) ||
1819 (strchr(SvPV(sval,na),')') != 0))
1820 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1824 GetPixelInfo(image,&pixel);
1825 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1826 pixel.red=geometry_info.rho;
1827 if ((flags & SigmaValue) != 0)
1828 pixel.green=geometry_info.sigma;
1829 if ((flags & XiValue) != 0)
1830 pixel.blue=geometry_info.xi;
1831 if ((flags & PsiValue) != 0)
1832 pixel.alpha=geometry_info.psi;
1833 if ((flags & ChiValue) != 0)
1834 pixel.black=geometry_info.chi;
1836 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1837 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1838 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1839 if (image->colorspace == CMYKColorspace)
1840 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1841 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1842 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1844 image_view=DestroyCacheView(image_view);
1848 if (LocaleCompare(attribute,"pointsize") == 0)
1852 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1853 info->image_info->pointsize=geometry_info.rho;
1857 if (LocaleCompare(attribute,"preview") == 0)
1859 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1860 SvPV(sval,na)) : SvIV(sval);
1863 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1868 info->image_info->preview_type=(PreviewType) sp;
1872 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1873 for ( ; image; image=image->next)
1874 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1880 if (LocaleCompare(attribute,"quality") == 0)
1883 info->image_info->quality=SvIV(sval);
1884 for ( ; image; image=image->next)
1885 image->quality=SvIV(sval);
1889 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1890 for ( ; image; image=image->next)
1891 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1897 if (LocaleCompare(attribute,"red-primary") == 0)
1899 for ( ; image; image=image->next)
1901 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1902 image->chromaticity.red_primary.x=geometry_info.rho;
1903 image->chromaticity.red_primary.y=geometry_info.sigma;
1904 if ((flags & SigmaValue) == 0)
1905 image->chromaticity.red_primary.y=
1906 image->chromaticity.red_primary.x;
1910 if (LocaleCompare(attribute,"render") == 0)
1912 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1913 SvPV(sval,na)) : SvIV(sval);
1916 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1920 for ( ; image; image=image->next)
1921 image->rendering_intent=(RenderingIntent) sp;
1924 if (LocaleCompare(attribute,"repage") == 0)
1929 for ( ; image; image=image->next)
1931 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1932 if ((flags & WidthValue) != 0)
1934 if ((flags & HeightValue) == 0)
1935 geometry.height=geometry.width;
1936 image->page.width=geometry.width;
1937 image->page.height=geometry.height;
1939 if ((flags & AspectValue) != 0)
1941 if ((flags & XValue) != 0)
1942 image->page.x+=geometry.x;
1943 if ((flags & YValue) != 0)
1944 image->page.y+=geometry.y;
1948 if ((flags & XValue) != 0)
1950 image->page.x=geometry.x;
1951 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1952 image->page.width=image->columns+geometry.x;
1954 if ((flags & YValue) != 0)
1956 image->page.y=geometry.y;
1957 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1958 image->page.height=image->rows+geometry.y;
1965 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1966 for ( ; image; image=image->next)
1967 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1973 if (LocaleCompare(attribute,"sampling-factor") == 0)
1975 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1977 ThrowPerlException(exception,OptionError,"MissingGeometry",
1982 (void) CloneString(&info->image_info->sampling_factor,
1986 if (LocaleCompare(attribute,"scene") == 0)
1988 for ( ; image; image=image->next)
1989 image->scene=SvIV(sval);
1992 if (LocaleCompare(attribute,"server") == 0)
1994 if (LocaleCompare(attribute,"size") == 0)
1998 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2000 ThrowPerlException(exception,OptionError,"MissingGeometry",
2004 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2008 if (LocaleCompare(attribute,"stroke") == 0)
2011 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2015 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2016 for ( ; image; image=image->next)
2017 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2023 if (LocaleCompare(attribute,"texture") == 0)
2026 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2029 if (LocaleCompare(attribute,"thread-limit") == 0)
2034 limit=MagickResourceInfinity;
2035 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2036 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2038 (void) SetMagickResourceLimit(ThreadResource,limit);
2041 if (LocaleCompare(attribute,"tile-offset") == 0)
2046 geometry=GetPageGeometry(SvPV(sval,na));
2048 (void) CloneString(&info->image_info->page,geometry);
2049 for ( ; image; image=image->next)
2050 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2052 geometry=(char *) RelinquishMagickMemory(geometry);
2055 if (LocaleCompare(attribute,"time-limit") == 0)
2060 limit=MagickResourceInfinity;
2061 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2062 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2064 (void) SetMagickResourceLimit(TimeResource,limit);
2067 if (LocaleCompare(attribute,"transparent-color") == 0)
2069 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2072 info->image_info->transparent_color=target_color;
2073 for ( ; image; image=image->next)
2074 image->transparent_color=target_color;
2077 if (LocaleCompare(attribute,"type") == 0)
2079 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2080 SvPV(sval,na)) : SvIV(sval);
2083 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2088 info->image_info->type=(ImageType) sp;
2089 for ( ; image; image=image->next)
2090 SetImageType(image,(ImageType) sp,exception);
2094 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2095 for ( ; image; image=image->next)
2096 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2102 if (LocaleCompare(attribute,"units") == 0)
2104 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2105 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2108 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2113 info->image_info->units=(ResolutionType) sp;
2114 for ( ; image; image=image->next)
2119 units=(ResolutionType) sp;
2120 if (image->units != units)
2121 switch (image->units)
2123 case UndefinedResolution:
2124 case PixelsPerInchResolution:
2126 if (units == PixelsPerCentimeterResolution)
2128 image->resolution.x*=2.54;
2129 image->resolution.y*=2.54;
2133 case PixelsPerCentimeterResolution:
2135 if (units == PixelsPerInchResolution)
2137 image->resolution.x/=2.54;
2138 image->resolution.y/=2.54;
2148 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2149 for ( ; image; image=image->next)
2150 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2156 if (LocaleCompare(attribute,"verbose") == 0)
2158 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2159 SvPV(sval,na)) : SvIV(sval);
2162 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2167 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2170 if (LocaleCompare(attribute,"view") == 0)
2173 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2176 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2178 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2179 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2182 ThrowPerlException(exception,OptionError,
2183 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2186 for ( ; image; image=image->next)
2187 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2191 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2192 for ( ; image; image=image->next)
2193 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2199 if (LocaleCompare(attribute,"white-point") == 0)
2201 for ( ; image; image=image->next)
2203 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2204 image->chromaticity.white_point.x=geometry_info.rho;
2205 image->chromaticity.white_point.y=geometry_info.sigma;
2206 if ((flags & SigmaValue) == 0)
2207 image->chromaticity.white_point.y=
2208 image->chromaticity.white_point.x;
2213 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2214 for ( ; image; image=image->next)
2215 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2221 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2222 for ( ; image; image=image->next)
2223 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2234 % S e t u p L i s t %
2238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2240 % Method SetupList returns the list of all the images linked by their
2241 % image->next and image->previous link lists for use with ImageMagick. If
2242 % info is non-NULL, an info structure is returned in *info. If
2243 % reference_vector is non-NULL,an array of SV* are returned in
2244 % *reference_vector. Reference_vector is used when the images are going to be
2245 % replaced with new Image*'s.
2247 % The format of the SetupList routine is:
2249 % Image *SetupList(SV *reference,struct PackageInfo **info,
2250 % SV ***reference_vector,ExceptionInfo *exception)
2252 % A description of each parameter follows:
2254 % o list: a list of strings.
2256 % o string: a character string.
2258 % o exception: Return any errors or warnings in this structure.
2261 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2262 SV ***reference_vector,ExceptionInfo *exception)
2271 if (reference_vector)
2272 *reference_vector=NULL;
2277 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2278 if (info && (SvTYPE(reference) == SVt_PVAV))
2279 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2289 % s t r E Q c a s e %
2293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2295 % strEQcase() compares two strings and returns 0 if they are the
2296 % same or if the second string runs out first. The comparison is case
2299 % The format of the strEQcase routine is:
2301 % ssize_t strEQcase(const char *p,const char *q)
2303 % A description of each parameter follows:
2305 % o p: a character string.
2307 % o q: a character string.
2311 static ssize_t strEQcase(const char *p,const char *q)
2319 for (i=0 ; (c=(*q)) != 0; i++)
2321 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2322 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2327 return(((*q == 0) && (*p == 0)) ? i : 0);
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 % I m a g e : : M a g i c k %
2339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2343 MODULE = Image::Magick PACKAGE = Image::Magick
2348 MagickCoreGenesis("PerlMagick",MagickFalse);
2349 SetWarningHandler(NULL);
2350 SetErrorHandler(NULL);
2351 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2352 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2358 if (magick_registry != (SplayTreeInfo *) NULL)
2359 magick_registry=DestroySplayTree(magick_registry);
2360 MagickCoreTerminus();
2364 constant(name,argument)
2369 ###############################################################################
2377 ###############################################################################
2382 Image::Magick ref=NO_INIT
2406 PERL_UNUSED_VAR(ref);
2407 PERL_UNUSED_VAR(ix);
2408 exception=AcquireExceptionInfo();
2409 perl_exception=newSVpv("",0);
2410 package_info=(struct PackageInfo *) NULL;
2411 if (sv_isobject(ST(0)) == 0)
2413 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2417 reference=SvRV(ST(0));
2418 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2419 if (image == (Image *) NULL)
2421 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2425 package_info=ClonePackageInfo(info,exception);
2427 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2430 for (i=2; i < items; i+=2)
2431 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2433 (void) AnimateImages(package_info->image_info,image,exception);
2434 (void) CatchImageException(image);
2437 if (package_info != (struct PackageInfo *) NULL)
2438 DestroyPackageInfo(package_info);
2439 InheritPerlException(exception,perl_exception);
2440 exception=DestroyExceptionInfo(exception);
2441 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2442 SvPOK_on(perl_exception);
2443 ST(0)=sv_2mortal(perl_exception);
2448 ###############################################################################
2456 ###############################################################################
2461 Image::Magick ref=NO_INIT
2499 PERL_UNUSED_VAR(ref);
2500 PERL_UNUSED_VAR(ix);
2501 exception=AcquireExceptionInfo();
2502 perl_exception=newSVpv("",0);
2506 if (sv_isobject(ST(0)) == 0)
2508 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2512 reference=SvRV(ST(0));
2513 hv=SvSTASH(reference);
2515 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2517 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2518 if (image == (Image *) NULL)
2520 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2524 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2529 for (i=2; i < items; i+=2)
2531 attribute=(char *) SvPV(ST(i-1),na);
2537 if (LocaleCompare(attribute,"stack") == 0)
2539 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2543 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2555 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2561 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2562 if (image == (Image *) NULL)
2564 for ( ; image; image=image->next)
2566 AddImageToRegistry(sv,image);
2568 av_push(av,sv_bless(rv,hv));
2571 exception=DestroyExceptionInfo(exception);
2573 SvREFCNT_dec(perl_exception);
2577 InheritPerlException(exception,perl_exception);
2578 exception=DestroyExceptionInfo(exception);
2579 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2580 SvPOK_on(perl_exception);
2581 ST(0)=sv_2mortal(perl_exception);
2586 ###############################################################################
2594 ###############################################################################
2599 Image::Magick ref=NO_INIT
2630 PERL_UNUSED_VAR(ref);
2631 PERL_UNUSED_VAR(ix);
2632 exception=AcquireExceptionInfo();
2633 perl_exception=newSVpv("",0);
2635 if (sv_isobject(ST(0)) == 0)
2637 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2641 reference=SvRV(ST(0));
2642 hv=SvSTASH(reference);
2643 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2644 if (image == (Image *) NULL)
2646 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2650 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2651 if (image == (Image *) NULL)
2654 Create blessed Perl array for the returned image.
2657 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2659 AddImageToRegistry(sv,image);
2661 av_push(av,sv_bless(rv,hv));
2663 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2664 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2665 "average-%.*s",(int) (MaxTextExtent-9),
2666 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2667 (void) CopyMagickString(image->filename,info->image_info->filename,
2669 SetImageInfo(info->image_info,0,exception);
2670 exception=DestroyExceptionInfo(exception);
2671 SvREFCNT_dec(perl_exception);
2675 InheritPerlException(exception,perl_exception);
2676 exception=DestroyExceptionInfo(exception);
2677 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2678 SvPOK_on(perl_exception);
2679 ST(0)=sv_2mortal(perl_exception);
2684 ###############################################################################
2688 # B l o b T o I m a g e #
2692 ###############################################################################
2696 BlobToImage(ref,...)
2697 Image::Magick ref=NO_INIT
2743 PERL_UNUSED_VAR(ref);
2744 PERL_UNUSED_VAR(ix);
2745 exception=AcquireExceptionInfo();
2746 perl_exception=newSVpv("",0);
2749 ac=(items < 2) ? 1 : items-1;
2750 length=(STRLEN *) NULL;
2751 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2752 if (list == (char **) NULL)
2754 ThrowPerlException(exception,ResourceLimitError,
2755 "MemoryAllocationFailed",PackageName);
2758 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2759 if (length == (STRLEN *) NULL)
2761 ThrowPerlException(exception,ResourceLimitError,
2762 "MemoryAllocationFailed",PackageName);
2765 if (sv_isobject(ST(0)) == 0)
2767 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2771 reference=SvRV(ST(0));
2772 hv=SvSTASH(reference);
2773 if (SvTYPE(reference) != SVt_PVAV)
2775 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2779 av=(AV *) reference;
2780 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2785 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2788 for (n=0, i=0; i < ac; i++)
2790 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2791 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2793 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2798 list[n]=(char *) NULL;
2800 for (i=number_images=0; i < n; i++)
2802 image=BlobToImage(info->image_info,list[i],length[i],exception);
2803 if (image == (Image *) NULL)
2805 for ( ; image; image=image->next)
2807 AddImageToRegistry(sv,image);
2809 av_push(av,sv_bless(rv,hv));
2817 for (i=0; i < n; i++)
2818 if (list[i] != (char *) NULL)
2819 for (p=keep; list[i] != *p++; )
2820 if (*p == (char *) NULL)
2822 list[i]=(char *) RelinquishMagickMemory(list[i]);
2828 list=(char **) RelinquishMagickMemory(list);
2830 length=(STRLEN *) RelinquishMagickMemory(length);
2831 InheritPerlException(exception,perl_exception);
2832 exception=DestroyExceptionInfo(exception);
2833 sv_setiv(perl_exception,(IV) number_images);
2834 SvPOK_on(perl_exception);
2835 ST(0)=sv_2mortal(perl_exception);
2840 ###############################################################################
2844 # C h a n n e l F x #
2848 ###############################################################################
2853 Image::Magick ref=NO_INIT
2865 expression[MaxTextExtent];
2893 PERL_UNUSED_VAR(ref);
2894 PERL_UNUSED_VAR(ix);
2895 exception=AcquireExceptionInfo();
2896 perl_exception=newSVpv("",0);
2900 if (sv_isobject(ST(0)) == 0)
2902 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2906 reference=SvRV(ST(0));
2907 hv=SvSTASH(reference);
2909 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2911 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2912 if (image == (Image *) NULL)
2914 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2918 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2922 channel=DefaultChannels;
2923 (void) CopyMagickString(expression,"u",MaxTextExtent);
2925 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2927 for (i=2; i < items; i+=2)
2929 attribute=(char *) SvPV(ST(i-1),na);
2935 if (LocaleCompare(attribute,"channel") == 0)
2940 option=ParseChannelOption(SvPV(ST(i),na));
2943 ThrowPerlException(exception,OptionError,
2944 "UnrecognizedType",SvPV(ST(i),na));
2947 channel=(ChannelType) option;
2950 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2957 if (LocaleCompare(attribute,"expression") == 0)
2959 (void) CopyMagickString(expression,SvPV(ST(i),na),
2963 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2975 channel_mask=SetImageChannelMask(image,channel);
2976 image=ChannelFxImage(image,expression,exception);
2977 if (image != (Image *) NULL)
2978 (void) SetImageChannelMask(image,channel_mask);
2979 if (image == (Image *) NULL)
2981 for ( ; image; image=image->next)
2983 AddImageToRegistry(sv,image);
2985 av_push(av,sv_bless(rv,hv));
2988 exception=DestroyExceptionInfo(exception);
2990 SvREFCNT_dec(perl_exception); /* can't return warning messages */
2994 InheritPerlException(exception,perl_exception);
2995 exception=DestroyExceptionInfo(exception);
2996 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2997 SvPOK_on(perl_exception);
2998 ST(0)=sv_2mortal(perl_exception);
3003 ###############################################################################
3011 ###############################################################################
3016 Image::Magick ref=NO_INIT
3049 PERL_UNUSED_VAR(ref);
3050 PERL_UNUSED_VAR(ix);
3051 exception=AcquireExceptionInfo();
3052 perl_exception=newSVpv("",0);
3054 if (sv_isobject(ST(0)) == 0)
3056 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3060 reference=SvRV(ST(0));
3061 hv=SvSTASH(reference);
3062 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3063 if (image == (Image *) NULL)
3065 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3070 Create blessed Perl array for the returned image.
3073 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3075 for ( ; image; image=image->next)
3077 clone=CloneImage(image,0,0,MagickTrue,exception);
3078 if (clone == (Image *) NULL)
3080 AddImageToRegistry(sv,clone);
3082 av_push(av,sv_bless(rv,hv));
3085 exception=DestroyExceptionInfo(exception);
3086 SvREFCNT_dec(perl_exception);
3090 InheritPerlException(exception,perl_exception);
3091 exception=DestroyExceptionInfo(exception);
3092 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3093 SvPOK_on(perl_exception);
3094 ST(0)=sv_2mortal(perl_exception);
3099 ###############################################################################
3107 ###############################################################################
3115 PERL_UNUSED_VAR(ref);
3116 if (magick_registry != (SplayTreeInfo *) NULL)
3121 ResetSplayTreeIterator(magick_registry);
3122 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3123 while (p != (Image *) NULL)
3126 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3132 ###############################################################################
3140 ###############################################################################
3145 Image::Magick ref=NO_INIT
3174 PERL_UNUSED_VAR(ref);
3175 PERL_UNUSED_VAR(ix);
3176 exception=AcquireExceptionInfo();
3177 perl_exception=newSVpv("",0);
3179 if (sv_isobject(ST(0)) == 0)
3181 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3185 reference=SvRV(ST(0));
3186 hv=SvSTASH(reference);
3188 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3190 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3191 if (image == (Image *) NULL)
3193 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3197 image=CoalesceImages(image,exception);
3198 if (image == (Image *) NULL)
3200 for ( ; image; image=image->next)
3202 AddImageToRegistry(sv,image);
3204 av_push(av,sv_bless(rv,hv));
3207 exception=DestroyExceptionInfo(exception);
3209 SvREFCNT_dec(perl_exception);
3213 InheritPerlException(exception,perl_exception);
3214 exception=DestroyExceptionInfo(exception);
3215 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3216 SvPOK_on(perl_exception);
3217 ST(0)=sv_2mortal(perl_exception);
3222 ###############################################################################
3230 ###############################################################################
3235 Image::Magick ref=NO_INIT
3281 PERL_UNUSED_VAR(ref);
3282 PERL_UNUSED_VAR(ix);
3283 exception=AcquireExceptionInfo();
3284 perl_exception=newSVpv("",0);
3288 if (sv_isobject(ST(0)) == 0)
3290 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3294 reference=SvRV(ST(0));
3295 hv=SvSTASH(reference);
3297 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3299 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3300 if (image == (Image *) NULL)
3302 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3306 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3310 reconstruct_image=image;
3311 metric=RootMeanSquaredErrorMetric;
3312 for (i=2; i < items; i+=2)
3314 attribute=(char *) SvPV(ST(i-1),na);
3320 if (LocaleCompare(attribute,"channel") == 0)
3325 option=ParseChannelOption(SvPV(ST(i),na));
3328 ThrowPerlException(exception,OptionError,
3329 "UnrecognizedType",SvPV(ST(i),na));
3332 SetPixelChannelMask(image,(ChannelType) option);
3335 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3342 if (LocaleCompare(attribute,"fuzz") == 0)
3344 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3354 if (LocaleCompare(attribute,"image") == 0)
3356 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3357 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3367 if (LocaleCompare(attribute,"metric") == 0)
3369 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3373 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3377 metric=(MetricType) option;
3380 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3386 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3392 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3394 if (difference_image != (Image *) NULL)
3396 difference_image->error.mean_error_per_pixel=distortion;
3397 AddImageToRegistry(sv,difference_image);
3399 av_push(av,sv_bless(rv,hv));
3402 exception=DestroyExceptionInfo(exception);
3404 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3408 InheritPerlException(exception,perl_exception);
3409 exception=DestroyExceptionInfo(exception);
3410 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3411 SvPOK_on(perl_exception);
3412 ST(0)=sv_2mortal(perl_exception);
3417 ###############################################################################
3421 # C o m p a r e L a y e r s #
3425 ###############################################################################
3430 Image::Magick ref=NO_INIT
3432 CompareImagesLayers = 1
3434 compareimagelayers = 3
3471 PERL_UNUSED_VAR(ref);
3472 PERL_UNUSED_VAR(ix);
3473 exception=AcquireExceptionInfo();
3474 perl_exception=newSVpv("",0);
3476 if (sv_isobject(ST(0)) == 0)
3478 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3482 reference=SvRV(ST(0));
3483 hv=SvSTASH(reference);
3485 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3487 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3488 if (image == (Image *) NULL)
3490 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3494 method=CompareAnyLayer;
3495 for (i=2; i < items; i+=2)
3497 attribute=(char *) SvPV(ST(i-1),na);
3503 if (LocaleCompare(attribute,"method") == 0)
3505 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3509 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3513 method=(LayerMethod) option;
3516 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3522 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3528 image=CompareImagesLayers(image,method,exception);
3529 if (image == (Image *) NULL)
3531 for ( ; image; image=image->next)
3533 AddImageToRegistry(sv,image);
3535 av_push(av,sv_bless(rv,hv));
3538 exception=DestroyExceptionInfo(exception);
3540 SvREFCNT_dec(perl_exception);
3544 InheritPerlException(exception,perl_exception);
3545 exception=DestroyExceptionInfo(exception);
3546 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3547 SvPOK_on(perl_exception);
3548 ST(0)=sv_2mortal(perl_exception);
3553 ###############################################################################
3561 ###############################################################################
3566 Image::Magick ref=NO_INIT
3572 PERL_UNUSED_VAR(ref);
3573 if (sv_isobject(ST(0)) == 0)
3574 croak("ReferenceIsNotMyType");
3575 reference=SvRV(ST(0));
3576 switch (SvTYPE(reference))
3581 message[MaxTextExtent];
3599 Array (AV *) reference
3601 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3602 XS_VERSION,reference);
3603 hv=gv_stashpv(PackageName, FALSE);
3606 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3610 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3612 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3613 DestroyPackageInfo(info);
3615 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3625 Blessed scalar = (Image *) SvIV(reference)
3627 image=INT2PTR(Image *,SvIV(reference));
3628 if (image != (Image *) NULL)
3629 DeleteImageFromRegistry(reference,image);
3638 ###############################################################################
3646 ###############################################################################
3651 Image::Magick ref=NO_INIT
3675 PERL_UNUSED_VAR(ref);
3676 PERL_UNUSED_VAR(ix);
3677 exception=AcquireExceptionInfo();
3678 perl_exception=newSVpv("",0);
3679 package_info=(struct PackageInfo *) NULL;
3680 if (sv_isobject(ST(0)) == 0)
3682 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3686 reference=SvRV(ST(0));
3687 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3688 if (image == (Image *) NULL)
3690 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3694 package_info=ClonePackageInfo(info,exception);
3696 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3699 for (i=2; i < items; i+=2)
3700 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3702 (void) DisplayImages(package_info->image_info,image,exception);
3703 (void) CatchImageException(image);
3706 if (package_info != (struct PackageInfo *) NULL)
3707 DestroyPackageInfo(package_info);
3708 InheritPerlException(exception,perl_exception);
3709 exception=DestroyExceptionInfo(exception);
3710 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3711 SvPOK_on(perl_exception);
3712 ST(0)=sv_2mortal(perl_exception);
3717 ###############################################################################
3721 # E v a l u a t e I m a g e s #
3725 ###############################################################################
3730 Image::Magick ref=NO_INIT
3752 MagickEvaluateOperator
3767 PERL_UNUSED_VAR(ref);
3768 PERL_UNUSED_VAR(ix);
3769 exception=AcquireExceptionInfo();
3770 perl_exception=newSVpv("",0);
3772 if (sv_isobject(ST(0)) == 0)
3774 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3778 reference=SvRV(ST(0));
3779 hv=SvSTASH(reference);
3780 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3781 if (image == (Image *) NULL)
3783 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3787 op=MeanEvaluateOperator;
3793 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3797 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3801 op=(MagickEvaluateOperator) in;
3804 for (i=2; i < items; i+=2)
3806 attribute=(char *) SvPV(ST(i-1),na);
3812 if (LocaleCompare(attribute,"operator") == 0)
3817 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3818 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3821 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3825 op=(MagickEvaluateOperator) in;
3828 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3834 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3840 image=EvaluateImages(image,op,exception);
3841 if (image == (Image *) NULL)
3844 Create blessed Perl array for the returned image.
3847 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3849 AddImageToRegistry(sv,image);
3851 av_push(av,sv_bless(rv,hv));
3853 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3854 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3855 "evaluate-%.*s",(int) (MaxTextExtent-9),
3856 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3857 (void) CopyMagickString(image->filename,info->image_info->filename,
3859 SetImageInfo(info->image_info,0,exception);
3860 exception=DestroyExceptionInfo(exception);
3861 SvREFCNT_dec(perl_exception);
3865 InheritPerlException(exception,perl_exception);
3866 exception=DestroyExceptionInfo(exception);
3867 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3868 SvPOK_on(perl_exception);
3869 ST(0)=sv_2mortal(perl_exception);
3874 ###############################################################################
3882 ###############################################################################
3887 Image::Magick ref=NO_INIT
3894 #define ChannelFeatures(channel,direction) \
3896 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3897 channel_features[channel].angular_second_moment[direction]); \
3898 PUSHs(sv_2mortal(newSVpv(message,0))); \
3899 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3900 channel_features[channel].contrast[direction]); \
3901 PUSHs(sv_2mortal(newSVpv(message,0))); \
3902 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3903 channel_features[channel].contrast[direction]); \
3904 PUSHs(sv_2mortal(newSVpv(message,0))); \
3905 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3906 channel_features[channel].variance_sum_of_squares[direction]); \
3907 PUSHs(sv_2mortal(newSVpv(message,0))); \
3908 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3909 channel_features[channel].inverse_difference_moment[direction]); \
3910 PUSHs(sv_2mortal(newSVpv(message,0))); \
3911 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3912 channel_features[channel].sum_average[direction]); \
3913 PUSHs(sv_2mortal(newSVpv(message,0))); \
3914 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3915 channel_features[channel].sum_variance[direction]); \
3916 PUSHs(sv_2mortal(newSVpv(message,0))); \
3917 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3918 channel_features[channel].sum_entropy[direction]); \
3919 PUSHs(sv_2mortal(newSVpv(message,0))); \
3920 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3921 channel_features[channel].entropy[direction]); \
3922 PUSHs(sv_2mortal(newSVpv(message,0))); \
3923 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3924 channel_features[channel].difference_variance[direction]); \
3925 PUSHs(sv_2mortal(newSVpv(message,0))); \
3926 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3927 channel_features[channel].difference_entropy[direction]); \
3928 PUSHs(sv_2mortal(newSVpv(message,0))); \
3929 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3930 channel_features[channel].measure_of_correlation_1[direction]); \
3931 PUSHs(sv_2mortal(newSVpv(message,0))); \
3932 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3933 channel_features[channel].measure_of_correlation_2[direction]); \
3934 PUSHs(sv_2mortal(newSVpv(message,0))); \
3935 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3936 channel_features[channel].maximum_correlation_coefficient[direction]); \
3937 PUSHs(sv_2mortal(newSVpv(message,0))); \
3945 message[MaxTextExtent];
3972 PERL_UNUSED_VAR(ref);
3973 PERL_UNUSED_VAR(ix);
3974 exception=AcquireExceptionInfo();
3975 perl_exception=newSVpv("",0);
3977 if (sv_isobject(ST(0)) == 0)
3979 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3983 reference=SvRV(ST(0));
3986 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3987 if (image == (Image *) NULL)
3989 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3993 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3995 for (i=2; i < items; i+=2)
3997 attribute=(char *) SvPV(ST(i-1),na);
4003 if (LocaleCompare(attribute,"distance") == 0)
4005 distance=StringToLong((char *) SvPV(ST(1),na));
4008 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4014 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4021 for ( ; image; image=image->next)
4023 channel_features=GetImageFeatures(image,distance,exception);
4024 if (channel_features == (ChannelFeatures *) NULL)
4027 EXTEND(sp,75*count);
4028 for (i=0; i < 4; i++)
4030 ChannelFeatures(RedChannel,i);
4031 ChannelFeatures(GreenChannel,i);
4032 ChannelFeatures(BlueChannel,i);
4033 if (image->colorspace == CMYKColorspace)
4034 ChannelFeatures(BlackChannel,i);
4035 if (image->alpha_trait == BlendPixelTrait)
4036 ChannelFeatures(AlphaChannel,i);
4038 channel_features=(ChannelFeatures *)
4039 RelinquishMagickMemory(channel_features);
4043 InheritPerlException(exception,perl_exception);
4044 exception=DestroyExceptionInfo(exception);
4045 SvREFCNT_dec(perl_exception);
4049 ###############################################################################
4057 ###############################################################################
4062 Image::Magick ref=NO_INIT
4100 PERL_UNUSED_VAR(ref);
4101 PERL_UNUSED_VAR(ix);
4102 exception=AcquireExceptionInfo();
4103 perl_exception=newSVpv("",0);
4105 if (sv_isobject(ST(0)) == 0)
4107 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4111 reference=SvRV(ST(0));
4112 hv=SvSTASH(reference);
4113 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4114 if (image == (Image *) NULL)
4116 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4120 background_color=image->background_color;
4122 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4123 &background_color,exception);
4125 for (i=2; i < items; i+=2)
4127 attribute=(char *) SvPV(ST(i-1),na);
4133 if (LocaleCompare(attribute,"background") == 0)
4135 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4136 AllCompliance,&background_color,exception);
4139 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4145 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4151 image->background_color=background_color;
4152 image=MergeImageLayers(image,FlattenLayer,exception);
4153 if (image == (Image *) NULL)
4156 Create blessed Perl array for the returned image.
4159 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4161 AddImageToRegistry(sv,image);
4163 av_push(av,sv_bless(rv,hv));
4165 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4166 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4167 "flatten-%.*s",(int) (MaxTextExtent-9),
4168 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4169 (void) CopyMagickString(image->filename,info->image_info->filename,
4171 SetImageInfo(info->image_info,0,exception);
4172 exception=DestroyExceptionInfo(exception);
4173 SvREFCNT_dec(perl_exception);
4177 InheritPerlException(exception,perl_exception);
4178 exception=DestroyExceptionInfo(exception);
4179 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4180 SvPOK_on(perl_exception); /* return messages in string context */
4181 ST(0)=sv_2mortal(perl_exception);
4186 ###############################################################################
4194 ###############################################################################
4199 Image::Magick ref=NO_INIT
4211 expression[MaxTextExtent];
4239 PERL_UNUSED_VAR(ref);
4240 PERL_UNUSED_VAR(ix);
4241 exception=AcquireExceptionInfo();
4242 perl_exception=newSVpv("",0);
4246 if (sv_isobject(ST(0)) == 0)
4248 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4252 reference=SvRV(ST(0));
4253 hv=SvSTASH(reference);
4255 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4257 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4258 if (image == (Image *) NULL)
4260 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4264 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4268 channel=DefaultChannels;
4269 (void) CopyMagickString(expression,"u",MaxTextExtent);
4271 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4273 for (i=2; i < items; i+=2)
4275 attribute=(char *) SvPV(ST(i-1),na);
4281 if (LocaleCompare(attribute,"channel") == 0)
4286 option=ParseChannelOption(SvPV(ST(i),na));
4289 ThrowPerlException(exception,OptionError,
4290 "UnrecognizedType",SvPV(ST(i),na));
4293 channel=(ChannelType) option;
4296 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4303 if (LocaleCompare(attribute,"expression") == 0)
4305 (void) CopyMagickString(expression,SvPV(ST(i),na),
4309 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4315 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4321 channel_mask=SetImageChannelMask(image,channel);
4322 image=FxImage(image,expression,exception);
4323 if (image != (Image *) NULL)
4324 (void) SetImageChannelMask(image,channel_mask);
4325 if (image == (Image *) NULL)
4327 for ( ; image; image=image->next)
4329 AddImageToRegistry(sv,image);
4331 av_push(av,sv_bless(rv,hv));
4334 exception=DestroyExceptionInfo(exception);
4336 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4340 InheritPerlException(exception,perl_exception);
4341 exception=DestroyExceptionInfo(exception);
4342 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4343 SvPOK_on(perl_exception);
4344 ST(0)=sv_2mortal(perl_exception);
4349 ###############################################################################
4357 ###############################################################################
4362 Image::Magick ref=NO_INIT
4373 color[MaxTextExtent];
4398 PERL_UNUSED_VAR(ref);
4399 PERL_UNUSED_VAR(ix);
4400 exception=AcquireExceptionInfo();
4401 perl_exception=newSVpv("",0);
4402 if (sv_isobject(ST(0)) == 0)
4404 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4408 reference=SvRV(ST(0));
4409 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4410 if (image == (Image *) NULL && !info)
4413 for (i=1; i < items; i++)
4415 attribute=(char *) SvPV(ST(i),na);
4422 if (LocaleCompare(attribute,"adjoin") == 0)
4425 s=newSViv((ssize_t) info->image_info->adjoin);
4426 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4429 if (LocaleCompare(attribute,"antialias") == 0)
4432 s=newSViv((ssize_t) info->image_info->antialias);
4433 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4436 if (LocaleCompare(attribute,"area") == 0)
4438 s=newSViv(GetMagickResource(AreaResource));
4439 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4442 if (LocaleCompare(attribute,"attenuate") == 0)
4447 value=GetImageProperty(image,attribute,exception);
4448 if (value != (const char *) NULL)
4450 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4453 if (LocaleCompare(attribute,"authenticate") == 0)
4460 option=GetImageOption(info->image_info,attribute);
4461 if (option != (const char *) NULL)
4462 s=newSVpv(option,0);
4464 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4467 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4474 if (LocaleCompare(attribute,"background") == 0)
4476 if (image == (Image *) NULL)
4478 (void) FormatLocaleString(color,MaxTextExtent,
4479 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4480 image->background_color.green,image->background_color.blue,
4481 image->background_color.alpha);
4483 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4486 if (LocaleCompare(attribute,"base-columns") == 0)
4488 if (image != (Image *) NULL)
4489 s=newSViv((ssize_t) image->magick_columns);
4490 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4493 if (LocaleCompare(attribute,"base-filename") == 0)
4495 if (image != (Image *) NULL)
4496 s=newSVpv(image->magick_filename,0);
4497 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4500 if (LocaleCompare(attribute,"base-height") == 0)
4502 if (image != (Image *) NULL)
4503 s=newSViv((ssize_t) image->magick_rows);
4504 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4507 if (LocaleCompare(attribute,"base-rows") == 0)
4509 if (image != (Image *) NULL)
4510 s=newSViv((ssize_t) image->magick_rows);
4511 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4514 if (LocaleCompare(attribute,"base-width") == 0)
4516 if (image != (Image *) NULL)
4517 s=newSViv((ssize_t) image->magick_columns);
4518 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4521 if (LocaleCompare(attribute,"blue-primary") == 0)
4523 if (image == (Image *) NULL)
4525 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4526 image->chromaticity.blue_primary.x,
4527 image->chromaticity.blue_primary.y);
4529 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4532 if (LocaleCompare(attribute,"bordercolor") == 0)
4534 if (image == (Image *) NULL)
4536 (void) FormatLocaleString(color,MaxTextExtent,
4537 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4538 image->border_color.green,image->border_color.blue,
4539 image->border_color.alpha);
4541 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4544 if (LocaleCompare(attribute,"bounding-box") == 0)
4547 geometry[MaxTextExtent];
4552 if (image == (Image *) NULL)
4554 page=GetImageBoundingBox(image,exception);
4555 (void) FormatLocaleString(geometry,MaxTextExtent,
4556 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4557 page.height,(double) page.x,(double) page.y);
4558 s=newSVpv(geometry,0);
4559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4569 if (LocaleCompare(attribute,"class") == 0)
4571 if (image == (Image *) NULL)
4573 s=newSViv(image->storage_class);
4574 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4575 image->storage_class));
4577 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4580 if (LocaleCompare(attribute,"clip-mask") == 0)
4582 if (image != (Image *) NULL)
4591 if (image->mask == MagickFalse)
4592 ClipImage(image,exception);
4593 mask_image=GetImageMask(image,exception);
4594 if (mask_image != (Image *) NULL)
4596 AddImageToRegistry(sv,mask_image);
4597 s=sv_bless(newRV(sv),SvSTASH(reference));
4600 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4603 if (LocaleCompare(attribute,"clip-path") == 0)
4605 if (image != (Image *) NULL)
4614 if (image->mask != MagickFalse)
4615 ClipImage(image,exception);
4616 mask_image=GetImageMask(image,exception);
4617 if (mask_image != (Image *) NULL)
4619 AddImageToRegistry(sv,mask_image);
4620 s=sv_bless(newRV(sv),SvSTASH(reference));
4623 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4626 if (LocaleCompare(attribute,"compression") == 0)
4628 j=info ? info->image_info->compression : image ?
4629 image->compression : UndefinedCompression;
4631 if (info->image_info->compression == UndefinedCompression)
4632 j=image->compression;
4634 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4637 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4640 if (LocaleCompare(attribute,"colorspace") == 0)
4642 j=image ? image->colorspace : RGBColorspace;
4644 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4647 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4650 if (LocaleCompare(attribute,"colors") == 0)
4652 if (image != (Image *) NULL)
4653 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4655 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4658 if (LocaleNCompare(attribute,"colormap",8) == 0)
4663 if (image == (Image *) NULL || !image->colormap)
4666 items=sscanf(attribute,"%*[^[][%ld",&j);
4668 if (j > (ssize_t) image->colors)
4670 (void) FormatLocaleString(color,MaxTextExtent,
4671 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4672 image->colormap[j].green,image->colormap[j].blue,
4673 image->colormap[j].alpha);
4675 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4678 if (LocaleCompare(attribute,"columns") == 0)
4680 if (image != (Image *) NULL)
4681 s=newSViv((ssize_t) image->columns);
4682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4685 if (LocaleCompare(attribute,"comment") == 0)
4690 value=GetImageProperty(image,attribute,exception);
4691 if (value != (const char *) NULL)
4693 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4696 if (LocaleCompare(attribute,"copyright") == 0)
4698 s=newSVpv(GetMagickCopyright(),0);
4699 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4709 if (LocaleCompare(attribute,"density") == 0)
4712 geometry[MaxTextExtent];
4714 if (image == (Image *) NULL)
4716 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4717 image->resolution.x,image->resolution.y);
4718 s=newSVpv(geometry,0);
4719 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4722 if (LocaleCompare(attribute,"delay") == 0)
4724 if (image != (Image *) NULL)
4725 s=newSViv((ssize_t) image->delay);
4726 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4729 if (LocaleCompare(attribute,"depth") == 0)
4731 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4732 if (image != (Image *) NULL)
4733 s=newSViv((ssize_t) GetImageDepth(image,exception));
4734 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4737 if (LocaleCompare(attribute,"directory") == 0)
4739 if (image && image->directory)
4740 s=newSVpv(image->directory,0);
4741 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4744 if (LocaleCompare(attribute,"dispose") == 0)
4746 if (image == (Image *) NULL)
4749 s=newSViv(image->dispose);
4751 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4753 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4756 if (LocaleCompare(attribute,"disk") == 0)
4758 s=newSViv(GetMagickResource(DiskResource));
4759 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4762 if (LocaleCompare(attribute,"dither") == 0)
4765 s=newSViv((ssize_t) info->image_info->dither);
4766 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4769 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4771 if (info && info->image_info->server_name)
4772 s=newSVpv(info->image_info->server_name,0);
4773 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4783 if (LocaleCompare(attribute,"elapsed-time") == 0)
4785 if (image != (Image *) NULL)
4786 s=newSVnv(GetElapsedTime(&image->timer));
4787 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4790 if (LocaleCompare(attribute,"endian") == 0)
4792 j=info ? info->image_info->endian : image ? image->endian :
4795 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4797 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4800 if (LocaleCompare(attribute,"error") == 0)
4802 if (image != (Image *) NULL)
4803 s=newSVnv(image->error.mean_error_per_pixel);
4804 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4807 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4814 if (LocaleCompare(attribute,"filesize") == 0)
4816 if (image != (Image *) NULL)
4817 s=newSViv((ssize_t) GetBlobSize(image));
4818 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4821 if (LocaleCompare(attribute,"filename") == 0)
4823 if (info && info->image_info->filename &&
4824 *info->image_info->filename)
4825 s=newSVpv(info->image_info->filename,0);
4826 if (image != (Image *) NULL)
4827 s=newSVpv(image->filename,0);
4828 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4831 if (LocaleCompare(attribute,"filter") == 0)
4833 s=image ? newSViv(image->filter) : newSViv(0);
4834 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4837 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4840 if (LocaleCompare(attribute,"font") == 0)
4842 if (info && info->image_info->font)
4843 s=newSVpv(info->image_info->font,0);
4844 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4847 if (LocaleCompare(attribute,"foreground") == 0)
4849 if (LocaleCompare(attribute,"format") == 0)
4854 magick_info=(const MagickInfo *) NULL;
4855 if (info && (*info->image_info->magick != '\0'))
4856 magick_info=GetMagickInfo(info->image_info->magick,exception);
4857 if (image != (Image *) NULL)
4858 magick_info=GetMagickInfo(image->magick,exception);
4859 if ((magick_info != (const MagickInfo *) NULL) &&
4860 (*magick_info->description != '\0'))
4861 s=newSVpv((char *) magick_info->description,0);
4862 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4865 if (LocaleCompare(attribute,"fuzz") == 0)
4868 s=newSVnv(info->image_info->fuzz);
4869 if (image != (Image *) NULL)
4870 s=newSVnv(image->fuzz);
4871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4874 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4881 if (LocaleCompare(attribute,"gamma") == 0)
4883 if (image != (Image *) NULL)
4884 s=newSVnv(image->gamma);
4885 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4888 if (LocaleCompare(attribute,"geometry") == 0)
4890 if (image && image->geometry)
4891 s=newSVpv(image->geometry,0);
4892 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4895 if (LocaleCompare(attribute,"gravity") == 0)
4897 s=image ? newSViv(image->gravity) : newSViv(0);
4898 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4901 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4904 if (LocaleCompare(attribute,"green-primary") == 0)
4906 if (image == (Image *) NULL)
4908 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4909 image->chromaticity.green_primary.x,
4910 image->chromaticity.green_primary.y);
4912 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4915 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4922 if (LocaleCompare(attribute,"height") == 0)
4924 if (image != (Image *) NULL)
4925 s=newSViv((ssize_t) image->rows);
4926 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4929 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4936 if (LocaleCompare(attribute,"icc") == 0)
4938 if (image != (Image *) NULL)
4943 profile=GetImageProfile(image,"icc");
4944 if (profile != (StringInfo *) NULL)
4945 s=newSVpv((const char *) GetStringInfoDatum(profile),
4946 GetStringInfoLength(profile));
4948 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4951 if (LocaleCompare(attribute,"icm") == 0)
4953 if (image != (Image *) NULL)
4958 profile=GetImageProfile(image,"icm");
4959 if (profile != (const StringInfo *) NULL)
4960 s=newSVpv((const char *) GetStringInfoDatum(profile),
4961 GetStringInfoLength(profile));
4963 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4966 if (LocaleCompare(attribute,"id") == 0)
4968 if (image != (Image *) NULL)
4979 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4981 status=SetImageRegistry(ImageRegistryType,key,image,
4986 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4989 if (LocaleNCompare(attribute,"index",5) == 0)
4992 name[MaxTextExtent];
5001 register const Quantum
5007 if (image == (Image *) NULL)
5009 if (image->storage_class != PseudoClass)
5013 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5015 image_view=AcquireVirtualCacheView(image,exception);
5016 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5017 if (p != (const Quantum *) NULL)
5019 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5020 GetPixelIndex(image,p));
5022 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5024 image_view=DestroyCacheView(image_view);
5027 if (LocaleCompare(attribute,"iptc") == 0)
5029 if (image != (Image *) NULL)
5034 profile=GetImageProfile(image,"iptc");
5035 if (profile != (const StringInfo *) NULL)
5036 s=newSVpv((const char *) GetStringInfoDatum(profile),
5037 GetStringInfoLength(profile));
5039 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5042 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5044 if (image != (Image *) NULL)
5045 s=newSViv((ssize_t) image->iterations);
5046 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5049 if (LocaleCompare(attribute,"interlace") == 0)
5051 j=info ? info->image_info->interlace : image ? image->interlace :
5054 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5057 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5060 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5067 if (LocaleCompare(attribute,"label") == 0)
5072 if (image == (Image *) NULL)
5074 value=GetImageProperty(image,"Label",exception);
5075 if (value != (const char *) NULL)
5077 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5080 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5082 if (image != (Image *) NULL)
5083 s=newSViv((ssize_t) image->iterations);
5084 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5087 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5094 if (LocaleCompare(attribute,"magick") == 0)
5096 if (info && *info->image_info->magick)
5097 s=newSVpv(info->image_info->magick,0);
5098 if (image != (Image *) NULL)
5099 s=newSVpv(image->magick,0);
5100 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5103 if (LocaleCompare(attribute,"map") == 0)
5105 s=newSViv(GetMagickResource(MapResource));
5106 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5109 if (LocaleCompare(attribute,"maximum-error") == 0)
5111 if (image != (Image *) NULL)
5112 s=newSVnv(image->error.normalized_maximum_error);
5113 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5116 if (LocaleCompare(attribute,"memory") == 0)
5118 s=newSViv(GetMagickResource(MemoryResource));
5119 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5122 if (LocaleCompare(attribute,"mean-error") == 0)
5124 if (image != (Image *) NULL)
5125 s=newSVnv(image->error.normalized_mean_error);
5126 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5129 if (LocaleCompare(attribute,"mime") == 0)
5131 if (info && *info->image_info->magick)
5132 s=newSVpv(MagickToMime(info->image_info->magick),0);
5133 if (image != (Image *) NULL)
5134 s=newSVpv(MagickToMime(image->magick),0);
5135 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5138 if (LocaleCompare(attribute,"mattecolor") == 0)
5140 if (image == (Image *) NULL)
5142 (void) FormatLocaleString(color,MaxTextExtent,
5143 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
5144 image->matte_color.green,image->matte_color.blue,
5145 image->matte_color.alpha);
5147 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5150 if (LocaleCompare(attribute,"matte") == 0)
5152 if (image != (Image *) NULL)
5153 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5155 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5158 if (LocaleCompare(attribute,"mime") == 0)
5164 if (info && *info->image_info->magick)
5165 magick=info->image_info->magick;
5166 if (image != (Image *) NULL)
5167 magick=image->magick;
5173 mime=MagickToMime(magick);
5175 mime=(char *) RelinquishMagickMemory(mime);
5177 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5180 if (LocaleCompare(attribute,"monochrome") == 0)
5182 if (image == (Image *) NULL)
5184 j=info ? info->image_info->monochrome :
5185 IsImageMonochrome(image,exception);
5187 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5190 if (LocaleCompare(attribute,"montage") == 0)
5192 if (image && image->montage)
5193 s=newSVpv(image->montage,0);
5194 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5197 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5204 if (LocaleCompare(attribute,"orientation") == 0)
5206 j=info ? info->image_info->orientation : image ?
5207 image->orientation : UndefinedOrientation;
5209 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5222 if (LocaleCompare(attribute,"page") == 0)
5224 if (info && info->image_info->page)
5225 s=newSVpv(info->image_info->page,0);
5226 if (image != (Image *) NULL)
5229 geometry[MaxTextExtent];
5231 (void) FormatLocaleString(geometry,MaxTextExtent,
5232 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5233 (double) image->page.height,(double) image->page.x,(double)
5235 s=newSVpv(geometry,0);
5237 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5240 if (LocaleCompare(attribute,"page.x") == 0)
5242 if (image != (Image *) NULL)
5243 s=newSViv((ssize_t) image->page.x);
5244 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5247 if (LocaleCompare(attribute,"page.y") == 0)
5249 if (image != (Image *) NULL)
5250 s=newSViv((ssize_t) image->page.y);
5251 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5254 if (LocaleNCompare(attribute,"pixel",5) == 0)
5257 tuple[MaxTextExtent];
5266 register const Quantum
5269 if (image == (Image *) NULL)
5273 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5275 p=GetVirtualPixels(image,x,y,1,1,exception);
5276 if (image->colorspace != CMYKColorspace)
5277 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5278 QuantumFormat "," QuantumFormat "," QuantumFormat,
5279 GetPixelRed(image,p),GetPixelGreen(image,p),
5280 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5282 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5283 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5284 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5285 GetPixelBlue(image,p),GetPixelBlack(image,p),
5286 GetPixelAlpha(image,p));
5288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5291 if (LocaleCompare(attribute,"pointsize") == 0)
5294 s=newSViv((ssize_t) info->image_info->pointsize);
5295 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5298 if (LocaleCompare(attribute,"preview") == 0)
5300 s=newSViv(info->image_info->preview_type);
5301 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5302 info->image_info->preview_type));
5304 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5307 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5314 if (LocaleCompare(attribute,"quality") == 0)
5317 s=newSViv((ssize_t) info->image_info->quality);
5318 if (image != (Image *) NULL)
5319 s=newSViv((ssize_t) image->quality);
5320 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5323 if (LocaleCompare(attribute,"quantum") == 0)
5326 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5327 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5330 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5337 if (LocaleCompare(attribute,"rendering-intent") == 0)
5339 s=newSViv(image->rendering_intent);
5340 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5341 image->rendering_intent));
5343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5346 if (LocaleCompare(attribute,"red-primary") == 0)
5348 if (image == (Image *) NULL)
5350 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5351 image->chromaticity.red_primary.x,
5352 image->chromaticity.red_primary.y);
5354 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5357 if (LocaleCompare(attribute,"rows") == 0)
5359 if (image != (Image *) NULL)
5360 s=newSViv((ssize_t) image->rows);
5361 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5364 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5371 if (LocaleCompare(attribute,"sampling-factor") == 0)
5373 if (info && info->image_info->sampling_factor)
5374 s=newSVpv(info->image_info->sampling_factor,0);
5375 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5378 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5380 if (info && info->image_info->server_name)
5381 s=newSVpv(info->image_info->server_name,0);
5382 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5385 if (LocaleCompare(attribute,"size") == 0)
5387 if (info && info->image_info->size)
5388 s=newSVpv(info->image_info->size,0);
5389 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5392 if (LocaleCompare(attribute,"scene") == 0)
5394 if (image != (Image *) NULL)
5395 s=newSViv((ssize_t) image->scene);
5396 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5399 if (LocaleCompare(attribute,"scenes") == 0)
5401 if (image != (Image *) NULL)
5402 s=newSViv((ssize_t) info->image_info->number_scenes);
5403 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5406 if (LocaleCompare(attribute,"signature") == 0)
5411 if (image == (Image *) NULL)
5413 (void) SignatureImage(image,exception);
5414 value=GetImageProperty(image,"Signature",exception);
5415 if (value != (const char *) NULL)
5417 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5420 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5427 if (LocaleCompare(attribute,"taint") == 0)
5429 if (image != (Image *) NULL)
5430 s=newSViv((ssize_t) IsTaintImage(image));
5431 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5434 if (LocaleCompare(attribute,"texture") == 0)
5436 if (info && info->image_info->texture)
5437 s=newSVpv(info->image_info->texture,0);
5438 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5441 if (LocaleCompare(attribute,"total-ink-density") == 0)
5443 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5444 if (image != (Image *) NULL)
5445 s=newSVnv(GetImageTotalInkDensity(image,exception));
5446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5449 if (LocaleCompare(attribute,"transparent-color") == 0)
5451 if (image == (Image *) NULL)
5453 (void) FormatLocaleString(color,MaxTextExtent,
5454 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5455 image->transparent_color.green,image->transparent_color.blue,
5456 image->transparent_color.alpha);
5458 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5461 if (LocaleCompare(attribute,"type") == 0)
5463 if (image == (Image *) NULL)
5465 j=(ssize_t) GetImageType(image,exception);
5467 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5469 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5472 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5479 if (LocaleCompare(attribute,"units") == 0)
5481 j=info ? info->image_info->units : image ? image->units :
5482 UndefinedResolution;
5483 if (info && (info->image_info->units == UndefinedResolution))
5486 if (j == UndefinedResolution)
5487 s=newSVpv("undefined units",0);
5489 if (j == PixelsPerInchResolution)
5490 s=newSVpv("pixels / inch",0);
5492 s=newSVpv("pixels / centimeter",0);
5493 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5496 if (LocaleCompare(attribute,"user-time") == 0)
5498 if (image != (Image *) NULL)
5499 s=newSVnv(GetUserTime(&image->timer));
5500 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5503 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5510 if (LocaleCompare(attribute,"verbose") == 0)
5513 s=newSViv((ssize_t) info->image_info->verbose);
5514 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5517 if (LocaleCompare(attribute,"version") == 0)
5519 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5520 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5523 if (LocaleCompare(attribute,"view") == 0)
5525 if (info && info->image_info->view)
5526 s=newSVpv(info->image_info->view,0);
5527 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5530 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5532 if (image == (Image *) NULL)
5534 j=(ssize_t) GetImageVirtualPixelMethod(image);
5536 (void) sv_setpv(s,CommandOptionToMnemonic(
5537 MagickVirtualPixelOptions,j));
5539 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5542 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5549 if (LocaleCompare(attribute,"white-point") == 0)
5551 if (image == (Image *) NULL)
5553 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5554 image->chromaticity.white_point.x,
5555 image->chromaticity.white_point.y);
5557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5560 if (LocaleCompare(attribute,"width") == 0)
5562 if (image != (Image *) NULL)
5563 s=newSViv((ssize_t) image->columns);
5564 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5567 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5574 if (LocaleCompare(attribute,"x-resolution") == 0)
5576 if (image != (Image *) NULL)
5577 s=newSVnv(image->resolution.x);
5578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5581 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5588 if (LocaleCompare(attribute,"y-resolution") == 0)
5590 if (image != (Image *) NULL)
5591 s=newSVnv(image->resolution.y);
5592 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5595 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5602 if (image == (Image *) NULL)
5603 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5607 value=GetImageProperty(image,attribute,exception);
5608 if (value != (const char *) NULL)
5611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5614 if (*attribute != '%')
5615 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5622 meta=InterpretImageProperties(info ? info->image_info :
5623 (ImageInfo *) NULL,image,attribute,exception);
5625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5626 meta=(char *) RelinquishMagickMemory(meta);
5630 exception=DestroyExceptionInfo(exception);
5631 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5635 ###############################################################################
5639 # G e t A u t h e n t i c P i x e l s #
5643 ###############################################################################
5647 GetAuthenticPixels(ref,...)
5648 Image::Magick ref = NO_INIT
5650 getauthenticpixels = 1
5680 PERL_UNUSED_VAR(ref);
5681 PERL_UNUSED_VAR(ix);
5682 exception=AcquireExceptionInfo();
5683 perl_exception=newSVpv("",0);
5684 if (sv_isobject(ST(0)) == 0)
5686 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5690 reference=SvRV(ST(0));
5692 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5693 if (image == (Image *) NULL)
5695 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5702 region.width=image->columns;
5705 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5706 for (i=2; i < items; i+=2)
5708 attribute=(char *) SvPV(ST(i-1),na);
5714 if (LocaleCompare(attribute,"geometry") == 0)
5716 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5719 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5726 if (LocaleCompare(attribute,"height") == 0)
5728 region.height=SvIV(ST(i));
5731 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5738 if (LocaleCompare(attribute,"x") == 0)
5740 region.x=SvIV(ST(i));
5743 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5750 if (LocaleCompare(attribute,"y") == 0)
5752 region.y=SvIV(ST(i));
5755 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5762 if (LocaleCompare(attribute,"width") == 0)
5764 region.width=SvIV(ST(i));
5767 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5773 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5774 region.height,exception);
5775 if (blob != (void *) NULL)
5779 InheritPerlException(exception,perl_exception);
5780 exception=DestroyExceptionInfo(exception);
5781 SvREFCNT_dec(perl_exception); /* throw away all errors */
5790 ###############################################################################
5794 # G e t V i r t u a l P i x e l s #
5798 ###############################################################################
5802 GetVirtualPixels(ref,...)
5803 Image::Magick ref = NO_INIT
5805 getvirtualpixels = 1
5806 AcquireImagePixels = 2
5807 acquireimagepixels = 3
5835 PERL_UNUSED_VAR(ref);
5836 PERL_UNUSED_VAR(ix);
5837 exception=AcquireExceptionInfo();
5838 perl_exception=newSVpv("",0);
5839 if (sv_isobject(ST(0)) == 0)
5841 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5845 reference=SvRV(ST(0));
5847 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5848 if (image == (Image *) NULL)
5850 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5857 region.width=image->columns;
5860 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5861 for (i=2; i < items; i+=2)
5863 attribute=(char *) SvPV(ST(i-1),na);
5869 if (LocaleCompare(attribute,"geometry") == 0)
5871 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5874 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5881 if (LocaleCompare(attribute,"height") == 0)
5883 region.height=SvIV(ST(i));
5886 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5893 if (LocaleCompare(attribute,"x") == 0)
5895 region.x=SvIV(ST(i));
5898 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5905 if (LocaleCompare(attribute,"y") == 0)
5907 region.y=SvIV(ST(i));
5910 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5917 if (LocaleCompare(attribute,"width") == 0)
5919 region.width=SvIV(ST(i));
5922 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5928 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5929 region.height,exception);
5930 if (blob != (void *) NULL)
5934 InheritPerlException(exception,perl_exception);
5935 exception=DestroyExceptionInfo(exception);
5936 SvREFCNT_dec(perl_exception); /* throw away all errors */
5939 RETVAL = (void *) blob;
5945 ###############################################################################
5949 # G e t A u t h e n t i c M e t a c o n t e n t #
5953 ###############################################################################
5957 GetAuthenticMetacontent(ref,...)
5958 Image::Magick ref = NO_INIT
5960 getauthenticmetacontent = 1
5981 PERL_UNUSED_VAR(ref);
5982 PERL_UNUSED_VAR(ix);
5983 exception=AcquireExceptionInfo();
5984 perl_exception=newSVpv("",0);
5985 if (sv_isobject(ST(0)) == 0)
5987 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5991 reference=SvRV(ST(0));
5993 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5994 if (image == (Image *) NULL)
5996 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6001 blob=(void *) GetAuthenticMetacontent(image);
6002 if (blob != (void *) NULL)
6006 InheritPerlException(exception,perl_exception);
6007 exception=DestroyExceptionInfo(exception);
6008 SvREFCNT_dec(perl_exception); /* throw away all errors */
6017 ###############################################################################
6021 # G e t V i r t u a l M e t a c o n t e n t #
6025 ###############################################################################
6029 GetVirtualMetacontent(ref,...)
6030 Image::Magick ref = NO_INIT
6032 getvirtualmetacontent = 1
6051 PERL_UNUSED_VAR(ref);
6052 PERL_UNUSED_VAR(ix);
6053 exception=AcquireExceptionInfo();
6054 perl_exception=newSVpv("",0);
6055 if (sv_isobject(ST(0)) == 0)
6057 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6061 reference=SvRV(ST(0));
6063 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6064 if (image == (Image *) NULL)
6066 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6071 blob=(void *) GetVirtualMetacontent(image);
6072 if (blob != (void *) NULL)
6076 InheritPerlException(exception,perl_exception);
6077 exception=DestroyExceptionInfo(exception);
6078 SvREFCNT_dec(perl_exception); /* throw away all errors */
6087 ###############################################################################
6091 # H i s t o g r a m #
6095 ###############################################################################
6100 Image::Magick ref=NO_INIT
6111 message[MaxTextExtent];
6138 PERL_UNUSED_VAR(ref);
6139 PERL_UNUSED_VAR(ix);
6140 exception=AcquireExceptionInfo();
6141 perl_exception=newSVpv("",0);
6143 if (sv_isobject(ST(0)) == 0)
6145 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6149 reference=SvRV(ST(0));
6152 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6153 if (image == (Image *) NULL)
6155 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6159 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6161 for ( ; image; image=image->next)
6163 histogram=GetImageHistogram(image,&number_colors,exception);
6164 if (histogram == (PixelInfo *) NULL)
6166 count+=(ssize_t) number_colors;
6168 for (i=0; i < (ssize_t) number_colors; i++)
6170 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6172 PUSHs(sv_2mortal(newSVpv(message,0)));
6173 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6174 histogram[i].green);
6175 PUSHs(sv_2mortal(newSVpv(message,0)));
6176 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6178 PUSHs(sv_2mortal(newSVpv(message,0)));
6179 if (image->colorspace == CMYKColorspace)
6181 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6182 histogram[i].black);
6183 PUSHs(sv_2mortal(newSVpv(message,0)));
6185 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6186 histogram[i].alpha);
6187 PUSHs(sv_2mortal(newSVpv(message,0)));
6188 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6189 histogram[i].count);
6190 PUSHs(sv_2mortal(newSVpv(message,0)));
6192 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6196 InheritPerlException(exception,perl_exception);
6197 exception=DestroyExceptionInfo(exception);
6198 SvREFCNT_dec(perl_exception);
6202 ###############################################################################
6210 ###############################################################################
6215 Image::Magick ref=NO_INIT
6239 register const Quantum
6253 *reference; /* reference is the SV* of ref=SvIV(reference) */
6255 PERL_UNUSED_VAR(ref);
6256 PERL_UNUSED_VAR(ix);
6257 exception=AcquireExceptionInfo();
6258 perl_exception=newSVpv("",0);
6259 reference=SvRV(ST(0));
6260 av=(AV *) reference;
6261 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6263 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6264 if (image == (Image *) NULL)
6266 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6270 normalize=MagickTrue;
6273 region.width=image->columns;
6276 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6277 for (i=2; i < items; i+=2)
6279 attribute=(char *) SvPV(ST(i-1),na);
6285 if (LocaleCompare(attribute,"channel") == 0)
6290 option=ParseChannelOption(SvPV(ST(i),na));
6293 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6297 SetPixelChannelMask(image,(ChannelType) option);
6300 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6307 if (LocaleCompare(attribute,"geometry") == 0)
6309 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6312 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6319 if (LocaleCompare(attribute,"normalize") == 0)
6321 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6325 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6329 normalize=option != 0 ? MagickTrue : MagickFalse;
6332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6339 if (LocaleCompare(attribute,"x") == 0)
6341 region.x=SvIV(ST(i));
6344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6351 if (LocaleCompare(attribute,"y") == 0)
6353 region.y=SvIV(ST(i));
6356 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6362 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6368 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6369 if (p == (const Quantum *) NULL)
6377 if (normalize != MagickFalse)
6378 scale=1.0/QuantumRange;
6379 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6380 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6381 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6382 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6383 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6384 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6385 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6386 (image->colorspace == CMYKColorspace))
6387 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6388 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6389 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6393 InheritPerlException(exception,perl_exception);
6394 exception=DestroyExceptionInfo(exception);
6395 SvREFCNT_dec(perl_exception);
6399 ###############################################################################
6403 # G e t P i x e l s #
6407 ###############################################################################
6412 Image::Magick ref=NO_INIT
6451 *reference; /* reference is the SV* of ref=SvIV(reference) */
6453 PERL_UNUSED_VAR(ref);
6454 PERL_UNUSED_VAR(ix);
6455 exception=AcquireExceptionInfo();
6456 perl_exception=newSVpv("",0);
6457 reference=SvRV(ST(0));
6458 av=(AV *) reference;
6459 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6461 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6462 if (image == (Image *) NULL)
6464 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6469 if (image->alpha_trait == BlendPixelTrait)
6471 if (image->colorspace == CMYKColorspace)
6474 if (image->alpha_trait == BlendPixelTrait)
6477 normalize=MagickFalse;
6480 region.width=image->columns;
6483 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6484 for (i=2; i < items; i+=2)
6486 attribute=(char *) SvPV(ST(i-1),na);
6492 if (LocaleCompare(attribute,"geometry") == 0)
6494 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6497 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6504 if (LocaleCompare(attribute,"height") == 0)
6506 region.height=SvIV(ST(i));
6509 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6516 if (LocaleCompare(attribute,"map") == 0)
6521 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6528 if (LocaleCompare(attribute,"normalize") == 0)
6530 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6534 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6538 normalize=option != 0 ? MagickTrue : MagickFalse;
6541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6548 if (LocaleCompare(attribute,"width") == 0)
6550 region.width=SvIV(ST(i));
6553 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6560 if (LocaleCompare(attribute,"x") == 0)
6562 region.x=SvIV(ST(i));
6565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6572 if (LocaleCompare(attribute,"y") == 0)
6574 region.y=SvIV(ST(i));
6577 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6583 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6589 if (normalize != MagickFalse)
6594 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6595 region.height*sizeof(*pixels));
6596 if (pixels == (float *) NULL)
6598 ThrowPerlException(exception,ResourceLimitError,
6599 "MemoryAllocationFailed",PackageName);
6602 status=ExportImagePixels(image,region.x,region.y,region.width,
6603 region.height,map,FloatPixel,pixels,exception);
6604 if (status == MagickFalse)
6608 EXTEND(sp,strlen(map)*region.width*region.height);
6609 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6610 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6612 pixels=(float *) RelinquishMagickMemory(pixels);
6619 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6620 region.height*sizeof(*pixels));
6621 if (pixels == (Quantum *) NULL)
6623 ThrowPerlException(exception,ResourceLimitError,
6624 "MemoryAllocationFailed",PackageName);
6627 status=ExportImagePixels(image,region.x,region.y,region.width,
6628 region.height,map,QuantumPixel,pixels,exception);
6629 if (status == MagickFalse)
6633 EXTEND(sp,strlen(map)*region.width*region.height);
6634 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6635 PUSHs(sv_2mortal(newSViv(pixels[i])));
6637 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6641 InheritPerlException(exception,perl_exception);
6642 exception=DestroyExceptionInfo(exception);
6643 SvREFCNT_dec(perl_exception);
6647 ###############################################################################
6651 # I m a g e T o B l o b #
6655 ###############################################################################
6659 ImageToBlob(ref,...)
6660 Image::Magick ref=NO_INIT
6669 filename[MaxTextExtent];
6698 PERL_UNUSED_VAR(ref);
6699 PERL_UNUSED_VAR(ix);
6700 exception=AcquireExceptionInfo();
6701 perl_exception=newSVpv("",0);
6702 package_info=(struct PackageInfo *) NULL;
6703 if (sv_isobject(ST(0)) == 0)
6705 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6709 reference=SvRV(ST(0));
6710 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6711 if (image == (Image *) NULL)
6713 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6717 package_info=ClonePackageInfo(info,exception);
6718 for (i=2; i < items; i+=2)
6719 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6720 (void) CopyMagickString(filename,package_info->image_info->filename,
6723 for (next=image; next; next=next->next)
6725 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6726 next->scene=scene++;
6728 SetImageInfo(package_info->image_info,(unsigned int)
6729 GetImageListLength(image),exception);
6730 EXTEND(sp,(ssize_t) GetImageListLength(image));
6731 for ( ; image; image=image->next)
6734 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6735 if (blob != (char *) NULL)
6737 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6738 blob=(unsigned char *) RelinquishMagickMemory(blob);
6740 if (package_info->image_info->adjoin)
6745 if (package_info != (struct PackageInfo *) NULL)
6746 DestroyPackageInfo(package_info);
6747 InheritPerlException(exception,perl_exception);
6748 exception=DestroyExceptionInfo(exception);
6749 SvREFCNT_dec(perl_exception); /* throw away all errors */
6753 ###############################################################################
6761 ###############################################################################
6766 Image::Magick ref=NO_INIT
6770 OptimizeImageLayers = 3
6772 optimizeimagelayers = 5
6814 PERL_UNUSED_VAR(ref);
6815 PERL_UNUSED_VAR(ix);
6816 exception=AcquireExceptionInfo();
6817 perl_exception=newSVpv("",0);
6819 if (sv_isobject(ST(0)) == 0)
6821 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6825 reference=SvRV(ST(0));
6826 hv=SvSTASH(reference);
6828 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6830 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6831 if (image == (Image *) NULL)
6833 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6837 compose=image->compose;
6838 method=OptimizeLayer;
6839 for (i=2; i < items; i+=2)
6841 attribute=(char *) SvPV(ST(i-1),na);
6847 if (LocaleCompare(attribute,"compose") == 0)
6849 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6850 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6853 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6857 compose=(CompositeOperator) sp;
6860 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6867 if (LocaleCompare(attribute,"method") == 0)
6869 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6873 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6877 method=(LayerMethod) option;
6880 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6886 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6892 layers=(Image *) NULL;
6895 case CompareAnyLayer:
6896 case CompareClearLayer:
6897 case CompareOverlayLayer:
6900 layers=CompareImagesLayers(image,method,exception);
6907 layers=MergeImageLayers(image,method,exception);
6912 layers=DisposeImages(image,exception);
6915 case OptimizeImageLayer:
6917 layers=OptimizeImageLayers(image,exception);
6920 case OptimizePlusLayer:
6922 layers=OptimizePlusImageLayers(image,exception);
6925 case OptimizeTransLayer:
6927 OptimizeImageTransparency(image,exception);
6930 case RemoveDupsLayer:
6932 RemoveDuplicateLayers(&image,exception);
6935 case RemoveZeroLayer:
6937 RemoveZeroDelayLayers(&image,exception);
6946 General Purpose, GIF Animation Optimizer.
6948 layers=CoalesceImages(image,exception);
6949 if (layers == (Image *) NULL)
6952 layers=OptimizeImageLayers(image,exception);
6953 if (layers == (Image *) NULL)
6955 image=DestroyImageList(image);
6957 layers=(Image *) NULL;
6958 OptimizeImageTransparency(image,exception);
6959 quantize_info=AcquireQuantizeInfo(info->image_info);
6960 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6961 quantize_info=DestroyQuantizeInfo(quantize_info);
6964 case CompositeLayer:
6973 Split image sequence at the first 'NULL:' image.
6976 while (source != (Image *) NULL)
6978 source=GetNextImageInList(source);
6979 if ((source != (Image *) NULL) &&
6980 (LocaleCompare(source->magick,"NULL") == 0))
6983 if (source != (Image *) NULL)
6985 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6986 (GetNextImageInList(source) == (Image *) NULL))
6987 source=(Image *) NULL;
6991 Separate the two lists, junk the null: image.
6993 source=SplitImageList(source->previous);
6994 DeleteImageFromList(&source);
6997 if (source == (Image *) NULL)
6999 (void) ThrowMagickException(exception,GetMagickModule(),
7000 OptionError,"MissingNullSeparator","layers Composite");
7004 Adjust offset with gravity and virtual canvas.
7006 SetGeometry(image,&geometry);
7007 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7008 geometry.width=source->page.width != 0 ? source->page.width :
7010 geometry.height=source->page.height != 0 ? source->page.height :
7012 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7013 image->columns,image->page.height != 0 ? image->page.height :
7014 image->rows,image->gravity,&geometry);
7015 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7016 source=DestroyImageList(source);
7020 if (layers != (Image *) NULL)
7022 if (image == (Image *) NULL)
7024 for ( ; image; image=image->next)
7026 AddImageToRegistry(sv,image);
7028 av_push(av,sv_bless(rv,hv));
7031 exception=DestroyExceptionInfo(exception);
7033 SvREFCNT_dec(perl_exception);
7037 InheritPerlException(exception,perl_exception);
7038 exception=DestroyExceptionInfo(exception);
7039 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7040 SvPOK_on(perl_exception);
7041 ST(0)=sv_2mortal(perl_exception);
7046 ###############################################################################
7050 # M a g i c k T o M i m e #
7054 ###############################################################################
7058 MagickToMime(ref,name)
7059 Image::Magick ref=NO_INIT
7068 PERL_UNUSED_VAR(ref);
7069 PERL_UNUSED_VAR(ix);
7070 mime=MagickToMime(name);
7071 RETVAL=newSVpv(mime,0);
7072 mime=(char *) RelinquishMagickMemory(mime);
7078 ###############################################################################
7086 ###############################################################################
7091 Image::Magick ref=NO_INIT
7128 MedianConvolveImage = 36
7134 ReduceNoiseImage = 42
7160 ColorFloodfillImage= 68
7166 CycleColormapImage = 74
7176 MatteFloodfillImage= 84
7184 NumberColorsImage = 92
7194 SignatureImage = 102
7204 TransparentImage = 112
7206 ThresholdImage = 114
7220 DeconstructImage = 130
7222 GaussianBlurImage = 132
7228 UnsharpMaskImage = 138
7230 MotionBlurImage = 140
7232 OrderedDitherImage = 142
7239 AffineTransform = 149
7240 AffineTransformImage = 150
7242 DifferenceImage = 152
7243 AdaptiveThreshold = 153
7244 AdaptiveThresholdImage = 154
7249 BlackThreshold = 159
7250 BlackThresholdImage= 160
7251 WhiteThreshold = 161
7252 WhiteThresholdImage= 162
7254 RadialBlurImage = 164
7256 ThumbnailImage = 166
7266 PosterizeImage = 176
7272 SepiaToneImage = 182
7273 SigmoidalContrast = 183
7274 SigmoidalContrastImage = 184
7279 ContrastStretch = 189
7280 ContrastStretchImage = 190
7285 AdaptiveSharpen = 195
7286 AdaptiveSharpenImage = 196
7288 TransposeImage = 198
7290 TransverseImage = 200
7292 AutoOrientImage = 202
7294 AdaptiveBlurImage = 204
7298 UniqueColorsImage = 208
7299 AdaptiveResize = 209
7300 AdaptiveResizeImage= 210
7304 LinearStretchImage = 214
7306 ColorMatrixImage = 216
7311 FloodfillPaint = 221
7312 FloodfillPaintImage= 222
7318 LiquidRescaleImage = 228
7328 SparseColorImage = 238
7332 SelectiveBlurImage = 242
7336 BlueShiftImage = 246
7337 ForwardFourierTransform = 247
7338 ForwardFourierTransformImage = 248
7339 InverseFourierTransform = 249
7340 InverseFourierTransformImage = 250
7341 ColorDecisionList = 251
7342 ColorDecisionListImage = 252
7344 AutoGammaImage = 254
7346 AutoLevelImage = 256
7348 LevelImageColors = 258
7351 BrightnessContrast = 261
7352 BrightnessContrastImage = 262
7354 MorphologyImage = 264
7360 StatisticImage = 270
7362 PerceptibleImage = 272
7373 attribute_flag[MaxArguments],
7374 message[MaxTextExtent];
7435 argument_list[MaxArguments];
7437 PERL_UNUSED_VAR(ref);
7438 PERL_UNUSED_VAR(ix);
7439 exception=AcquireExceptionInfo();
7440 perl_exception=newSVpv("",0);
7441 reference_vector=NULL;
7445 if (sv_isobject(ST(0)) == 0)
7447 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7451 reference=SvRV(ST(0));
7452 region_info.width=0;
7453 region_info.height=0;
7456 region_image=(Image *) NULL;
7457 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7458 if (ix && (ix != 666))
7461 Called as Method(...)
7464 rp=(&Methods[ix-1]);
7470 Called as Mogrify("Method",...)
7472 attribute=(char *) SvPV(ST(1),na);
7475 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7476 attribute=(char *) SvPV(ST(2),na);
7479 for (rp=Methods; ; rp++)
7481 if (rp >= EndOf(Methods))
7483 ThrowPerlException(exception,OptionError,
7484 "UnrecognizedPerlMagickMethod",attribute);
7487 if (strEQcase(attribute,rp->name))
7493 if (image == (Image *) NULL)
7495 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7498 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7499 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7500 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7517 pp=(Arguments *) NULL;
7525 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7527 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7529 if (strEQcase(attribute,qq->method) > ssize_test)
7532 ssize_test=strEQcase(attribute,qq->method);
7535 if (pp == (Arguments *) NULL)
7537 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7539 goto continue_outer_loop;
7541 al=(&argument_list[pp-rp->arguments]);
7544 case ArrayReference:
7546 if (SvTYPE(sv) != SVt_RV)
7548 (void) FormatLocaleString(message,MaxTextExtent,
7549 "invalid %.60s value",pp->method);
7550 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7551 goto continue_outer_loop;
7553 al->array_reference=SvRV(sv);
7558 al->real_reference=SvNV(sv);
7563 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7566 case ImageReference:
7568 if (!sv_isobject(sv) ||
7569 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7570 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7572 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7578 case IntegerReference:
7580 al->integer_reference=SvIV(sv);
7583 case StringReference:
7585 al->string_reference=(char *) SvPV(sv,al->length);
7586 if (sv_isobject(sv))
7587 al->image_reference=SetupList(aTHX_ SvRV(sv),
7588 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7594 Is a string; look up name.
7596 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7598 al->string_reference=(char *) SvPV(sv,al->length);
7599 al->integer_reference=(-1);
7602 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7603 MagickFalse,SvPV(sv,na));
7604 if (pp->type == MagickChannelOptions)
7605 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7606 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7608 (void) FormatLocaleString(message,MaxTextExtent,
7609 "invalid %.60s value",pp->method);
7610 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7611 goto continue_outer_loop;
7616 attribute_flag[pp-rp->arguments]++;
7617 continue_outer_loop: ;
7619 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7620 pv=reference_vector;
7621 SetGeometryInfo(&geometry_info);
7622 channel=DefaultChannels;
7623 for (next=image; next; next=next->next)
7626 SetGeometry(image,&geometry);
7627 if ((region_info.width*region_info.height) != 0)
7630 image=CropImage(image,®ion_info,exception);
7636 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7637 ThrowPerlException(exception,OptionError,
7638 "UnrecognizedPerlMagickMethod",message);
7641 case 1: /* Comment */
7643 if (attribute_flag[0] == 0)
7644 argument_list[0].string_reference=(char *) NULL;
7645 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7646 info ? info->image_info : (ImageInfo *) NULL,image,
7647 argument_list[0].string_reference,exception),exception);
7652 if (attribute_flag[0] == 0)
7653 argument_list[0].string_reference=(char *) NULL;
7654 (void) SetImageProperty(image,"label",InterpretImageProperties(
7655 info ? info->image_info : (ImageInfo *) NULL,image,
7656 argument_list[0].string_reference,exception),exception);
7659 case 3: /* AddNoise */
7664 if (attribute_flag[0] == 0)
7665 argument_list[0].integer_reference=UniformNoise;
7667 if (attribute_flag[1] != 0)
7668 attenuate=argument_list[1].real_reference;
7669 if (attribute_flag[2] != 0)
7670 channel=(ChannelType) argument_list[2].integer_reference;
7671 channel_mask=SetImageChannelMask(image,channel);
7672 image=AddNoiseImage(image,(NoiseType)
7673 argument_list[0].integer_reference,attenuate,exception);
7674 if (image != (Image *) NULL)
7675 (void) SetImageChannelMask(image,channel_mask);
7678 case 4: /* Colorize */
7683 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7684 0,0,&target,exception);
7685 if (attribute_flag[0] != 0)
7686 (void) QueryColorCompliance(argument_list[0].string_reference,
7687 AllCompliance,&target,exception);
7688 if (attribute_flag[1] == 0)
7689 argument_list[1].string_reference="100%";
7690 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7694 case 5: /* Border */
7701 if (attribute_flag[0] != 0)
7702 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7703 &geometry,exception);
7704 if (attribute_flag[1] != 0)
7705 geometry.width=argument_list[1].integer_reference;
7706 if (attribute_flag[2] != 0)
7707 geometry.height=argument_list[2].integer_reference;
7708 if (attribute_flag[3] != 0)
7709 QueryColorCompliance(argument_list[3].string_reference,
7710 AllCompliance,&image->border_color,exception);
7711 if (attribute_flag[4] != 0)
7712 QueryColorCompliance(argument_list[4].string_reference,
7713 AllCompliance,&image->border_color,exception);
7714 if (attribute_flag[5] != 0)
7715 QueryColorCompliance(argument_list[5].string_reference,
7716 AllCompliance,&image->border_color,exception);
7717 compose=image->compose;
7718 if (attribute_flag[6] != 0)
7719 compose=(CompositeOperator) argument_list[6].integer_reference;
7720 image=BorderImage(image,&geometry,compose,exception);
7725 if (attribute_flag[0] != 0)
7727 flags=ParseGeometry(argument_list[0].string_reference,
7729 if ((flags & SigmaValue) == 0)
7730 geometry_info.sigma=1.0;
7732 if (attribute_flag[1] != 0)
7733 geometry_info.rho=argument_list[1].real_reference;
7734 if (attribute_flag[2] != 0)
7735 geometry_info.sigma=argument_list[2].real_reference;
7736 if (attribute_flag[3] != 0)
7737 channel=(ChannelType) argument_list[3].integer_reference;
7738 channel_mask=SetImageChannelMask(image,channel);
7739 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7741 if (image != (Image *) NULL)
7742 (void) SetImageChannelMask(image,channel_mask);
7747 if (attribute_flag[0] != 0)
7748 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7749 &geometry,exception);
7750 if (attribute_flag[1] != 0)
7751 geometry.width=argument_list[1].integer_reference;
7752 if (attribute_flag[2] != 0)
7753 geometry.height=argument_list[2].integer_reference;
7754 if (attribute_flag[3] != 0)
7755 geometry.x=argument_list[3].integer_reference;
7756 if (attribute_flag[4] != 0)
7757 geometry.y=argument_list[4].integer_reference;
7758 image=ChopImage(image,&geometry,exception);
7763 if (attribute_flag[6] != 0)
7764 image->gravity=(GravityType) argument_list[6].integer_reference;
7765 if (attribute_flag[0] != 0)
7766 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7767 &geometry,exception);
7768 if (attribute_flag[1] != 0)
7769 geometry.width=argument_list[1].integer_reference;
7770 if (attribute_flag[2] != 0)
7771 geometry.height=argument_list[2].integer_reference;
7772 if (attribute_flag[3] != 0)
7773 geometry.x=argument_list[3].integer_reference;
7774 if (attribute_flag[4] != 0)
7775 geometry.y=argument_list[4].integer_reference;
7776 if (attribute_flag[5] != 0)
7777 image->fuzz=StringToDoubleInterval(
7778 argument_list[5].string_reference,(double) QuantumRange+1.0);
7779 image=CropImage(image,&geometry,exception);
7782 case 9: /* Despeckle */
7784 image=DespeckleImage(image,exception);
7789 if (attribute_flag[0] != 0)
7790 geometry_info.rho=argument_list[0].real_reference;
7791 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7795 case 11: /* Emboss */
7797 if (attribute_flag[0] != 0)
7799 flags=ParseGeometry(argument_list[0].string_reference,
7801 if ((flags & SigmaValue) == 0)
7802 geometry_info.sigma=1.0;
7804 if (attribute_flag[1] != 0)
7805 geometry_info.rho=argument_list[1].real_reference;
7806 if (attribute_flag[2] != 0)
7807 geometry_info.sigma=argument_list[2].real_reference;
7808 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7812 case 12: /* Enhance */
7814 image=EnhanceImage(image,exception);
7819 image=FlipImage(image,exception);
7824 image=FlopImage(image,exception);
7827 case 15: /* Frame */
7835 if (attribute_flag[0] != 0)
7837 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7838 &geometry,exception);
7839 frame_info.width=geometry.width;
7840 frame_info.height=geometry.height;
7841 frame_info.outer_bevel=geometry.x;
7842 frame_info.inner_bevel=geometry.y;
7844 if (attribute_flag[1] != 0)
7845 frame_info.width=argument_list[1].integer_reference;
7846 if (attribute_flag[2] != 0)
7847 frame_info.height=argument_list[2].integer_reference;
7848 if (attribute_flag[3] != 0)
7849 frame_info.inner_bevel=argument_list[3].integer_reference;
7850 if (attribute_flag[4] != 0)
7851 frame_info.outer_bevel=argument_list[4].integer_reference;
7852 if (attribute_flag[5] != 0)
7853 QueryColorCompliance(argument_list[5].string_reference,
7854 AllCompliance,&fill_color,exception);
7855 if (attribute_flag[6] != 0)
7856 QueryColorCompliance(argument_list[6].string_reference,
7857 AllCompliance,&fill_color,exception);
7858 frame_info.x=(ssize_t) frame_info.width;
7859 frame_info.y=(ssize_t) frame_info.height;
7860 frame_info.width=image->columns+2*frame_info.x;
7861 frame_info.height=image->rows+2*frame_info.y;
7862 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7863 image->matte_color=fill_color;
7864 compose=image->compose;
7865 if (attribute_flag[7] != 0)
7866 compose=(CompositeOperator) argument_list[7].integer_reference;
7867 image=FrameImage(image,&frame_info,compose,exception);
7870 case 16: /* Implode */
7872 PixelInterpolateMethod
7875 if (attribute_flag[0] == 0)
7876 argument_list[0].real_reference=0.5;
7877 method=UndefinedInterpolatePixel;
7878 if (attribute_flag[1] != 0)
7879 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7880 image=ImplodeImage(image,argument_list[0].real_reference,
7884 case 17: /* Magnify */
7886 image=MagnifyImage(image,exception);
7889 case 18: /* MedianFilter */
7891 if (attribute_flag[0] != 0)
7893 flags=ParseGeometry(argument_list[0].string_reference,
7895 if ((flags & SigmaValue) == 0)
7896 geometry_info.sigma=geometry_info.rho;
7898 if (attribute_flag[1] != 0)
7899 geometry_info.rho=argument_list[1].real_reference;
7900 if (attribute_flag[2] != 0)
7901 geometry_info.sigma=argument_list[2].real_reference;
7902 if (attribute_flag[3] != 0)
7903 channel=(ChannelType) argument_list[3].integer_reference;
7904 channel_mask=SetImageChannelMask(image,channel);
7905 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7906 (size_t) geometry_info.sigma,exception);
7907 if (image != (Image *) NULL)
7908 (void) SetImageChannelMask(image,channel_mask);
7911 case 19: /* Minify */
7913 image=MinifyImage(image,exception);
7916 case 20: /* OilPaint */
7918 if (attribute_flag[0] == 0)
7919 argument_list[0].real_reference=0.0;
7920 if (attribute_flag[1] == 0)
7921 argument_list[1].real_reference=1.0;
7922 image=OilPaintImage(image,argument_list[0].real_reference,
7923 argument_list[1].real_reference,exception);
7926 case 21: /* ReduceNoise */
7928 if (attribute_flag[0] != 0)
7930 flags=ParseGeometry(argument_list[0].string_reference,
7932 if ((flags & SigmaValue) == 0)
7933 geometry_info.sigma=1.0;
7935 if (attribute_flag[1] != 0)
7936 geometry_info.rho=argument_list[1].real_reference;
7937 if (attribute_flag[2] != 0)
7938 geometry_info.sigma=argument_list[2].real_reference;
7939 if (attribute_flag[3] != 0)
7940 channel=(ChannelType) argument_list[3].integer_reference;
7941 channel_mask=SetImageChannelMask(image,channel);
7942 image=StatisticImage(image,NonpeakStatistic,(size_t)
7943 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7944 if (image != (Image *) NULL)
7945 (void) SetImageChannelMask(image,channel_mask);
7950 if (attribute_flag[0] != 0)
7951 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7952 &geometry,exception);
7953 if (attribute_flag[1] != 0)
7954 geometry.x=argument_list[1].integer_reference;
7955 if (attribute_flag[2] != 0)
7956 geometry.y=argument_list[2].integer_reference;
7957 image=RollImage(image,geometry.x,geometry.y,exception);
7960 case 23: /* Rotate */
7962 if (attribute_flag[0] == 0)
7963 argument_list[0].real_reference=90.0;
7964 if (attribute_flag[1] != 0)
7966 QueryColorCompliance(argument_list[1].string_reference,
7967 AllCompliance,&image->background_color,exception);
7968 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
7969 (image->alpha_trait != BlendPixelTrait))
7970 (void) SetImageAlpha(image,OpaqueAlpha,exception);
7972 image=RotateImage(image,argument_list[0].real_reference,exception);
7975 case 24: /* Sample */
7977 if (attribute_flag[0] != 0)
7978 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7979 &geometry,exception);
7980 if (attribute_flag[1] != 0)
7981 geometry.width=argument_list[1].integer_reference;
7982 if (attribute_flag[2] != 0)
7983 geometry.height=argument_list[2].integer_reference;
7984 image=SampleImage(image,geometry.width,geometry.height,exception);
7987 case 25: /* Scale */
7989 if (attribute_flag[0] != 0)
7990 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7991 &geometry,exception);
7992 if (attribute_flag[1] != 0)
7993 geometry.width=argument_list[1].integer_reference;
7994 if (attribute_flag[2] != 0)
7995 geometry.height=argument_list[2].integer_reference;
7996 image=ScaleImage(image,geometry.width,geometry.height,exception);
7999 case 26: /* Shade */
8001 if (attribute_flag[0] != 0)
8003 flags=ParseGeometry(argument_list[0].string_reference,
8005 if ((flags & SigmaValue) == 0)
8006 geometry_info.sigma=0.0;
8008 if (attribute_flag[1] != 0)
8009 geometry_info.rho=argument_list[1].real_reference;
8010 if (attribute_flag[2] != 0)
8011 geometry_info.sigma=argument_list[2].real_reference;
8012 image=ShadeImage(image,
8013 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8014 geometry_info.rho,geometry_info.sigma,exception);
8017 case 27: /* Sharpen */
8019 if (attribute_flag[0] != 0)
8021 flags=ParseGeometry(argument_list[0].string_reference,
8023 if ((flags & SigmaValue) == 0)
8024 geometry_info.sigma=1.0;
8026 if (attribute_flag[1] != 0)
8027 geometry_info.rho=argument_list[1].real_reference;
8028 if (attribute_flag[2] != 0)
8029 geometry_info.sigma=argument_list[2].real_reference;
8030 if (attribute_flag[3] != 0)
8031 channel=(ChannelType) argument_list[3].integer_reference;
8032 channel_mask=SetImageChannelMask(image,channel);
8033 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8035 if (image != (Image *) NULL)
8036 (void) SetImageChannelMask(image,channel_mask);
8039 case 28: /* Shear */
8041 if (attribute_flag[0] != 0)
8043 flags=ParseGeometry(argument_list[0].string_reference,
8045 if ((flags & SigmaValue) == 0)
8046 geometry_info.sigma=geometry_info.rho;
8048 if (attribute_flag[1] != 0)
8049 geometry_info.rho=argument_list[1].real_reference;
8050 if (attribute_flag[2] != 0)
8051 geometry_info.sigma=argument_list[2].real_reference;
8052 if (attribute_flag[3] != 0)
8053 QueryColorCompliance(argument_list[3].string_reference,
8054 AllCompliance,&image->background_color,exception);
8055 if (attribute_flag[4] != 0)
8056 QueryColorCompliance(argument_list[4].string_reference,
8057 AllCompliance,&image->background_color,exception);
8058 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8062 case 29: /* Spread */
8064 PixelInterpolateMethod
8067 if (attribute_flag[0] == 0)
8068 argument_list[0].real_reference=1.0;
8069 method=UndefinedInterpolatePixel;
8070 if (attribute_flag[1] != 0)
8071 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8072 image=SpreadImage(image,argument_list[0].real_reference,method,
8076 case 30: /* Swirl */
8078 PixelInterpolateMethod
8081 if (attribute_flag[0] == 0)
8082 argument_list[0].real_reference=50.0;
8083 method=UndefinedInterpolatePixel;
8084 if (attribute_flag[1] != 0)
8085 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8086 image=SwirlImage(image,argument_list[0].real_reference,
8090 case 31: /* Resize */
8093 if (attribute_flag[0] != 0)
8094 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8095 &geometry,exception);
8096 if (attribute_flag[1] != 0)
8097 geometry.width=argument_list[1].integer_reference;
8098 if (attribute_flag[2] != 0)
8099 geometry.height=argument_list[2].integer_reference;
8100 if (attribute_flag[3] == 0)
8101 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8102 if (attribute_flag[4] != 0)
8103 SetImageArtifact(image,"filter:support",
8104 argument_list[4].string_reference);
8105 image=ResizeImage(image,geometry.width,geometry.height,
8106 (FilterTypes) argument_list[3].integer_reference,
8110 case 33: /* Annotate */
8115 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8117 if (attribute_flag[0] != 0)
8122 text=InterpretImageProperties(info ? info->image_info :
8123 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8125 (void) CloneString(&draw_info->text,text);
8126 text=DestroyString(text);
8128 if (attribute_flag[1] != 0)
8129 (void) CloneString(&draw_info->font,
8130 argument_list[1].string_reference);
8131 if (attribute_flag[2] != 0)
8132 draw_info->pointsize=argument_list[2].real_reference;
8133 if (attribute_flag[3] != 0)
8134 (void) CloneString(&draw_info->density,
8135 argument_list[3].string_reference);
8136 if (attribute_flag[4] != 0)
8137 (void) QueryColorCompliance(argument_list[4].string_reference,
8138 AllCompliance,&draw_info->undercolor,exception);
8139 if (attribute_flag[5] != 0)
8141 (void) QueryColorCompliance(argument_list[5].string_reference,
8142 AllCompliance,&draw_info->stroke,exception);
8143 if (argument_list[5].image_reference != (Image *) NULL)
8144 draw_info->stroke_pattern=CloneImage(
8145 argument_list[5].image_reference,0,0,MagickTrue,exception);
8147 if (attribute_flag[6] != 0)
8149 (void) QueryColorCompliance(argument_list[6].string_reference,
8150 AllCompliance,&draw_info->fill,exception);
8151 if (argument_list[6].image_reference != (Image *) NULL)
8152 draw_info->fill_pattern=CloneImage(
8153 argument_list[6].image_reference,0,0,MagickTrue,exception);
8155 if (attribute_flag[7] != 0)
8157 (void) CloneString(&draw_info->geometry,
8158 argument_list[7].string_reference);
8159 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8160 &geometry,exception);
8161 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8162 geometry_info.sigma=geometry_info.xi;
8164 if (attribute_flag[8] != 0)
8165 (void) QueryColorCompliance(argument_list[8].string_reference,
8166 AllCompliance,&draw_info->fill,exception);
8167 if (attribute_flag[11] != 0)
8168 draw_info->gravity=(GravityType)
8169 argument_list[11].integer_reference;
8170 if (attribute_flag[25] != 0)
8175 av=(AV *) argument_list[25].array_reference;
8176 if ((av_len(av) != 3) && (av_len(av) != 5))
8178 ThrowPerlException(exception,OptionError,
8179 "affine matrix must have 4 or 6 elements",PackageName);
8182 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8183 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8184 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8185 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8186 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8187 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8189 ThrowPerlException(exception,OptionError,
8190 "affine matrix is singular",PackageName);
8193 if (av_len(av) == 5)
8195 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8196 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8199 for (j=12; j < 17; j++)
8201 if (attribute_flag[j] == 0)
8203 value=argument_list[j].string_reference;
8204 angle=argument_list[j].real_reference;
8205 current=draw_info->affine;
8206 GetAffineMatrix(&affine);
8214 flags=ParseGeometry(value,&geometry_info);
8215 affine.tx=geometry_info.xi;
8216 affine.ty=geometry_info.psi;
8217 if ((flags & PsiValue) == 0)
8218 affine.ty=affine.tx;
8226 flags=ParseGeometry(value,&geometry_info);
8227 affine.sx=geometry_info.rho;
8228 affine.sy=geometry_info.sigma;
8229 if ((flags & SigmaValue) == 0)
8230 affine.sy=affine.sx;
8240 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8241 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8242 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8243 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8251 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8259 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8263 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8264 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8265 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8266 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8267 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8269 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8272 if (attribute_flag[9] == 0)
8273 argument_list[9].real_reference=0.0;
8274 if (attribute_flag[10] == 0)
8275 argument_list[10].real_reference=0.0;
8276 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8279 geometry[MaxTextExtent];
8281 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8282 (double) argument_list[9].real_reference+draw_info->affine.tx,
8283 (double) argument_list[10].real_reference+draw_info->affine.ty);
8284 (void) CloneString(&draw_info->geometry,geometry);
8286 if (attribute_flag[17] != 0)
8287 draw_info->stroke_width=argument_list[17].real_reference;
8288 if (attribute_flag[18] != 0)
8290 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8291 MagickTrue : MagickFalse;
8292 draw_info->stroke_antialias=draw_info->text_antialias;
8294 if (attribute_flag[19] != 0)
8295 (void) CloneString(&draw_info->family,
8296 argument_list[19].string_reference);
8297 if (attribute_flag[20] != 0)
8298 draw_info->style=(StyleType) argument_list[20].integer_reference;
8299 if (attribute_flag[21] != 0)
8300 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8301 if (attribute_flag[22] != 0)
8302 draw_info->weight=argument_list[22].integer_reference;
8303 if (attribute_flag[23] != 0)
8304 draw_info->align=(AlignType) argument_list[23].integer_reference;
8305 if (attribute_flag[24] != 0)
8306 (void) CloneString(&draw_info->encoding,
8307 argument_list[24].string_reference);
8308 if (attribute_flag[25] != 0)
8309 draw_info->fill_pattern=CloneImage(
8310 argument_list[25].image_reference,0,0,MagickTrue,exception);
8311 if (attribute_flag[26] != 0)
8312 draw_info->fill_pattern=CloneImage(
8313 argument_list[26].image_reference,0,0,MagickTrue,exception);
8314 if (attribute_flag[27] != 0)
8315 draw_info->stroke_pattern=CloneImage(
8316 argument_list[27].image_reference,0,0,MagickTrue,exception);
8317 if (attribute_flag[29] != 0)
8318 draw_info->kerning=argument_list[29].real_reference;
8319 if (attribute_flag[30] != 0)
8320 draw_info->interline_spacing=argument_list[30].real_reference;
8321 if (attribute_flag[31] != 0)
8322 draw_info->interword_spacing=argument_list[31].real_reference;
8323 if (attribute_flag[32] != 0)
8324 draw_info->direction=(DirectionType)
8325 argument_list[32].integer_reference;
8326 (void) AnnotateImage(image,draw_info,exception);
8327 draw_info=DestroyDrawInfo(draw_info);
8330 case 34: /* ColorFloodfill */
8341 draw_info=CloneDrawInfo(info ? info->image_info :
8342 (ImageInfo *) NULL,(DrawInfo *) NULL);
8343 if (attribute_flag[0] != 0)
8344 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8345 &geometry,exception);
8346 if (attribute_flag[1] != 0)
8347 geometry.x=argument_list[1].integer_reference;
8348 if (attribute_flag[2] != 0)
8349 geometry.y=argument_list[2].integer_reference;
8350 if (attribute_flag[3] != 0)
8351 (void) QueryColorCompliance(argument_list[3].string_reference,
8352 AllCompliance,&draw_info->fill,exception);
8353 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8354 geometry.x,geometry.y,&target,exception);
8356 if (attribute_flag[4] != 0)
8358 QueryColorCompliance(argument_list[4].string_reference,
8359 AllCompliance,&target,exception);
8362 if (attribute_flag[5] != 0)
8363 image->fuzz=StringToDoubleInterval(
8364 argument_list[5].string_reference,(double) QuantumRange+1.0);
8365 if (attribute_flag[6] != 0)
8366 invert=(MagickBooleanType) argument_list[6].integer_reference;
8367 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8368 geometry.y,invert,exception);
8369 draw_info=DestroyDrawInfo(draw_info);
8372 case 35: /* Composite */
8375 composite_geometry[MaxTextExtent];
8384 compose=OverCompositeOp;
8385 if (attribute_flag[0] != 0)
8386 composite_image=argument_list[0].image_reference;
8389 ThrowPerlException(exception,OptionError,
8390 "CompositeImageRequired",PackageName);
8394 Parameter Handling used for BOTH normal and tiled composition.
8396 if (attribute_flag[1] != 0) /* compose */
8397 compose=(CompositeOperator) argument_list[1].integer_reference;
8398 if (attribute_flag[6] != 0) /* opacity */
8400 if (compose != DissolveCompositeOp)
8401 (void) SetImageAlpha(composite_image,(Quantum)
8402 StringToDoubleInterval(argument_list[6].string_reference,
8403 (double) QuantumRange+1.0),exception);
8425 Handle dissolve composite operator (patch by
8428 (void) CloneString(&image->geometry,
8429 argument_list[6].string_reference);
8430 opacity=(Quantum) StringToDoubleInterval(
8431 argument_list[6].string_reference,(double) QuantumRange+
8433 if (composite_image->alpha_trait == BlendPixelTrait)
8434 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8435 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8436 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8438 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8439 composite_image->columns,1,exception);
8440 for (x=0; x < (ssize_t) composite_image->columns; x++)
8442 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8443 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8445 q+=GetPixelChannels(composite_image);
8447 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8448 if (sync == MagickFalse)
8451 composite_view=DestroyCacheView(composite_view);
8454 if (attribute_flag[9] != 0) /* "color=>" */
8455 QueryColorCompliance(argument_list[9].string_reference,
8456 AllCompliance,&composite_image->background_color,exception);
8457 if (attribute_flag[12] != 0) /* "interpolate=>" */
8458 image->interpolate=(PixelInterpolateMethod)
8459 argument_list[12].integer_reference;
8460 if (attribute_flag[13] != 0) /* "args=>" */
8461 (void) SetImageArtifact(composite_image,"compose:args",
8462 argument_list[13].string_reference);
8463 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8464 (void) SetImageArtifact(composite_image,"compose:args",
8465 argument_list[14].string_reference);
8466 clip_to_self=MagickTrue;
8467 if (attribute_flag[15] != 0)
8468 clip_to_self=(MagickBooleanType)
8469 argument_list[15].integer_reference;
8471 Tiling Composition (with orthogonal rotate).
8473 rotate_image=(Image *) NULL;
8474 if (attribute_flag[8] != 0) /* "rotate=>" */
8479 rotate_image=RotateImage(composite_image,
8480 argument_list[8].real_reference,exception);
8481 if (rotate_image == (Image *) NULL)
8484 if ((attribute_flag[7] != 0) &&
8485 (argument_list[7].integer_reference != 0)) /* tile */
8492 Tile the composite image.
8494 if (attribute_flag[8] != 0) /* "tile=>" */
8495 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8498 (void) SetImageArtifact(composite_image,
8499 "compose:outside-overlay","false");
8500 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8501 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8503 if (attribute_flag[8] != 0) /* rotate */
8504 (void) CompositeImage(image,rotate_image,compose,
8505 MagickTrue,x,y,exception);
8507 (void) CompositeImage(image,composite_image,compose,
8508 MagickTrue,x,y,exception);
8510 if (attribute_flag[8] != 0) /* rotate */
8511 rotate_image=DestroyImage(rotate_image);
8515 Parameter Handling used used ONLY for normal composition.
8517 if (attribute_flag[5] != 0) /* gravity */
8518 image->gravity=(GravityType) argument_list[5].integer_reference;
8519 if (attribute_flag[2] != 0) /* geometry offset */
8521 SetGeometry(image,&geometry);
8522 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8524 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8527 if (attribute_flag[3] != 0) /* x offset */
8528 geometry.x=argument_list[3].integer_reference;
8529 if (attribute_flag[4] != 0) /* y offset */
8530 geometry.y=argument_list[4].integer_reference;
8531 if (attribute_flag[10] != 0) /* mask */
8533 if ((image->compose == DisplaceCompositeOp) ||
8534 (image->compose == DistortCompositeOp))
8537 Merge Y displacement into X displacement image.
8539 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8541 (void) CompositeImage(composite_image,
8542 argument_list[10].image_reference,CopyGreenCompositeOp,
8543 MagickTrue,0,0,exception);
8551 Set a blending mask for the composition.
8553 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8554 MagickTrue,exception);
8555 (void) NegateImage(mask_image,MagickFalse,exception);
8556 (void) SetImageMask(composite_image,mask_image,exception);
8557 mask_image=DestroyImage(mask_image);
8560 if (attribute_flag[11] != 0) /* channel */
8561 channel=(ChannelType) argument_list[11].integer_reference;
8563 Composite two images (normal composition).
8565 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8566 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8567 (double) composite_image->rows,(double) geometry.x,(double)
8569 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8571 channel_mask=SetImageChannelMask(image,channel);
8572 if (attribute_flag[8] == 0) /* no rotate */
8573 CompositeImage(image,composite_image,compose,clip_to_self,
8574 geometry.x,geometry.y,exception);
8578 Position adjust rotated image then composite.
8580 geometry.x-=(ssize_t) (rotate_image->columns-
8581 composite_image->columns)/2;
8582 geometry.y-=(ssize_t) (rotate_image->rows-
8583 composite_image->rows)/2;
8584 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8585 geometry.y,exception);
8586 rotate_image=DestroyImage(rotate_image);
8588 if (attribute_flag[10] != 0) /* mask */
8590 if ((image->compose == DisplaceCompositeOp) ||
8591 (image->compose == DistortCompositeOp))
8592 composite_image=DestroyImage(composite_image);
8594 (void) SetImageMask(image,(Image *) NULL,exception);
8596 (void) SetImageChannelMask(image,channel_mask);
8599 case 36: /* Contrast */
8601 if (attribute_flag[0] == 0)
8602 argument_list[0].integer_reference=0;
8603 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8604 MagickTrue : MagickFalse,exception);
8607 case 37: /* CycleColormap */
8609 if (attribute_flag[0] == 0)
8610 argument_list[0].integer_reference=6;
8611 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8620 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8622 (void) CloneString(&draw_info->primitive,"point");
8623 if (attribute_flag[0] != 0)
8625 if (argument_list[0].integer_reference < 0)
8626 (void) CloneString(&draw_info->primitive,
8627 argument_list[0].string_reference);
8629 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8630 MagickPrimitiveOptions,argument_list[0].integer_reference));
8632 if (attribute_flag[1] != 0)
8634 if (LocaleCompare(draw_info->primitive,"path") == 0)
8636 (void) ConcatenateString(&draw_info->primitive," '");
8637 ConcatenateString(&draw_info->primitive,
8638 argument_list[1].string_reference);
8639 (void) ConcatenateString(&draw_info->primitive,"'");
8643 (void) ConcatenateString(&draw_info->primitive," ");
8644 ConcatenateString(&draw_info->primitive,
8645 argument_list[1].string_reference);
8648 if (attribute_flag[2] != 0)
8650 (void) ConcatenateString(&draw_info->primitive," ");
8651 (void) ConcatenateString(&draw_info->primitive,
8652 CommandOptionToMnemonic(MagickMethodOptions,
8653 argument_list[2].integer_reference));
8655 if (attribute_flag[3] != 0)
8657 (void) QueryColorCompliance(argument_list[3].string_reference,
8658 AllCompliance,&draw_info->stroke,exception);
8659 if (argument_list[3].image_reference != (Image *) NULL)
8660 draw_info->stroke_pattern=CloneImage(
8661 argument_list[3].image_reference,0,0,MagickTrue,exception);
8663 if (attribute_flag[4] != 0)
8665 (void) QueryColorCompliance(argument_list[4].string_reference,
8666 AllCompliance,&draw_info->fill,exception);
8667 if (argument_list[4].image_reference != (Image *) NULL)
8668 draw_info->fill_pattern=CloneImage(
8669 argument_list[4].image_reference,0,0,MagickTrue,exception);
8671 if (attribute_flag[5] != 0)
8672 draw_info->stroke_width=argument_list[5].real_reference;
8673 if (attribute_flag[6] != 0)
8674 (void) CloneString(&draw_info->font,
8675 argument_list[6].string_reference);
8676 if (attribute_flag[7] != 0)
8677 (void) QueryColorCompliance(argument_list[7].string_reference,
8678 AllCompliance,&draw_info->border_color,exception);
8679 if (attribute_flag[8] != 0)
8680 draw_info->affine.tx=argument_list[8].real_reference;
8681 if (attribute_flag[9] != 0)
8682 draw_info->affine.ty=argument_list[9].real_reference;
8683 if (attribute_flag[20] != 0)
8688 av=(AV *) argument_list[20].array_reference;
8689 if ((av_len(av) != 3) && (av_len(av) != 5))
8691 ThrowPerlException(exception,OptionError,
8692 "affine matrix must have 4 or 6 elements",PackageName);
8695 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8696 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8697 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8698 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8699 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8700 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8702 ThrowPerlException(exception,OptionError,
8703 "affine matrix is singular",PackageName);
8706 if (av_len(av) == 5)
8708 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8709 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8712 for (j=10; j < 15; j++)
8714 if (attribute_flag[j] == 0)
8716 value=argument_list[j].string_reference;
8717 angle=argument_list[j].real_reference;
8718 current=draw_info->affine;
8719 GetAffineMatrix(&affine);
8727 flags=ParseGeometry(value,&geometry_info);
8728 affine.tx=geometry_info.xi;
8729 affine.ty=geometry_info.psi;
8730 if ((flags & PsiValue) == 0)
8731 affine.ty=affine.tx;
8739 flags=ParseGeometry(value,&geometry_info);
8740 affine.sx=geometry_info.rho;
8741 affine.sy=geometry_info.sigma;
8742 if ((flags & SigmaValue) == 0)
8743 affine.sy=affine.sx;
8753 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8754 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8755 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8756 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8764 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8772 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8776 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8777 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8778 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8779 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8780 draw_info->affine.tx=
8781 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8782 draw_info->affine.ty=
8783 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8785 if (attribute_flag[15] != 0)
8786 draw_info->fill_pattern=CloneImage(
8787 argument_list[15].image_reference,0,0,MagickTrue,exception);
8788 if (attribute_flag[16] != 0)
8789 draw_info->pointsize=argument_list[16].real_reference;
8790 if (attribute_flag[17] != 0)
8792 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8793 ? MagickTrue : MagickFalse;
8794 draw_info->text_antialias=draw_info->stroke_antialias;
8796 if (attribute_flag[18] != 0)
8797 (void) CloneString(&draw_info->density,
8798 argument_list[18].string_reference);
8799 if (attribute_flag[19] != 0)
8800 draw_info->stroke_width=argument_list[19].real_reference;
8801 if (attribute_flag[21] != 0)
8802 draw_info->dash_offset=argument_list[21].real_reference;
8803 if (attribute_flag[22] != 0)
8808 av=(AV *) argument_list[22].array_reference;
8809 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8810 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8811 if (draw_info->dash_pattern != (double *) NULL)
8813 for (i=0; i <= av_len(av); i++)
8814 draw_info->dash_pattern[i]=(double)
8815 SvNV(*(av_fetch(av,i,0)));
8816 draw_info->dash_pattern[i]=0.0;
8819 if (attribute_flag[23] != 0)
8820 image->interpolate=(PixelInterpolateMethod)
8821 argument_list[23].integer_reference;
8822 if ((attribute_flag[24] != 0) &&
8823 (draw_info->fill_pattern != (Image *) NULL))
8824 flags=ParsePageGeometry(draw_info->fill_pattern,
8825 argument_list[24].string_reference,
8826 &draw_info->fill_pattern->tile_offset,exception);
8827 if (attribute_flag[25] != 0)
8829 (void) ConcatenateString(&draw_info->primitive," '");
8830 (void) ConcatenateString(&draw_info->primitive,
8831 argument_list[25].string_reference);
8832 (void) ConcatenateString(&draw_info->primitive,"'");
8834 if (attribute_flag[26] != 0)
8835 draw_info->fill_pattern=CloneImage(
8836 argument_list[26].image_reference,0,0,MagickTrue,exception);
8837 if (attribute_flag[27] != 0)
8838 draw_info->stroke_pattern=CloneImage(
8839 argument_list[27].image_reference,0,0,MagickTrue,exception);
8840 if (attribute_flag[28] != 0)
8841 (void) CloneString(&draw_info->primitive,
8842 argument_list[28].string_reference);
8843 if (attribute_flag[29] != 0)
8844 draw_info->kerning=argument_list[29].real_reference;
8845 if (attribute_flag[30] != 0)
8846 draw_info->interline_spacing=argument_list[30].real_reference;
8847 if (attribute_flag[31] != 0)
8848 draw_info->interword_spacing=argument_list[31].real_reference;
8849 if (attribute_flag[32] != 0)
8850 draw_info->direction=(DirectionType)
8851 argument_list[32].integer_reference;
8852 DrawImage(image,draw_info,exception);
8853 draw_info=DestroyDrawInfo(draw_info);
8856 case 39: /* Equalize */
8858 if (attribute_flag[0] != 0)
8859 channel=(ChannelType) argument_list[0].integer_reference;
8860 channel_mask=SetImageChannelMask(image,channel);
8861 EqualizeImage(image,exception);
8862 (void) SetImageChannelMask(image,channel_mask);
8865 case 40: /* Gamma */
8867 if (attribute_flag[1] != 0)
8868 channel=(ChannelType) argument_list[1].integer_reference;
8869 if (attribute_flag[2] == 0)
8870 argument_list[2].real_reference=1.0;
8871 if (attribute_flag[3] == 0)
8872 argument_list[3].real_reference=1.0;
8873 if (attribute_flag[4] == 0)
8874 argument_list[4].real_reference=1.0;
8875 if (attribute_flag[0] == 0)
8877 (void) FormatLocaleString(message,MaxTextExtent,
8878 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8879 (double) argument_list[3].real_reference,
8880 (double) argument_list[4].real_reference);
8881 argument_list[0].string_reference=message;
8883 (void) GammaImage(image,StringToDouble(
8884 argument_list[0].string_reference,(char **) NULL),exception);
8892 if (attribute_flag[0] == 0)
8894 ThrowPerlException(exception,OptionError,"MapImageRequired",
8898 quantize_info=AcquireQuantizeInfo(info->image_info);
8899 if (attribute_flag[1] != 0)
8900 quantize_info->dither_method=(DitherMethod)
8901 argument_list[1].integer_reference;
8902 (void) RemapImages(quantize_info,image,
8903 argument_list[0].image_reference,exception);
8904 quantize_info=DestroyQuantizeInfo(quantize_info);
8907 case 42: /* MatteFloodfill */
8918 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8920 if (attribute_flag[0] != 0)
8921 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8922 &geometry,exception);
8923 if (attribute_flag[1] != 0)
8924 geometry.x=argument_list[1].integer_reference;
8925 if (attribute_flag[2] != 0)
8926 geometry.y=argument_list[2].integer_reference;
8927 if (image->alpha_trait != BlendPixelTrait)
8928 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8929 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8930 geometry.x,geometry.y,&target,exception);
8931 if (attribute_flag[4] != 0)
8932 QueryColorCompliance(argument_list[4].string_reference,
8933 AllCompliance,&target,exception);
8934 if (attribute_flag[3] != 0)
8935 target.alpha=StringToDoubleInterval(
8936 argument_list[3].string_reference,(double) (double) QuantumRange+
8938 if (attribute_flag[5] != 0)
8939 image->fuzz=StringToDoubleInterval(
8940 argument_list[5].string_reference,(double) QuantumRange+1.0);
8942 if (attribute_flag[6] != 0)
8943 invert=(MagickBooleanType) argument_list[6].integer_reference;
8944 channel_mask=SetImageChannelMask(image,AlphaChannel);
8945 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8946 geometry.y,invert,exception);
8947 (void) SetImageChannelMask(image,channel_mask);
8948 draw_info=DestroyDrawInfo(draw_info);
8951 case 43: /* Modulate */
8954 modulate[MaxTextExtent];
8956 geometry_info.rho=100.0;
8957 geometry_info.sigma=100.0;
8958 geometry_info.xi=100.0;
8959 if (attribute_flag[0] != 0)
8960 (void)ParseGeometry(argument_list[0].string_reference,
8962 if (attribute_flag[1] != 0)
8963 geometry_info.xi=argument_list[1].real_reference;
8964 if (attribute_flag[2] != 0)
8965 geometry_info.sigma=argument_list[2].real_reference;
8966 if (attribute_flag[3] != 0)
8968 geometry_info.sigma=argument_list[3].real_reference;
8969 SetImageArtifact(image,"modulate:colorspace","HWB");
8971 if (attribute_flag[4] != 0)
8973 geometry_info.rho=argument_list[4].real_reference;
8974 SetImageArtifact(image,"modulate:colorspace","HSB");
8976 if (attribute_flag[5] != 0)
8978 geometry_info.sigma=argument_list[5].real_reference;
8979 SetImageArtifact(image,"modulate:colorspace","HSL");
8981 if (attribute_flag[6] != 0)
8983 geometry_info.rho=argument_list[6].real_reference;
8984 SetImageArtifact(image,"modulate:colorspace","HWB");
8986 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8987 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8988 (void) ModulateImage(image,modulate,exception);
8991 case 44: /* Negate */
8993 if (attribute_flag[0] == 0)
8994 argument_list[0].integer_reference=0;
8995 if (attribute_flag[1] != 0)
8996 channel=(ChannelType) argument_list[1].integer_reference;
8997 channel_mask=SetImageChannelMask(image,channel);
8998 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8999 MagickTrue : MagickFalse,exception);
9000 (void) SetImageChannelMask(image,channel_mask);
9003 case 45: /* Normalize */
9005 if (attribute_flag[0] != 0)
9006 channel=(ChannelType) argument_list[0].integer_reference;
9007 channel_mask=SetImageChannelMask(image,channel);
9008 NormalizeImage(image,exception);
9009 (void) SetImageChannelMask(image,channel_mask);
9012 case 46: /* NumberColors */
9014 case 47: /* Opaque */
9023 (void) QueryColorCompliance("none",AllCompliance,&target,
9025 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9027 if (attribute_flag[0] != 0)
9028 (void) QueryColorCompliance(argument_list[0].string_reference,
9029 AllCompliance,&target,exception);
9030 if (attribute_flag[1] != 0)
9031 (void) QueryColorCompliance(argument_list[1].string_reference,
9032 AllCompliance,&fill_color,exception);
9033 if (attribute_flag[2] != 0)
9034 image->fuzz=StringToDoubleInterval(
9035 argument_list[2].string_reference,(double) QuantumRange+1.0);
9036 if (attribute_flag[3] != 0)
9037 channel=(ChannelType) argument_list[3].integer_reference;
9039 if (attribute_flag[4] != 0)
9040 invert=(MagickBooleanType) argument_list[4].integer_reference;
9041 channel_mask=SetImageChannelMask(image,channel);
9042 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9043 (void) SetImageChannelMask(image,channel_mask);
9046 case 48: /* Quantize */
9051 quantize_info=AcquireQuantizeInfo(info->image_info);
9052 if (attribute_flag[0] != 0)
9053 quantize_info->number_colors=(size_t)
9054 argument_list[0].integer_reference;
9055 if (attribute_flag[1] != 0)
9056 quantize_info->tree_depth=(size_t)
9057 argument_list[1].integer_reference;
9058 if (attribute_flag[2] != 0)
9059 quantize_info->colorspace=(ColorspaceType)
9060 argument_list[2].integer_reference;
9061 if (attribute_flag[3] != 0)
9062 quantize_info->dither_method=(DitherMethod)
9063 argument_list[3].integer_reference;
9064 if (attribute_flag[4] != 0)
9065 quantize_info->measure_error=argument_list[4].integer_reference !=
9066 0 ? MagickTrue : MagickFalse;
9067 if (attribute_flag[5] != 0)
9068 (void) QueryColorCompliance(argument_list[5].string_reference,
9069 AllCompliance,&image->transparent_color,exception);
9070 if (attribute_flag[5] && argument_list[5].integer_reference)
9072 (void) QuantizeImages(quantize_info,image,exception);
9075 if (attribute_flag[6] != 0)
9076 quantize_info->dither_method=(DitherMethod)
9077 argument_list[6].integer_reference;
9078 if ((image->storage_class == DirectClass) ||
9079 (image->colors > quantize_info->number_colors) ||
9080 (quantize_info->colorspace == GRAYColorspace))
9081 (void) QuantizeImage(quantize_info,image,exception);
9083 CompressImageColormap(image,exception);
9084 quantize_info=DestroyQuantizeInfo(quantize_info);
9087 case 49: /* Raise */
9089 if (attribute_flag[0] != 0)
9090 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9091 &geometry,exception);
9092 if (attribute_flag[1] != 0)
9093 geometry.width=argument_list[1].integer_reference;
9094 if (attribute_flag[2] != 0)
9095 geometry.height=argument_list[2].integer_reference;
9096 if (attribute_flag[3] == 0)
9097 argument_list[3].integer_reference=1;
9098 (void) RaiseImage(image,&geometry,
9099 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9103 case 50: /* Segment */
9110 smoothing_threshold;
9115 cluster_threshold=1.0;
9116 smoothing_threshold=1.5;
9117 colorspace=sRGBColorspace;
9118 verbose=MagickFalse;
9119 if (attribute_flag[0] != 0)
9121 flags=ParseGeometry(argument_list[0].string_reference,
9123 cluster_threshold=geometry_info.rho;
9124 if (flags & SigmaValue)
9125 smoothing_threshold=geometry_info.sigma;
9127 if (attribute_flag[1] != 0)
9128 cluster_threshold=argument_list[1].real_reference;
9129 if (attribute_flag[2] != 0)
9130 smoothing_threshold=argument_list[2].real_reference;
9131 if (attribute_flag[3] != 0)
9132 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9133 if (attribute_flag[4] != 0)
9134 verbose=argument_list[4].integer_reference != 0 ?
9135 MagickTrue : MagickFalse;
9136 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9137 smoothing_threshold,exception);
9140 case 51: /* Signature */
9142 (void) SignatureImage(image,exception);
9145 case 52: /* Solarize */
9147 geometry_info.rho=QuantumRange/2.0;
9148 if (attribute_flag[0] != 0)
9149 flags=ParseGeometry(argument_list[0].string_reference,
9151 if (attribute_flag[1] != 0)
9152 geometry_info.rho=StringToDoubleInterval(
9153 argument_list[1].string_reference,(double) QuantumRange+1.0);
9154 (void) SolarizeImage(image,geometry_info.rho,exception);
9159 (void) SyncImage(image,exception);
9162 case 54: /* Texture */
9164 if (attribute_flag[0] == 0)
9166 TextureImage(image,argument_list[0].image_reference,exception);
9169 case 55: /* Evalute */
9171 MagickEvaluateOperator
9174 op=SetEvaluateOperator;
9175 if (attribute_flag[0] == MagickFalse)
9176 argument_list[0].real_reference=0.0;
9177 if (attribute_flag[1] != MagickFalse)
9178 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9179 if (attribute_flag[2] != MagickFalse)
9180 channel=(ChannelType) argument_list[2].integer_reference;
9181 channel_mask=SetImageChannelMask(image,channel);
9182 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9184 (void) SetImageChannelMask(image,channel_mask);
9187 case 56: /* Transparent */
9198 (void) QueryColorCompliance("none",AllCompliance,&target,
9200 if (attribute_flag[0] != 0)
9201 (void) QueryColorCompliance(argument_list[0].string_reference,
9202 AllCompliance,&target,exception);
9203 opacity=TransparentAlpha;
9204 if (attribute_flag[1] != 0)
9205 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9206 (double) QuantumRange+1.0);
9207 if (attribute_flag[2] != 0)
9208 image->fuzz=StringToDoubleInterval(
9209 argument_list[2].string_reference,(double) QuantumRange+1.0);
9210 if (attribute_flag[3] == 0)
9211 argument_list[3].integer_reference=0;
9213 if (attribute_flag[3] != 0)
9214 invert=(MagickBooleanType) argument_list[3].integer_reference;
9215 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9219 case 57: /* Threshold */
9224 if (attribute_flag[0] == 0)
9225 argument_list[0].string_reference="50%";
9226 if (attribute_flag[1] != 0)
9227 channel=(ChannelType) argument_list[1].integer_reference;
9228 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9229 (double) QuantumRange+1.0);
9230 channel_mask=SetImageChannelMask(image,channel);
9231 (void) BilevelImage(image,threshold,exception);
9232 (void) SetImageChannelMask(image,channel_mask);
9235 case 58: /* Charcoal */
9237 if (attribute_flag[0] != 0)
9239 flags=ParseGeometry(argument_list[0].string_reference,
9241 if ((flags & SigmaValue) == 0)
9242 geometry_info.sigma=1.0;
9244 if (attribute_flag[1] != 0)
9245 geometry_info.rho=argument_list[1].real_reference;
9246 if (attribute_flag[2] != 0)
9247 geometry_info.sigma=argument_list[2].real_reference;
9248 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9254 if (attribute_flag[0] != 0)
9255 image->fuzz=StringToDoubleInterval(
9256 argument_list[0].string_reference,(double) QuantumRange+1.0);
9257 image=TrimImage(image,exception);
9262 PixelInterpolateMethod
9265 if (attribute_flag[0] != 0)
9267 flags=ParseGeometry(argument_list[0].string_reference,
9269 if ((flags & SigmaValue) == 0)
9270 geometry_info.sigma=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 method=UndefinedInterpolatePixel;
9277 if (attribute_flag[3] != 0)
9278 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9279 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9283 case 61: /* Separate */
9285 if (attribute_flag[0] != 0)
9286 channel=(ChannelType) argument_list[0].integer_reference;
9287 image=SeparateImage(image,channel,exception);
9290 case 63: /* Stereo */
9292 if (attribute_flag[0] == 0)
9294 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9298 if (attribute_flag[1] != 0)
9299 geometry.x=argument_list[1].integer_reference;
9300 if (attribute_flag[2] != 0)
9301 geometry.y=argument_list[2].integer_reference;
9302 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9303 geometry.x,geometry.y,exception);
9306 case 64: /* Stegano */
9308 if (attribute_flag[0] == 0)
9310 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9314 if (attribute_flag[1] == 0)
9315 argument_list[1].integer_reference=0;
9316 image->offset=argument_list[1].integer_reference;
9317 image=SteganoImage(image,argument_list[0].image_reference,exception);
9320 case 65: /* Deconstruct */
9322 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9325 case 66: /* GaussianBlur */
9327 if (attribute_flag[0] != 0)
9329 flags=ParseGeometry(argument_list[0].string_reference,
9331 if ((flags & SigmaValue) == 0)
9332 geometry_info.sigma=1.0;
9334 if (attribute_flag[1] != 0)
9335 geometry_info.rho=argument_list[1].real_reference;
9336 if (attribute_flag[2] != 0)
9337 geometry_info.sigma=argument_list[2].real_reference;
9338 if (attribute_flag[3] != 0)
9339 channel=(ChannelType) argument_list[3].integer_reference;
9340 channel_mask=SetImageChannelMask(image,channel);
9341 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9343 if (image != (Image *) NULL)
9344 (void) SetImageChannelMask(image,channel_mask);
9347 case 67: /* Convolve */
9352 kernel=(KernelInfo *) NULL;
9353 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9355 if (attribute_flag[0] != 0)
9363 kernel=AcquireKernelInfo((const char *) NULL);
9364 if (kernel == (KernelInfo *) NULL)
9366 av=(AV *) argument_list[0].array_reference;
9367 order=(size_t) sqrt(av_len(av)+1);
9368 kernel->width=order;
9369 kernel->height=order;
9370 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9371 order*sizeof(*kernel->values));
9372 if (kernel->values == (MagickRealType *) NULL)
9374 kernel=DestroyKernelInfo(kernel);
9375 ThrowPerlException(exception,ResourceLimitFatalError,
9376 "MemoryAllocationFailed",PackageName);
9379 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9380 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9381 for ( ; j < (ssize_t) (order*order); j++)
9382 kernel->values[j]=0.0;
9384 if (attribute_flag[1] != 0)
9385 channel=(ChannelType) argument_list[1].integer_reference;
9386 if (attribute_flag[2] != 0)
9387 SetImageArtifact(image,"filter:blur",
9388 argument_list[2].string_reference);
9389 if (attribute_flag[3] != 0)
9391 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9392 if (kernel == (KernelInfo *) NULL)
9395 channel_mask=SetImageChannelMask(image,channel);
9396 image=ConvolveImage(image,kernel,exception);
9397 if (image != (Image *) NULL)
9398 (void) SetImageChannelMask(image,channel_mask);
9399 kernel=DestroyKernelInfo(kernel);
9402 case 68: /* Profile */
9417 if (attribute_flag[0] != 0)
9418 name=argument_list[0].string_reference;
9419 if (attribute_flag[2] != 0)
9420 image->rendering_intent=(RenderingIntent)
9421 argument_list[2].integer_reference;
9422 if (attribute_flag[3] != 0)
9423 image->black_point_compensation=
9424 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9425 if (attribute_flag[1] != 0)
9427 if (argument_list[1].length == 0)
9430 Remove a profile from the image.
9432 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9437 Associate user supplied profile with the image.
9439 profile=AcquireStringInfo(argument_list[1].length);
9440 SetStringInfoDatum(profile,(const unsigned char *)
9441 argument_list[1].string_reference);
9442 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9443 (size_t) GetStringInfoLength(profile),exception);
9444 profile=DestroyStringInfo(profile);
9448 Associate a profile with the image.
9450 profile_info=CloneImageInfo(info ? info->image_info :
9451 (ImageInfo *) NULL);
9452 profile_image=ReadImages(profile_info,name,exception);
9453 if (profile_image == (Image *) NULL)
9455 ResetImageProfileIterator(profile_image);
9456 name=GetNextImageProfile(profile_image);
9457 while (name != (const char *) NULL)
9462 profile=GetImageProfile(profile_image,name);
9463 if (profile != (const StringInfo *) NULL)
9464 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9465 (size_t) GetStringInfoLength(profile),exception);
9466 name=GetNextImageProfile(profile_image);
9468 profile_image=DestroyImage(profile_image);
9469 profile_info=DestroyImageInfo(profile_info);
9472 case 69: /* UnsharpMask */
9474 if (attribute_flag[0] != 0)
9476 flags=ParseGeometry(argument_list[0].string_reference,
9478 if ((flags & SigmaValue) == 0)
9479 geometry_info.sigma=1.0;
9480 if ((flags & XiValue) == 0)
9481 geometry_info.xi=1.0;
9482 if ((flags & PsiValue) == 0)
9483 geometry_info.psi=0.5;
9485 if (attribute_flag[1] != 0)
9486 geometry_info.rho=argument_list[1].real_reference;
9487 if (attribute_flag[2] != 0)
9488 geometry_info.sigma=argument_list[2].real_reference;
9489 if (attribute_flag[3] != 0)
9490 geometry_info.xi=argument_list[3].real_reference;
9491 if (attribute_flag[4] != 0)
9492 geometry_info.psi=argument_list[4].real_reference;
9493 if (attribute_flag[5] != 0)
9494 channel=(ChannelType) argument_list[5].integer_reference;
9495 channel_mask=SetImageChannelMask(image,channel);
9496 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9497 geometry_info.xi,geometry_info.psi,exception);
9498 if (image != (Image *) NULL)
9499 (void) SetImageChannelMask(image,channel_mask);
9502 case 70: /* MotionBlur */
9504 if (attribute_flag[0] != 0)
9506 flags=ParseGeometry(argument_list[0].string_reference,
9508 if ((flags & SigmaValue) == 0)
9509 geometry_info.sigma=1.0;
9510 if ((flags & XiValue) == 0)
9511 geometry_info.xi=1.0;
9513 if (attribute_flag[1] != 0)
9514 geometry_info.rho=argument_list[1].real_reference;
9515 if (attribute_flag[2] != 0)
9516 geometry_info.sigma=argument_list[2].real_reference;
9517 if (attribute_flag[3] != 0)
9518 geometry_info.xi=argument_list[3].real_reference;
9519 if (attribute_flag[4] != 0)
9520 channel=(ChannelType) argument_list[4].integer_reference;
9521 channel_mask=SetImageChannelMask(image,channel);
9522 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9523 geometry_info.xi,exception);
9524 if (image != (Image *) NULL)
9525 (void) SetImageChannelMask(image,channel_mask);
9528 case 71: /* OrderedDither */
9530 if (attribute_flag[0] == 0)
9531 argument_list[0].string_reference="o8x8";
9532 if (attribute_flag[1] != 0)
9533 channel=(ChannelType) argument_list[1].integer_reference;
9534 channel_mask=SetImageChannelMask(image,channel);
9535 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9537 (void) SetImageChannelMask(image,channel_mask);
9540 case 72: /* Shave */
9542 if (attribute_flag[0] != 0)
9543 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9544 &geometry,exception);
9545 if (attribute_flag[1] != 0)
9546 geometry.width=argument_list[1].integer_reference;
9547 if (attribute_flag[2] != 0)
9548 geometry.height=argument_list[2].integer_reference;
9549 image=ShaveImage(image,&geometry,exception);
9552 case 73: /* Level */
9560 white_point=(double) image->columns*image->rows;
9562 if (attribute_flag[0] != 0)
9564 flags=ParseGeometry(argument_list[0].string_reference,
9566 black_point=geometry_info.rho;
9567 if ((flags & SigmaValue) != 0)
9568 white_point=geometry_info.sigma;
9569 if ((flags & XiValue) != 0)
9570 gamma=geometry_info.xi;
9571 if ((flags & PercentValue) != 0)
9573 black_point*=(double) (QuantumRange/100.0);
9574 white_point*=(double) (QuantumRange/100.0);
9576 if ((flags & SigmaValue) == 0)
9577 white_point=(double) QuantumRange-black_point;
9579 if (attribute_flag[1] != 0)
9580 black_point=argument_list[1].real_reference;
9581 if (attribute_flag[2] != 0)
9582 white_point=argument_list[2].real_reference;
9583 if (attribute_flag[3] != 0)
9584 gamma=argument_list[3].real_reference;
9585 if (attribute_flag[4] != 0)
9586 channel=(ChannelType) argument_list[4].integer_reference;
9587 if (attribute_flag[5] != 0)
9589 argument_list[0].real_reference=argument_list[5].real_reference;
9590 attribute_flag[0]=attribute_flag[5];
9592 channel_mask=SetImageChannelMask(image,channel);
9593 (void) LevelImage(image,black_point,white_point,gamma,exception);
9594 (void) SetImageChannelMask(image,channel_mask);
9599 if (attribute_flag[0] == 0)
9600 argument_list[0].string_reference="#1";
9601 if (attribute_flag[1] == 0)
9602 argument_list[1].integer_reference=MagickTrue;
9603 (void) ClipImagePath(image,argument_list[0].string_reference,
9604 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9608 case 75: /* AffineTransform */
9613 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9615 if (attribute_flag[0] != 0)
9620 av=(AV *) argument_list[0].array_reference;
9621 if ((av_len(av) != 3) && (av_len(av) != 5))
9623 ThrowPerlException(exception,OptionError,
9624 "affine matrix must have 4 or 6 elements",PackageName);
9627 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9628 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9629 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9630 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9631 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9632 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9634 ThrowPerlException(exception,OptionError,
9635 "affine matrix is singular",PackageName);
9638 if (av_len(av) == 5)
9640 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9641 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9644 for (j=1; j < 6; j++)
9646 if (attribute_flag[j] == 0)
9648 value=argument_list[j].string_reference;
9649 angle=argument_list[j].real_reference;
9650 current=draw_info->affine;
9651 GetAffineMatrix(&affine);
9659 flags=ParseGeometry(value,&geometry_info);
9660 affine.tx=geometry_info.xi;
9661 affine.ty=geometry_info.psi;
9662 if ((flags & PsiValue) == 0)
9663 affine.ty=affine.tx;
9671 flags=ParseGeometry(value,&geometry_info);
9672 affine.sx=geometry_info.rho;
9673 affine.sy=geometry_info.sigma;
9674 if ((flags & SigmaValue) == 0)
9675 affine.sy=affine.sx;
9685 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9686 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9687 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9688 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9696 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9704 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9708 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9709 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9710 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9711 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9712 draw_info->affine.tx=
9713 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9714 draw_info->affine.ty=
9715 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9717 if (attribute_flag[6] != 0)
9718 image->interpolate=(PixelInterpolateMethod)
9719 argument_list[6].integer_reference;
9720 if (attribute_flag[7] != 0)
9721 QueryColorCompliance(argument_list[7].string_reference,
9722 AllCompliance,&image->background_color,exception);
9723 image=AffineTransformImage(image,&draw_info->affine,exception);
9724 draw_info=DestroyDrawInfo(draw_info);
9727 case 76: /* Difference */
9729 if (attribute_flag[0] == 0)
9731 ThrowPerlException(exception,OptionError,
9732 "ReferenceImageRequired",PackageName);
9735 if (attribute_flag[1] != 0)
9736 image->fuzz=StringToDoubleInterval(
9737 argument_list[1].string_reference,(double) QuantumRange+1.0);
9738 (void) IsImagesEqual(image,argument_list[0].image_reference,
9742 case 77: /* AdaptiveThreshold */
9744 if (attribute_flag[0] != 0)
9746 flags=ParseGeometry(argument_list[0].string_reference,
9748 if ((flags & PercentValue) != 0)
9749 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9751 if (attribute_flag[1] != 0)
9752 geometry_info.rho=argument_list[1].integer_reference;
9753 if (attribute_flag[2] != 0)
9754 geometry_info.sigma=argument_list[2].integer_reference;
9755 if (attribute_flag[3] != 0)
9756 geometry_info.xi=argument_list[3].integer_reference;;
9757 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9758 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9761 case 78: /* Resample */
9767 if (attribute_flag[0] != 0)
9769 flags=ParseGeometry(argument_list[0].string_reference,
9771 if ((flags & SigmaValue) == 0)
9772 geometry_info.sigma=geometry_info.rho;
9774 if (attribute_flag[1] != 0)
9775 geometry_info.rho=argument_list[1].real_reference;
9776 if (attribute_flag[2] != 0)
9777 geometry_info.sigma=argument_list[2].real_reference;
9778 if (attribute_flag[3] == 0)
9779 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9780 if (attribute_flag[4] == 0)
9781 SetImageArtifact(image,"filter:support",
9782 argument_list[4].string_reference);
9783 width=(size_t) (geometry_info.rho*image->columns/
9784 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9785 height=(size_t) (geometry_info.sigma*image->rows/
9786 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9787 image=ResizeImage(image,width,height,(FilterTypes)
9788 argument_list[3].integer_reference,exception);
9789 if (image != (Image *) NULL)
9791 image->resolution.x=geometry_info.rho;
9792 image->resolution.y=geometry_info.sigma;
9796 case 79: /* Describe */
9798 if (attribute_flag[0] == 0)
9799 argument_list[0].file_reference=(FILE *) NULL;
9800 if (attribute_flag[1] != 0)
9801 (void) SetImageArtifact(image,"identify:features",
9802 argument_list[1].string_reference);
9803 (void) IdentifyImage(image,argument_list[0].file_reference,
9804 MagickTrue,exception);
9807 case 80: /* BlackThreshold */
9809 if (attribute_flag[0] == 0)
9810 argument_list[0].string_reference="50%";
9811 if (attribute_flag[2] != 0)
9812 channel=(ChannelType) argument_list[2].integer_reference;
9813 channel_mask=SetImageChannelMask(image,channel);
9814 BlackThresholdImage(image,argument_list[0].string_reference,
9816 (void) SetImageChannelMask(image,channel_mask);
9819 case 81: /* WhiteThreshold */
9821 if (attribute_flag[0] == 0)
9822 argument_list[0].string_reference="50%";
9823 if (attribute_flag[2] != 0)
9824 channel=(ChannelType) argument_list[2].integer_reference;
9825 channel_mask=SetImageChannelMask(image,channel);
9826 WhiteThresholdImage(image,argument_list[0].string_reference,
9828 (void) SetImageChannelMask(image,channel_mask);
9831 case 82: /* RadialBlur */
9833 if (attribute_flag[0] != 0)
9835 flags=ParseGeometry(argument_list[0].string_reference,
9838 if (attribute_flag[1] != 0)
9839 geometry_info.rho=argument_list[1].real_reference;
9840 if (attribute_flag[2] != 0)
9841 channel=(ChannelType) argument_list[2].integer_reference;
9842 channel_mask=SetImageChannelMask(image,channel);
9843 image=RadialBlurImage(image,geometry_info.rho,exception);
9844 if (image != (Image *) NULL)
9845 (void) SetImageChannelMask(image,channel_mask);
9848 case 83: /* Thumbnail */
9850 if (attribute_flag[0] != 0)
9851 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9852 &geometry,exception);
9853 if (attribute_flag[1] != 0)
9854 geometry.width=argument_list[1].integer_reference;
9855 if (attribute_flag[2] != 0)
9856 geometry.height=argument_list[2].integer_reference;
9857 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9860 case 84: /* Strip */
9862 (void) StripImage(image,exception);
9870 GetPixelInfo(image,&tint);
9871 if (attribute_flag[0] != 0)
9872 (void) QueryColorCompliance(argument_list[0].string_reference,
9873 AllCompliance,&tint,exception);
9874 if (attribute_flag[1] == 0)
9875 argument_list[1].string_reference="100";
9876 image=TintImage(image,argument_list[1].string_reference,&tint,
9880 case 86: /* Channel */
9882 if (attribute_flag[0] != 0)
9883 channel=(ChannelType) argument_list[0].integer_reference;
9884 image=SeparateImage(image,channel,exception);
9887 case 87: /* Splice */
9889 if (attribute_flag[0] != 0)
9890 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9891 &geometry,exception);
9892 if (attribute_flag[1] != 0)
9893 geometry.width=argument_list[1].integer_reference;
9894 if (attribute_flag[2] != 0)
9895 geometry.height=argument_list[2].integer_reference;
9896 if (attribute_flag[3] != 0)
9897 geometry.x=argument_list[3].integer_reference;
9898 if (attribute_flag[4] != 0)
9899 geometry.y=argument_list[4].integer_reference;
9900 if (attribute_flag[5] != 0)
9901 image->fuzz=StringToDoubleInterval(
9902 argument_list[5].string_reference,(double) QuantumRange+1.0);
9903 if (attribute_flag[6] != 0)
9904 (void) QueryColorCompliance(argument_list[6].string_reference,
9905 AllCompliance,&image->background_color,exception);
9906 if (attribute_flag[7] != 0)
9907 image->gravity=(GravityType) argument_list[7].integer_reference;
9908 image=SpliceImage(image,&geometry,exception);
9911 case 88: /* Posterize */
9913 if (attribute_flag[0] == 0)
9914 argument_list[0].integer_reference=3;
9915 if (attribute_flag[1] == 0)
9916 argument_list[1].integer_reference=0;
9917 (void) PosterizeImage(image,argument_list[0].integer_reference,
9918 argument_list[1].integer_reference ? RiemersmaDitherMethod :
9919 NoDitherMethod,exception);
9922 case 89: /* Shadow */
9924 if (attribute_flag[0] != 0)
9926 flags=ParseGeometry(argument_list[0].string_reference,
9928 if ((flags & SigmaValue) == 0)
9929 geometry_info.sigma=1.0;
9930 if ((flags & XiValue) == 0)
9931 geometry_info.xi=4.0;
9932 if ((flags & PsiValue) == 0)
9933 geometry_info.psi=4.0;
9935 if (attribute_flag[1] != 0)
9936 geometry_info.rho=argument_list[1].real_reference;
9937 if (attribute_flag[2] != 0)
9938 geometry_info.sigma=argument_list[2].real_reference;
9939 if (attribute_flag[3] != 0)
9940 geometry_info.xi=argument_list[3].integer_reference;
9941 if (attribute_flag[4] != 0)
9942 geometry_info.psi=argument_list[4].integer_reference;
9943 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9944 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
9945 ceil(geometry_info.psi-0.5),exception);
9948 case 90: /* Identify */
9950 if (attribute_flag[0] == 0)
9951 argument_list[0].file_reference=(FILE *) NULL;
9952 if (attribute_flag[1] != 0)
9953 (void) SetImageArtifact(image,"identify:features",
9954 argument_list[1].string_reference);
9955 if ((attribute_flag[2] != 0) &&
9956 (argument_list[2].integer_reference != 0))
9957 (void) SetImageArtifact(image,"identify:unique","true");
9958 (void) IdentifyImage(image,argument_list[0].file_reference,
9959 MagickTrue,exception);
9962 case 91: /* SepiaTone */
9964 if (attribute_flag[0] == 0)
9965 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9966 image=SepiaToneImage(image,argument_list[0].real_reference,
9970 case 92: /* SigmoidalContrast */
9975 if (attribute_flag[0] != 0)
9977 flags=ParseGeometry(argument_list[0].string_reference,
9979 if ((flags & SigmaValue) == 0)
9980 geometry_info.sigma=QuantumRange/2.0;
9981 if ((flags & PercentValue) != 0)
9982 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9984 if (attribute_flag[1] != 0)
9985 geometry_info.rho=argument_list[1].real_reference;
9986 if (attribute_flag[2] != 0)
9987 geometry_info.sigma=argument_list[2].real_reference;
9988 if (attribute_flag[3] != 0)
9989 channel=(ChannelType) argument_list[3].integer_reference;
9991 if (attribute_flag[4] != 0)
9992 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9994 channel_mask=SetImageChannelMask(image,channel);
9995 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9996 geometry_info.sigma,exception);
9997 (void) SetImageChannelMask(image,channel_mask);
10000 case 93: /* Extent */
10002 if (attribute_flag[7] != 0)
10003 image->gravity=(GravityType) argument_list[7].integer_reference;
10004 if (attribute_flag[0] != 0)
10009 flags=ParseGravityGeometry(image,
10010 argument_list[0].string_reference,&geometry,exception);
10012 if (geometry.width == 0)
10013 geometry.width=image->columns;
10014 if (geometry.height == 0)
10015 geometry.height=image->rows;
10017 if (attribute_flag[1] != 0)
10018 geometry.width=argument_list[1].integer_reference;
10019 if (attribute_flag[2] != 0)
10020 geometry.height=argument_list[2].integer_reference;
10021 if (attribute_flag[3] != 0)
10022 geometry.x=argument_list[3].integer_reference;
10023 if (attribute_flag[4] != 0)
10024 geometry.y=argument_list[4].integer_reference;
10025 if (attribute_flag[5] != 0)
10026 image->fuzz=StringToDoubleInterval(
10027 argument_list[5].string_reference,(double) QuantumRange+1.0);
10028 if (attribute_flag[6] != 0)
10029 (void) QueryColorCompliance(argument_list[6].string_reference,
10030 AllCompliance,&image->background_color,exception);
10031 image=ExtentImage(image,&geometry,exception);
10034 case 94: /* Vignette */
10036 if (attribute_flag[0] != 0)
10038 flags=ParseGeometry(argument_list[0].string_reference,
10040 if ((flags & SigmaValue) == 0)
10041 geometry_info.sigma=1.0;
10042 if ((flags & XiValue) == 0)
10043 geometry_info.xi=0.1*image->columns;
10044 if ((flags & PsiValue) == 0)
10045 geometry_info.psi=0.1*image->rows;
10047 if (attribute_flag[1] != 0)
10048 geometry_info.rho=argument_list[1].real_reference;
10049 if (attribute_flag[2] != 0)
10050 geometry_info.sigma=argument_list[2].real_reference;
10051 if (attribute_flag[3] != 0)
10052 geometry_info.xi=argument_list[3].integer_reference;
10053 if (attribute_flag[4] != 0)
10054 geometry_info.psi=argument_list[4].integer_reference;
10055 if (attribute_flag[5] != 0)
10056 (void) QueryColorCompliance(argument_list[5].string_reference,
10057 AllCompliance,&image->background_color,exception);
10058 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10059 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10060 ceil(geometry_info.psi-0.5),exception);
10063 case 95: /* ContrastStretch */
10070 white_point=(double) image->columns*image->rows;
10071 if (attribute_flag[0] != 0)
10073 flags=ParseGeometry(argument_list[0].string_reference,
10075 black_point=geometry_info.rho;
10076 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10078 if ((flags & PercentValue) != 0)
10080 black_point*=(double) image->columns*image->rows/100.0;
10081 white_point*=(double) image->columns*image->rows/100.0;
10083 white_point=(double) image->columns*image->rows-
10086 if (attribute_flag[1] != 0)
10087 black_point=argument_list[1].real_reference;
10088 if (attribute_flag[2] != 0)
10089 white_point=argument_list[2].real_reference;
10090 if (attribute_flag[4] != 0)
10091 channel=(ChannelType) argument_list[4].integer_reference;
10092 channel_mask=SetImageChannelMask(image,channel);
10093 (void) ContrastStretchImage(image,black_point,white_point,exception);
10094 (void) SetImageChannelMask(image,channel_mask);
10097 case 96: /* Sans0 */
10101 case 97: /* Sans1 */
10105 case 98: /* AdaptiveSharpen */
10107 if (attribute_flag[0] != 0)
10109 flags=ParseGeometry(argument_list[0].string_reference,
10111 if ((flags & SigmaValue) == 0)
10112 geometry_info.sigma=1.0;
10113 if ((flags & XiValue) == 0)
10114 geometry_info.xi=0.0;
10116 if (attribute_flag[1] != 0)
10117 geometry_info.rho=argument_list[1].real_reference;
10118 if (attribute_flag[2] != 0)
10119 geometry_info.sigma=argument_list[2].real_reference;
10120 if (attribute_flag[3] != 0)
10121 geometry_info.xi=argument_list[3].real_reference;
10122 if (attribute_flag[4] != 0)
10123 channel=(ChannelType) argument_list[4].integer_reference;
10124 channel_mask=SetImageChannelMask(image,channel);
10125 image=AdaptiveSharpenImage(image,geometry_info.rho,
10126 geometry_info.sigma,exception);
10127 if (image != (Image *) NULL)
10128 (void) SetImageChannelMask(image,channel_mask);
10131 case 99: /* Transpose */
10133 image=TransposeImage(image,exception);
10136 case 100: /* Tranverse */
10138 image=TransverseImage(image,exception);
10141 case 101: /* AutoOrient */
10143 image=AutoOrientImage(image,image->orientation,exception);
10146 case 102: /* AdaptiveBlur */
10148 if (attribute_flag[0] != 0)
10150 flags=ParseGeometry(argument_list[0].string_reference,
10152 if ((flags & SigmaValue) == 0)
10153 geometry_info.sigma=1.0;
10154 if ((flags & XiValue) == 0)
10155 geometry_info.xi=0.0;
10157 if (attribute_flag[1] != 0)
10158 geometry_info.rho=argument_list[1].real_reference;
10159 if (attribute_flag[2] != 0)
10160 geometry_info.sigma=argument_list[2].real_reference;
10161 if (attribute_flag[3] != 0)
10162 channel=(ChannelType) argument_list[3].integer_reference;
10163 channel_mask=SetImageChannelMask(image,channel);
10164 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10166 if (image != (Image *) NULL)
10167 (void) SetImageChannelMask(image,channel_mask);
10170 case 103: /* Sketch */
10172 if (attribute_flag[0] != 0)
10174 flags=ParseGeometry(argument_list[0].string_reference,
10176 if ((flags & SigmaValue) == 0)
10177 geometry_info.sigma=1.0;
10178 if ((flags & XiValue) == 0)
10179 geometry_info.xi=1.0;
10181 if (attribute_flag[1] != 0)
10182 geometry_info.rho=argument_list[1].real_reference;
10183 if (attribute_flag[2] != 0)
10184 geometry_info.sigma=argument_list[2].real_reference;
10185 if (attribute_flag[3] != 0)
10186 geometry_info.xi=argument_list[3].real_reference;
10187 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10188 geometry_info.xi,exception);
10191 case 104: /* UniqueColors */
10193 image=UniqueImageColors(image,exception);
10196 case 105: /* AdaptiveResize */
10198 if (attribute_flag[0] != 0)
10199 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10200 &geometry,exception);
10201 if (attribute_flag[1] != 0)
10202 geometry.width=argument_list[1].integer_reference;
10203 if (attribute_flag[2] != 0)
10204 geometry.height=argument_list[2].integer_reference;
10205 if (attribute_flag[3] != 0)
10206 image->filter=(FilterTypes) argument_list[4].integer_reference;
10207 if (attribute_flag[4] != 0)
10208 SetImageArtifact(image,"filter:support",
10209 argument_list[4].string_reference);
10210 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10214 case 106: /* ClipMask */
10219 if (attribute_flag[0] == 0)
10221 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10223 goto PerlException;
10225 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10227 (void) NegateImage(mask_image,MagickFalse,exception);
10228 (void) SetImageMask(image,mask_image,exception);
10229 mask_image=DestroyImage(mask_image);
10232 case 107: /* LinearStretch */
10239 white_point=(double) image->columns*image->rows;
10240 if (attribute_flag[0] != 0)
10242 flags=ParseGeometry(argument_list[0].string_reference,
10244 if ((flags & SigmaValue) != 0)
10245 white_point=geometry_info.sigma;
10246 if ((flags & PercentValue) != 0)
10248 black_point*=(double) image->columns*image->rows/100.0;
10249 white_point*=(double) image->columns*image->rows/100.0;
10251 if ((flags & SigmaValue) == 0)
10252 white_point=(double) image->columns*image->rows-black_point;
10254 if (attribute_flag[1] != 0)
10255 black_point=argument_list[1].real_reference;
10256 if (attribute_flag[2] != 0)
10257 white_point=argument_list[2].real_reference;
10258 (void) LinearStretchImage(image,black_point,white_point,exception);
10261 case 108: /* ColorMatrix */
10275 if (attribute_flag[0] == 0)
10277 av=(AV *) argument_list[0].array_reference;
10278 order=(size_t) sqrt(av_len(av)+1);
10279 color_matrix=(double *) AcquireQuantumMemory(order,order*
10280 sizeof(*color_matrix));
10281 if (color_matrix == (double *) NULL)
10283 ThrowPerlException(exception,ResourceLimitFatalError,
10284 "MemoryAllocationFailed",PackageName);
10285 goto PerlException;
10287 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10288 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10289 for ( ; j < (ssize_t) (order*order); j++)
10290 color_matrix[j]=0.0;
10291 kernel_info=AcquireKernelInfo((const char *) NULL);
10292 if (kernel_info == (KernelInfo *) NULL)
10294 kernel_info->width=order;
10295 kernel_info->height=order;
10296 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10297 order*sizeof(*kernel_info->values));
10298 if (kernel_info->values != (MagickRealType *) NULL)
10300 for (i=0; i < (ssize_t) (order*order); i++)
10301 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10302 image=ColorMatrixImage(image,kernel_info,exception);
10304 kernel_info=DestroyKernelInfo(kernel_info);
10305 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10308 case 109: /* Mask */
10313 if (attribute_flag[0] == 0)
10315 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10317 goto PerlException;
10319 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10320 MagickTrue,exception);
10321 (void) NegateImage(mask_image,MagickFalse,exception);
10322 (void) SetImageMask(image,mask_image,exception);
10323 mask_image=DestroyImage(mask_image);
10326 case 110: /* Polaroid */
10337 PixelInterpolateMethod
10340 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10341 (DrawInfo *) NULL);
10342 caption=(char *) NULL;
10343 if (attribute_flag[0] != 0)
10344 caption=InterpretImageProperties(info ? info->image_info :
10345 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10348 if (attribute_flag[1] != 0)
10349 angle=argument_list[1].real_reference;
10350 if (attribute_flag[2] != 0)
10351 (void) CloneString(&draw_info->font,
10352 argument_list[2].string_reference);
10353 if (attribute_flag[3] != 0)
10354 (void) QueryColorCompliance(argument_list[3].string_reference,
10355 AllCompliance,&draw_info->stroke,exception);
10356 if (attribute_flag[4] != 0)
10357 (void) QueryColorCompliance(argument_list[4].string_reference,
10358 AllCompliance,&draw_info->fill,exception);
10359 if (attribute_flag[5] != 0)
10360 draw_info->stroke_width=argument_list[5].real_reference;
10361 if (attribute_flag[6] != 0)
10362 draw_info->pointsize=argument_list[6].real_reference;
10363 if (attribute_flag[7] != 0)
10364 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10365 if (attribute_flag[8] != 0)
10366 (void) QueryColorCompliance(argument_list[8].string_reference,
10367 AllCompliance,&image->background_color,exception);
10368 method=UndefinedInterpolatePixel;
10369 if (attribute_flag[9] != 0)
10370 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10371 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10372 draw_info=DestroyDrawInfo(draw_info);
10373 if (caption != (char *) NULL)
10374 caption=DestroyString(caption);
10377 case 111: /* FloodfillPaint */
10388 draw_info=CloneDrawInfo(info ? info->image_info :
10389 (ImageInfo *) NULL,(DrawInfo *) NULL);
10390 if (attribute_flag[0] != 0)
10391 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10392 &geometry,exception);
10393 if (attribute_flag[1] != 0)
10394 geometry.x=argument_list[1].integer_reference;
10395 if (attribute_flag[2] != 0)
10396 geometry.y=argument_list[2].integer_reference;
10397 if (attribute_flag[3] != 0)
10398 (void) QueryColorCompliance(argument_list[3].string_reference,
10399 AllCompliance,&draw_info->fill,exception);
10400 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10401 geometry.x,geometry.y,&target,exception);
10402 if (attribute_flag[4] != 0)
10403 QueryColorCompliance(argument_list[4].string_reference,
10404 AllCompliance,&target,exception);
10405 if (attribute_flag[5] != 0)
10406 image->fuzz=StringToDoubleInterval(
10407 argument_list[5].string_reference,(double) QuantumRange+1.0);
10408 if (attribute_flag[6] != 0)
10409 channel=(ChannelType) argument_list[6].integer_reference;
10410 invert=MagickFalse;
10411 if (attribute_flag[7] != 0)
10412 invert=(MagickBooleanType) argument_list[7].integer_reference;
10413 channel_mask=SetImageChannelMask(image,channel);
10414 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10415 geometry.y,invert,exception);
10416 (void) SetImageChannelMask(image,channel_mask);
10417 draw_info=DestroyDrawInfo(draw_info);
10420 case 112: /* Distort */
10432 number_coordinates;
10437 if (attribute_flag[0] == 0)
10439 method=UndefinedDistortion;
10440 if (attribute_flag[1] != 0)
10441 method=(DistortImageMethod) argument_list[1].integer_reference;
10442 av=(AV *) argument_list[0].array_reference;
10443 number_coordinates=(size_t) av_len(av)+1;
10444 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10445 sizeof(*coordinates));
10446 if (coordinates == (double *) NULL)
10448 ThrowPerlException(exception,ResourceLimitFatalError,
10449 "MemoryAllocationFailed",PackageName);
10450 goto PerlException;
10452 for (j=0; j < (ssize_t) number_coordinates; j++)
10453 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10454 virtual_pixel=UndefinedVirtualPixelMethod;
10455 if (attribute_flag[2] != 0)
10456 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10457 argument_list[2].integer_reference,exception);
10458 image=DistortImage(image,method,number_coordinates,coordinates,
10459 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10461 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10462 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10464 coordinates=(double *) RelinquishMagickMemory(coordinates);
10467 case 113: /* Clut */
10469 PixelInterpolateMethod
10472 if (attribute_flag[0] == 0)
10474 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10476 goto PerlException;
10478 method=UndefinedInterpolatePixel;
10479 if (attribute_flag[1] != 0)
10480 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10481 if (attribute_flag[2] != 0)
10482 channel=(ChannelType) argument_list[2].integer_reference;
10483 channel_mask=SetImageChannelMask(image,channel);
10484 (void) ClutImage(image,argument_list[0].image_reference,method,
10486 (void) SetImageChannelMask(image,channel_mask);
10489 case 114: /* LiquidRescale */
10491 if (attribute_flag[0] != 0)
10492 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10493 &geometry,exception);
10494 if (attribute_flag[1] != 0)
10495 geometry.width=argument_list[1].integer_reference;
10496 if (attribute_flag[2] != 0)
10497 geometry.height=argument_list[2].integer_reference;
10498 if (attribute_flag[3] == 0)
10499 argument_list[3].real_reference=1.0;
10500 if (attribute_flag[4] == 0)
10501 argument_list[4].real_reference=0.0;
10502 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10503 argument_list[3].real_reference,argument_list[4].real_reference,
10507 case 115: /* EncipherImage */
10509 (void) EncipherImage(image,argument_list[0].string_reference,
10513 case 116: /* DecipherImage */
10515 (void) DecipherImage(image,argument_list[0].string_reference,
10519 case 117: /* Deskew */
10521 geometry_info.rho=QuantumRange/2.0;
10522 if (attribute_flag[0] != 0)
10523 flags=ParseGeometry(argument_list[0].string_reference,
10525 if (attribute_flag[1] != 0)
10526 geometry_info.rho=StringToDoubleInterval(
10527 argument_list[1].string_reference,(double) QuantumRange+1.0);
10528 image=DeskewImage(image,geometry_info.rho,exception);
10531 case 118: /* Remap */
10536 if (attribute_flag[0] == 0)
10538 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10540 goto PerlException;
10542 quantize_info=AcquireQuantizeInfo(info->image_info);
10543 if (attribute_flag[1] != 0)
10544 quantize_info->dither_method=(DitherMethod)
10545 argument_list[1].integer_reference;
10546 (void) RemapImages(quantize_info,image,
10547 argument_list[0].image_reference,exception);
10548 quantize_info=DestroyQuantizeInfo(quantize_info);
10551 case 119: /* SparseColor */
10563 number_coordinates;
10568 if (attribute_flag[0] == 0)
10570 method=UndefinedColorInterpolate;
10571 if (attribute_flag[1] != 0)
10572 method=(SparseColorMethod) argument_list[1].integer_reference;
10573 av=(AV *) argument_list[0].array_reference;
10574 number_coordinates=(size_t) av_len(av)+1;
10575 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10576 sizeof(*coordinates));
10577 if (coordinates == (double *) NULL)
10579 ThrowPerlException(exception,ResourceLimitFatalError,
10580 "MemoryAllocationFailed",PackageName);
10581 goto PerlException;
10583 for (j=0; j < (ssize_t) number_coordinates; j++)
10584 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10585 virtual_pixel=UndefinedVirtualPixelMethod;
10586 if (attribute_flag[2] != 0)
10587 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10588 argument_list[2].integer_reference,exception);
10589 if (attribute_flag[3] != 0)
10590 channel=(ChannelType) argument_list[3].integer_reference;
10591 channel_mask=SetImageChannelMask(image,channel);
10592 image=SparseColorImage(image,method,number_coordinates,coordinates,
10594 if (image != (Image *) NULL)
10595 (void) SetImageChannelMask(image,channel_mask);
10596 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10597 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10599 coordinates=(double *) RelinquishMagickMemory(coordinates);
10602 case 120: /* Function */
10619 if (attribute_flag[0] == 0)
10621 function=UndefinedFunction;
10622 if (attribute_flag[1] != 0)
10623 function=(MagickFunction) argument_list[1].integer_reference;
10624 av=(AV *) argument_list[0].array_reference;
10625 number_parameters=(size_t) av_len(av)+1;
10626 parameters=(double *) AcquireQuantumMemory(number_parameters,
10627 sizeof(*parameters));
10628 if (parameters == (double *) NULL)
10630 ThrowPerlException(exception,ResourceLimitFatalError,
10631 "MemoryAllocationFailed",PackageName);
10632 goto PerlException;
10634 for (j=0; j < (ssize_t) number_parameters; j++)
10635 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10636 virtual_pixel=UndefinedVirtualPixelMethod;
10637 if (attribute_flag[2] != 0)
10638 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10639 argument_list[2].integer_reference,exception);
10640 (void) FunctionImage(image,function,number_parameters,parameters,
10642 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10643 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10645 parameters=(double *) RelinquishMagickMemory(parameters);
10648 case 121: /* SelectiveBlur */
10650 if (attribute_flag[0] != 0)
10652 flags=ParseGeometry(argument_list[0].string_reference,
10654 if ((flags & SigmaValue) == 0)
10655 geometry_info.sigma=1.0;
10656 if ((flags & PercentValue) != 0)
10657 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10659 if (attribute_flag[1] != 0)
10660 geometry_info.rho=argument_list[1].real_reference;
10661 if (attribute_flag[2] != 0)
10662 geometry_info.sigma=argument_list[2].real_reference;
10663 if (attribute_flag[3] != 0)
10664 geometry_info.xi=argument_list[3].integer_reference;;
10665 if (attribute_flag[5] != 0)
10666 channel=(ChannelType) argument_list[5].integer_reference;
10667 channel_mask=SetImageChannelMask(image,channel);
10668 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10669 geometry_info.xi,exception);
10670 if (image != (Image *) NULL)
10671 (void) SetImageChannelMask(image,channel_mask);
10674 case 122: /* HaldClut */
10676 if (attribute_flag[0] == 0)
10678 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10680 goto PerlException;
10682 if (attribute_flag[1] != 0)
10683 channel=(ChannelType) argument_list[1].integer_reference;
10684 channel_mask=SetImageChannelMask(image,channel);
10685 (void) HaldClutImage(image,argument_list[0].image_reference,
10687 (void) SetImageChannelMask(image,channel_mask);
10690 case 123: /* BlueShift */
10692 if (attribute_flag[0] != 0)
10693 (void) ParseGeometry(argument_list[0].string_reference,
10695 image=BlueShiftImage(image,geometry_info.rho,exception);
10698 case 124: /* ForwardFourierTransformImage */
10700 image=ForwardFourierTransformImage(image,
10701 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10705 case 125: /* InverseFourierTransformImage */
10707 image=InverseFourierTransformImage(image,image->next,
10708 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10712 case 126: /* ColorDecisionList */
10714 if (attribute_flag[0] == 0)
10715 argument_list[0].string_reference=(char *) NULL;
10716 (void) ColorDecisionListImage(image,
10717 argument_list[0].string_reference,exception);
10720 case 127: /* AutoGamma */
10722 if (attribute_flag[0] != 0)
10723 channel=(ChannelType) argument_list[0].integer_reference;
10724 channel_mask=SetImageChannelMask(image,channel);
10725 (void) AutoGammaImage(image,exception);
10726 (void) SetImageChannelMask(image,channel_mask);
10729 case 128: /* AutoLevel */
10731 if (attribute_flag[0] != 0)
10732 channel=(ChannelType) argument_list[0].integer_reference;
10733 channel_mask=SetImageChannelMask(image,channel);
10734 (void) AutoLevelImage(image,exception);
10735 (void) SetImageChannelMask(image,channel_mask);
10738 case 129: /* LevelColors */
10744 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10746 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10748 if (attribute_flag[1] != 0)
10749 (void) QueryColorCompliance(
10750 argument_list[1].string_reference,AllCompliance,&black_point,
10752 if (attribute_flag[2] != 0)
10753 (void) QueryColorCompliance(
10754 argument_list[2].string_reference,AllCompliance,&white_point,
10756 if (attribute_flag[3] != 0)
10757 channel=(ChannelType) argument_list[3].integer_reference;
10758 channel_mask=SetImageChannelMask(image,channel);
10759 (void) LevelImageColors(image,&black_point,&white_point,
10760 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10762 (void) SetImageChannelMask(image,channel_mask);
10765 case 130: /* Clamp */
10767 if (attribute_flag[0] != 0)
10768 channel=(ChannelType) argument_list[0].integer_reference;
10769 channel_mask=SetImageChannelMask(image,channel);
10770 (void) ClampImage(image,exception);
10771 (void) SetImageChannelMask(image,channel_mask);
10774 case 131: /* BrightnessContrast */
10782 if (attribute_flag[0] != 0)
10784 flags=ParseGeometry(argument_list[0].string_reference,
10786 brightness=geometry_info.rho;
10787 if ((flags & SigmaValue) == 0)
10788 contrast=geometry_info.sigma;
10790 if (attribute_flag[1] != 0)
10791 brightness=argument_list[1].real_reference;
10792 if (attribute_flag[2] != 0)
10793 contrast=argument_list[2].real_reference;
10794 if (attribute_flag[4] != 0)
10795 channel=(ChannelType) argument_list[4].integer_reference;
10796 channel_mask=SetImageChannelMask(image,channel);
10797 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10798 (void) SetImageChannelMask(image,channel_mask);
10801 case 132: /* Morphology */
10812 if (attribute_flag[0] == 0)
10814 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10815 if (kernel == (KernelInfo *) NULL)
10817 if (attribute_flag[1] != 0)
10818 channel=(ChannelType) argument_list[1].integer_reference;
10819 method=UndefinedMorphology;
10820 if (attribute_flag[2] != 0)
10821 method=argument_list[2].integer_reference;
10823 if (attribute_flag[3] != 0)
10824 iterations=argument_list[3].integer_reference;
10825 channel_mask=SetImageChannelMask(image,channel);
10826 image=MorphologyImage(image,method,iterations,kernel,exception);
10827 if (image != (Image *) NULL)
10828 (void) SetImageChannelMask(image,channel_mask);
10829 kernel=DestroyKernelInfo(kernel);
10832 case 133: /* Mode */
10834 if (attribute_flag[0] != 0)
10836 flags=ParseGeometry(argument_list[0].string_reference,
10838 if ((flags & SigmaValue) == 0)
10839 geometry_info.sigma=1.0;
10841 if (attribute_flag[1] != 0)
10842 geometry_info.rho=argument_list[1].real_reference;
10843 if (attribute_flag[2] != 0)
10844 geometry_info.sigma=argument_list[2].real_reference;
10845 if (attribute_flag[3] != 0)
10846 channel=(ChannelType) argument_list[3].integer_reference;
10847 channel_mask=SetImageChannelMask(image,channel);
10848 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10849 (size_t) geometry_info.sigma,exception);
10850 if (image != (Image *) NULL)
10851 (void) SetImageChannelMask(image,channel_mask);
10854 case 134: /* Statistic */
10859 statistic=UndefinedStatistic;
10860 if (attribute_flag[0] != 0)
10862 flags=ParseGeometry(argument_list[0].string_reference,
10864 if ((flags & SigmaValue) == 0)
10865 geometry_info.sigma=1.0;
10867 if (attribute_flag[1] != 0)
10868 geometry_info.rho=argument_list[1].real_reference;
10869 if (attribute_flag[2] != 0)
10870 geometry_info.sigma=argument_list[2].real_reference;
10871 if (attribute_flag[3] != 0)
10872 channel=(ChannelType) argument_list[3].integer_reference;
10873 if (attribute_flag[4] != 0)
10874 statistic=(StatisticType) argument_list[4].integer_reference;
10875 channel_mask=SetImageChannelMask(image,channel);
10876 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10877 (size_t) geometry_info.sigma,exception);
10878 if (image != (Image *) NULL)
10879 (void) SetImageChannelMask(image,channel_mask);
10882 case 135: /* Perceptible */
10887 epsilon=MagickEpsilon;
10888 if (attribute_flag[0] != 0)
10889 epsilon=argument_list[0].real_reference;
10890 if (attribute_flag[1] != 0)
10891 channel=(ChannelType) argument_list[1].integer_reference;
10892 channel_mask=SetImageChannelMask(image,channel);
10893 (void) PerceptibleImage(image,epsilon,exception);
10894 (void) SetImageChannelMask(image,channel_mask);
10897 case 136: /* Poly */
10908 if (attribute_flag[0] == 0)
10910 if (attribute_flag[1] != 0)
10911 channel=(ChannelType) argument_list[1].integer_reference;
10912 av=(AV *) argument_list[0].array_reference;
10913 number_terms=(size_t) av_len(av);
10914 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
10915 if (terms == (double *) NULL)
10917 ThrowPerlException(exception,ResourceLimitFatalError,
10918 "MemoryAllocationFailed",PackageName);
10919 goto PerlException;
10921 for (j=0; j < av_len(av); j++)
10922 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
10923 image=PolynomialImage(image,number_terms >> 1,terms,exception);
10924 terms=(double *) RelinquishMagickMemory(terms);
10928 if (next != (Image *) NULL)
10929 (void) CatchImageException(next);
10930 if (region_image != (Image *) NULL)
10935 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
10936 region_info.x,region_info.y,exception);
10938 (void) CatchImageException(region_image);
10939 image=DestroyImage(image);
10940 image=region_image;
10942 if (image != (Image *) NULL)
10945 if (next && (next != image))
10947 image->next=next->next;
10948 if (image->next != (Image *) NULL)
10949 image->next->previous=image;
10950 DeleteImageFromRegistry(*pv,next);
10952 sv_setiv(*pv,PTR2IV(image));
10960 if (reference_vector)
10961 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10962 InheritPerlException(exception,perl_exception);
10963 exception=DestroyExceptionInfo(exception);
10964 sv_setiv(perl_exception,(IV) number_images);
10965 SvPOK_on(perl_exception);
10966 ST(0)=sv_2mortal(perl_exception);
10971 ###############################################################################
10979 ###############################################################################
10984 Image::Magick ref=NO_INIT
11029 PERL_UNUSED_VAR(ref);
11030 PERL_UNUSED_VAR(ix);
11031 exception=AcquireExceptionInfo();
11032 perl_exception=newSVpv("",0);
11035 if (sv_isobject(ST(0)) == 0)
11037 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11039 goto PerlException;
11041 reference=SvRV(ST(0));
11042 hv=SvSTASH(reference);
11044 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11046 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11047 if (image == (Image *) NULL)
11049 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11051 goto PerlException;
11056 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11057 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11058 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11060 for (i=2; i < items; i+=2)
11062 attribute=(char *) SvPV(ST(i-1),na);
11063 switch (*attribute)
11068 if (LocaleCompare(attribute,"background") == 0)
11070 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11071 &montage_info->background_color,exception);
11072 for (next=image; next; next=next->next)
11073 next->background_color=montage_info->background_color;
11076 if (LocaleCompare(attribute,"border") == 0)
11078 montage_info->border_width=SvIV(ST(i));
11081 if (LocaleCompare(attribute,"bordercolor") == 0)
11083 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11084 &montage_info->border_color,exception);
11085 for (next=image; next; next=next->next)
11086 next->border_color=montage_info->border_color;
11089 if (LocaleCompare(attribute,"borderwidth") == 0)
11091 montage_info->border_width=SvIV(ST(i));
11094 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11101 if (LocaleCompare(attribute,"compose") == 0)
11103 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11104 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11107 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11111 for (next=image; next; next=next->next)
11112 next->compose=(CompositeOperator) sp;
11115 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11122 if (LocaleCompare(attribute,"fill") == 0)
11124 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11125 &montage_info->fill,exception);
11128 if (LocaleCompare(attribute,"font") == 0)
11130 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11133 if (LocaleCompare(attribute,"frame") == 0)
11139 if (IsGeometry(p) == MagickFalse)
11141 ThrowPerlException(exception,OptionError,"MissingGeometry",
11145 (void) CloneString(&montage_info->frame,p);
11147 montage_info->frame=(char *) NULL;
11150 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11157 if (LocaleCompare(attribute,"geometry") == 0)
11163 if (IsGeometry(p) == MagickFalse)
11165 ThrowPerlException(exception,OptionError,"MissingGeometry",
11169 (void) CloneString(&montage_info->geometry,p);
11171 montage_info->geometry=(char *) NULL;
11174 if (LocaleCompare(attribute,"gravity") == 0)
11179 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11180 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11183 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11187 montage_info->gravity=(GravityType) in;
11188 for (next=image; next; next=next->next)
11189 next->gravity=(GravityType) in;
11192 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11199 if (LocaleCompare(attribute,"label") == 0)
11201 for (next=image; next; next=next->next)
11202 (void) SetImageProperty(next,"label",InterpretImageProperties(
11203 info ? info->image_info : (ImageInfo *) NULL,next,
11204 SvPV(ST(i),na),exception),exception);
11207 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11214 if (LocaleCompare(attribute,"mattecolor") == 0)
11216 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11217 &montage_info->matte_color,exception);
11218 for (next=image; next; next=next->next)
11219 next->matte_color=montage_info->matte_color;
11222 if (LocaleCompare(attribute,"mode") == 0)
11227 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11228 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11233 ThrowPerlException(exception,OptionError,
11234 "UnrecognizedModeType",SvPV(ST(i),na));
11239 (void) CloneString(&montage_info->frame,"15x15+3+3");
11240 montage_info->shadow=MagickTrue;
11245 montage_info->frame=(char *) NULL;
11246 montage_info->shadow=MagickFalse;
11247 montage_info->border_width=0;
11250 case ConcatenateMode:
11252 montage_info->frame=(char *) NULL;
11253 montage_info->shadow=MagickFalse;
11254 (void) CloneString(&montage_info->geometry,"+0+0");
11255 montage_info->border_width=0;
11260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11267 if (LocaleCompare(attribute,"pointsize") == 0)
11269 montage_info->pointsize=SvIV(ST(i));
11272 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11279 if (LocaleCompare(attribute,"shadow") == 0)
11281 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11282 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11285 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11289 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11292 if (LocaleCompare(attribute,"stroke") == 0)
11294 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11295 &montage_info->stroke,exception);
11298 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11305 if (LocaleCompare(attribute,"texture") == 0)
11307 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11310 if (LocaleCompare(attribute,"tile") == 0)
11312 char *p=SvPV(ST(i),na);
11313 if (IsGeometry(p) == MagickFalse)
11315 ThrowPerlException(exception,OptionError,"MissingGeometry",
11319 (void) CloneString(&montage_info->tile,p);
11321 montage_info->tile=(char *) NULL;
11324 if (LocaleCompare(attribute,"title") == 0)
11326 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11329 if (LocaleCompare(attribute,"transparent") == 0)
11334 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11335 &transparent_color,exception);
11336 for (next=image; next; next=next->next)
11337 (void) TransparentPaintImage(next,&transparent_color,
11338 TransparentAlpha,MagickFalse,exception);
11341 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11353 image=MontageImageList(info->image_info,montage_info,image,exception);
11354 montage_info=DestroyMontageInfo(montage_info);
11355 if (image == (Image *) NULL)
11356 goto PerlException;
11357 if (transparent_color.alpha != TransparentAlpha)
11358 for (next=image; next; next=next->next)
11359 (void) TransparentPaintImage(next,&transparent_color,
11360 TransparentAlpha,MagickFalse,exception);
11361 for ( ; image; image=image->next)
11363 AddImageToRegistry(sv,image);
11365 av_push(av,sv_bless(rv,hv));
11368 exception=DestroyExceptionInfo(exception);
11369 ST(0)=av_reference;
11370 SvREFCNT_dec(perl_exception);
11374 InheritPerlException(exception,perl_exception);
11375 exception=DestroyExceptionInfo(exception);
11376 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11377 SvPOK_on(perl_exception);
11378 ST(0)=sv_2mortal(perl_exception);
11383 ###############################################################################
11391 ###############################################################################
11396 Image::Magick ref=NO_INIT
11434 PERL_UNUSED_VAR(ref);
11435 PERL_UNUSED_VAR(ix);
11436 exception=AcquireExceptionInfo();
11437 perl_exception=newSVpv("",0);
11441 if (sv_isobject(ST(0)) == 0)
11443 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11445 goto PerlException;
11447 reference=SvRV(ST(0));
11448 hv=SvSTASH(reference);
11450 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11452 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11453 if (image == (Image *) NULL)
11455 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11457 goto PerlException;
11459 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11464 for (i=2; i < items; i+=2)
11466 attribute=(char *) SvPV(ST(i-1),na);
11467 switch (*attribute)
11472 if (LocaleCompare(attribute,"frames") == 0)
11474 number_frames=SvIV(ST(i));
11477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11483 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11489 image=MorphImages(image,number_frames,exception);
11490 if (image == (Image *) NULL)
11491 goto PerlException;
11492 for ( ; image; image=image->next)
11494 AddImageToRegistry(sv,image);
11496 av_push(av,sv_bless(rv,hv));
11499 exception=DestroyExceptionInfo(exception);
11500 ST(0)=av_reference;
11501 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11505 InheritPerlException(exception,perl_exception);
11506 exception=DestroyExceptionInfo(exception);
11507 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11508 SvPOK_on(perl_exception);
11509 ST(0)=sv_2mortal(perl_exception);
11514 ###############################################################################
11522 ###############################################################################
11527 Image::Magick ref=NO_INIT
11555 PERL_UNUSED_VAR(ref);
11556 PERL_UNUSED_VAR(ix);
11557 exception=AcquireExceptionInfo();
11558 perl_exception=newSVpv("",0);
11560 if (sv_isobject(ST(0)) == 0)
11562 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11564 goto PerlException;
11566 reference=SvRV(ST(0));
11567 hv=SvSTASH(reference);
11568 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11569 if (image == (Image *) NULL)
11571 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11573 goto PerlException;
11575 image=MergeImageLayers(image,MosaicLayer,exception);
11577 Create blessed Perl array for the returned image.
11580 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11582 AddImageToRegistry(sv,image);
11584 av_push(av,sv_bless(rv,hv));
11586 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11587 (void) CopyMagickString(info->image_info->filename,image->filename,
11589 SetImageInfo(info->image_info,0,exception);
11590 exception=DestroyExceptionInfo(exception);
11591 SvREFCNT_dec(perl_exception);
11595 InheritPerlException(exception,perl_exception);
11596 exception=DestroyExceptionInfo(exception);
11597 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11598 SvPOK_on(perl_exception); /* return messages in string context */
11599 ST(0)=sv_2mortal(perl_exception);
11604 ###############################################################################
11612 ###############################################################################
11617 Image::Magick ref=NO_INIT
11667 PERL_UNUSED_VAR(ref);
11668 PERL_UNUSED_VAR(ix);
11669 exception=AcquireExceptionInfo();
11670 perl_exception=newSVpv("",0);
11671 package_info=(struct PackageInfo *) NULL;
11672 ac=(items < 2) ? 1 : items-1;
11673 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11675 length=(STRLEN *) NULL;
11676 if (list == (char **) NULL)
11678 ThrowPerlException(exception,ResourceLimitError,
11679 "MemoryAllocationFailed",PackageName);
11680 goto PerlException;
11683 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11684 if (length == (STRLEN *) NULL)
11686 ThrowPerlException(exception,ResourceLimitError,
11687 "MemoryAllocationFailed",PackageName);
11688 goto PerlException;
11690 if (sv_isobject(ST(0)) == 0)
11692 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11694 goto PerlException;
11696 reference=SvRV(ST(0));
11697 if (SvTYPE(reference) != SVt_PVAV)
11699 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11701 goto PerlException;
11703 av=(AV *) reference;
11704 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11706 package_info=ClonePackageInfo(info,exception);
11709 *list=(char *) (*package_info->image_info->filename ?
11710 package_info->image_info->filename : "XC:black");
11712 for (n=0, i=0; i < ac; i++)
11714 list[n]=(char *) SvPV(ST(i+1),length[n]);
11715 if ((items >= 3) && strEQcase(list[n],"blob"))
11721 blob=(void *) (SvPV(ST(i+1),length[n]));
11722 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11724 if ((items >= 3) && strEQcase(list[n],"filename"))
11726 if ((items >= 3) && strEQcase(list[n],"file"))
11735 io_info=IoIFP(sv_2io(ST(i+1)));
11736 if (io_info == (PerlIO *) NULL)
11738 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11742 file=PerlIO_findFILE(io_info);
11743 if (file == (FILE *) NULL)
11745 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11749 SetImageInfoFile(package_info->image_info,file);
11751 if ((items >= 3) && strEQcase(list[n],"magick"))
11755 list[n]=(char *) NULL;
11757 status=ExpandFilenames(&n,&list);
11758 if (status == MagickFalse)
11760 ThrowPerlException(exception,ResourceLimitError,
11761 "MemoryAllocationFailed",PackageName);
11762 goto PerlException;
11765 for (i=0; i < n; i++)
11767 (void) CopyMagickString(package_info->image_info->filename,list[i],
11769 image=PingImage(package_info->image_info,exception);
11770 if (image == (Image *) NULL)
11772 if ((package_info->image_info->file != (FILE *) NULL) ||
11773 (package_info->image_info->blob != (void *) NULL))
11774 DisassociateImageStream(image);
11775 count+=GetImageListLength(image);
11776 EXTEND(sp,4*count);
11777 for (next=image; next; next=next->next)
11779 PUSHs(sv_2mortal(newSViv(next->columns)));
11780 PUSHs(sv_2mortal(newSViv(next->rows)));
11781 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11782 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11784 image=DestroyImageList(image);
11789 for (i=0; i < n; i++)
11790 if (list[i] != (char *) NULL)
11791 for (p=keep; list[i] != *p++; )
11794 list[i]=(char *) RelinquishMagickMemory(list[i]);
11799 if (package_info != (struct PackageInfo *) NULL)
11800 DestroyPackageInfo(package_info);
11801 if (list && (list != keep))
11802 list=(char **) RelinquishMagickMemory(list);
11804 keep=(char **) RelinquishMagickMemory(keep);
11806 length=(STRLEN *) RelinquishMagickMemory(length);
11807 InheritPerlException(exception,perl_exception);
11808 exception=DestroyExceptionInfo(exception);
11809 SvREFCNT_dec(perl_exception); /* throw away all errors */
11813 ###############################################################################
11821 ###############################################################################
11826 Image::Magick ref=NO_INIT
11859 PERL_UNUSED_VAR(ref);
11860 PERL_UNUSED_VAR(ix);
11861 exception=AcquireExceptionInfo();
11862 perl_exception=newSVpv("",0);
11865 if (sv_isobject(ST(0)) == 0)
11867 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11869 goto PerlException;
11871 reference=SvRV(ST(0));
11872 hv=SvSTASH(reference);
11874 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11876 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11877 if (image == (Image *) NULL)
11879 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11881 goto PerlException;
11883 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11884 preview_type=GammaPreview;
11886 preview_type=(PreviewType)
11887 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11888 for ( ; image; image=image->next)
11890 preview_image=PreviewImage(image,preview_type,exception);
11891 if (preview_image == (Image *) NULL)
11892 goto PerlException;
11893 AddImageToRegistry(sv,preview_image);
11895 av_push(av,sv_bless(rv,hv));
11898 exception=DestroyExceptionInfo(exception);
11899 ST(0)=av_reference;
11900 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11904 InheritPerlException(exception,perl_exception);
11905 exception=DestroyExceptionInfo(exception);
11906 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11907 SvPOK_on(perl_exception);
11908 ST(0)=sv_2mortal(perl_exception);
11913 ###############################################################################
11917 # Q u e r y C o l o r #
11921 ###############################################################################
11925 QueryColor(ref,...)
11926 Image::Magick ref=NO_INIT
11946 PERL_UNUSED_VAR(ref);
11947 PERL_UNUSED_VAR(ix);
11948 exception=AcquireExceptionInfo();
11949 perl_exception=newSVpv("",0);
11958 colorlist=GetColorInfoList("*",&colors,exception);
11960 for (i=0; i < (ssize_t) colors; i++)
11962 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11964 colorlist=(const ColorInfo **)
11965 RelinquishMagickMemory((ColorInfo **) colorlist);
11966 goto PerlException;
11968 EXTEND(sp,5*items);
11969 for (i=1; i < items; i++)
11971 name=(char *) SvPV(ST(i),na);
11972 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11977 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11978 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11979 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11980 if (color.colorspace == CMYKColorspace)
11981 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11982 if (color.alpha_trait == BlendPixelTrait)
11983 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11987 InheritPerlException(exception,perl_exception);
11988 exception=DestroyExceptionInfo(exception);
11989 SvREFCNT_dec(perl_exception);
11993 ###############################################################################
11997 # Q u e r y C o l o r N a m e #
12001 ###############################################################################
12005 QueryColorname(ref,...)
12006 Image::Magick ref=NO_INIT
12015 message[MaxTextExtent];
12034 *reference; /* reference is the SV* of ref=SvIV(reference) */
12036 PERL_UNUSED_VAR(ref);
12037 PERL_UNUSED_VAR(ix);
12038 exception=AcquireExceptionInfo();
12039 perl_exception=newSVpv("",0);
12040 reference=SvRV(ST(0));
12041 av=(AV *) reference;
12042 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12044 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12045 if (image == (Image *) NULL)
12047 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12049 goto PerlException;
12052 for (i=1; i < items; i++)
12054 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12056 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12058 PUSHs(sv_2mortal(newSVpv(message,0)));
12062 InheritPerlException(exception,perl_exception);
12063 exception=DestroyExceptionInfo(exception);
12064 SvREFCNT_dec(perl_exception);
12068 ###############################################################################
12072 # Q u e r y F o n t #
12076 ###############################################################################
12081 Image::Magick ref=NO_INIT
12088 message[MaxTextExtent];
12099 volatile const TypeInfo
12102 PERL_UNUSED_VAR(ref);
12103 PERL_UNUSED_VAR(ix);
12104 exception=AcquireExceptionInfo();
12105 perl_exception=newSVpv("",0);
12114 typelist=GetTypeInfoList("*",&types,exception);
12116 for (i=0; i < (ssize_t) types; i++)
12118 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12120 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12122 goto PerlException;
12124 EXTEND(sp,10*items);
12125 for (i=1; i < items; i++)
12127 name=(char *) SvPV(ST(i),na);
12128 type_info=GetTypeInfo(name,exception);
12129 if (type_info == (TypeInfo *) NULL)
12134 if (type_info->name == (char *) NULL)
12137 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12138 if (type_info->description == (char *) NULL)
12141 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12142 if (type_info->family == (char *) NULL)
12145 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12146 if (type_info->style == UndefinedStyle)
12149 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12150 type_info->style),0)));
12151 if (type_info->stretch == UndefinedStretch)
12154 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12155 type_info->stretch),0)));
12156 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12157 type_info->weight);
12158 PUSHs(sv_2mortal(newSVpv(message,0)));
12159 if (type_info->encoding == (char *) NULL)
12162 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12163 if (type_info->foundry == (char *) NULL)
12166 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12167 if (type_info->format == (char *) NULL)
12170 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12171 if (type_info->metrics == (char *) NULL)
12174 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12175 if (type_info->glyphs == (char *) NULL)
12178 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12182 InheritPerlException(exception,perl_exception);
12183 exception=DestroyExceptionInfo(exception);
12184 SvREFCNT_dec(perl_exception);
12188 ###############################################################################
12192 # Q u e r y F o n t M e t r i c s #
12196 ###############################################################################
12200 QueryFontMetrics(ref,...)
12201 Image::Magick ref=NO_INIT
12203 queryfontmetrics = 1
12250 *reference; /* reference is the SV* of ref=SvIV(reference) */
12255 PERL_UNUSED_VAR(ref);
12256 PERL_UNUSED_VAR(ix);
12257 exception=AcquireExceptionInfo();
12258 package_info=(struct PackageInfo *) NULL;
12259 perl_exception=newSVpv("",0);
12260 reference=SvRV(ST(0));
12261 av=(AV *) reference;
12262 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12264 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12265 if (image == (Image *) NULL)
12267 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12269 goto PerlException;
12271 package_info=ClonePackageInfo(info,exception);
12272 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12273 CloneString(&draw_info->text,"");
12274 current=draw_info->affine;
12275 GetAffineMatrix(&affine);
12278 EXTEND(sp,7*items);
12279 for (i=2; i < items; i+=2)
12281 attribute=(char *) SvPV(ST(i-1),na);
12282 switch (*attribute)
12287 if (LocaleCompare(attribute,"antialias") == 0)
12289 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12293 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12297 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12300 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12307 if (LocaleCompare(attribute,"density") == 0)
12309 CloneString(&draw_info->density,SvPV(ST(i),na));
12312 if (LocaleCompare(attribute,"direction") == 0)
12314 draw_info->direction=(DirectionType) ParseCommandOption(
12315 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12318 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12325 if (LocaleCompare(attribute,"encoding") == 0)
12327 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12330 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12337 if (LocaleCompare(attribute,"family") == 0)
12339 CloneString(&draw_info->family,SvPV(ST(i),na));
12342 if (LocaleCompare(attribute,"fill") == 0)
12345 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12346 &draw_info->fill,exception);
12349 if (LocaleCompare(attribute,"font") == 0)
12351 CloneString(&draw_info->font,SvPV(ST(i),na));
12354 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12361 if (LocaleCompare(attribute,"geometry") == 0)
12363 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12366 if (LocaleCompare(attribute,"gravity") == 0)
12368 draw_info->gravity=(GravityType) ParseCommandOption(
12369 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12379 if (LocaleCompare(attribute,"interline-spacing") == 0)
12381 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12382 draw_info->interline_spacing=geometry_info.rho;
12385 if (LocaleCompare(attribute,"interword-spacing") == 0)
12387 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12388 draw_info->interword_spacing=geometry_info.rho;
12391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12398 if (LocaleCompare(attribute,"kerning") == 0)
12400 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12401 draw_info->kerning=geometry_info.rho;
12404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12411 if (LocaleCompare(attribute,"pointsize") == 0)
12413 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12414 draw_info->pointsize=geometry_info.rho;
12417 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12424 if (LocaleCompare(attribute,"rotate") == 0)
12426 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12427 affine.rx=geometry_info.rho;
12428 affine.ry=geometry_info.sigma;
12429 if ((flags & SigmaValue) == 0)
12430 affine.ry=affine.rx;
12433 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12440 if (LocaleCompare(attribute,"scale") == 0)
12442 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12443 affine.sx=geometry_info.rho;
12444 affine.sy=geometry_info.sigma;
12445 if ((flags & SigmaValue) == 0)
12446 affine.sy=affine.sx;
12449 if (LocaleCompare(attribute,"skew") == 0)
12455 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12456 x_angle=geometry_info.rho;
12457 y_angle=geometry_info.sigma;
12458 if ((flags & SigmaValue) == 0)
12460 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12461 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12464 if (LocaleCompare(attribute,"stroke") == 0)
12467 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12468 &draw_info->stroke,exception);
12471 if (LocaleCompare(attribute,"style") == 0)
12473 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12477 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12481 draw_info->style=(StyleType) type;
12484 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12491 if (LocaleCompare(attribute,"text") == 0)
12493 CloneString(&draw_info->text,SvPV(ST(i),na));
12496 if (LocaleCompare(attribute,"translate") == 0)
12498 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12499 affine.tx=geometry_info.rho;
12500 affine.ty=geometry_info.sigma;
12501 if ((flags & SigmaValue) == 0)
12502 affine.ty=affine.tx;
12505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12512 if (LocaleCompare(attribute,"weight") == 0)
12514 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12515 draw_info->weight=(size_t) geometry_info.rho;
12518 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12525 if (LocaleCompare(attribute,"x") == 0)
12527 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12528 x=geometry_info.rho;
12531 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12538 if (LocaleCompare(attribute,"y") == 0)
12540 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12541 y=geometry_info.rho;
12544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12556 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12557 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12558 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12559 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12560 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12561 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12562 if (draw_info->geometry == (char *) NULL)
12564 draw_info->geometry=AcquireString((char *) NULL);
12565 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12566 "%.15g,%.15g",x,y);
12568 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12569 (void) CatchImageException(image);
12570 if (status == MagickFalse)
12574 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12575 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12576 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12577 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12578 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12579 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12580 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12581 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12582 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12583 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12584 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12585 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12586 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12588 draw_info=DestroyDrawInfo(draw_info);
12591 if (package_info != (struct PackageInfo *) NULL)
12592 DestroyPackageInfo(package_info);
12593 InheritPerlException(exception,perl_exception);
12594 exception=DestroyExceptionInfo(exception);
12595 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12599 ###############################################################################
12603 # 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 #
12607 ###############################################################################
12611 QueryMultilineFontMetrics(ref,...)
12612 Image::Magick ref=NO_INIT
12614 querymultilinefontmetrics = 1
12661 *reference; /* reference is the SV* of ref=SvIV(reference) */
12666 PERL_UNUSED_VAR(ref);
12667 PERL_UNUSED_VAR(ix);
12668 exception=AcquireExceptionInfo();
12669 package_info=(struct PackageInfo *) NULL;
12670 perl_exception=newSVpv("",0);
12671 reference=SvRV(ST(0));
12672 av=(AV *) reference;
12673 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12675 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12676 if (image == (Image *) NULL)
12678 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12680 goto PerlException;
12682 package_info=ClonePackageInfo(info,exception);
12683 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12684 CloneString(&draw_info->text,"");
12685 current=draw_info->affine;
12686 GetAffineMatrix(&affine);
12689 EXTEND(sp,7*items);
12690 for (i=2; i < items; i+=2)
12692 attribute=(char *) SvPV(ST(i-1),na);
12693 switch (*attribute)
12698 if (LocaleCompare(attribute,"antialias") == 0)
12700 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12704 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12708 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12711 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12718 if (LocaleCompare(attribute,"density") == 0)
12720 CloneString(&draw_info->density,SvPV(ST(i),na));
12723 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12730 if (LocaleCompare(attribute,"encoding") == 0)
12732 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12735 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12742 if (LocaleCompare(attribute,"family") == 0)
12744 CloneString(&draw_info->family,SvPV(ST(i),na));
12747 if (LocaleCompare(attribute,"fill") == 0)
12750 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12751 &draw_info->fill,exception);
12754 if (LocaleCompare(attribute,"font") == 0)
12756 CloneString(&draw_info->font,SvPV(ST(i),na));
12759 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12766 if (LocaleCompare(attribute,"geometry") == 0)
12768 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12771 if (LocaleCompare(attribute,"gravity") == 0)
12773 draw_info->gravity=(GravityType) ParseCommandOption(
12774 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12777 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12784 if (LocaleCompare(attribute,"pointsize") == 0)
12786 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12787 draw_info->pointsize=geometry_info.rho;
12790 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12797 if (LocaleCompare(attribute,"rotate") == 0)
12799 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12800 affine.rx=geometry_info.rho;
12801 affine.ry=geometry_info.sigma;
12802 if ((flags & SigmaValue) == 0)
12803 affine.ry=affine.rx;
12806 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12813 if (LocaleCompare(attribute,"scale") == 0)
12815 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12816 affine.sx=geometry_info.rho;
12817 affine.sy=geometry_info.sigma;
12818 if ((flags & SigmaValue) == 0)
12819 affine.sy=affine.sx;
12822 if (LocaleCompare(attribute,"skew") == 0)
12828 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12829 x_angle=geometry_info.rho;
12830 y_angle=geometry_info.sigma;
12831 if ((flags & SigmaValue) == 0)
12833 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12834 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12837 if (LocaleCompare(attribute,"stroke") == 0)
12840 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12841 &draw_info->stroke,exception);
12844 if (LocaleCompare(attribute,"style") == 0)
12846 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12850 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12854 draw_info->style=(StyleType) type;
12857 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12864 if (LocaleCompare(attribute,"text") == 0)
12866 CloneString(&draw_info->text,SvPV(ST(i),na));
12869 if (LocaleCompare(attribute,"translate") == 0)
12871 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12872 affine.tx=geometry_info.rho;
12873 affine.ty=geometry_info.sigma;
12874 if ((flags & SigmaValue) == 0)
12875 affine.ty=affine.tx;
12878 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12885 if (LocaleCompare(attribute,"weight") == 0)
12887 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12888 draw_info->weight=(size_t) geometry_info.rho;
12891 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12898 if (LocaleCompare(attribute,"x") == 0)
12900 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12901 x=geometry_info.rho;
12904 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12911 if (LocaleCompare(attribute,"y") == 0)
12913 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12914 y=geometry_info.rho;
12917 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12923 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12929 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12930 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12931 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12932 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12933 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12934 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12935 if (draw_info->geometry == (char *) NULL)
12937 draw_info->geometry=AcquireString((char *) NULL);
12938 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12939 "%.15g,%.15g",x,y);
12941 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12942 (void) CatchException(exception);
12943 if (status == MagickFalse)
12947 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12948 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12949 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12950 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12951 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12952 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12953 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12954 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12955 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12956 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12957 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12958 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12959 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12961 draw_info=DestroyDrawInfo(draw_info);
12964 if (package_info != (struct PackageInfo *) NULL)
12965 DestroyPackageInfo(package_info);
12966 InheritPerlException(exception,perl_exception);
12967 exception=DestroyExceptionInfo(exception);
12968 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12972 ###############################################################################
12976 # Q u e r y F o r m a t #
12980 ###############################################################################
12984 QueryFormat(ref,...)
12985 Image::Magick ref=NO_INIT
13002 volatile const MagickInfo
13005 PERL_UNUSED_VAR(ref);
13006 PERL_UNUSED_VAR(ix);
13007 exception=AcquireExceptionInfo();
13008 perl_exception=newSVpv("",0);
13012 format[MaxTextExtent];
13020 format_list=GetMagickInfoList("*",&types,exception);
13022 for (i=0; i < (ssize_t) types; i++)
13024 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13025 LocaleLower(format);
13026 PUSHs(sv_2mortal(newSVpv(format,0)));
13028 format_list=(const MagickInfo **)
13029 RelinquishMagickMemory((MagickInfo *) format_list);
13030 goto PerlException;
13032 EXTEND(sp,8*items);
13033 for (i=1; i < items; i++)
13035 name=(char *) SvPV(ST(i),na);
13036 magick_info=GetMagickInfo(name,exception);
13037 if (magick_info == (const MagickInfo *) NULL)
13042 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13043 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13044 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13045 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13046 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13047 if (magick_info->description == (char *) NULL)
13050 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13051 if (magick_info->module == (char *) NULL)
13054 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13058 InheritPerlException(exception,perl_exception);
13059 exception=DestroyExceptionInfo(exception);
13060 SvREFCNT_dec(perl_exception);
13064 ###############################################################################
13068 # Q u e r y O p t i o n #
13072 ###############################################################################
13076 QueryOption(ref,...)
13077 Image::Magick ref=NO_INIT
13098 PERL_UNUSED_VAR(ref);
13099 PERL_UNUSED_VAR(ix);
13100 exception=AcquireExceptionInfo();
13101 perl_exception=newSVpv("",0);
13102 EXTEND(sp,8*items);
13103 for (i=1; i < items; i++)
13105 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13107 options=GetCommandOptions((CommandOption) option);
13108 if (options == (char **) NULL)
13112 for (j=0; options[j] != (char *) NULL; j++)
13113 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13114 options=DestroyStringList(options);
13118 InheritPerlException(exception,perl_exception);
13119 exception=DestroyExceptionInfo(exception);
13120 SvREFCNT_dec(perl_exception);
13124 ###############################################################################
13132 ###############################################################################
13137 Image::Magick ref=NO_INIT
13184 *perl_exception, /* Perl variable for storing messages */
13189 PERL_UNUSED_VAR(ref);
13190 PERL_UNUSED_VAR(ix);
13191 exception=AcquireExceptionInfo();
13192 perl_exception=newSVpv("",0);
13194 package_info=(struct PackageInfo *) NULL;
13196 ac=(items < 2) ? 1 : items-1;
13197 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13199 length=(STRLEN *) NULL;
13200 if (list == (char **) NULL)
13202 ThrowPerlException(exception,ResourceLimitError,
13203 "MemoryAllocationFailed",PackageName);
13204 goto PerlException;
13206 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13207 if (length == (STRLEN *) NULL)
13209 ThrowPerlException(exception,ResourceLimitError,
13210 "MemoryAllocationFailed",PackageName);
13211 goto PerlException;
13213 if (sv_isobject(ST(0)) == 0)
13215 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13217 goto PerlException;
13219 reference=SvRV(ST(0));
13220 hv=SvSTASH(reference);
13221 if (SvTYPE(reference) != SVt_PVAV)
13223 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13225 goto PerlException;
13227 av=(AV *) reference;
13228 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13230 package_info=ClonePackageInfo(info,exception);
13233 *list=(char *) (*package_info->image_info->filename ?
13234 package_info->image_info->filename : "XC:black");
13236 for (n=0, i=0; i < ac; i++)
13238 list[n]=(char *) SvPV(ST(i+1),length[n]);
13239 if ((items >= 3) && strEQcase(list[n],"blob"))
13245 blob=(void *) (SvPV(ST(i+1),length[n]));
13246 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13248 if ((items >= 3) && strEQcase(list[n],"filename"))
13250 if ((items >= 3) && strEQcase(list[n],"file"))
13259 io_info=IoIFP(sv_2io(ST(i+1)));
13260 if (io_info == (PerlIO *) NULL)
13262 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13266 file=PerlIO_findFILE(io_info);
13267 if (file == (FILE *) NULL)
13269 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13273 SetImageInfoFile(package_info->image_info,file);
13275 if ((items >= 3) && strEQcase(list[n],"magick"))
13279 list[n]=(char *) NULL;
13281 status=ExpandFilenames(&n,&list);
13282 if (status == MagickFalse)
13284 ThrowPerlException(exception,ResourceLimitError,
13285 "MemoryAllocationFailed",PackageName);
13286 goto PerlException;
13289 for (i=0; i < n; i++)
13291 if ((package_info->image_info->file == (FILE *) NULL) &&
13292 (package_info->image_info->blob == (void *) NULL))
13293 image=ReadImages(package_info->image_info,list[i],exception);
13296 image=ReadImages(package_info->image_info,
13297 package_info->image_info->filename,exception);
13298 if (image != (Image *) NULL)
13299 DisassociateImageStream(image);
13301 if (image == (Image *) NULL)
13303 for ( ; image; image=image->next)
13305 AddImageToRegistry(sv,image);
13307 av_push(av,sv_bless(rv,hv));
13315 for (i=0; i < n; i++)
13316 if (list[i] != (char *) NULL)
13317 for (p=keep; list[i] != *p++; )
13318 if (*p == (char *) NULL)
13320 list[i]=(char *) RelinquishMagickMemory(list[i]);
13325 if (package_info != (struct PackageInfo *) NULL)
13326 DestroyPackageInfo(package_info);
13327 if (list && (list != keep))
13328 list=(char **) RelinquishMagickMemory(list);
13330 keep=(char **) RelinquishMagickMemory(keep);
13332 length=(STRLEN *) RelinquishMagickMemory(length);
13333 InheritPerlException(exception,perl_exception);
13334 exception=DestroyExceptionInfo(exception);
13335 sv_setiv(perl_exception,(IV) number_images);
13336 SvPOK_on(perl_exception);
13337 ST(0)=sv_2mortal(perl_exception);
13342 ###############################################################################
13350 ###############################################################################
13355 Image::Magick ref=NO_INIT
13378 PERL_UNUSED_VAR(ref);
13379 PERL_UNUSED_VAR(ix);
13380 exception=AcquireExceptionInfo();
13381 perl_exception=newSVpv("",0);
13382 reference=SvRV(ST(0));
13383 av=(AV *) reference;
13384 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13386 for (i=1; i < items; i++)
13387 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13388 SvPV(ST(i),na),exception);
13389 InheritPerlException(exception,perl_exception);
13390 exception=DestroyExceptionInfo(exception);
13391 SvREFCNT_dec(perl_exception); /* throw away all errors */
13395 ###############################################################################
13403 ###############################################################################
13408 Image::Magick ref=NO_INIT
13431 *reference; /* reference is the SV* of ref=SvIV(reference) */
13433 PERL_UNUSED_VAR(ref);
13434 PERL_UNUSED_VAR(ix);
13435 exception=AcquireExceptionInfo();
13436 perl_exception=newSVpv("",0);
13437 if (sv_isobject(ST(0)) == 0)
13439 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13441 goto PerlException;
13443 reference=SvRV(ST(0));
13444 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13446 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13448 for (i=2; i < items; i+=2)
13449 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13452 InheritPerlException(exception,perl_exception);
13453 exception=DestroyExceptionInfo(exception);
13454 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13455 SvPOK_on(perl_exception);
13456 ST(0)=sv_2mortal(perl_exception);
13461 ###############################################################################
13465 # S e t P i x e l #
13469 ###############################################################################
13474 Image::Magick ref=NO_INIT
13516 *reference; /* reference is the SV* of ref=SvIV(reference) */
13518 PERL_UNUSED_VAR(ref);
13519 PERL_UNUSED_VAR(ix);
13520 exception=AcquireExceptionInfo();
13521 perl_exception=newSVpv("",0);
13522 reference=SvRV(ST(0));
13523 av=(AV *) reference;
13524 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13526 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13527 if (image == (Image *) NULL)
13529 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13531 goto PerlException;
13534 normalize=MagickTrue;
13537 region.width=image->columns;
13540 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13541 channel=DefaultChannels;
13542 for (i=2; i < items; i+=2)
13544 attribute=(char *) SvPV(ST(i-1),na);
13545 switch (*attribute)
13550 if (LocaleCompare(attribute,"channel") == 0)
13555 option=ParseChannelOption(SvPV(ST(i),na));
13558 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13562 channel=(ChannelType) option;
13565 if (LocaleCompare(attribute,"color") == 0)
13567 if (SvTYPE(ST(i)) != SVt_RV)
13570 message[MaxTextExtent];
13572 (void) FormatLocaleString(message,MaxTextExtent,
13573 "invalid %.60s value",attribute);
13574 ThrowPerlException(exception,OptionError,message,
13577 av=(AV *) SvRV(ST(i));
13580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13587 if (LocaleCompare(attribute,"geometry") == 0)
13589 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13592 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13599 if (LocaleCompare(attribute,"normalize") == 0)
13601 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13605 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13609 normalize=option != 0 ? MagickTrue : MagickFalse;
13612 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13619 if (LocaleCompare(attribute,"x") == 0)
13621 region.x=SvIV(ST(i));
13624 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13631 if (LocaleCompare(attribute,"y") == 0)
13633 region.y=SvIV(ST(i));
13636 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13642 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13648 (void) SetImageStorageClass(image,DirectClass,exception);
13649 channel_mask=SetImageChannelMask(image,channel);
13650 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13651 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13652 (SvTYPE(av) != SVt_PVAV))
13664 if (normalize != MagickFalse)
13665 scale=QuantumRange;
13666 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13669 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13670 av_fetch(av,i,0)))),q);
13673 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13676 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13677 av_fetch(av,i,0)))),q);
13680 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13683 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13684 av_fetch(av,i,0)))),q);
13687 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13688 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13690 SetPixelBlack(image,ClampToQuantum(scale*
13691 SvNV(*(av_fetch(av,i,0)))),q);
13694 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13697 SetPixelAlpha(image,ClampToQuantum(scale*
13698 SvNV(*(av_fetch(av,i,0)))),q);
13701 (void) SyncAuthenticPixels(image,exception);
13703 (void) SetImageChannelMask(image,channel_mask);
13706 InheritPerlException(exception,perl_exception);
13707 exception=DestroyExceptionInfo(exception);
13708 SvREFCNT_dec(perl_exception);
13712 ###############################################################################
13720 ###############################################################################
13725 Image::Magick ref=NO_INIT
13764 PERL_UNUSED_VAR(ref);
13765 PERL_UNUSED_VAR(ix);
13766 exception=AcquireExceptionInfo();
13767 perl_exception=newSVpv("",0);
13771 if (sv_isobject(ST(0)) == 0)
13773 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13775 goto PerlException;
13777 reference=SvRV(ST(0));
13778 hv=SvSTASH(reference);
13780 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13782 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13783 if (image == (Image *) NULL)
13785 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13787 goto PerlException;
13789 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13795 for (i=2; i < items; i+=2)
13797 attribute=(char *) SvPV(ST(i-1),na);
13798 switch (*attribute)
13803 if (LocaleCompare(attribute,"offset") == 0)
13805 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13808 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13815 if (LocaleCompare(attribute,"stack") == 0)
13817 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13821 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13827 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13833 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13839 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13841 if (image == (Image *) NULL)
13842 goto PerlException;
13843 for ( ; image; image=image->next)
13845 AddImageToRegistry(sv,image);
13847 av_push(av,sv_bless(rv,hv));
13850 exception=DestroyExceptionInfo(exception);
13851 ST(0)=av_reference;
13852 SvREFCNT_dec(perl_exception);
13856 InheritPerlException(exception,perl_exception);
13857 exception=DestroyExceptionInfo(exception);
13858 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13859 SvPOK_on(perl_exception);
13860 ST(0)=sv_2mortal(perl_exception);
13865 ###############################################################################
13869 # S t a t i s t i c s #
13873 ###############################################################################
13877 Statistics(ref,...)
13878 Image::Magick ref=NO_INIT
13880 StatisticsImage = 1
13882 statisticsimage = 3
13885 #define ChannelStatistics(channel) \
13887 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13888 (double) channel_statistics[channel].depth); \
13889 PUSHs(sv_2mortal(newSVpv(message,0))); \
13890 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13891 channel_statistics[channel].minima/scale); \
13892 PUSHs(sv_2mortal(newSVpv(message,0))); \
13893 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13894 channel_statistics[channel].maxima/scale); \
13895 PUSHs(sv_2mortal(newSVpv(message,0))); \
13896 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13897 channel_statistics[channel].mean/scale); \
13898 PUSHs(sv_2mortal(newSVpv(message,0))); \
13899 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13900 channel_statistics[channel].standard_deviation/scale); \
13901 PUSHs(sv_2mortal(newSVpv(message,0))); \
13902 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13903 channel_statistics[channel].kurtosis); \
13904 PUSHs(sv_2mortal(newSVpv(message,0))); \
13905 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13906 channel_statistics[channel].skewness); \
13907 PUSHs(sv_2mortal(newSVpv(message,0))); \
13914 message[MaxTextExtent];
13917 *channel_statistics;
13938 PERL_UNUSED_VAR(ref);
13939 PERL_UNUSED_VAR(ix);
13940 exception=AcquireExceptionInfo();
13941 perl_exception=newSVpv("",0);
13943 if (sv_isobject(ST(0)) == 0)
13945 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13947 goto PerlException;
13949 reference=SvRV(ST(0));
13952 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13953 if (image == (Image *) NULL)
13955 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13957 goto PerlException;
13959 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13961 for ( ; image; image=image->next)
13963 channel_statistics=GetImageStatistics(image,exception);
13964 if (channel_statistics == (ChannelStatistics *) NULL)
13967 EXTEND(sp,35*count);
13968 scale=(double) QuantumRange;
13969 ChannelStatistics(RedChannel);
13970 ChannelStatistics(GreenChannel);
13971 ChannelStatistics(BlueChannel);
13972 if (image->colorspace == CMYKColorspace)
13973 ChannelStatistics(BlackChannel);
13974 if (image->alpha_trait == BlendPixelTrait)
13975 ChannelStatistics(AlphaChannel);
13976 channel_statistics=(ChannelStatistics *)
13977 RelinquishMagickMemory(channel_statistics);
13981 InheritPerlException(exception,perl_exception);
13982 exception=DestroyExceptionInfo(exception);
13983 SvREFCNT_dec(perl_exception);
13987 ###############################################################################
13991 # S y n c A u t h e n t i c P i x e l s #
13995 ###############################################################################
13999 SyncAuthenticPixels(ref,...)
14000 Image::Magick ref = NO_INIT
14002 Syncauthenticpixels = 1
14003 SyncImagePixels = 2
14004 syncimagepixels = 3
14023 PERL_UNUSED_VAR(ref);
14024 PERL_UNUSED_VAR(ix);
14025 exception=AcquireExceptionInfo();
14026 perl_exception=newSVpv("",0);
14027 if (sv_isobject(ST(0)) == 0)
14029 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14031 goto PerlException;
14034 reference=SvRV(ST(0));
14035 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14036 if (image == (Image *) NULL)
14038 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14040 goto PerlException;
14043 status=SyncAuthenticPixels(image,exception);
14044 if (status != MagickFalse)
14048 InheritPerlException(exception,perl_exception);
14049 exception=DestroyExceptionInfo(exception);
14050 SvREFCNT_dec(perl_exception); /* throw away all errors */
14054 ###############################################################################
14058 # T r a n s f o r m #
14062 ###############################################################################
14067 Image::Magick ref=NO_INIT
14105 PERL_UNUSED_VAR(ref);
14106 PERL_UNUSED_VAR(ix);
14107 exception=AcquireExceptionInfo();
14108 perl_exception=newSVpv("",0);
14112 if (sv_isobject(ST(0)) == 0)
14114 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14116 goto PerlException;
14118 reference=SvRV(ST(0));
14119 hv=SvSTASH(reference);
14121 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14123 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14124 if (image == (Image *) NULL)
14126 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14128 goto PerlException;
14130 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14134 crop_geometry=(char *) NULL;
14135 geometry=(char *) NULL;
14136 for (i=2; i < items; i+=2)
14138 attribute=(char *) SvPV(ST(i-1),na);
14139 switch (*attribute)
14144 if (LocaleCompare(attribute,"crop") == 0)
14146 crop_geometry=SvPV(ST(i),na);
14149 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14156 if (LocaleCompare(attribute,"geometry") == 0)
14158 geometry=SvPV(ST(i),na);
14161 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14173 for ( ; image; image=image->next)
14175 clone=CloneImage(image,0,0,MagickTrue,exception);
14176 if (clone == (Image *) NULL)
14177 goto PerlException;
14178 TransformImage(&clone,crop_geometry,geometry,exception);
14179 for ( ; clone; clone=clone->next)
14181 AddImageToRegistry(sv,clone);
14183 av_push(av,sv_bless(rv,hv));
14187 exception=DestroyExceptionInfo(exception);
14188 ST(0)=av_reference;
14189 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14193 InheritPerlException(exception,perl_exception);
14194 exception=DestroyExceptionInfo(exception);
14195 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14196 SvPOK_on(perl_exception);
14197 ST(0)=sv_2mortal(perl_exception);
14202 ###############################################################################
14210 ###############################################################################
14215 Image::Magick ref=NO_INIT
14223 filename[MaxTextExtent];
14247 PERL_UNUSED_VAR(ref);
14248 PERL_UNUSED_VAR(ix);
14249 exception=AcquireExceptionInfo();
14250 perl_exception=newSVpv("",0);
14252 package_info=(struct PackageInfo *) NULL;
14253 if (sv_isobject(ST(0)) == 0)
14255 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14257 goto PerlException;
14259 reference=SvRV(ST(0));
14260 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14261 if (image == (Image *) NULL)
14263 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14265 goto PerlException;
14267 package_info=ClonePackageInfo(info,exception);
14269 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14272 for (i=2; i < items; i+=2)
14273 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14275 (void) CopyMagickString(filename,package_info->image_info->filename,
14278 for (next=image; next; next=next->next)
14280 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14281 next->scene=scene++;
14283 SetImageInfo(package_info->image_info,(unsigned int)
14284 GetImageListLength(image),exception);
14285 for (next=image; next; next=next->next)
14287 (void) WriteImage(package_info->image_info,next,exception);
14289 if (package_info->image_info->adjoin)
14294 if (package_info != (struct PackageInfo *) NULL)
14295 DestroyPackageInfo(package_info);
14296 InheritPerlException(exception,perl_exception);
14297 exception=DestroyExceptionInfo(exception);
14298 sv_setiv(perl_exception,(IV) number_images);
14299 SvPOK_on(perl_exception);
14300 ST(0)=sv_2mortal(perl_exception);