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::@MAGICK_ABI_NAME@"
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__@MAGICK_ABI_SUFFIX@; /* data type for the Image::Magick::@MAGICK_ABI_NAME@ 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 {"gain", 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::@MAGICK_ABI_SUFFIX@ PACKAGE = Image::Magick::@MAGICK_ABI_SUFFIX@
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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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::@MAGICK_ABI_SUFFIX@ 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,exception);
7794 case 11: /* Emboss */
7796 if (attribute_flag[0] != 0)
7798 flags=ParseGeometry(argument_list[0].string_reference,
7800 if ((flags & SigmaValue) == 0)
7801 geometry_info.sigma=1.0;
7803 if (attribute_flag[1] != 0)
7804 geometry_info.rho=argument_list[1].real_reference;
7805 if (attribute_flag[2] != 0)
7806 geometry_info.sigma=argument_list[2].real_reference;
7807 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7811 case 12: /* Enhance */
7813 image=EnhanceImage(image,exception);
7818 image=FlipImage(image,exception);
7823 image=FlopImage(image,exception);
7826 case 15: /* Frame */
7834 if (attribute_flag[0] != 0)
7836 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7837 &geometry,exception);
7838 frame_info.width=geometry.width;
7839 frame_info.height=geometry.height;
7840 frame_info.outer_bevel=geometry.x;
7841 frame_info.inner_bevel=geometry.y;
7843 if (attribute_flag[1] != 0)
7844 frame_info.width=argument_list[1].integer_reference;
7845 if (attribute_flag[2] != 0)
7846 frame_info.height=argument_list[2].integer_reference;
7847 if (attribute_flag[3] != 0)
7848 frame_info.inner_bevel=argument_list[3].integer_reference;
7849 if (attribute_flag[4] != 0)
7850 frame_info.outer_bevel=argument_list[4].integer_reference;
7851 if (attribute_flag[5] != 0)
7852 QueryColorCompliance(argument_list[5].string_reference,
7853 AllCompliance,&fill_color,exception);
7854 if (attribute_flag[6] != 0)
7855 QueryColorCompliance(argument_list[6].string_reference,
7856 AllCompliance,&fill_color,exception);
7857 frame_info.x=(ssize_t) frame_info.width;
7858 frame_info.y=(ssize_t) frame_info.height;
7859 frame_info.width=image->columns+2*frame_info.x;
7860 frame_info.height=image->rows+2*frame_info.y;
7861 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7862 image->matte_color=fill_color;
7863 compose=image->compose;
7864 if (attribute_flag[7] != 0)
7865 compose=(CompositeOperator) argument_list[7].integer_reference;
7866 image=FrameImage(image,&frame_info,compose,exception);
7869 case 16: /* Implode */
7871 PixelInterpolateMethod
7874 if (attribute_flag[0] == 0)
7875 argument_list[0].real_reference=0.5;
7876 method=UndefinedInterpolatePixel;
7877 if (attribute_flag[1] != 0)
7878 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7879 image=ImplodeImage(image,argument_list[0].real_reference,
7883 case 17: /* Magnify */
7885 image=MagnifyImage(image,exception);
7888 case 18: /* MedianFilter */
7890 if (attribute_flag[0] != 0)
7892 flags=ParseGeometry(argument_list[0].string_reference,
7894 if ((flags & SigmaValue) == 0)
7895 geometry_info.sigma=geometry_info.rho;
7897 if (attribute_flag[1] != 0)
7898 geometry_info.rho=argument_list[1].real_reference;
7899 if (attribute_flag[2] != 0)
7900 geometry_info.sigma=argument_list[2].real_reference;
7901 if (attribute_flag[3] != 0)
7902 channel=(ChannelType) argument_list[3].integer_reference;
7903 channel_mask=SetImageChannelMask(image,channel);
7904 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7905 (size_t) geometry_info.sigma,exception);
7906 if (image != (Image *) NULL)
7907 (void) SetImageChannelMask(image,channel_mask);
7910 case 19: /* Minify */
7912 image=MinifyImage(image,exception);
7915 case 20: /* OilPaint */
7917 if (attribute_flag[0] == 0)
7918 argument_list[0].real_reference=0.0;
7919 if (attribute_flag[1] == 0)
7920 argument_list[1].real_reference=1.0;
7921 image=OilPaintImage(image,argument_list[0].real_reference,
7922 argument_list[1].real_reference,exception);
7925 case 21: /* ReduceNoise */
7927 if (attribute_flag[0] != 0)
7929 flags=ParseGeometry(argument_list[0].string_reference,
7931 if ((flags & SigmaValue) == 0)
7932 geometry_info.sigma=1.0;
7934 if (attribute_flag[1] != 0)
7935 geometry_info.rho=argument_list[1].real_reference;
7936 if (attribute_flag[2] != 0)
7937 geometry_info.sigma=argument_list[2].real_reference;
7938 if (attribute_flag[3] != 0)
7939 channel=(ChannelType) argument_list[3].integer_reference;
7940 channel_mask=SetImageChannelMask(image,channel);
7941 image=StatisticImage(image,NonpeakStatistic,(size_t)
7942 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7943 if (image != (Image *) NULL)
7944 (void) SetImageChannelMask(image,channel_mask);
7949 if (attribute_flag[0] != 0)
7950 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7951 &geometry,exception);
7952 if (attribute_flag[1] != 0)
7953 geometry.x=argument_list[1].integer_reference;
7954 if (attribute_flag[2] != 0)
7955 geometry.y=argument_list[2].integer_reference;
7956 image=RollImage(image,geometry.x,geometry.y,exception);
7959 case 23: /* Rotate */
7961 if (attribute_flag[0] == 0)
7962 argument_list[0].real_reference=90.0;
7963 if (attribute_flag[1] != 0)
7965 QueryColorCompliance(argument_list[1].string_reference,
7966 AllCompliance,&image->background_color,exception);
7967 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
7968 (image->alpha_trait != BlendPixelTrait))
7969 (void) SetImageAlpha(image,OpaqueAlpha,exception);
7971 image=RotateImage(image,argument_list[0].real_reference,exception);
7974 case 24: /* Sample */
7976 if (attribute_flag[0] != 0)
7977 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7978 &geometry,exception);
7979 if (attribute_flag[1] != 0)
7980 geometry.width=argument_list[1].integer_reference;
7981 if (attribute_flag[2] != 0)
7982 geometry.height=argument_list[2].integer_reference;
7983 image=SampleImage(image,geometry.width,geometry.height,exception);
7986 case 25: /* Scale */
7988 if (attribute_flag[0] != 0)
7989 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7990 &geometry,exception);
7991 if (attribute_flag[1] != 0)
7992 geometry.width=argument_list[1].integer_reference;
7993 if (attribute_flag[2] != 0)
7994 geometry.height=argument_list[2].integer_reference;
7995 image=ScaleImage(image,geometry.width,geometry.height,exception);
7998 case 26: /* Shade */
8000 if (attribute_flag[0] != 0)
8002 flags=ParseGeometry(argument_list[0].string_reference,
8004 if ((flags & SigmaValue) == 0)
8005 geometry_info.sigma=0.0;
8007 if (attribute_flag[1] != 0)
8008 geometry_info.rho=argument_list[1].real_reference;
8009 if (attribute_flag[2] != 0)
8010 geometry_info.sigma=argument_list[2].real_reference;
8011 image=ShadeImage(image,
8012 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8013 geometry_info.rho,geometry_info.sigma,exception);
8016 case 27: /* Sharpen */
8018 if (attribute_flag[0] != 0)
8020 flags=ParseGeometry(argument_list[0].string_reference,
8022 if ((flags & SigmaValue) == 0)
8023 geometry_info.sigma=1.0;
8025 if (attribute_flag[1] != 0)
8026 geometry_info.rho=argument_list[1].real_reference;
8027 if (attribute_flag[2] != 0)
8028 geometry_info.sigma=argument_list[2].real_reference;
8029 if (attribute_flag[3] != 0)
8030 channel=(ChannelType) argument_list[3].integer_reference;
8031 channel_mask=SetImageChannelMask(image,channel);
8032 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8034 if (image != (Image *) NULL)
8035 (void) SetImageChannelMask(image,channel_mask);
8038 case 28: /* Shear */
8040 if (attribute_flag[0] != 0)
8042 flags=ParseGeometry(argument_list[0].string_reference,
8044 if ((flags & SigmaValue) == 0)
8045 geometry_info.sigma=geometry_info.rho;
8047 if (attribute_flag[1] != 0)
8048 geometry_info.rho=argument_list[1].real_reference;
8049 if (attribute_flag[2] != 0)
8050 geometry_info.sigma=argument_list[2].real_reference;
8051 if (attribute_flag[3] != 0)
8052 QueryColorCompliance(argument_list[3].string_reference,
8053 AllCompliance,&image->background_color,exception);
8054 if (attribute_flag[4] != 0)
8055 QueryColorCompliance(argument_list[4].string_reference,
8056 AllCompliance,&image->background_color,exception);
8057 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8061 case 29: /* Spread */
8063 PixelInterpolateMethod
8066 if (attribute_flag[0] == 0)
8067 argument_list[0].real_reference=1.0;
8068 method=UndefinedInterpolatePixel;
8069 if (attribute_flag[1] != 0)
8070 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8071 image=SpreadImage(image,argument_list[0].real_reference,method,
8075 case 30: /* Swirl */
8077 PixelInterpolateMethod
8080 if (attribute_flag[0] == 0)
8081 argument_list[0].real_reference=50.0;
8082 method=UndefinedInterpolatePixel;
8083 if (attribute_flag[1] != 0)
8084 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8085 image=SwirlImage(image,argument_list[0].real_reference,
8089 case 31: /* Resize */
8092 if (attribute_flag[0] != 0)
8093 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8094 &geometry,exception);
8095 if (attribute_flag[1] != 0)
8096 geometry.width=argument_list[1].integer_reference;
8097 if (attribute_flag[2] != 0)
8098 geometry.height=argument_list[2].integer_reference;
8099 if (attribute_flag[3] == 0)
8100 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8101 if (attribute_flag[4] != 0)
8102 SetImageArtifact(image,"filter:support",
8103 argument_list[4].string_reference);
8104 image=ResizeImage(image,geometry.width,geometry.height,
8105 (FilterTypes) argument_list[3].integer_reference,
8109 case 33: /* Annotate */
8114 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8116 if (attribute_flag[0] != 0)
8121 text=InterpretImageProperties(info ? info->image_info :
8122 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8124 (void) CloneString(&draw_info->text,text);
8125 text=DestroyString(text);
8127 if (attribute_flag[1] != 0)
8128 (void) CloneString(&draw_info->font,
8129 argument_list[1].string_reference);
8130 if (attribute_flag[2] != 0)
8131 draw_info->pointsize=argument_list[2].real_reference;
8132 if (attribute_flag[3] != 0)
8133 (void) CloneString(&draw_info->density,
8134 argument_list[3].string_reference);
8135 if (attribute_flag[4] != 0)
8136 (void) QueryColorCompliance(argument_list[4].string_reference,
8137 AllCompliance,&draw_info->undercolor,exception);
8138 if (attribute_flag[5] != 0)
8140 (void) QueryColorCompliance(argument_list[5].string_reference,
8141 AllCompliance,&draw_info->stroke,exception);
8142 if (argument_list[5].image_reference != (Image *) NULL)
8143 draw_info->stroke_pattern=CloneImage(
8144 argument_list[5].image_reference,0,0,MagickTrue,exception);
8146 if (attribute_flag[6] != 0)
8148 (void) QueryColorCompliance(argument_list[6].string_reference,
8149 AllCompliance,&draw_info->fill,exception);
8150 if (argument_list[6].image_reference != (Image *) NULL)
8151 draw_info->fill_pattern=CloneImage(
8152 argument_list[6].image_reference,0,0,MagickTrue,exception);
8154 if (attribute_flag[7] != 0)
8156 (void) CloneString(&draw_info->geometry,
8157 argument_list[7].string_reference);
8158 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8159 &geometry,exception);
8160 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8161 geometry_info.sigma=geometry_info.xi;
8163 if (attribute_flag[8] != 0)
8164 (void) QueryColorCompliance(argument_list[8].string_reference,
8165 AllCompliance,&draw_info->fill,exception);
8166 if (attribute_flag[11] != 0)
8167 draw_info->gravity=(GravityType)
8168 argument_list[11].integer_reference;
8169 if (attribute_flag[25] != 0)
8174 av=(AV *) argument_list[25].array_reference;
8175 if ((av_len(av) != 3) && (av_len(av) != 5))
8177 ThrowPerlException(exception,OptionError,
8178 "affine matrix must have 4 or 6 elements",PackageName);
8181 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8182 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8183 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8184 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8185 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8186 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8188 ThrowPerlException(exception,OptionError,
8189 "affine matrix is singular",PackageName);
8192 if (av_len(av) == 5)
8194 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8195 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8198 for (j=12; j < 17; j++)
8200 if (attribute_flag[j] == 0)
8202 value=argument_list[j].string_reference;
8203 angle=argument_list[j].real_reference;
8204 current=draw_info->affine;
8205 GetAffineMatrix(&affine);
8213 flags=ParseGeometry(value,&geometry_info);
8214 affine.tx=geometry_info.xi;
8215 affine.ty=geometry_info.psi;
8216 if ((flags & PsiValue) == 0)
8217 affine.ty=affine.tx;
8225 flags=ParseGeometry(value,&geometry_info);
8226 affine.sx=geometry_info.rho;
8227 affine.sy=geometry_info.sigma;
8228 if ((flags & SigmaValue) == 0)
8229 affine.sy=affine.sx;
8239 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8240 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8241 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8242 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8250 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8258 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8262 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8263 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8264 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8265 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8266 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8268 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8271 if (attribute_flag[9] == 0)
8272 argument_list[9].real_reference=0.0;
8273 if (attribute_flag[10] == 0)
8274 argument_list[10].real_reference=0.0;
8275 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8278 geometry[MaxTextExtent];
8280 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8281 (double) argument_list[9].real_reference+draw_info->affine.tx,
8282 (double) argument_list[10].real_reference+draw_info->affine.ty);
8283 (void) CloneString(&draw_info->geometry,geometry);
8285 if (attribute_flag[17] != 0)
8286 draw_info->stroke_width=argument_list[17].real_reference;
8287 if (attribute_flag[18] != 0)
8289 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8290 MagickTrue : MagickFalse;
8291 draw_info->stroke_antialias=draw_info->text_antialias;
8293 if (attribute_flag[19] != 0)
8294 (void) CloneString(&draw_info->family,
8295 argument_list[19].string_reference);
8296 if (attribute_flag[20] != 0)
8297 draw_info->style=(StyleType) argument_list[20].integer_reference;
8298 if (attribute_flag[21] != 0)
8299 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8300 if (attribute_flag[22] != 0)
8301 draw_info->weight=argument_list[22].integer_reference;
8302 if (attribute_flag[23] != 0)
8303 draw_info->align=(AlignType) argument_list[23].integer_reference;
8304 if (attribute_flag[24] != 0)
8305 (void) CloneString(&draw_info->encoding,
8306 argument_list[24].string_reference);
8307 if (attribute_flag[25] != 0)
8308 draw_info->fill_pattern=CloneImage(
8309 argument_list[25].image_reference,0,0,MagickTrue,exception);
8310 if (attribute_flag[26] != 0)
8311 draw_info->fill_pattern=CloneImage(
8312 argument_list[26].image_reference,0,0,MagickTrue,exception);
8313 if (attribute_flag[27] != 0)
8314 draw_info->stroke_pattern=CloneImage(
8315 argument_list[27].image_reference,0,0,MagickTrue,exception);
8316 if (attribute_flag[29] != 0)
8317 draw_info->kerning=argument_list[29].real_reference;
8318 if (attribute_flag[30] != 0)
8319 draw_info->interline_spacing=argument_list[30].real_reference;
8320 if (attribute_flag[31] != 0)
8321 draw_info->interword_spacing=argument_list[31].real_reference;
8322 if (attribute_flag[32] != 0)
8323 draw_info->direction=(DirectionType)
8324 argument_list[32].integer_reference;
8325 (void) AnnotateImage(image,draw_info,exception);
8326 draw_info=DestroyDrawInfo(draw_info);
8329 case 34: /* ColorFloodfill */
8340 draw_info=CloneDrawInfo(info ? info->image_info :
8341 (ImageInfo *) NULL,(DrawInfo *) NULL);
8342 if (attribute_flag[0] != 0)
8343 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8344 &geometry,exception);
8345 if (attribute_flag[1] != 0)
8346 geometry.x=argument_list[1].integer_reference;
8347 if (attribute_flag[2] != 0)
8348 geometry.y=argument_list[2].integer_reference;
8349 if (attribute_flag[3] != 0)
8350 (void) QueryColorCompliance(argument_list[3].string_reference,
8351 AllCompliance,&draw_info->fill,exception);
8352 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8353 geometry.x,geometry.y,&target,exception);
8355 if (attribute_flag[4] != 0)
8357 QueryColorCompliance(argument_list[4].string_reference,
8358 AllCompliance,&target,exception);
8361 if (attribute_flag[5] != 0)
8362 image->fuzz=StringToDoubleInterval(
8363 argument_list[5].string_reference,(double) QuantumRange+1.0);
8364 if (attribute_flag[6] != 0)
8365 invert=(MagickBooleanType) argument_list[6].integer_reference;
8366 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8367 geometry.y,invert,exception);
8368 draw_info=DestroyDrawInfo(draw_info);
8371 case 35: /* Composite */
8374 composite_geometry[MaxTextExtent];
8383 compose=OverCompositeOp;
8384 if (attribute_flag[0] != 0)
8385 composite_image=argument_list[0].image_reference;
8388 ThrowPerlException(exception,OptionError,
8389 "CompositeImageRequired",PackageName);
8393 Parameter Handling used for BOTH normal and tiled composition.
8395 if (attribute_flag[1] != 0) /* compose */
8396 compose=(CompositeOperator) argument_list[1].integer_reference;
8397 if (attribute_flag[6] != 0) /* opacity */
8399 if (compose != DissolveCompositeOp)
8400 (void) SetImageAlpha(composite_image,(Quantum)
8401 StringToDoubleInterval(argument_list[6].string_reference,
8402 (double) QuantumRange+1.0),exception);
8424 Handle dissolve composite operator (patch by
8427 (void) CloneString(&image->geometry,
8428 argument_list[6].string_reference);
8429 opacity=(Quantum) StringToDoubleInterval(
8430 argument_list[6].string_reference,(double) QuantumRange+
8432 if (composite_image->alpha_trait == BlendPixelTrait)
8433 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8434 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8435 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8437 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8438 composite_image->columns,1,exception);
8439 for (x=0; x < (ssize_t) composite_image->columns; x++)
8441 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8442 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8444 q+=GetPixelChannels(composite_image);
8446 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8447 if (sync == MagickFalse)
8450 composite_view=DestroyCacheView(composite_view);
8453 if (attribute_flag[9] != 0) /* "color=>" */
8454 QueryColorCompliance(argument_list[9].string_reference,
8455 AllCompliance,&composite_image->background_color,exception);
8456 if (attribute_flag[12] != 0) /* "interpolate=>" */
8457 image->interpolate=(PixelInterpolateMethod)
8458 argument_list[12].integer_reference;
8459 if (attribute_flag[13] != 0) /* "args=>" */
8460 (void) SetImageArtifact(composite_image,"compose:args",
8461 argument_list[13].string_reference);
8462 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8463 (void) SetImageArtifact(composite_image,"compose:args",
8464 argument_list[14].string_reference);
8465 clip_to_self=MagickTrue;
8466 if (attribute_flag[15] != 0)
8467 clip_to_self=(MagickBooleanType)
8468 argument_list[15].integer_reference;
8470 Tiling Composition (with orthogonal rotate).
8472 rotate_image=(Image *) NULL;
8473 if (attribute_flag[8] != 0) /* "rotate=>" */
8478 rotate_image=RotateImage(composite_image,
8479 argument_list[8].real_reference,exception);
8480 if (rotate_image == (Image *) NULL)
8483 if ((attribute_flag[7] != 0) &&
8484 (argument_list[7].integer_reference != 0)) /* tile */
8491 Tile the composite image.
8493 if (attribute_flag[8] != 0) /* "tile=>" */
8494 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8497 (void) SetImageArtifact(composite_image,
8498 "compose:outside-overlay","false");
8499 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8500 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8502 if (attribute_flag[8] != 0) /* rotate */
8503 (void) CompositeImage(image,rotate_image,compose,
8504 MagickTrue,x,y,exception);
8506 (void) CompositeImage(image,composite_image,compose,
8507 MagickTrue,x,y,exception);
8509 if (attribute_flag[8] != 0) /* rotate */
8510 rotate_image=DestroyImage(rotate_image);
8514 Parameter Handling used used ONLY for normal composition.
8516 if (attribute_flag[5] != 0) /* gravity */
8517 image->gravity=(GravityType) argument_list[5].integer_reference;
8518 if (attribute_flag[2] != 0) /* geometry offset */
8520 SetGeometry(image,&geometry);
8521 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8523 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8526 if (attribute_flag[3] != 0) /* x offset */
8527 geometry.x=argument_list[3].integer_reference;
8528 if (attribute_flag[4] != 0) /* y offset */
8529 geometry.y=argument_list[4].integer_reference;
8530 if (attribute_flag[10] != 0) /* mask */
8532 if ((image->compose == DisplaceCompositeOp) ||
8533 (image->compose == DistortCompositeOp))
8536 Merge Y displacement into X displacement image.
8538 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8540 (void) CompositeImage(composite_image,
8541 argument_list[10].image_reference,CopyGreenCompositeOp,
8542 MagickTrue,0,0,exception);
8550 Set a blending mask for the composition.
8552 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8553 MagickTrue,exception);
8554 (void) NegateImage(mask_image,MagickFalse,exception);
8555 (void) SetImageMask(composite_image,mask_image,exception);
8556 mask_image=DestroyImage(mask_image);
8559 if (attribute_flag[11] != 0) /* channel */
8560 channel=(ChannelType) argument_list[11].integer_reference;
8562 Composite two images (normal composition).
8564 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8565 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8566 (double) composite_image->rows,(double) geometry.x,(double)
8568 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8570 channel_mask=SetImageChannelMask(image,channel);
8571 if (attribute_flag[8] == 0) /* no rotate */
8572 CompositeImage(image,composite_image,compose,clip_to_self,
8573 geometry.x,geometry.y,exception);
8577 Position adjust rotated image then composite.
8579 geometry.x-=(ssize_t) (rotate_image->columns-
8580 composite_image->columns)/2;
8581 geometry.y-=(ssize_t) (rotate_image->rows-
8582 composite_image->rows)/2;
8583 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8584 geometry.y,exception);
8585 rotate_image=DestroyImage(rotate_image);
8587 if (attribute_flag[10] != 0) /* mask */
8589 if ((image->compose == DisplaceCompositeOp) ||
8590 (image->compose == DistortCompositeOp))
8591 composite_image=DestroyImage(composite_image);
8593 (void) SetImageMask(image,(Image *) NULL,exception);
8595 (void) SetImageChannelMask(image,channel_mask);
8598 case 36: /* Contrast */
8600 if (attribute_flag[0] == 0)
8601 argument_list[0].integer_reference=0;
8602 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8603 MagickTrue : MagickFalse,exception);
8606 case 37: /* CycleColormap */
8608 if (attribute_flag[0] == 0)
8609 argument_list[0].integer_reference=6;
8610 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8619 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8621 (void) CloneString(&draw_info->primitive,"point");
8622 if (attribute_flag[0] != 0)
8624 if (argument_list[0].integer_reference < 0)
8625 (void) CloneString(&draw_info->primitive,
8626 argument_list[0].string_reference);
8628 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8629 MagickPrimitiveOptions,argument_list[0].integer_reference));
8631 if (attribute_flag[1] != 0)
8633 if (LocaleCompare(draw_info->primitive,"path") == 0)
8635 (void) ConcatenateString(&draw_info->primitive," '");
8636 ConcatenateString(&draw_info->primitive,
8637 argument_list[1].string_reference);
8638 (void) ConcatenateString(&draw_info->primitive,"'");
8642 (void) ConcatenateString(&draw_info->primitive," ");
8643 ConcatenateString(&draw_info->primitive,
8644 argument_list[1].string_reference);
8647 if (attribute_flag[2] != 0)
8649 (void) ConcatenateString(&draw_info->primitive," ");
8650 (void) ConcatenateString(&draw_info->primitive,
8651 CommandOptionToMnemonic(MagickMethodOptions,
8652 argument_list[2].integer_reference));
8654 if (attribute_flag[3] != 0)
8656 (void) QueryColorCompliance(argument_list[3].string_reference,
8657 AllCompliance,&draw_info->stroke,exception);
8658 if (argument_list[3].image_reference != (Image *) NULL)
8659 draw_info->stroke_pattern=CloneImage(
8660 argument_list[3].image_reference,0,0,MagickTrue,exception);
8662 if (attribute_flag[4] != 0)
8664 (void) QueryColorCompliance(argument_list[4].string_reference,
8665 AllCompliance,&draw_info->fill,exception);
8666 if (argument_list[4].image_reference != (Image *) NULL)
8667 draw_info->fill_pattern=CloneImage(
8668 argument_list[4].image_reference,0,0,MagickTrue,exception);
8670 if (attribute_flag[5] != 0)
8671 draw_info->stroke_width=argument_list[5].real_reference;
8672 if (attribute_flag[6] != 0)
8673 (void) CloneString(&draw_info->font,
8674 argument_list[6].string_reference);
8675 if (attribute_flag[7] != 0)
8676 (void) QueryColorCompliance(argument_list[7].string_reference,
8677 AllCompliance,&draw_info->border_color,exception);
8678 if (attribute_flag[8] != 0)
8679 draw_info->affine.tx=argument_list[8].real_reference;
8680 if (attribute_flag[9] != 0)
8681 draw_info->affine.ty=argument_list[9].real_reference;
8682 if (attribute_flag[20] != 0)
8687 av=(AV *) argument_list[20].array_reference;
8688 if ((av_len(av) != 3) && (av_len(av) != 5))
8690 ThrowPerlException(exception,OptionError,
8691 "affine matrix must have 4 or 6 elements",PackageName);
8694 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8695 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8696 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8697 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8698 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8699 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8701 ThrowPerlException(exception,OptionError,
8702 "affine matrix is singular",PackageName);
8705 if (av_len(av) == 5)
8707 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8708 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8711 for (j=10; j < 15; j++)
8713 if (attribute_flag[j] == 0)
8715 value=argument_list[j].string_reference;
8716 angle=argument_list[j].real_reference;
8717 current=draw_info->affine;
8718 GetAffineMatrix(&affine);
8726 flags=ParseGeometry(value,&geometry_info);
8727 affine.tx=geometry_info.xi;
8728 affine.ty=geometry_info.psi;
8729 if ((flags & PsiValue) == 0)
8730 affine.ty=affine.tx;
8738 flags=ParseGeometry(value,&geometry_info);
8739 affine.sx=geometry_info.rho;
8740 affine.sy=geometry_info.sigma;
8741 if ((flags & SigmaValue) == 0)
8742 affine.sy=affine.sx;
8752 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8753 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8754 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8755 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8763 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8771 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8775 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8776 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8777 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8778 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8779 draw_info->affine.tx=
8780 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8781 draw_info->affine.ty=
8782 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8784 if (attribute_flag[15] != 0)
8785 draw_info->fill_pattern=CloneImage(
8786 argument_list[15].image_reference,0,0,MagickTrue,exception);
8787 if (attribute_flag[16] != 0)
8788 draw_info->pointsize=argument_list[16].real_reference;
8789 if (attribute_flag[17] != 0)
8791 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8792 ? MagickTrue : MagickFalse;
8793 draw_info->text_antialias=draw_info->stroke_antialias;
8795 if (attribute_flag[18] != 0)
8796 (void) CloneString(&draw_info->density,
8797 argument_list[18].string_reference);
8798 if (attribute_flag[19] != 0)
8799 draw_info->stroke_width=argument_list[19].real_reference;
8800 if (attribute_flag[21] != 0)
8801 draw_info->dash_offset=argument_list[21].real_reference;
8802 if (attribute_flag[22] != 0)
8807 av=(AV *) argument_list[22].array_reference;
8808 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8809 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8810 if (draw_info->dash_pattern != (double *) NULL)
8812 for (i=0; i <= av_len(av); i++)
8813 draw_info->dash_pattern[i]=(double)
8814 SvNV(*(av_fetch(av,i,0)));
8815 draw_info->dash_pattern[i]=0.0;
8818 if (attribute_flag[23] != 0)
8819 image->interpolate=(PixelInterpolateMethod)
8820 argument_list[23].integer_reference;
8821 if ((attribute_flag[24] != 0) &&
8822 (draw_info->fill_pattern != (Image *) NULL))
8823 flags=ParsePageGeometry(draw_info->fill_pattern,
8824 argument_list[24].string_reference,
8825 &draw_info->fill_pattern->tile_offset,exception);
8826 if (attribute_flag[25] != 0)
8828 (void) ConcatenateString(&draw_info->primitive," '");
8829 (void) ConcatenateString(&draw_info->primitive,
8830 argument_list[25].string_reference);
8831 (void) ConcatenateString(&draw_info->primitive,"'");
8833 if (attribute_flag[26] != 0)
8834 draw_info->fill_pattern=CloneImage(
8835 argument_list[26].image_reference,0,0,MagickTrue,exception);
8836 if (attribute_flag[27] != 0)
8837 draw_info->stroke_pattern=CloneImage(
8838 argument_list[27].image_reference,0,0,MagickTrue,exception);
8839 if (attribute_flag[28] != 0)
8840 (void) CloneString(&draw_info->primitive,
8841 argument_list[28].string_reference);
8842 if (attribute_flag[29] != 0)
8843 draw_info->kerning=argument_list[29].real_reference;
8844 if (attribute_flag[30] != 0)
8845 draw_info->interline_spacing=argument_list[30].real_reference;
8846 if (attribute_flag[31] != 0)
8847 draw_info->interword_spacing=argument_list[31].real_reference;
8848 if (attribute_flag[32] != 0)
8849 draw_info->direction=(DirectionType)
8850 argument_list[32].integer_reference;
8851 DrawImage(image,draw_info,exception);
8852 draw_info=DestroyDrawInfo(draw_info);
8855 case 39: /* Equalize */
8857 if (attribute_flag[0] != 0)
8858 channel=(ChannelType) argument_list[0].integer_reference;
8859 channel_mask=SetImageChannelMask(image,channel);
8860 EqualizeImage(image,exception);
8861 (void) SetImageChannelMask(image,channel_mask);
8864 case 40: /* Gamma */
8866 if (attribute_flag[1] != 0)
8867 channel=(ChannelType) argument_list[1].integer_reference;
8868 if (attribute_flag[2] == 0)
8869 argument_list[2].real_reference=1.0;
8870 if (attribute_flag[3] == 0)
8871 argument_list[3].real_reference=1.0;
8872 if (attribute_flag[4] == 0)
8873 argument_list[4].real_reference=1.0;
8874 if (attribute_flag[0] == 0)
8876 (void) FormatLocaleString(message,MaxTextExtent,
8877 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8878 (double) argument_list[3].real_reference,
8879 (double) argument_list[4].real_reference);
8880 argument_list[0].string_reference=message;
8882 (void) GammaImage(image,StringToDouble(
8883 argument_list[0].string_reference,(char **) NULL),exception);
8891 if (attribute_flag[0] == 0)
8893 ThrowPerlException(exception,OptionError,"MapImageRequired",
8897 quantize_info=AcquireQuantizeInfo(info->image_info);
8898 if (attribute_flag[1] != 0)
8899 quantize_info->dither_method=(DitherMethod)
8900 argument_list[1].integer_reference;
8901 (void) RemapImages(quantize_info,image,
8902 argument_list[0].image_reference,exception);
8903 quantize_info=DestroyQuantizeInfo(quantize_info);
8906 case 42: /* MatteFloodfill */
8917 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8919 if (attribute_flag[0] != 0)
8920 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8921 &geometry,exception);
8922 if (attribute_flag[1] != 0)
8923 geometry.x=argument_list[1].integer_reference;
8924 if (attribute_flag[2] != 0)
8925 geometry.y=argument_list[2].integer_reference;
8926 if (image->alpha_trait != BlendPixelTrait)
8927 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8928 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8929 geometry.x,geometry.y,&target,exception);
8930 if (attribute_flag[4] != 0)
8931 QueryColorCompliance(argument_list[4].string_reference,
8932 AllCompliance,&target,exception);
8933 if (attribute_flag[3] != 0)
8934 target.alpha=StringToDoubleInterval(
8935 argument_list[3].string_reference,(double) (double) QuantumRange+
8937 if (attribute_flag[5] != 0)
8938 image->fuzz=StringToDoubleInterval(
8939 argument_list[5].string_reference,(double) QuantumRange+1.0);
8941 if (attribute_flag[6] != 0)
8942 invert=(MagickBooleanType) argument_list[6].integer_reference;
8943 channel_mask=SetImageChannelMask(image,AlphaChannel);
8944 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8945 geometry.y,invert,exception);
8946 (void) SetImageChannelMask(image,channel_mask);
8947 draw_info=DestroyDrawInfo(draw_info);
8950 case 43: /* Modulate */
8953 modulate[MaxTextExtent];
8955 geometry_info.rho=100.0;
8956 geometry_info.sigma=100.0;
8957 geometry_info.xi=100.0;
8958 if (attribute_flag[0] != 0)
8959 (void)ParseGeometry(argument_list[0].string_reference,
8961 if (attribute_flag[1] != 0)
8962 geometry_info.xi=argument_list[1].real_reference;
8963 if (attribute_flag[2] != 0)
8964 geometry_info.sigma=argument_list[2].real_reference;
8965 if (attribute_flag[3] != 0)
8967 geometry_info.sigma=argument_list[3].real_reference;
8968 SetImageArtifact(image,"modulate:colorspace","HWB");
8970 if (attribute_flag[4] != 0)
8972 geometry_info.rho=argument_list[4].real_reference;
8973 SetImageArtifact(image,"modulate:colorspace","HSB");
8975 if (attribute_flag[5] != 0)
8977 geometry_info.sigma=argument_list[5].real_reference;
8978 SetImageArtifact(image,"modulate:colorspace","HSL");
8980 if (attribute_flag[6] != 0)
8982 geometry_info.rho=argument_list[6].real_reference;
8983 SetImageArtifact(image,"modulate:colorspace","HWB");
8985 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8986 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8987 (void) ModulateImage(image,modulate,exception);
8990 case 44: /* Negate */
8992 if (attribute_flag[0] == 0)
8993 argument_list[0].integer_reference=0;
8994 if (attribute_flag[1] != 0)
8995 channel=(ChannelType) argument_list[1].integer_reference;
8996 channel_mask=SetImageChannelMask(image,channel);
8997 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8998 MagickTrue : MagickFalse,exception);
8999 (void) SetImageChannelMask(image,channel_mask);
9002 case 45: /* Normalize */
9004 if (attribute_flag[0] != 0)
9005 channel=(ChannelType) argument_list[0].integer_reference;
9006 channel_mask=SetImageChannelMask(image,channel);
9007 NormalizeImage(image,exception);
9008 (void) SetImageChannelMask(image,channel_mask);
9011 case 46: /* NumberColors */
9013 case 47: /* Opaque */
9022 (void) QueryColorCompliance("none",AllCompliance,&target,
9024 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9026 if (attribute_flag[0] != 0)
9027 (void) QueryColorCompliance(argument_list[0].string_reference,
9028 AllCompliance,&target,exception);
9029 if (attribute_flag[1] != 0)
9030 (void) QueryColorCompliance(argument_list[1].string_reference,
9031 AllCompliance,&fill_color,exception);
9032 if (attribute_flag[2] != 0)
9033 image->fuzz=StringToDoubleInterval(
9034 argument_list[2].string_reference,(double) QuantumRange+1.0);
9035 if (attribute_flag[3] != 0)
9036 channel=(ChannelType) argument_list[3].integer_reference;
9038 if (attribute_flag[4] != 0)
9039 invert=(MagickBooleanType) argument_list[4].integer_reference;
9040 channel_mask=SetImageChannelMask(image,channel);
9041 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9042 (void) SetImageChannelMask(image,channel_mask);
9045 case 48: /* Quantize */
9050 quantize_info=AcquireQuantizeInfo(info->image_info);
9051 if (attribute_flag[0] != 0)
9052 quantize_info->number_colors=(size_t)
9053 argument_list[0].integer_reference;
9054 if (attribute_flag[1] != 0)
9055 quantize_info->tree_depth=(size_t)
9056 argument_list[1].integer_reference;
9057 if (attribute_flag[2] != 0)
9058 quantize_info->colorspace=(ColorspaceType)
9059 argument_list[2].integer_reference;
9060 if (attribute_flag[3] != 0)
9061 quantize_info->dither_method=(DitherMethod)
9062 argument_list[3].integer_reference;
9063 if (attribute_flag[4] != 0)
9064 quantize_info->measure_error=argument_list[4].integer_reference !=
9065 0 ? MagickTrue : MagickFalse;
9066 if (attribute_flag[5] != 0)
9067 (void) QueryColorCompliance(argument_list[5].string_reference,
9068 AllCompliance,&image->transparent_color,exception);
9069 if (attribute_flag[5] && argument_list[5].integer_reference)
9071 (void) QuantizeImages(quantize_info,image,exception);
9074 if (attribute_flag[6] != 0)
9075 quantize_info->dither_method=(DitherMethod)
9076 argument_list[6].integer_reference;
9077 if ((image->storage_class == DirectClass) ||
9078 (image->colors > quantize_info->number_colors) ||
9079 (quantize_info->colorspace == GRAYColorspace))
9080 (void) QuantizeImage(quantize_info,image,exception);
9082 CompressImageColormap(image,exception);
9083 quantize_info=DestroyQuantizeInfo(quantize_info);
9086 case 49: /* Raise */
9088 if (attribute_flag[0] != 0)
9089 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9090 &geometry,exception);
9091 if (attribute_flag[1] != 0)
9092 geometry.width=argument_list[1].integer_reference;
9093 if (attribute_flag[2] != 0)
9094 geometry.height=argument_list[2].integer_reference;
9095 if (attribute_flag[3] == 0)
9096 argument_list[3].integer_reference=1;
9097 (void) RaiseImage(image,&geometry,
9098 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9102 case 50: /* Segment */
9109 smoothing_threshold;
9114 cluster_threshold=1.0;
9115 smoothing_threshold=1.5;
9116 colorspace=sRGBColorspace;
9117 verbose=MagickFalse;
9118 if (attribute_flag[0] != 0)
9120 flags=ParseGeometry(argument_list[0].string_reference,
9122 cluster_threshold=geometry_info.rho;
9123 if (flags & SigmaValue)
9124 smoothing_threshold=geometry_info.sigma;
9126 if (attribute_flag[1] != 0)
9127 cluster_threshold=argument_list[1].real_reference;
9128 if (attribute_flag[2] != 0)
9129 smoothing_threshold=argument_list[2].real_reference;
9130 if (attribute_flag[3] != 0)
9131 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9132 if (attribute_flag[4] != 0)
9133 verbose=argument_list[4].integer_reference != 0 ?
9134 MagickTrue : MagickFalse;
9135 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9136 smoothing_threshold,exception);
9139 case 51: /* Signature */
9141 (void) SignatureImage(image,exception);
9144 case 52: /* Solarize */
9146 geometry_info.rho=QuantumRange/2.0;
9147 if (attribute_flag[0] != 0)
9148 flags=ParseGeometry(argument_list[0].string_reference,
9150 if (attribute_flag[1] != 0)
9151 geometry_info.rho=StringToDoubleInterval(
9152 argument_list[1].string_reference,(double) QuantumRange+1.0);
9153 (void) SolarizeImage(image,geometry_info.rho,exception);
9158 (void) SyncImage(image,exception);
9161 case 54: /* Texture */
9163 if (attribute_flag[0] == 0)
9165 TextureImage(image,argument_list[0].image_reference,exception);
9168 case 55: /* Evalute */
9170 MagickEvaluateOperator
9173 op=SetEvaluateOperator;
9174 if (attribute_flag[0] == MagickFalse)
9175 argument_list[0].real_reference=0.0;
9176 if (attribute_flag[1] != MagickFalse)
9177 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9178 if (attribute_flag[2] != MagickFalse)
9179 channel=(ChannelType) argument_list[2].integer_reference;
9180 channel_mask=SetImageChannelMask(image,channel);
9181 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9183 (void) SetImageChannelMask(image,channel_mask);
9186 case 56: /* Transparent */
9197 (void) QueryColorCompliance("none",AllCompliance,&target,
9199 if (attribute_flag[0] != 0)
9200 (void) QueryColorCompliance(argument_list[0].string_reference,
9201 AllCompliance,&target,exception);
9202 opacity=TransparentAlpha;
9203 if (attribute_flag[1] != 0)
9204 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9205 (double) QuantumRange+1.0);
9206 if (attribute_flag[2] != 0)
9207 image->fuzz=StringToDoubleInterval(
9208 argument_list[2].string_reference,(double) QuantumRange+1.0);
9209 if (attribute_flag[3] == 0)
9210 argument_list[3].integer_reference=0;
9212 if (attribute_flag[3] != 0)
9213 invert=(MagickBooleanType) argument_list[3].integer_reference;
9214 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9218 case 57: /* Threshold */
9223 if (attribute_flag[0] == 0)
9224 argument_list[0].string_reference="50%";
9225 if (attribute_flag[1] != 0)
9226 channel=(ChannelType) argument_list[1].integer_reference;
9227 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9228 (double) QuantumRange+1.0);
9229 channel_mask=SetImageChannelMask(image,channel);
9230 (void) BilevelImage(image,threshold,exception);
9231 (void) SetImageChannelMask(image,channel_mask);
9234 case 58: /* Charcoal */
9236 if (attribute_flag[0] != 0)
9238 flags=ParseGeometry(argument_list[0].string_reference,
9240 if ((flags & SigmaValue) == 0)
9241 geometry_info.sigma=1.0;
9243 if (attribute_flag[1] != 0)
9244 geometry_info.rho=argument_list[1].real_reference;
9245 if (attribute_flag[2] != 0)
9246 geometry_info.sigma=argument_list[2].real_reference;
9247 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9253 if (attribute_flag[0] != 0)
9254 image->fuzz=StringToDoubleInterval(
9255 argument_list[0].string_reference,(double) QuantumRange+1.0);
9256 image=TrimImage(image,exception);
9261 PixelInterpolateMethod
9264 if (attribute_flag[0] != 0)
9266 flags=ParseGeometry(argument_list[0].string_reference,
9268 if ((flags & SigmaValue) == 0)
9269 geometry_info.sigma=1.0;
9271 if (attribute_flag[1] != 0)
9272 geometry_info.rho=argument_list[1].real_reference;
9273 if (attribute_flag[2] != 0)
9274 geometry_info.sigma=argument_list[2].real_reference;
9275 method=UndefinedInterpolatePixel;
9276 if (attribute_flag[3] != 0)
9277 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9278 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9282 case 61: /* Separate */
9284 if (attribute_flag[0] != 0)
9285 channel=(ChannelType) argument_list[0].integer_reference;
9286 image=SeparateImage(image,channel,exception);
9289 case 63: /* Stereo */
9291 if (attribute_flag[0] == 0)
9293 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9297 if (attribute_flag[1] != 0)
9298 geometry.x=argument_list[1].integer_reference;
9299 if (attribute_flag[2] != 0)
9300 geometry.y=argument_list[2].integer_reference;
9301 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9302 geometry.x,geometry.y,exception);
9305 case 64: /* Stegano */
9307 if (attribute_flag[0] == 0)
9309 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9313 if (attribute_flag[1] == 0)
9314 argument_list[1].integer_reference=0;
9315 image->offset=argument_list[1].integer_reference;
9316 image=SteganoImage(image,argument_list[0].image_reference,exception);
9319 case 65: /* Deconstruct */
9321 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9324 case 66: /* GaussianBlur */
9326 if (attribute_flag[0] != 0)
9328 flags=ParseGeometry(argument_list[0].string_reference,
9330 if ((flags & SigmaValue) == 0)
9331 geometry_info.sigma=1.0;
9333 if (attribute_flag[1] != 0)
9334 geometry_info.rho=argument_list[1].real_reference;
9335 if (attribute_flag[2] != 0)
9336 geometry_info.sigma=argument_list[2].real_reference;
9337 if (attribute_flag[3] != 0)
9338 channel=(ChannelType) argument_list[3].integer_reference;
9339 channel_mask=SetImageChannelMask(image,channel);
9340 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9342 if (image != (Image *) NULL)
9343 (void) SetImageChannelMask(image,channel_mask);
9346 case 67: /* Convolve */
9351 kernel=(KernelInfo *) NULL;
9352 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9354 if (attribute_flag[0] != 0)
9362 kernel=AcquireKernelInfo((const char *) NULL);
9363 if (kernel == (KernelInfo *) NULL)
9365 av=(AV *) argument_list[0].array_reference;
9366 order=(size_t) sqrt(av_len(av)+1);
9367 kernel->width=order;
9368 kernel->height=order;
9369 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9370 order*sizeof(*kernel->values));
9371 if (kernel->values == (MagickRealType *) NULL)
9373 kernel=DestroyKernelInfo(kernel);
9374 ThrowPerlException(exception,ResourceLimitFatalError,
9375 "MemoryAllocationFailed",PackageName);
9378 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9379 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9380 for ( ; j < (ssize_t) (order*order); j++)
9381 kernel->values[j]=0.0;
9383 if (attribute_flag[1] != 0)
9384 channel=(ChannelType) argument_list[1].integer_reference;
9385 if (attribute_flag[2] != 0)
9386 SetImageArtifact(image,"filter:blur",
9387 argument_list[2].string_reference);
9388 if (attribute_flag[3] != 0)
9390 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9391 if (kernel == (KernelInfo *) NULL)
9394 channel_mask=SetImageChannelMask(image,channel);
9395 image=ConvolveImage(image,kernel,exception);
9396 if (image != (Image *) NULL)
9397 (void) SetImageChannelMask(image,channel_mask);
9398 kernel=DestroyKernelInfo(kernel);
9401 case 68: /* Profile */
9416 if (attribute_flag[0] != 0)
9417 name=argument_list[0].string_reference;
9418 if (attribute_flag[2] != 0)
9419 image->rendering_intent=(RenderingIntent)
9420 argument_list[2].integer_reference;
9421 if (attribute_flag[3] != 0)
9422 image->black_point_compensation=
9423 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9424 if (attribute_flag[1] != 0)
9426 if (argument_list[1].length == 0)
9429 Remove a profile from the image.
9431 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9436 Associate user supplied profile with the image.
9438 profile=AcquireStringInfo(argument_list[1].length);
9439 SetStringInfoDatum(profile,(const unsigned char *)
9440 argument_list[1].string_reference);
9441 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9442 (size_t) GetStringInfoLength(profile),exception);
9443 profile=DestroyStringInfo(profile);
9447 Associate a profile with the image.
9449 profile_info=CloneImageInfo(info ? info->image_info :
9450 (ImageInfo *) NULL);
9451 profile_image=ReadImages(profile_info,name,exception);
9452 if (profile_image == (Image *) NULL)
9454 ResetImageProfileIterator(profile_image);
9455 name=GetNextImageProfile(profile_image);
9456 while (name != (const char *) NULL)
9461 profile=GetImageProfile(profile_image,name);
9462 if (profile != (const StringInfo *) NULL)
9463 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9464 (size_t) GetStringInfoLength(profile),exception);
9465 name=GetNextImageProfile(profile_image);
9467 profile_image=DestroyImage(profile_image);
9468 profile_info=DestroyImageInfo(profile_info);
9471 case 69: /* UnsharpMask */
9473 if (attribute_flag[0] != 0)
9475 flags=ParseGeometry(argument_list[0].string_reference,
9477 if ((flags & SigmaValue) == 0)
9478 geometry_info.sigma=1.0;
9479 if ((flags & XiValue) == 0)
9480 geometry_info.xi=1.0;
9481 if ((flags & PsiValue) == 0)
9482 geometry_info.psi=0.5;
9484 if (attribute_flag[1] != 0)
9485 geometry_info.rho=argument_list[1].real_reference;
9486 if (attribute_flag[2] != 0)
9487 geometry_info.sigma=argument_list[2].real_reference;
9488 if (attribute_flag[3] != 0)
9489 geometry_info.xi=argument_list[3].real_reference;
9490 if (attribute_flag[4] != 0)
9491 geometry_info.psi=argument_list[4].real_reference;
9492 if (attribute_flag[5] != 0)
9493 channel=(ChannelType) argument_list[5].integer_reference;
9494 channel_mask=SetImageChannelMask(image,channel);
9495 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9496 geometry_info.xi,geometry_info.psi,exception);
9497 if (image != (Image *) NULL)
9498 (void) SetImageChannelMask(image,channel_mask);
9501 case 70: /* MotionBlur */
9503 if (attribute_flag[0] != 0)
9505 flags=ParseGeometry(argument_list[0].string_reference,
9507 if ((flags & SigmaValue) == 0)
9508 geometry_info.sigma=1.0;
9509 if ((flags & XiValue) == 0)
9510 geometry_info.xi=1.0;
9512 if (attribute_flag[1] != 0)
9513 geometry_info.rho=argument_list[1].real_reference;
9514 if (attribute_flag[2] != 0)
9515 geometry_info.sigma=argument_list[2].real_reference;
9516 if (attribute_flag[3] != 0)
9517 geometry_info.xi=argument_list[3].real_reference;
9518 if (attribute_flag[4] != 0)
9519 channel=(ChannelType) argument_list[4].integer_reference;
9520 channel_mask=SetImageChannelMask(image,channel);
9521 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9522 geometry_info.xi,exception);
9523 if (image != (Image *) NULL)
9524 (void) SetImageChannelMask(image,channel_mask);
9527 case 71: /* OrderedDither */
9529 if (attribute_flag[0] == 0)
9530 argument_list[0].string_reference="o8x8";
9531 if (attribute_flag[1] != 0)
9532 channel=(ChannelType) argument_list[1].integer_reference;
9533 channel_mask=SetImageChannelMask(image,channel);
9534 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9536 (void) SetImageChannelMask(image,channel_mask);
9539 case 72: /* Shave */
9541 if (attribute_flag[0] != 0)
9542 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9543 &geometry,exception);
9544 if (attribute_flag[1] != 0)
9545 geometry.width=argument_list[1].integer_reference;
9546 if (attribute_flag[2] != 0)
9547 geometry.height=argument_list[2].integer_reference;
9548 image=ShaveImage(image,&geometry,exception);
9551 case 73: /* Level */
9559 white_point=(double) image->columns*image->rows;
9561 if (attribute_flag[0] != 0)
9563 flags=ParseGeometry(argument_list[0].string_reference,
9565 black_point=geometry_info.rho;
9566 if ((flags & SigmaValue) != 0)
9567 white_point=geometry_info.sigma;
9568 if ((flags & XiValue) != 0)
9569 gamma=geometry_info.xi;
9570 if ((flags & PercentValue) != 0)
9572 black_point*=(double) (QuantumRange/100.0);
9573 white_point*=(double) (QuantumRange/100.0);
9575 if ((flags & SigmaValue) == 0)
9576 white_point=(double) QuantumRange-black_point;
9578 if (attribute_flag[1] != 0)
9579 black_point=argument_list[1].real_reference;
9580 if (attribute_flag[2] != 0)
9581 white_point=argument_list[2].real_reference;
9582 if (attribute_flag[3] != 0)
9583 gamma=argument_list[3].real_reference;
9584 if (attribute_flag[4] != 0)
9585 channel=(ChannelType) argument_list[4].integer_reference;
9586 if (attribute_flag[5] != 0)
9588 argument_list[0].real_reference=argument_list[5].real_reference;
9589 attribute_flag[0]=attribute_flag[5];
9591 channel_mask=SetImageChannelMask(image,channel);
9592 (void) LevelImage(image,black_point,white_point,gamma,exception);
9593 (void) SetImageChannelMask(image,channel_mask);
9598 if (attribute_flag[0] == 0)
9599 argument_list[0].string_reference="#1";
9600 if (attribute_flag[1] == 0)
9601 argument_list[1].integer_reference=MagickTrue;
9602 (void) ClipImagePath(image,argument_list[0].string_reference,
9603 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9607 case 75: /* AffineTransform */
9612 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9614 if (attribute_flag[0] != 0)
9619 av=(AV *) argument_list[0].array_reference;
9620 if ((av_len(av) != 3) && (av_len(av) != 5))
9622 ThrowPerlException(exception,OptionError,
9623 "affine matrix must have 4 or 6 elements",PackageName);
9626 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9627 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9628 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9629 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9630 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9631 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9633 ThrowPerlException(exception,OptionError,
9634 "affine matrix is singular",PackageName);
9637 if (av_len(av) == 5)
9639 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9640 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9643 for (j=1; j < 6; j++)
9645 if (attribute_flag[j] == 0)
9647 value=argument_list[j].string_reference;
9648 angle=argument_list[j].real_reference;
9649 current=draw_info->affine;
9650 GetAffineMatrix(&affine);
9658 flags=ParseGeometry(value,&geometry_info);
9659 affine.tx=geometry_info.xi;
9660 affine.ty=geometry_info.psi;
9661 if ((flags & PsiValue) == 0)
9662 affine.ty=affine.tx;
9670 flags=ParseGeometry(value,&geometry_info);
9671 affine.sx=geometry_info.rho;
9672 affine.sy=geometry_info.sigma;
9673 if ((flags & SigmaValue) == 0)
9674 affine.sy=affine.sx;
9684 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9685 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9686 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9687 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9695 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9703 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9707 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9708 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9709 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9710 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9711 draw_info->affine.tx=
9712 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9713 draw_info->affine.ty=
9714 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9716 if (attribute_flag[6] != 0)
9717 image->interpolate=(PixelInterpolateMethod)
9718 argument_list[6].integer_reference;
9719 if (attribute_flag[7] != 0)
9720 QueryColorCompliance(argument_list[7].string_reference,
9721 AllCompliance,&image->background_color,exception);
9722 image=AffineTransformImage(image,&draw_info->affine,exception);
9723 draw_info=DestroyDrawInfo(draw_info);
9726 case 76: /* Difference */
9728 if (attribute_flag[0] == 0)
9730 ThrowPerlException(exception,OptionError,
9731 "ReferenceImageRequired",PackageName);
9734 if (attribute_flag[1] != 0)
9735 image->fuzz=StringToDoubleInterval(
9736 argument_list[1].string_reference,(double) QuantumRange+1.0);
9737 (void) IsImagesEqual(image,argument_list[0].image_reference,
9741 case 77: /* AdaptiveThreshold */
9743 if (attribute_flag[0] != 0)
9745 flags=ParseGeometry(argument_list[0].string_reference,
9747 if ((flags & PercentValue) != 0)
9748 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9750 if (attribute_flag[1] != 0)
9751 geometry_info.rho=argument_list[1].integer_reference;
9752 if (attribute_flag[2] != 0)
9753 geometry_info.sigma=argument_list[2].integer_reference;
9754 if (attribute_flag[3] != 0)
9755 geometry_info.xi=argument_list[3].integer_reference;;
9756 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9757 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9760 case 78: /* Resample */
9766 if (attribute_flag[0] != 0)
9768 flags=ParseGeometry(argument_list[0].string_reference,
9770 if ((flags & SigmaValue) == 0)
9771 geometry_info.sigma=geometry_info.rho;
9773 if (attribute_flag[1] != 0)
9774 geometry_info.rho=argument_list[1].real_reference;
9775 if (attribute_flag[2] != 0)
9776 geometry_info.sigma=argument_list[2].real_reference;
9777 if (attribute_flag[3] == 0)
9778 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9779 if (attribute_flag[4] == 0)
9780 SetImageArtifact(image,"filter:support",
9781 argument_list[4].string_reference);
9782 width=(size_t) (geometry_info.rho*image->columns/
9783 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9784 height=(size_t) (geometry_info.sigma*image->rows/
9785 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9786 image=ResizeImage(image,width,height,(FilterTypes)
9787 argument_list[3].integer_reference,exception);
9788 if (image != (Image *) NULL)
9790 image->resolution.x=geometry_info.rho;
9791 image->resolution.y=geometry_info.sigma;
9795 case 79: /* Describe */
9797 if (attribute_flag[0] == 0)
9798 argument_list[0].file_reference=(FILE *) NULL;
9799 if (attribute_flag[1] != 0)
9800 (void) SetImageArtifact(image,"identify:features",
9801 argument_list[1].string_reference);
9802 (void) IdentifyImage(image,argument_list[0].file_reference,
9803 MagickTrue,exception);
9806 case 80: /* BlackThreshold */
9808 if (attribute_flag[0] == 0)
9809 argument_list[0].string_reference="50%";
9810 if (attribute_flag[2] != 0)
9811 channel=(ChannelType) argument_list[2].integer_reference;
9812 channel_mask=SetImageChannelMask(image,channel);
9813 BlackThresholdImage(image,argument_list[0].string_reference,
9815 (void) SetImageChannelMask(image,channel_mask);
9818 case 81: /* WhiteThreshold */
9820 if (attribute_flag[0] == 0)
9821 argument_list[0].string_reference="50%";
9822 if (attribute_flag[2] != 0)
9823 channel=(ChannelType) argument_list[2].integer_reference;
9824 channel_mask=SetImageChannelMask(image,channel);
9825 WhiteThresholdImage(image,argument_list[0].string_reference,
9827 (void) SetImageChannelMask(image,channel_mask);
9830 case 82: /* RadialBlur */
9832 if (attribute_flag[0] != 0)
9834 flags=ParseGeometry(argument_list[0].string_reference,
9837 if (attribute_flag[1] != 0)
9838 geometry_info.rho=argument_list[1].real_reference;
9839 if (attribute_flag[2] != 0)
9840 channel=(ChannelType) argument_list[2].integer_reference;
9841 channel_mask=SetImageChannelMask(image,channel);
9842 image=RadialBlurImage(image,geometry_info.rho,exception);
9843 if (image != (Image *) NULL)
9844 (void) SetImageChannelMask(image,channel_mask);
9847 case 83: /* Thumbnail */
9849 if (attribute_flag[0] != 0)
9850 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9851 &geometry,exception);
9852 if (attribute_flag[1] != 0)
9853 geometry.width=argument_list[1].integer_reference;
9854 if (attribute_flag[2] != 0)
9855 geometry.height=argument_list[2].integer_reference;
9856 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9859 case 84: /* Strip */
9861 (void) StripImage(image,exception);
9869 GetPixelInfo(image,&tint);
9870 if (attribute_flag[0] != 0)
9871 (void) QueryColorCompliance(argument_list[0].string_reference,
9872 AllCompliance,&tint,exception);
9873 if (attribute_flag[1] == 0)
9874 argument_list[1].string_reference="100";
9875 image=TintImage(image,argument_list[1].string_reference,&tint,
9879 case 86: /* Channel */
9881 if (attribute_flag[0] != 0)
9882 channel=(ChannelType) argument_list[0].integer_reference;
9883 image=SeparateImage(image,channel,exception);
9886 case 87: /* Splice */
9888 if (attribute_flag[0] != 0)
9889 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9890 &geometry,exception);
9891 if (attribute_flag[1] != 0)
9892 geometry.width=argument_list[1].integer_reference;
9893 if (attribute_flag[2] != 0)
9894 geometry.height=argument_list[2].integer_reference;
9895 if (attribute_flag[3] != 0)
9896 geometry.x=argument_list[3].integer_reference;
9897 if (attribute_flag[4] != 0)
9898 geometry.y=argument_list[4].integer_reference;
9899 if (attribute_flag[5] != 0)
9900 image->fuzz=StringToDoubleInterval(
9901 argument_list[5].string_reference,(double) QuantumRange+1.0);
9902 if (attribute_flag[6] != 0)
9903 (void) QueryColorCompliance(argument_list[6].string_reference,
9904 AllCompliance,&image->background_color,exception);
9905 if (attribute_flag[7] != 0)
9906 image->gravity=(GravityType) argument_list[7].integer_reference;
9907 image=SpliceImage(image,&geometry,exception);
9910 case 88: /* Posterize */
9912 if (attribute_flag[0] == 0)
9913 argument_list[0].integer_reference=3;
9914 if (attribute_flag[1] == 0)
9915 argument_list[1].integer_reference=0;
9916 (void) PosterizeImage(image,argument_list[0].integer_reference,
9917 argument_list[1].integer_reference ? RiemersmaDitherMethod :
9918 NoDitherMethod,exception);
9921 case 89: /* Shadow */
9923 if (attribute_flag[0] != 0)
9925 flags=ParseGeometry(argument_list[0].string_reference,
9927 if ((flags & SigmaValue) == 0)
9928 geometry_info.sigma=1.0;
9929 if ((flags & XiValue) == 0)
9930 geometry_info.xi=4.0;
9931 if ((flags & PsiValue) == 0)
9932 geometry_info.psi=4.0;
9934 if (attribute_flag[1] != 0)
9935 geometry_info.rho=argument_list[1].real_reference;
9936 if (attribute_flag[2] != 0)
9937 geometry_info.sigma=argument_list[2].real_reference;
9938 if (attribute_flag[3] != 0)
9939 geometry_info.xi=argument_list[3].integer_reference;
9940 if (attribute_flag[4] != 0)
9941 geometry_info.psi=argument_list[4].integer_reference;
9942 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9943 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
9944 ceil(geometry_info.psi-0.5),exception);
9947 case 90: /* Identify */
9949 if (attribute_flag[0] == 0)
9950 argument_list[0].file_reference=(FILE *) NULL;
9951 if (attribute_flag[1] != 0)
9952 (void) SetImageArtifact(image,"identify:features",
9953 argument_list[1].string_reference);
9954 if ((attribute_flag[2] != 0) &&
9955 (argument_list[2].integer_reference != 0))
9956 (void) SetImageArtifact(image,"identify:unique","true");
9957 (void) IdentifyImage(image,argument_list[0].file_reference,
9958 MagickTrue,exception);
9961 case 91: /* SepiaTone */
9963 if (attribute_flag[0] == 0)
9964 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9965 image=SepiaToneImage(image,argument_list[0].real_reference,
9969 case 92: /* SigmoidalContrast */
9974 if (attribute_flag[0] != 0)
9976 flags=ParseGeometry(argument_list[0].string_reference,
9978 if ((flags & SigmaValue) == 0)
9979 geometry_info.sigma=QuantumRange/2.0;
9980 if ((flags & PercentValue) != 0)
9981 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9983 if (attribute_flag[1] != 0)
9984 geometry_info.rho=argument_list[1].real_reference;
9985 if (attribute_flag[2] != 0)
9986 geometry_info.sigma=argument_list[2].real_reference;
9987 if (attribute_flag[3] != 0)
9988 channel=(ChannelType) argument_list[3].integer_reference;
9990 if (attribute_flag[4] != 0)
9991 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9993 channel_mask=SetImageChannelMask(image,channel);
9994 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9995 geometry_info.sigma,exception);
9996 (void) SetImageChannelMask(image,channel_mask);
9999 case 93: /* Extent */
10001 if (attribute_flag[7] != 0)
10002 image->gravity=(GravityType) argument_list[7].integer_reference;
10003 if (attribute_flag[0] != 0)
10008 flags=ParseGravityGeometry(image,
10009 argument_list[0].string_reference,&geometry,exception);
10011 if (geometry.width == 0)
10012 geometry.width=image->columns;
10013 if (geometry.height == 0)
10014 geometry.height=image->rows;
10016 if (attribute_flag[1] != 0)
10017 geometry.width=argument_list[1].integer_reference;
10018 if (attribute_flag[2] != 0)
10019 geometry.height=argument_list[2].integer_reference;
10020 if (attribute_flag[3] != 0)
10021 geometry.x=argument_list[3].integer_reference;
10022 if (attribute_flag[4] != 0)
10023 geometry.y=argument_list[4].integer_reference;
10024 if (attribute_flag[5] != 0)
10025 image->fuzz=StringToDoubleInterval(
10026 argument_list[5].string_reference,(double) QuantumRange+1.0);
10027 if (attribute_flag[6] != 0)
10028 (void) QueryColorCompliance(argument_list[6].string_reference,
10029 AllCompliance,&image->background_color,exception);
10030 image=ExtentImage(image,&geometry,exception);
10033 case 94: /* Vignette */
10035 if (attribute_flag[0] != 0)
10037 flags=ParseGeometry(argument_list[0].string_reference,
10039 if ((flags & SigmaValue) == 0)
10040 geometry_info.sigma=1.0;
10041 if ((flags & XiValue) == 0)
10042 geometry_info.xi=0.1*image->columns;
10043 if ((flags & PsiValue) == 0)
10044 geometry_info.psi=0.1*image->rows;
10046 if (attribute_flag[1] != 0)
10047 geometry_info.rho=argument_list[1].real_reference;
10048 if (attribute_flag[2] != 0)
10049 geometry_info.sigma=argument_list[2].real_reference;
10050 if (attribute_flag[3] != 0)
10051 geometry_info.xi=argument_list[3].integer_reference;
10052 if (attribute_flag[4] != 0)
10053 geometry_info.psi=argument_list[4].integer_reference;
10054 if (attribute_flag[5] != 0)
10055 (void) QueryColorCompliance(argument_list[5].string_reference,
10056 AllCompliance,&image->background_color,exception);
10057 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10058 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10059 ceil(geometry_info.psi-0.5),exception);
10062 case 95: /* ContrastStretch */
10069 white_point=(double) image->columns*image->rows;
10070 if (attribute_flag[0] != 0)
10072 flags=ParseGeometry(argument_list[0].string_reference,
10074 black_point=geometry_info.rho;
10075 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10077 if ((flags & PercentValue) != 0)
10079 black_point*=(double) image->columns*image->rows/100.0;
10080 white_point*=(double) image->columns*image->rows/100.0;
10082 white_point=(double) image->columns*image->rows-
10085 if (attribute_flag[1] != 0)
10086 black_point=argument_list[1].real_reference;
10087 if (attribute_flag[2] != 0)
10088 white_point=argument_list[2].real_reference;
10089 if (attribute_flag[4] != 0)
10090 channel=(ChannelType) argument_list[4].integer_reference;
10091 channel_mask=SetImageChannelMask(image,channel);
10092 (void) ContrastStretchImage(image,black_point,white_point,exception);
10093 (void) SetImageChannelMask(image,channel_mask);
10096 case 96: /* Sans0 */
10100 case 97: /* Sans1 */
10104 case 98: /* AdaptiveSharpen */
10106 if (attribute_flag[0] != 0)
10108 flags=ParseGeometry(argument_list[0].string_reference,
10110 if ((flags & SigmaValue) == 0)
10111 geometry_info.sigma=1.0;
10112 if ((flags & XiValue) == 0)
10113 geometry_info.xi=0.0;
10115 if (attribute_flag[1] != 0)
10116 geometry_info.rho=argument_list[1].real_reference;
10117 if (attribute_flag[2] != 0)
10118 geometry_info.sigma=argument_list[2].real_reference;
10119 if (attribute_flag[3] != 0)
10120 geometry_info.xi=argument_list[3].real_reference;
10121 if (attribute_flag[4] != 0)
10122 channel=(ChannelType) argument_list[4].integer_reference;
10123 channel_mask=SetImageChannelMask(image,channel);
10124 image=AdaptiveSharpenImage(image,geometry_info.rho,
10125 geometry_info.sigma,exception);
10126 if (image != (Image *) NULL)
10127 (void) SetImageChannelMask(image,channel_mask);
10130 case 99: /* Transpose */
10132 image=TransposeImage(image,exception);
10135 case 100: /* Tranverse */
10137 image=TransverseImage(image,exception);
10140 case 101: /* AutoOrient */
10142 image=AutoOrientImage(image,image->orientation,exception);
10145 case 102: /* AdaptiveBlur */
10147 if (attribute_flag[0] != 0)
10149 flags=ParseGeometry(argument_list[0].string_reference,
10151 if ((flags & SigmaValue) == 0)
10152 geometry_info.sigma=1.0;
10153 if ((flags & XiValue) == 0)
10154 geometry_info.xi=0.0;
10156 if (attribute_flag[1] != 0)
10157 geometry_info.rho=argument_list[1].real_reference;
10158 if (attribute_flag[2] != 0)
10159 geometry_info.sigma=argument_list[2].real_reference;
10160 if (attribute_flag[3] != 0)
10161 channel=(ChannelType) argument_list[3].integer_reference;
10162 channel_mask=SetImageChannelMask(image,channel);
10163 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10165 if (image != (Image *) NULL)
10166 (void) SetImageChannelMask(image,channel_mask);
10169 case 103: /* Sketch */
10171 if (attribute_flag[0] != 0)
10173 flags=ParseGeometry(argument_list[0].string_reference,
10175 if ((flags & SigmaValue) == 0)
10176 geometry_info.sigma=1.0;
10177 if ((flags & XiValue) == 0)
10178 geometry_info.xi=1.0;
10180 if (attribute_flag[1] != 0)
10181 geometry_info.rho=argument_list[1].real_reference;
10182 if (attribute_flag[2] != 0)
10183 geometry_info.sigma=argument_list[2].real_reference;
10184 if (attribute_flag[3] != 0)
10185 geometry_info.xi=argument_list[3].real_reference;
10186 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10187 geometry_info.xi,exception);
10190 case 104: /* UniqueColors */
10192 image=UniqueImageColors(image,exception);
10195 case 105: /* AdaptiveResize */
10197 if (attribute_flag[0] != 0)
10198 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10199 &geometry,exception);
10200 if (attribute_flag[1] != 0)
10201 geometry.width=argument_list[1].integer_reference;
10202 if (attribute_flag[2] != 0)
10203 geometry.height=argument_list[2].integer_reference;
10204 if (attribute_flag[3] != 0)
10205 image->filter=(FilterTypes) argument_list[4].integer_reference;
10206 if (attribute_flag[4] != 0)
10207 SetImageArtifact(image,"filter:support",
10208 argument_list[4].string_reference);
10209 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10213 case 106: /* ClipMask */
10218 if (attribute_flag[0] == 0)
10220 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10222 goto PerlException;
10224 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10226 (void) NegateImage(mask_image,MagickFalse,exception);
10227 (void) SetImageMask(image,mask_image,exception);
10228 mask_image=DestroyImage(mask_image);
10231 case 107: /* LinearStretch */
10238 white_point=(double) image->columns*image->rows;
10239 if (attribute_flag[0] != 0)
10241 flags=ParseGeometry(argument_list[0].string_reference,
10243 if ((flags & SigmaValue) != 0)
10244 white_point=geometry_info.sigma;
10245 if ((flags & PercentValue) != 0)
10247 black_point*=(double) image->columns*image->rows/100.0;
10248 white_point*=(double) image->columns*image->rows/100.0;
10250 if ((flags & SigmaValue) == 0)
10251 white_point=(double) image->columns*image->rows-black_point;
10253 if (attribute_flag[1] != 0)
10254 black_point=argument_list[1].real_reference;
10255 if (attribute_flag[2] != 0)
10256 white_point=argument_list[2].real_reference;
10257 (void) LinearStretchImage(image,black_point,white_point,exception);
10260 case 108: /* ColorMatrix */
10274 if (attribute_flag[0] == 0)
10276 av=(AV *) argument_list[0].array_reference;
10277 order=(size_t) sqrt(av_len(av)+1);
10278 color_matrix=(double *) AcquireQuantumMemory(order,order*
10279 sizeof(*color_matrix));
10280 if (color_matrix == (double *) NULL)
10282 ThrowPerlException(exception,ResourceLimitFatalError,
10283 "MemoryAllocationFailed",PackageName);
10284 goto PerlException;
10286 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10287 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10288 for ( ; j < (ssize_t) (order*order); j++)
10289 color_matrix[j]=0.0;
10290 kernel_info=AcquireKernelInfo((const char *) NULL);
10291 if (kernel_info == (KernelInfo *) NULL)
10293 kernel_info->width=order;
10294 kernel_info->height=order;
10295 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10296 order*sizeof(*kernel_info->values));
10297 if (kernel_info->values != (MagickRealType *) NULL)
10299 for (i=0; i < (ssize_t) (order*order); i++)
10300 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10301 image=ColorMatrixImage(image,kernel_info,exception);
10303 kernel_info=DestroyKernelInfo(kernel_info);
10304 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10307 case 109: /* Mask */
10312 if (attribute_flag[0] == 0)
10314 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10316 goto PerlException;
10318 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10319 MagickTrue,exception);
10320 (void) NegateImage(mask_image,MagickFalse,exception);
10321 (void) SetImageMask(image,mask_image,exception);
10322 mask_image=DestroyImage(mask_image);
10325 case 110: /* Polaroid */
10336 PixelInterpolateMethod
10339 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10340 (DrawInfo *) NULL);
10341 caption=(char *) NULL;
10342 if (attribute_flag[0] != 0)
10343 caption=InterpretImageProperties(info ? info->image_info :
10344 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10347 if (attribute_flag[1] != 0)
10348 angle=argument_list[1].real_reference;
10349 if (attribute_flag[2] != 0)
10350 (void) CloneString(&draw_info->font,
10351 argument_list[2].string_reference);
10352 if (attribute_flag[3] != 0)
10353 (void) QueryColorCompliance(argument_list[3].string_reference,
10354 AllCompliance,&draw_info->stroke,exception);
10355 if (attribute_flag[4] != 0)
10356 (void) QueryColorCompliance(argument_list[4].string_reference,
10357 AllCompliance,&draw_info->fill,exception);
10358 if (attribute_flag[5] != 0)
10359 draw_info->stroke_width=argument_list[5].real_reference;
10360 if (attribute_flag[6] != 0)
10361 draw_info->pointsize=argument_list[6].real_reference;
10362 if (attribute_flag[7] != 0)
10363 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10364 if (attribute_flag[8] != 0)
10365 (void) QueryColorCompliance(argument_list[8].string_reference,
10366 AllCompliance,&image->background_color,exception);
10367 method=UndefinedInterpolatePixel;
10368 if (attribute_flag[9] != 0)
10369 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10370 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10371 draw_info=DestroyDrawInfo(draw_info);
10372 if (caption != (char *) NULL)
10373 caption=DestroyString(caption);
10376 case 111: /* FloodfillPaint */
10387 draw_info=CloneDrawInfo(info ? info->image_info :
10388 (ImageInfo *) NULL,(DrawInfo *) NULL);
10389 if (attribute_flag[0] != 0)
10390 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10391 &geometry,exception);
10392 if (attribute_flag[1] != 0)
10393 geometry.x=argument_list[1].integer_reference;
10394 if (attribute_flag[2] != 0)
10395 geometry.y=argument_list[2].integer_reference;
10396 if (attribute_flag[3] != 0)
10397 (void) QueryColorCompliance(argument_list[3].string_reference,
10398 AllCompliance,&draw_info->fill,exception);
10399 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10400 geometry.x,geometry.y,&target,exception);
10401 if (attribute_flag[4] != 0)
10402 QueryColorCompliance(argument_list[4].string_reference,
10403 AllCompliance,&target,exception);
10404 if (attribute_flag[5] != 0)
10405 image->fuzz=StringToDoubleInterval(
10406 argument_list[5].string_reference,(double) QuantumRange+1.0);
10407 if (attribute_flag[6] != 0)
10408 channel=(ChannelType) argument_list[6].integer_reference;
10409 invert=MagickFalse;
10410 if (attribute_flag[7] != 0)
10411 invert=(MagickBooleanType) argument_list[7].integer_reference;
10412 channel_mask=SetImageChannelMask(image,channel);
10413 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10414 geometry.y,invert,exception);
10415 (void) SetImageChannelMask(image,channel_mask);
10416 draw_info=DestroyDrawInfo(draw_info);
10419 case 112: /* Distort */
10431 number_coordinates;
10436 if (attribute_flag[0] == 0)
10438 method=UndefinedDistortion;
10439 if (attribute_flag[1] != 0)
10440 method=(DistortImageMethod) argument_list[1].integer_reference;
10441 av=(AV *) argument_list[0].array_reference;
10442 number_coordinates=(size_t) av_len(av)+1;
10443 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10444 sizeof(*coordinates));
10445 if (coordinates == (double *) NULL)
10447 ThrowPerlException(exception,ResourceLimitFatalError,
10448 "MemoryAllocationFailed",PackageName);
10449 goto PerlException;
10451 for (j=0; j < (ssize_t) number_coordinates; j++)
10452 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10453 virtual_pixel=UndefinedVirtualPixelMethod;
10454 if (attribute_flag[2] != 0)
10455 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10456 argument_list[2].integer_reference,exception);
10457 image=DistortImage(image,method,number_coordinates,coordinates,
10458 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10460 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10461 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10463 coordinates=(double *) RelinquishMagickMemory(coordinates);
10466 case 113: /* Clut */
10468 PixelInterpolateMethod
10471 if (attribute_flag[0] == 0)
10473 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10475 goto PerlException;
10477 method=UndefinedInterpolatePixel;
10478 if (attribute_flag[1] != 0)
10479 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10480 if (attribute_flag[2] != 0)
10481 channel=(ChannelType) argument_list[2].integer_reference;
10482 channel_mask=SetImageChannelMask(image,channel);
10483 (void) ClutImage(image,argument_list[0].image_reference,method,
10485 (void) SetImageChannelMask(image,channel_mask);
10488 case 114: /* LiquidRescale */
10490 if (attribute_flag[0] != 0)
10491 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10492 &geometry,exception);
10493 if (attribute_flag[1] != 0)
10494 geometry.width=argument_list[1].integer_reference;
10495 if (attribute_flag[2] != 0)
10496 geometry.height=argument_list[2].integer_reference;
10497 if (attribute_flag[3] == 0)
10498 argument_list[3].real_reference=1.0;
10499 if (attribute_flag[4] == 0)
10500 argument_list[4].real_reference=0.0;
10501 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10502 argument_list[3].real_reference,argument_list[4].real_reference,
10506 case 115: /* EncipherImage */
10508 (void) EncipherImage(image,argument_list[0].string_reference,
10512 case 116: /* DecipherImage */
10514 (void) DecipherImage(image,argument_list[0].string_reference,
10518 case 117: /* Deskew */
10520 geometry_info.rho=QuantumRange/2.0;
10521 if (attribute_flag[0] != 0)
10522 flags=ParseGeometry(argument_list[0].string_reference,
10524 if (attribute_flag[1] != 0)
10525 geometry_info.rho=StringToDoubleInterval(
10526 argument_list[1].string_reference,(double) QuantumRange+1.0);
10527 image=DeskewImage(image,geometry_info.rho,exception);
10530 case 118: /* Remap */
10535 if (attribute_flag[0] == 0)
10537 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10539 goto PerlException;
10541 quantize_info=AcquireQuantizeInfo(info->image_info);
10542 if (attribute_flag[1] != 0)
10543 quantize_info->dither_method=(DitherMethod)
10544 argument_list[1].integer_reference;
10545 (void) RemapImages(quantize_info,image,
10546 argument_list[0].image_reference,exception);
10547 quantize_info=DestroyQuantizeInfo(quantize_info);
10550 case 119: /* SparseColor */
10562 number_coordinates;
10567 if (attribute_flag[0] == 0)
10569 method=UndefinedColorInterpolate;
10570 if (attribute_flag[1] != 0)
10571 method=(SparseColorMethod) argument_list[1].integer_reference;
10572 av=(AV *) argument_list[0].array_reference;
10573 number_coordinates=(size_t) av_len(av)+1;
10574 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10575 sizeof(*coordinates));
10576 if (coordinates == (double *) NULL)
10578 ThrowPerlException(exception,ResourceLimitFatalError,
10579 "MemoryAllocationFailed",PackageName);
10580 goto PerlException;
10582 for (j=0; j < (ssize_t) number_coordinates; j++)
10583 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10584 virtual_pixel=UndefinedVirtualPixelMethod;
10585 if (attribute_flag[2] != 0)
10586 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10587 argument_list[2].integer_reference,exception);
10588 if (attribute_flag[3] != 0)
10589 channel=(ChannelType) argument_list[3].integer_reference;
10590 channel_mask=SetImageChannelMask(image,channel);
10591 image=SparseColorImage(image,method,number_coordinates,coordinates,
10593 if (image != (Image *) NULL)
10594 (void) SetImageChannelMask(image,channel_mask);
10595 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10596 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10598 coordinates=(double *) RelinquishMagickMemory(coordinates);
10601 case 120: /* Function */
10618 if (attribute_flag[0] == 0)
10620 function=UndefinedFunction;
10621 if (attribute_flag[1] != 0)
10622 function=(MagickFunction) argument_list[1].integer_reference;
10623 av=(AV *) argument_list[0].array_reference;
10624 number_parameters=(size_t) av_len(av)+1;
10625 parameters=(double *) AcquireQuantumMemory(number_parameters,
10626 sizeof(*parameters));
10627 if (parameters == (double *) NULL)
10629 ThrowPerlException(exception,ResourceLimitFatalError,
10630 "MemoryAllocationFailed",PackageName);
10631 goto PerlException;
10633 for (j=0; j < (ssize_t) number_parameters; j++)
10634 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10635 virtual_pixel=UndefinedVirtualPixelMethod;
10636 if (attribute_flag[2] != 0)
10637 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10638 argument_list[2].integer_reference,exception);
10639 (void) FunctionImage(image,function,number_parameters,parameters,
10641 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10642 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10644 parameters=(double *) RelinquishMagickMemory(parameters);
10647 case 121: /* SelectiveBlur */
10649 if (attribute_flag[0] != 0)
10651 flags=ParseGeometry(argument_list[0].string_reference,
10653 if ((flags & SigmaValue) == 0)
10654 geometry_info.sigma=1.0;
10655 if ((flags & PercentValue) != 0)
10656 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10658 if (attribute_flag[1] != 0)
10659 geometry_info.rho=argument_list[1].real_reference;
10660 if (attribute_flag[2] != 0)
10661 geometry_info.sigma=argument_list[2].real_reference;
10662 if (attribute_flag[3] != 0)
10663 geometry_info.xi=argument_list[3].integer_reference;;
10664 if (attribute_flag[5] != 0)
10665 channel=(ChannelType) argument_list[5].integer_reference;
10666 channel_mask=SetImageChannelMask(image,channel);
10667 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10668 geometry_info.xi,exception);
10669 if (image != (Image *) NULL)
10670 (void) SetImageChannelMask(image,channel_mask);
10673 case 122: /* HaldClut */
10675 if (attribute_flag[0] == 0)
10677 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10679 goto PerlException;
10681 if (attribute_flag[1] != 0)
10682 channel=(ChannelType) argument_list[1].integer_reference;
10683 channel_mask=SetImageChannelMask(image,channel);
10684 (void) HaldClutImage(image,argument_list[0].image_reference,
10686 (void) SetImageChannelMask(image,channel_mask);
10689 case 123: /* BlueShift */
10691 if (attribute_flag[0] != 0)
10692 (void) ParseGeometry(argument_list[0].string_reference,
10694 image=BlueShiftImage(image,geometry_info.rho,exception);
10697 case 124: /* ForwardFourierTransformImage */
10699 image=ForwardFourierTransformImage(image,
10700 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10704 case 125: /* InverseFourierTransformImage */
10706 image=InverseFourierTransformImage(image,image->next,
10707 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10711 case 126: /* ColorDecisionList */
10713 if (attribute_flag[0] == 0)
10714 argument_list[0].string_reference=(char *) NULL;
10715 (void) ColorDecisionListImage(image,
10716 argument_list[0].string_reference,exception);
10719 case 127: /* AutoGamma */
10721 if (attribute_flag[0] != 0)
10722 channel=(ChannelType) argument_list[0].integer_reference;
10723 channel_mask=SetImageChannelMask(image,channel);
10724 (void) AutoGammaImage(image,exception);
10725 (void) SetImageChannelMask(image,channel_mask);
10728 case 128: /* AutoLevel */
10730 if (attribute_flag[0] != 0)
10731 channel=(ChannelType) argument_list[0].integer_reference;
10732 channel_mask=SetImageChannelMask(image,channel);
10733 (void) AutoLevelImage(image,exception);
10734 (void) SetImageChannelMask(image,channel_mask);
10737 case 129: /* LevelColors */
10743 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10745 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10747 if (attribute_flag[1] != 0)
10748 (void) QueryColorCompliance(
10749 argument_list[1].string_reference,AllCompliance,&black_point,
10751 if (attribute_flag[2] != 0)
10752 (void) QueryColorCompliance(
10753 argument_list[2].string_reference,AllCompliance,&white_point,
10755 if (attribute_flag[3] != 0)
10756 channel=(ChannelType) argument_list[3].integer_reference;
10757 channel_mask=SetImageChannelMask(image,channel);
10758 (void) LevelImageColors(image,&black_point,&white_point,
10759 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10761 (void) SetImageChannelMask(image,channel_mask);
10764 case 130: /* Clamp */
10766 if (attribute_flag[0] != 0)
10767 channel=(ChannelType) argument_list[0].integer_reference;
10768 channel_mask=SetImageChannelMask(image,channel);
10769 (void) ClampImage(image,exception);
10770 (void) SetImageChannelMask(image,channel_mask);
10773 case 131: /* BrightnessContrast */
10781 if (attribute_flag[0] != 0)
10783 flags=ParseGeometry(argument_list[0].string_reference,
10785 brightness=geometry_info.rho;
10786 if ((flags & SigmaValue) == 0)
10787 contrast=geometry_info.sigma;
10789 if (attribute_flag[1] != 0)
10790 brightness=argument_list[1].real_reference;
10791 if (attribute_flag[2] != 0)
10792 contrast=argument_list[2].real_reference;
10793 if (attribute_flag[4] != 0)
10794 channel=(ChannelType) argument_list[4].integer_reference;
10795 channel_mask=SetImageChannelMask(image,channel);
10796 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10797 (void) SetImageChannelMask(image,channel_mask);
10800 case 132: /* Morphology */
10811 if (attribute_flag[0] == 0)
10813 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10814 if (kernel == (KernelInfo *) NULL)
10816 if (attribute_flag[1] != 0)
10817 channel=(ChannelType) argument_list[1].integer_reference;
10818 method=UndefinedMorphology;
10819 if (attribute_flag[2] != 0)
10820 method=argument_list[2].integer_reference;
10822 if (attribute_flag[3] != 0)
10823 iterations=argument_list[3].integer_reference;
10824 channel_mask=SetImageChannelMask(image,channel);
10825 image=MorphologyImage(image,method,iterations,kernel,exception);
10826 if (image != (Image *) NULL)
10827 (void) SetImageChannelMask(image,channel_mask);
10828 kernel=DestroyKernelInfo(kernel);
10831 case 133: /* Mode */
10833 if (attribute_flag[0] != 0)
10835 flags=ParseGeometry(argument_list[0].string_reference,
10837 if ((flags & SigmaValue) == 0)
10838 geometry_info.sigma=1.0;
10840 if (attribute_flag[1] != 0)
10841 geometry_info.rho=argument_list[1].real_reference;
10842 if (attribute_flag[2] != 0)
10843 geometry_info.sigma=argument_list[2].real_reference;
10844 if (attribute_flag[3] != 0)
10845 channel=(ChannelType) argument_list[3].integer_reference;
10846 channel_mask=SetImageChannelMask(image,channel);
10847 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10848 (size_t) geometry_info.sigma,exception);
10849 if (image != (Image *) NULL)
10850 (void) SetImageChannelMask(image,channel_mask);
10853 case 134: /* Statistic */
10858 statistic=UndefinedStatistic;
10859 if (attribute_flag[0] != 0)
10861 flags=ParseGeometry(argument_list[0].string_reference,
10863 if ((flags & SigmaValue) == 0)
10864 geometry_info.sigma=1.0;
10866 if (attribute_flag[1] != 0)
10867 geometry_info.rho=argument_list[1].real_reference;
10868 if (attribute_flag[2] != 0)
10869 geometry_info.sigma=argument_list[2].real_reference;
10870 if (attribute_flag[3] != 0)
10871 channel=(ChannelType) argument_list[3].integer_reference;
10872 if (attribute_flag[4] != 0)
10873 statistic=(StatisticType) argument_list[4].integer_reference;
10874 channel_mask=SetImageChannelMask(image,channel);
10875 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10876 (size_t) geometry_info.sigma,exception);
10877 if (image != (Image *) NULL)
10878 (void) SetImageChannelMask(image,channel_mask);
10881 case 135: /* Perceptible */
10886 epsilon=MagickEpsilon;
10887 if (attribute_flag[0] != 0)
10888 epsilon=argument_list[0].real_reference;
10889 if (attribute_flag[1] != 0)
10890 channel=(ChannelType) argument_list[1].integer_reference;
10891 channel_mask=SetImageChannelMask(image,channel);
10892 (void) PerceptibleImage(image,epsilon,exception);
10893 (void) SetImageChannelMask(image,channel_mask);
10896 case 136: /* Poly */
10907 if (attribute_flag[0] == 0)
10909 if (attribute_flag[1] != 0)
10910 channel=(ChannelType) argument_list[1].integer_reference;
10911 av=(AV *) argument_list[0].array_reference;
10912 number_terms=(size_t) av_len(av);
10913 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
10914 if (terms == (double *) NULL)
10916 ThrowPerlException(exception,ResourceLimitFatalError,
10917 "MemoryAllocationFailed",PackageName);
10918 goto PerlException;
10920 for (j=0; j < av_len(av); j++)
10921 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
10922 image=PolynomialImage(image,number_terms >> 1,terms,exception);
10923 terms=(double *) RelinquishMagickMemory(terms);
10927 if (next != (Image *) NULL)
10928 (void) CatchImageException(next);
10929 if (region_image != (Image *) NULL)
10934 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
10935 region_info.x,region_info.y,exception);
10937 (void) CatchImageException(region_image);
10938 image=DestroyImage(image);
10939 image=region_image;
10941 if (image != (Image *) NULL)
10944 if (next && (next != image))
10946 image->next=next->next;
10947 if (image->next != (Image *) NULL)
10948 image->next->previous=image;
10949 DeleteImageFromRegistry(*pv,next);
10951 sv_setiv(*pv,PTR2IV(image));
10959 if (reference_vector)
10960 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10961 InheritPerlException(exception,perl_exception);
10962 exception=DestroyExceptionInfo(exception);
10963 sv_setiv(perl_exception,(IV) number_images);
10964 SvPOK_on(perl_exception);
10965 ST(0)=sv_2mortal(perl_exception);
10970 ###############################################################################
10978 ###############################################################################
10983 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
11028 PERL_UNUSED_VAR(ref);
11029 PERL_UNUSED_VAR(ix);
11030 exception=AcquireExceptionInfo();
11031 perl_exception=newSVpv("",0);
11034 if (sv_isobject(ST(0)) == 0)
11036 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11038 goto PerlException;
11040 reference=SvRV(ST(0));
11041 hv=SvSTASH(reference);
11043 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11045 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11046 if (image == (Image *) NULL)
11048 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11050 goto PerlException;
11055 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11056 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11057 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11059 for (i=2; i < items; i+=2)
11061 attribute=(char *) SvPV(ST(i-1),na);
11062 switch (*attribute)
11067 if (LocaleCompare(attribute,"background") == 0)
11069 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11070 &montage_info->background_color,exception);
11071 for (next=image; next; next=next->next)
11072 next->background_color=montage_info->background_color;
11075 if (LocaleCompare(attribute,"border") == 0)
11077 montage_info->border_width=SvIV(ST(i));
11080 if (LocaleCompare(attribute,"bordercolor") == 0)
11082 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11083 &montage_info->border_color,exception);
11084 for (next=image; next; next=next->next)
11085 next->border_color=montage_info->border_color;
11088 if (LocaleCompare(attribute,"borderwidth") == 0)
11090 montage_info->border_width=SvIV(ST(i));
11093 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11100 if (LocaleCompare(attribute,"compose") == 0)
11102 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11103 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11106 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11110 for (next=image; next; next=next->next)
11111 next->compose=(CompositeOperator) sp;
11114 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11121 if (LocaleCompare(attribute,"fill") == 0)
11123 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11124 &montage_info->fill,exception);
11127 if (LocaleCompare(attribute,"font") == 0)
11129 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11132 if (LocaleCompare(attribute,"frame") == 0)
11138 if (IsGeometry(p) == MagickFalse)
11140 ThrowPerlException(exception,OptionError,"MissingGeometry",
11144 (void) CloneString(&montage_info->frame,p);
11146 montage_info->frame=(char *) NULL;
11149 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11156 if (LocaleCompare(attribute,"geometry") == 0)
11162 if (IsGeometry(p) == MagickFalse)
11164 ThrowPerlException(exception,OptionError,"MissingGeometry",
11168 (void) CloneString(&montage_info->geometry,p);
11170 montage_info->geometry=(char *) NULL;
11173 if (LocaleCompare(attribute,"gravity") == 0)
11178 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11179 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11182 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11186 montage_info->gravity=(GravityType) in;
11187 for (next=image; next; next=next->next)
11188 next->gravity=(GravityType) in;
11191 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11198 if (LocaleCompare(attribute,"label") == 0)
11200 for (next=image; next; next=next->next)
11201 (void) SetImageProperty(next,"label",InterpretImageProperties(
11202 info ? info->image_info : (ImageInfo *) NULL,next,
11203 SvPV(ST(i),na),exception),exception);
11206 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11213 if (LocaleCompare(attribute,"mattecolor") == 0)
11215 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11216 &montage_info->matte_color,exception);
11217 for (next=image; next; next=next->next)
11218 next->matte_color=montage_info->matte_color;
11221 if (LocaleCompare(attribute,"mode") == 0)
11226 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11227 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11232 ThrowPerlException(exception,OptionError,
11233 "UnrecognizedModeType",SvPV(ST(i),na));
11238 (void) CloneString(&montage_info->frame,"15x15+3+3");
11239 montage_info->shadow=MagickTrue;
11244 montage_info->frame=(char *) NULL;
11245 montage_info->shadow=MagickFalse;
11246 montage_info->border_width=0;
11249 case ConcatenateMode:
11251 montage_info->frame=(char *) NULL;
11252 montage_info->shadow=MagickFalse;
11253 (void) CloneString(&montage_info->geometry,"+0+0");
11254 montage_info->border_width=0;
11259 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11266 if (LocaleCompare(attribute,"pointsize") == 0)
11268 montage_info->pointsize=SvIV(ST(i));
11271 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11278 if (LocaleCompare(attribute,"shadow") == 0)
11280 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11281 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11284 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11288 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11291 if (LocaleCompare(attribute,"stroke") == 0)
11293 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11294 &montage_info->stroke,exception);
11297 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11304 if (LocaleCompare(attribute,"texture") == 0)
11306 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11309 if (LocaleCompare(attribute,"tile") == 0)
11311 char *p=SvPV(ST(i),na);
11312 if (IsGeometry(p) == MagickFalse)
11314 ThrowPerlException(exception,OptionError,"MissingGeometry",
11318 (void) CloneString(&montage_info->tile,p);
11320 montage_info->tile=(char *) NULL;
11323 if (LocaleCompare(attribute,"title") == 0)
11325 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11328 if (LocaleCompare(attribute,"transparent") == 0)
11333 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11334 &transparent_color,exception);
11335 for (next=image; next; next=next->next)
11336 (void) TransparentPaintImage(next,&transparent_color,
11337 TransparentAlpha,MagickFalse,exception);
11340 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11346 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11352 image=MontageImageList(info->image_info,montage_info,image,exception);
11353 montage_info=DestroyMontageInfo(montage_info);
11354 if (image == (Image *) NULL)
11355 goto PerlException;
11356 if (transparent_color.alpha != TransparentAlpha)
11357 for (next=image; next; next=next->next)
11358 (void) TransparentPaintImage(next,&transparent_color,
11359 TransparentAlpha,MagickFalse,exception);
11360 for ( ; image; image=image->next)
11362 AddImageToRegistry(sv,image);
11364 av_push(av,sv_bless(rv,hv));
11367 exception=DestroyExceptionInfo(exception);
11368 ST(0)=av_reference;
11369 SvREFCNT_dec(perl_exception);
11373 InheritPerlException(exception,perl_exception);
11374 exception=DestroyExceptionInfo(exception);
11375 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11376 SvPOK_on(perl_exception);
11377 ST(0)=sv_2mortal(perl_exception);
11382 ###############################################################################
11390 ###############################################################################
11395 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
11433 PERL_UNUSED_VAR(ref);
11434 PERL_UNUSED_VAR(ix);
11435 exception=AcquireExceptionInfo();
11436 perl_exception=newSVpv("",0);
11440 if (sv_isobject(ST(0)) == 0)
11442 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11444 goto PerlException;
11446 reference=SvRV(ST(0));
11447 hv=SvSTASH(reference);
11449 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11451 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11452 if (image == (Image *) NULL)
11454 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11456 goto PerlException;
11458 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11463 for (i=2; i < items; i+=2)
11465 attribute=(char *) SvPV(ST(i-1),na);
11466 switch (*attribute)
11471 if (LocaleCompare(attribute,"frames") == 0)
11473 number_frames=SvIV(ST(i));
11476 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11482 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11488 image=MorphImages(image,number_frames,exception);
11489 if (image == (Image *) NULL)
11490 goto PerlException;
11491 for ( ; image; image=image->next)
11493 AddImageToRegistry(sv,image);
11495 av_push(av,sv_bless(rv,hv));
11498 exception=DestroyExceptionInfo(exception);
11499 ST(0)=av_reference;
11500 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11504 InheritPerlException(exception,perl_exception);
11505 exception=DestroyExceptionInfo(exception);
11506 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11507 SvPOK_on(perl_exception);
11508 ST(0)=sv_2mortal(perl_exception);
11513 ###############################################################################
11521 ###############################################################################
11526 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
11554 PERL_UNUSED_VAR(ref);
11555 PERL_UNUSED_VAR(ix);
11556 exception=AcquireExceptionInfo();
11557 perl_exception=newSVpv("",0);
11559 if (sv_isobject(ST(0)) == 0)
11561 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11563 goto PerlException;
11565 reference=SvRV(ST(0));
11566 hv=SvSTASH(reference);
11567 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11568 if (image == (Image *) NULL)
11570 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11572 goto PerlException;
11574 image=MergeImageLayers(image,MosaicLayer,exception);
11576 Create blessed Perl array for the returned image.
11579 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11581 AddImageToRegistry(sv,image);
11583 av_push(av,sv_bless(rv,hv));
11585 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11586 (void) CopyMagickString(info->image_info->filename,image->filename,
11588 SetImageInfo(info->image_info,0,exception);
11589 exception=DestroyExceptionInfo(exception);
11590 SvREFCNT_dec(perl_exception);
11594 InheritPerlException(exception,perl_exception);
11595 exception=DestroyExceptionInfo(exception);
11596 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11597 SvPOK_on(perl_exception); /* return messages in string context */
11598 ST(0)=sv_2mortal(perl_exception);
11603 ###############################################################################
11611 ###############################################################################
11616 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
11666 PERL_UNUSED_VAR(ref);
11667 PERL_UNUSED_VAR(ix);
11668 exception=AcquireExceptionInfo();
11669 perl_exception=newSVpv("",0);
11670 package_info=(struct PackageInfo *) NULL;
11671 ac=(items < 2) ? 1 : items-1;
11672 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11674 length=(STRLEN *) NULL;
11675 if (list == (char **) NULL)
11677 ThrowPerlException(exception,ResourceLimitError,
11678 "MemoryAllocationFailed",PackageName);
11679 goto PerlException;
11682 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11683 if (length == (STRLEN *) NULL)
11685 ThrowPerlException(exception,ResourceLimitError,
11686 "MemoryAllocationFailed",PackageName);
11687 goto PerlException;
11689 if (sv_isobject(ST(0)) == 0)
11691 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11693 goto PerlException;
11695 reference=SvRV(ST(0));
11696 if (SvTYPE(reference) != SVt_PVAV)
11698 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11700 goto PerlException;
11702 av=(AV *) reference;
11703 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11705 package_info=ClonePackageInfo(info,exception);
11708 *list=(char *) (*package_info->image_info->filename ?
11709 package_info->image_info->filename : "XC:black");
11711 for (n=0, i=0; i < ac; i++)
11713 list[n]=(char *) SvPV(ST(i+1),length[n]);
11714 if ((items >= 3) && strEQcase(list[n],"blob"))
11720 blob=(void *) (SvPV(ST(i+1),length[n]));
11721 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11723 if ((items >= 3) && strEQcase(list[n],"filename"))
11725 if ((items >= 3) && strEQcase(list[n],"file"))
11734 io_info=IoIFP(sv_2io(ST(i+1)));
11735 if (io_info == (PerlIO *) NULL)
11737 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11741 file=PerlIO_findFILE(io_info);
11742 if (file == (FILE *) NULL)
11744 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11748 SetImageInfoFile(package_info->image_info,file);
11750 if ((items >= 3) && strEQcase(list[n],"magick"))
11754 list[n]=(char *) NULL;
11756 status=ExpandFilenames(&n,&list);
11757 if (status == MagickFalse)
11759 ThrowPerlException(exception,ResourceLimitError,
11760 "MemoryAllocationFailed",PackageName);
11761 goto PerlException;
11764 for (i=0; i < n; i++)
11766 (void) CopyMagickString(package_info->image_info->filename,list[i],
11768 image=PingImage(package_info->image_info,exception);
11769 if (image == (Image *) NULL)
11771 if ((package_info->image_info->file != (FILE *) NULL) ||
11772 (package_info->image_info->blob != (void *) NULL))
11773 DisassociateImageStream(image);
11774 count+=GetImageListLength(image);
11775 EXTEND(sp,4*count);
11776 for (next=image; next; next=next->next)
11778 PUSHs(sv_2mortal(newSViv(next->columns)));
11779 PUSHs(sv_2mortal(newSViv(next->rows)));
11780 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11781 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11783 image=DestroyImageList(image);
11788 for (i=0; i < n; i++)
11789 if (list[i] != (char *) NULL)
11790 for (p=keep; list[i] != *p++; )
11793 list[i]=(char *) RelinquishMagickMemory(list[i]);
11798 if (package_info != (struct PackageInfo *) NULL)
11799 DestroyPackageInfo(package_info);
11800 if (list && (list != keep))
11801 list=(char **) RelinquishMagickMemory(list);
11803 keep=(char **) RelinquishMagickMemory(keep);
11805 length=(STRLEN *) RelinquishMagickMemory(length);
11806 InheritPerlException(exception,perl_exception);
11807 exception=DestroyExceptionInfo(exception);
11808 SvREFCNT_dec(perl_exception); /* throw away all errors */
11812 ###############################################################################
11820 ###############################################################################
11825 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
11858 PERL_UNUSED_VAR(ref);
11859 PERL_UNUSED_VAR(ix);
11860 exception=AcquireExceptionInfo();
11861 perl_exception=newSVpv("",0);
11864 if (sv_isobject(ST(0)) == 0)
11866 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11868 goto PerlException;
11870 reference=SvRV(ST(0));
11871 hv=SvSTASH(reference);
11873 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11875 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11876 if (image == (Image *) NULL)
11878 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11880 goto PerlException;
11882 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11883 preview_type=GammaPreview;
11885 preview_type=(PreviewType)
11886 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11887 for ( ; image; image=image->next)
11889 preview_image=PreviewImage(image,preview_type,exception);
11890 if (preview_image == (Image *) NULL)
11891 goto PerlException;
11892 AddImageToRegistry(sv,preview_image);
11894 av_push(av,sv_bless(rv,hv));
11897 exception=DestroyExceptionInfo(exception);
11898 ST(0)=av_reference;
11899 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11903 InheritPerlException(exception,perl_exception);
11904 exception=DestroyExceptionInfo(exception);
11905 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11906 SvPOK_on(perl_exception);
11907 ST(0)=sv_2mortal(perl_exception);
11912 ###############################################################################
11916 # Q u e r y C o l o r #
11920 ###############################################################################
11924 QueryColor(ref,...)
11925 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
11945 PERL_UNUSED_VAR(ref);
11946 PERL_UNUSED_VAR(ix);
11947 exception=AcquireExceptionInfo();
11948 perl_exception=newSVpv("",0);
11957 colorlist=GetColorInfoList("*",&colors,exception);
11959 for (i=0; i < (ssize_t) colors; i++)
11961 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11963 colorlist=(const ColorInfo **)
11964 RelinquishMagickMemory((ColorInfo **) colorlist);
11965 goto PerlException;
11967 EXTEND(sp,5*items);
11968 for (i=1; i < items; i++)
11970 name=(char *) SvPV(ST(i),na);
11971 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11976 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11977 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11978 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11979 if (color.colorspace == CMYKColorspace)
11980 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11981 if (color.alpha_trait == BlendPixelTrait)
11982 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11986 InheritPerlException(exception,perl_exception);
11987 exception=DestroyExceptionInfo(exception);
11988 SvREFCNT_dec(perl_exception);
11992 ###############################################################################
11996 # Q u e r y C o l o r N a m e #
12000 ###############################################################################
12004 QueryColorname(ref,...)
12005 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
12014 message[MaxTextExtent];
12033 *reference; /* reference is the SV* of ref=SvIV(reference) */
12035 PERL_UNUSED_VAR(ref);
12036 PERL_UNUSED_VAR(ix);
12037 exception=AcquireExceptionInfo();
12038 perl_exception=newSVpv("",0);
12039 reference=SvRV(ST(0));
12040 av=(AV *) reference;
12041 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12043 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12044 if (image == (Image *) NULL)
12046 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12048 goto PerlException;
12051 for (i=1; i < items; i++)
12053 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12055 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12057 PUSHs(sv_2mortal(newSVpv(message,0)));
12061 InheritPerlException(exception,perl_exception);
12062 exception=DestroyExceptionInfo(exception);
12063 SvREFCNT_dec(perl_exception);
12067 ###############################################################################
12071 # Q u e r y F o n t #
12075 ###############################################################################
12080 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
12087 message[MaxTextExtent];
12098 volatile const TypeInfo
12101 PERL_UNUSED_VAR(ref);
12102 PERL_UNUSED_VAR(ix);
12103 exception=AcquireExceptionInfo();
12104 perl_exception=newSVpv("",0);
12113 typelist=GetTypeInfoList("*",&types,exception);
12115 for (i=0; i < (ssize_t) types; i++)
12117 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12119 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12121 goto PerlException;
12123 EXTEND(sp,10*items);
12124 for (i=1; i < items; i++)
12126 name=(char *) SvPV(ST(i),na);
12127 type_info=GetTypeInfo(name,exception);
12128 if (type_info == (TypeInfo *) NULL)
12133 if (type_info->name == (char *) NULL)
12136 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12137 if (type_info->description == (char *) NULL)
12140 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12141 if (type_info->family == (char *) NULL)
12144 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12145 if (type_info->style == UndefinedStyle)
12148 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12149 type_info->style),0)));
12150 if (type_info->stretch == UndefinedStretch)
12153 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12154 type_info->stretch),0)));
12155 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12156 type_info->weight);
12157 PUSHs(sv_2mortal(newSVpv(message,0)));
12158 if (type_info->encoding == (char *) NULL)
12161 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12162 if (type_info->foundry == (char *) NULL)
12165 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12166 if (type_info->format == (char *) NULL)
12169 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12170 if (type_info->metrics == (char *) NULL)
12173 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12174 if (type_info->glyphs == (char *) NULL)
12177 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12181 InheritPerlException(exception,perl_exception);
12182 exception=DestroyExceptionInfo(exception);
12183 SvREFCNT_dec(perl_exception);
12187 ###############################################################################
12191 # Q u e r y F o n t M e t r i c s #
12195 ###############################################################################
12199 QueryFontMetrics(ref,...)
12200 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
12202 queryfontmetrics = 1
12249 *reference; /* reference is the SV* of ref=SvIV(reference) */
12254 PERL_UNUSED_VAR(ref);
12255 PERL_UNUSED_VAR(ix);
12256 exception=AcquireExceptionInfo();
12257 package_info=(struct PackageInfo *) NULL;
12258 perl_exception=newSVpv("",0);
12259 reference=SvRV(ST(0));
12260 av=(AV *) reference;
12261 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12263 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12264 if (image == (Image *) NULL)
12266 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12268 goto PerlException;
12270 package_info=ClonePackageInfo(info,exception);
12271 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12272 CloneString(&draw_info->text,"");
12273 current=draw_info->affine;
12274 GetAffineMatrix(&affine);
12277 EXTEND(sp,7*items);
12278 for (i=2; i < items; i+=2)
12280 attribute=(char *) SvPV(ST(i-1),na);
12281 switch (*attribute)
12286 if (LocaleCompare(attribute,"antialias") == 0)
12288 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12292 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12296 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12299 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12306 if (LocaleCompare(attribute,"density") == 0)
12308 CloneString(&draw_info->density,SvPV(ST(i),na));
12311 if (LocaleCompare(attribute,"direction") == 0)
12313 draw_info->direction=(DirectionType) ParseCommandOption(
12314 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12317 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12324 if (LocaleCompare(attribute,"encoding") == 0)
12326 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12336 if (LocaleCompare(attribute,"family") == 0)
12338 CloneString(&draw_info->family,SvPV(ST(i),na));
12341 if (LocaleCompare(attribute,"fill") == 0)
12344 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12345 &draw_info->fill,exception);
12348 if (LocaleCompare(attribute,"font") == 0)
12350 CloneString(&draw_info->font,SvPV(ST(i),na));
12353 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12360 if (LocaleCompare(attribute,"geometry") == 0)
12362 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12365 if (LocaleCompare(attribute,"gravity") == 0)
12367 draw_info->gravity=(GravityType) ParseCommandOption(
12368 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12371 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12378 if (LocaleCompare(attribute,"interline-spacing") == 0)
12380 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12381 draw_info->interline_spacing=geometry_info.rho;
12384 if (LocaleCompare(attribute,"interword-spacing") == 0)
12386 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12387 draw_info->interword_spacing=geometry_info.rho;
12390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12397 if (LocaleCompare(attribute,"kerning") == 0)
12399 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12400 draw_info->kerning=geometry_info.rho;
12403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12410 if (LocaleCompare(attribute,"pointsize") == 0)
12412 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12413 draw_info->pointsize=geometry_info.rho;
12416 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12423 if (LocaleCompare(attribute,"rotate") == 0)
12425 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12426 affine.rx=geometry_info.rho;
12427 affine.ry=geometry_info.sigma;
12428 if ((flags & SigmaValue) == 0)
12429 affine.ry=affine.rx;
12432 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12439 if (LocaleCompare(attribute,"scale") == 0)
12441 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12442 affine.sx=geometry_info.rho;
12443 affine.sy=geometry_info.sigma;
12444 if ((flags & SigmaValue) == 0)
12445 affine.sy=affine.sx;
12448 if (LocaleCompare(attribute,"skew") == 0)
12454 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12455 x_angle=geometry_info.rho;
12456 y_angle=geometry_info.sigma;
12457 if ((flags & SigmaValue) == 0)
12459 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12460 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12463 if (LocaleCompare(attribute,"stroke") == 0)
12466 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12467 &draw_info->stroke,exception);
12470 if (LocaleCompare(attribute,"style") == 0)
12472 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12476 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12480 draw_info->style=(StyleType) type;
12483 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12490 if (LocaleCompare(attribute,"text") == 0)
12492 CloneString(&draw_info->text,SvPV(ST(i),na));
12495 if (LocaleCompare(attribute,"translate") == 0)
12497 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12498 affine.tx=geometry_info.rho;
12499 affine.ty=geometry_info.sigma;
12500 if ((flags & SigmaValue) == 0)
12501 affine.ty=affine.tx;
12504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12511 if (LocaleCompare(attribute,"weight") == 0)
12513 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12514 draw_info->weight=(size_t) geometry_info.rho;
12517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12524 if (LocaleCompare(attribute,"x") == 0)
12526 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12527 x=geometry_info.rho;
12530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12537 if (LocaleCompare(attribute,"y") == 0)
12539 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12540 y=geometry_info.rho;
12543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12555 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12556 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12557 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12558 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12559 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12560 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12561 if (draw_info->geometry == (char *) NULL)
12563 draw_info->geometry=AcquireString((char *) NULL);
12564 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12565 "%.15g,%.15g",x,y);
12567 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12568 (void) CatchImageException(image);
12569 if (status == MagickFalse)
12573 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12574 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12575 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12576 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12577 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12578 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12579 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12580 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12581 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12582 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12583 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12584 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12585 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12587 draw_info=DestroyDrawInfo(draw_info);
12590 if (package_info != (struct PackageInfo *) NULL)
12591 DestroyPackageInfo(package_info);
12592 InheritPerlException(exception,perl_exception);
12593 exception=DestroyExceptionInfo(exception);
12594 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12598 ###############################################################################
12602 # 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 #
12606 ###############################################################################
12610 QueryMultilineFontMetrics(ref,...)
12611 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
12613 querymultilinefontmetrics = 1
12660 *reference; /* reference is the SV* of ref=SvIV(reference) */
12665 PERL_UNUSED_VAR(ref);
12666 PERL_UNUSED_VAR(ix);
12667 exception=AcquireExceptionInfo();
12668 package_info=(struct PackageInfo *) NULL;
12669 perl_exception=newSVpv("",0);
12670 reference=SvRV(ST(0));
12671 av=(AV *) reference;
12672 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12674 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12675 if (image == (Image *) NULL)
12677 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12679 goto PerlException;
12681 package_info=ClonePackageInfo(info,exception);
12682 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12683 CloneString(&draw_info->text,"");
12684 current=draw_info->affine;
12685 GetAffineMatrix(&affine);
12688 EXTEND(sp,7*items);
12689 for (i=2; i < items; i+=2)
12691 attribute=(char *) SvPV(ST(i-1),na);
12692 switch (*attribute)
12697 if (LocaleCompare(attribute,"antialias") == 0)
12699 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12703 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12707 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12710 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12717 if (LocaleCompare(attribute,"density") == 0)
12719 CloneString(&draw_info->density,SvPV(ST(i),na));
12722 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12729 if (LocaleCompare(attribute,"encoding") == 0)
12731 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12734 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12741 if (LocaleCompare(attribute,"family") == 0)
12743 CloneString(&draw_info->family,SvPV(ST(i),na));
12746 if (LocaleCompare(attribute,"fill") == 0)
12749 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12750 &draw_info->fill,exception);
12753 if (LocaleCompare(attribute,"font") == 0)
12755 CloneString(&draw_info->font,SvPV(ST(i),na));
12758 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12765 if (LocaleCompare(attribute,"geometry") == 0)
12767 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12770 if (LocaleCompare(attribute,"gravity") == 0)
12772 draw_info->gravity=(GravityType) ParseCommandOption(
12773 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12783 if (LocaleCompare(attribute,"pointsize") == 0)
12785 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12786 draw_info->pointsize=geometry_info.rho;
12789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12796 if (LocaleCompare(attribute,"rotate") == 0)
12798 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12799 affine.rx=geometry_info.rho;
12800 affine.ry=geometry_info.sigma;
12801 if ((flags & SigmaValue) == 0)
12802 affine.ry=affine.rx;
12805 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12812 if (LocaleCompare(attribute,"scale") == 0)
12814 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12815 affine.sx=geometry_info.rho;
12816 affine.sy=geometry_info.sigma;
12817 if ((flags & SigmaValue) == 0)
12818 affine.sy=affine.sx;
12821 if (LocaleCompare(attribute,"skew") == 0)
12827 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12828 x_angle=geometry_info.rho;
12829 y_angle=geometry_info.sigma;
12830 if ((flags & SigmaValue) == 0)
12832 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12833 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12836 if (LocaleCompare(attribute,"stroke") == 0)
12839 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12840 &draw_info->stroke,exception);
12843 if (LocaleCompare(attribute,"style") == 0)
12845 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12849 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12853 draw_info->style=(StyleType) type;
12856 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12863 if (LocaleCompare(attribute,"text") == 0)
12865 CloneString(&draw_info->text,SvPV(ST(i),na));
12868 if (LocaleCompare(attribute,"translate") == 0)
12870 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12871 affine.tx=geometry_info.rho;
12872 affine.ty=geometry_info.sigma;
12873 if ((flags & SigmaValue) == 0)
12874 affine.ty=affine.tx;
12877 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12884 if (LocaleCompare(attribute,"weight") == 0)
12886 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12887 draw_info->weight=(size_t) geometry_info.rho;
12890 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12897 if (LocaleCompare(attribute,"x") == 0)
12899 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12900 x=geometry_info.rho;
12903 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12910 if (LocaleCompare(attribute,"y") == 0)
12912 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12913 y=geometry_info.rho;
12916 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12922 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12928 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12929 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12930 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12931 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12932 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12933 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12934 if (draw_info->geometry == (char *) NULL)
12936 draw_info->geometry=AcquireString((char *) NULL);
12937 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12938 "%.15g,%.15g",x,y);
12940 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12941 (void) CatchException(exception);
12942 if (status == MagickFalse)
12946 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12947 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12948 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12949 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12950 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12951 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12952 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12953 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12954 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12955 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12956 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12957 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12958 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12960 draw_info=DestroyDrawInfo(draw_info);
12963 if (package_info != (struct PackageInfo *) NULL)
12964 DestroyPackageInfo(package_info);
12965 InheritPerlException(exception,perl_exception);
12966 exception=DestroyExceptionInfo(exception);
12967 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12971 ###############################################################################
12975 # Q u e r y F o r m a t #
12979 ###############################################################################
12983 QueryFormat(ref,...)
12984 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13001 volatile const MagickInfo
13004 PERL_UNUSED_VAR(ref);
13005 PERL_UNUSED_VAR(ix);
13006 exception=AcquireExceptionInfo();
13007 perl_exception=newSVpv("",0);
13011 format[MaxTextExtent];
13019 format_list=GetMagickInfoList("*",&types,exception);
13021 for (i=0; i < (ssize_t) types; i++)
13023 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13024 LocaleLower(format);
13025 PUSHs(sv_2mortal(newSVpv(format,0)));
13027 format_list=(const MagickInfo **)
13028 RelinquishMagickMemory((MagickInfo *) format_list);
13029 goto PerlException;
13031 EXTEND(sp,8*items);
13032 for (i=1; i < items; i++)
13034 name=(char *) SvPV(ST(i),na);
13035 magick_info=GetMagickInfo(name,exception);
13036 if (magick_info == (const MagickInfo *) NULL)
13041 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13042 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13043 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13044 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13045 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13046 if (magick_info->description == (char *) NULL)
13049 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13050 if (magick_info->module == (char *) NULL)
13053 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13057 InheritPerlException(exception,perl_exception);
13058 exception=DestroyExceptionInfo(exception);
13059 SvREFCNT_dec(perl_exception);
13063 ###############################################################################
13067 # Q u e r y O p t i o n #
13071 ###############################################################################
13075 QueryOption(ref,...)
13076 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13097 PERL_UNUSED_VAR(ref);
13098 PERL_UNUSED_VAR(ix);
13099 exception=AcquireExceptionInfo();
13100 perl_exception=newSVpv("",0);
13101 EXTEND(sp,8*items);
13102 for (i=1; i < items; i++)
13104 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13106 options=GetCommandOptions((CommandOption) option);
13107 if (options == (char **) NULL)
13111 for (j=0; options[j] != (char *) NULL; j++)
13112 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13113 options=DestroyStringList(options);
13117 InheritPerlException(exception,perl_exception);
13118 exception=DestroyExceptionInfo(exception);
13119 SvREFCNT_dec(perl_exception);
13123 ###############################################################################
13131 ###############################################################################
13136 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13183 *perl_exception, /* Perl variable for storing messages */
13188 PERL_UNUSED_VAR(ref);
13189 PERL_UNUSED_VAR(ix);
13190 exception=AcquireExceptionInfo();
13191 perl_exception=newSVpv("",0);
13193 package_info=(struct PackageInfo *) NULL;
13195 ac=(items < 2) ? 1 : items-1;
13196 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13198 length=(STRLEN *) NULL;
13199 if (list == (char **) NULL)
13201 ThrowPerlException(exception,ResourceLimitError,
13202 "MemoryAllocationFailed",PackageName);
13203 goto PerlException;
13205 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13206 if (length == (STRLEN *) NULL)
13208 ThrowPerlException(exception,ResourceLimitError,
13209 "MemoryAllocationFailed",PackageName);
13210 goto PerlException;
13212 if (sv_isobject(ST(0)) == 0)
13214 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13216 goto PerlException;
13218 reference=SvRV(ST(0));
13219 hv=SvSTASH(reference);
13220 if (SvTYPE(reference) != SVt_PVAV)
13222 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13224 goto PerlException;
13226 av=(AV *) reference;
13227 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13229 package_info=ClonePackageInfo(info,exception);
13232 *list=(char *) (*package_info->image_info->filename ?
13233 package_info->image_info->filename : "XC:black");
13235 for (n=0, i=0; i < ac; i++)
13237 list[n]=(char *) SvPV(ST(i+1),length[n]);
13238 if ((items >= 3) && strEQcase(list[n],"blob"))
13244 blob=(void *) (SvPV(ST(i+1),length[n]));
13245 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13247 if ((items >= 3) && strEQcase(list[n],"filename"))
13249 if ((items >= 3) && strEQcase(list[n],"file"))
13258 io_info=IoIFP(sv_2io(ST(i+1)));
13259 if (io_info == (PerlIO *) NULL)
13261 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13265 file=PerlIO_findFILE(io_info);
13266 if (file == (FILE *) NULL)
13268 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13272 SetImageInfoFile(package_info->image_info,file);
13274 if ((items >= 3) && strEQcase(list[n],"magick"))
13278 list[n]=(char *) NULL;
13280 status=ExpandFilenames(&n,&list);
13281 if (status == MagickFalse)
13283 ThrowPerlException(exception,ResourceLimitError,
13284 "MemoryAllocationFailed",PackageName);
13285 goto PerlException;
13288 for (i=0; i < n; i++)
13290 if ((package_info->image_info->file == (FILE *) NULL) &&
13291 (package_info->image_info->blob == (void *) NULL))
13292 image=ReadImages(package_info->image_info,list[i],exception);
13295 image=ReadImages(package_info->image_info,
13296 package_info->image_info->filename,exception);
13297 if (image != (Image *) NULL)
13298 DisassociateImageStream(image);
13300 if (image == (Image *) NULL)
13302 for ( ; image; image=image->next)
13304 AddImageToRegistry(sv,image);
13306 av_push(av,sv_bless(rv,hv));
13314 for (i=0; i < n; i++)
13315 if (list[i] != (char *) NULL)
13316 for (p=keep; list[i] != *p++; )
13317 if (*p == (char *) NULL)
13319 list[i]=(char *) RelinquishMagickMemory(list[i]);
13324 if (package_info != (struct PackageInfo *) NULL)
13325 DestroyPackageInfo(package_info);
13326 if (list && (list != keep))
13327 list=(char **) RelinquishMagickMemory(list);
13329 keep=(char **) RelinquishMagickMemory(keep);
13331 length=(STRLEN *) RelinquishMagickMemory(length);
13332 InheritPerlException(exception,perl_exception);
13333 exception=DestroyExceptionInfo(exception);
13334 sv_setiv(perl_exception,(IV) number_images);
13335 SvPOK_on(perl_exception);
13336 ST(0)=sv_2mortal(perl_exception);
13341 ###############################################################################
13349 ###############################################################################
13354 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13377 PERL_UNUSED_VAR(ref);
13378 PERL_UNUSED_VAR(ix);
13379 exception=AcquireExceptionInfo();
13380 perl_exception=newSVpv("",0);
13381 reference=SvRV(ST(0));
13382 av=(AV *) reference;
13383 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13385 for (i=1; i < items; i++)
13386 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13387 SvPV(ST(i),na),exception);
13388 InheritPerlException(exception,perl_exception);
13389 exception=DestroyExceptionInfo(exception);
13390 SvREFCNT_dec(perl_exception); /* throw away all errors */
13394 ###############################################################################
13402 ###############################################################################
13407 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13430 *reference; /* reference is the SV* of ref=SvIV(reference) */
13432 PERL_UNUSED_VAR(ref);
13433 PERL_UNUSED_VAR(ix);
13434 exception=AcquireExceptionInfo();
13435 perl_exception=newSVpv("",0);
13436 if (sv_isobject(ST(0)) == 0)
13438 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13440 goto PerlException;
13442 reference=SvRV(ST(0));
13443 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13445 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13447 for (i=2; i < items; i+=2)
13448 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13451 InheritPerlException(exception,perl_exception);
13452 exception=DestroyExceptionInfo(exception);
13453 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13454 SvPOK_on(perl_exception);
13455 ST(0)=sv_2mortal(perl_exception);
13460 ###############################################################################
13464 # S e t P i x e l #
13468 ###############################################################################
13473 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13515 *reference; /* reference is the SV* of ref=SvIV(reference) */
13517 PERL_UNUSED_VAR(ref);
13518 PERL_UNUSED_VAR(ix);
13519 exception=AcquireExceptionInfo();
13520 perl_exception=newSVpv("",0);
13521 reference=SvRV(ST(0));
13522 av=(AV *) reference;
13523 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13525 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13526 if (image == (Image *) NULL)
13528 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13530 goto PerlException;
13533 normalize=MagickTrue;
13536 region.width=image->columns;
13539 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13540 channel=DefaultChannels;
13541 for (i=2; i < items; i+=2)
13543 attribute=(char *) SvPV(ST(i-1),na);
13544 switch (*attribute)
13549 if (LocaleCompare(attribute,"channel") == 0)
13554 option=ParseChannelOption(SvPV(ST(i),na));
13557 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13561 channel=(ChannelType) option;
13564 if (LocaleCompare(attribute,"color") == 0)
13566 if (SvTYPE(ST(i)) != SVt_RV)
13569 message[MaxTextExtent];
13571 (void) FormatLocaleString(message,MaxTextExtent,
13572 "invalid %.60s value",attribute);
13573 ThrowPerlException(exception,OptionError,message,
13576 av=(AV *) SvRV(ST(i));
13579 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13586 if (LocaleCompare(attribute,"geometry") == 0)
13588 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13598 if (LocaleCompare(attribute,"normalize") == 0)
13600 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13604 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13608 normalize=option != 0 ? MagickTrue : MagickFalse;
13611 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13618 if (LocaleCompare(attribute,"x") == 0)
13620 region.x=SvIV(ST(i));
13623 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13630 if (LocaleCompare(attribute,"y") == 0)
13632 region.y=SvIV(ST(i));
13635 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13641 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13647 (void) SetImageStorageClass(image,DirectClass,exception);
13648 channel_mask=SetImageChannelMask(image,channel);
13649 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13650 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13651 (SvTYPE(av) != SVt_PVAV))
13663 if (normalize != MagickFalse)
13664 scale=QuantumRange;
13665 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13668 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13669 av_fetch(av,i,0)))),q);
13672 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13675 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13676 av_fetch(av,i,0)))),q);
13679 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13682 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13683 av_fetch(av,i,0)))),q);
13686 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13687 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13689 SetPixelBlack(image,ClampToQuantum(scale*
13690 SvNV(*(av_fetch(av,i,0)))),q);
13693 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13696 SetPixelAlpha(image,ClampToQuantum(scale*
13697 SvNV(*(av_fetch(av,i,0)))),q);
13700 (void) SyncAuthenticPixels(image,exception);
13702 (void) SetImageChannelMask(image,channel_mask);
13705 InheritPerlException(exception,perl_exception);
13706 exception=DestroyExceptionInfo(exception);
13707 SvREFCNT_dec(perl_exception);
13711 ###############################################################################
13719 ###############################################################################
13724 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13763 PERL_UNUSED_VAR(ref);
13764 PERL_UNUSED_VAR(ix);
13765 exception=AcquireExceptionInfo();
13766 perl_exception=newSVpv("",0);
13770 if (sv_isobject(ST(0)) == 0)
13772 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13774 goto PerlException;
13776 reference=SvRV(ST(0));
13777 hv=SvSTASH(reference);
13779 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13781 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13782 if (image == (Image *) NULL)
13784 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13786 goto PerlException;
13788 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13794 for (i=2; i < items; i+=2)
13796 attribute=(char *) SvPV(ST(i-1),na);
13797 switch (*attribute)
13802 if (LocaleCompare(attribute,"offset") == 0)
13804 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13807 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13814 if (LocaleCompare(attribute,"stack") == 0)
13816 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13820 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13826 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13832 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13838 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13840 if (image == (Image *) NULL)
13841 goto PerlException;
13842 for ( ; image; image=image->next)
13844 AddImageToRegistry(sv,image);
13846 av_push(av,sv_bless(rv,hv));
13849 exception=DestroyExceptionInfo(exception);
13850 ST(0)=av_reference;
13851 SvREFCNT_dec(perl_exception);
13855 InheritPerlException(exception,perl_exception);
13856 exception=DestroyExceptionInfo(exception);
13857 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13858 SvPOK_on(perl_exception);
13859 ST(0)=sv_2mortal(perl_exception);
13864 ###############################################################################
13868 # S t a t i s t i c s #
13872 ###############################################################################
13876 Statistics(ref,...)
13877 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
13879 StatisticsImage = 1
13881 statisticsimage = 3
13884 #define ChannelStatistics(channel) \
13886 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13887 (double) channel_statistics[channel].depth); \
13888 PUSHs(sv_2mortal(newSVpv(message,0))); \
13889 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13890 channel_statistics[channel].minima/scale); \
13891 PUSHs(sv_2mortal(newSVpv(message,0))); \
13892 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13893 channel_statistics[channel].maxima/scale); \
13894 PUSHs(sv_2mortal(newSVpv(message,0))); \
13895 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13896 channel_statistics[channel].mean/scale); \
13897 PUSHs(sv_2mortal(newSVpv(message,0))); \
13898 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13899 channel_statistics[channel].standard_deviation/scale); \
13900 PUSHs(sv_2mortal(newSVpv(message,0))); \
13901 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13902 channel_statistics[channel].kurtosis); \
13903 PUSHs(sv_2mortal(newSVpv(message,0))); \
13904 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13905 channel_statistics[channel].skewness); \
13906 PUSHs(sv_2mortal(newSVpv(message,0))); \
13913 message[MaxTextExtent];
13916 *channel_statistics;
13937 PERL_UNUSED_VAR(ref);
13938 PERL_UNUSED_VAR(ix);
13939 exception=AcquireExceptionInfo();
13940 perl_exception=newSVpv("",0);
13942 if (sv_isobject(ST(0)) == 0)
13944 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13946 goto PerlException;
13948 reference=SvRV(ST(0));
13951 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13952 if (image == (Image *) NULL)
13954 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13956 goto PerlException;
13958 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13960 for ( ; image; image=image->next)
13962 channel_statistics=GetImageStatistics(image,exception);
13963 if (channel_statistics == (ChannelStatistics *) NULL)
13966 EXTEND(sp,35*count);
13967 scale=(double) QuantumRange;
13968 ChannelStatistics(RedChannel);
13969 ChannelStatistics(GreenChannel);
13970 ChannelStatistics(BlueChannel);
13971 if (image->colorspace == CMYKColorspace)
13972 ChannelStatistics(BlackChannel);
13973 if (image->alpha_trait == BlendPixelTrait)
13974 ChannelStatistics(AlphaChannel);
13975 channel_statistics=(ChannelStatistics *)
13976 RelinquishMagickMemory(channel_statistics);
13980 InheritPerlException(exception,perl_exception);
13981 exception=DestroyExceptionInfo(exception);
13982 SvREFCNT_dec(perl_exception);
13986 ###############################################################################
13990 # S y n c A u t h e n t i c P i x e l s #
13994 ###############################################################################
13998 SyncAuthenticPixels(ref,...)
13999 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14001 Syncauthenticpixels = 1
14002 SyncImagePixels = 2
14003 syncimagepixels = 3
14022 PERL_UNUSED_VAR(ref);
14023 PERL_UNUSED_VAR(ix);
14024 exception=AcquireExceptionInfo();
14025 perl_exception=newSVpv("",0);
14026 if (sv_isobject(ST(0)) == 0)
14028 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14030 goto PerlException;
14033 reference=SvRV(ST(0));
14034 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14035 if (image == (Image *) NULL)
14037 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14039 goto PerlException;
14042 status=SyncAuthenticPixels(image,exception);
14043 if (status != MagickFalse)
14047 InheritPerlException(exception,perl_exception);
14048 exception=DestroyExceptionInfo(exception);
14049 SvREFCNT_dec(perl_exception); /* throw away all errors */
14053 ###############################################################################
14057 # T r a n s f o r m #
14061 ###############################################################################
14066 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
14104 PERL_UNUSED_VAR(ref);
14105 PERL_UNUSED_VAR(ix);
14106 exception=AcquireExceptionInfo();
14107 perl_exception=newSVpv("",0);
14111 if (sv_isobject(ST(0)) == 0)
14113 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14115 goto PerlException;
14117 reference=SvRV(ST(0));
14118 hv=SvSTASH(reference);
14120 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14122 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14123 if (image == (Image *) NULL)
14125 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14127 goto PerlException;
14129 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14133 crop_geometry=(char *) NULL;
14134 geometry=(char *) NULL;
14135 for (i=2; i < items; i+=2)
14137 attribute=(char *) SvPV(ST(i-1),na);
14138 switch (*attribute)
14143 if (LocaleCompare(attribute,"crop") == 0)
14145 crop_geometry=SvPV(ST(i),na);
14148 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14155 if (LocaleCompare(attribute,"geometry") == 0)
14157 geometry=SvPV(ST(i),na);
14160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14172 for ( ; image; image=image->next)
14174 clone=CloneImage(image,0,0,MagickTrue,exception);
14175 if (clone == (Image *) NULL)
14176 goto PerlException;
14177 TransformImage(&clone,crop_geometry,geometry,exception);
14178 for ( ; clone; clone=clone->next)
14180 AddImageToRegistry(sv,clone);
14182 av_push(av,sv_bless(rv,hv));
14186 exception=DestroyExceptionInfo(exception);
14187 ST(0)=av_reference;
14188 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14192 InheritPerlException(exception,perl_exception);
14193 exception=DestroyExceptionInfo(exception);
14194 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14195 SvPOK_on(perl_exception);
14196 ST(0)=sv_2mortal(perl_exception);
14201 ###############################################################################
14209 ###############################################################################
14214 Image::Magick::@MAGICK_ABI_SUFFIX@ ref=NO_INIT
14222 filename[MaxTextExtent];
14246 PERL_UNUSED_VAR(ref);
14247 PERL_UNUSED_VAR(ix);
14248 exception=AcquireExceptionInfo();
14249 perl_exception=newSVpv("",0);
14251 package_info=(struct PackageInfo *) NULL;
14252 if (sv_isobject(ST(0)) == 0)
14254 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14256 goto PerlException;
14258 reference=SvRV(ST(0));
14259 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14260 if (image == (Image *) NULL)
14262 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14264 goto PerlException;
14266 package_info=ClonePackageInfo(info,exception);
14268 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14271 for (i=2; i < items; i+=2)
14272 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14274 (void) CopyMagickString(filename,package_info->image_info->filename,
14277 for (next=image; next; next=next->next)
14279 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14280 next->scene=scene++;
14282 SetImageInfo(package_info->image_info,(unsigned int)
14283 GetImageListLength(image),exception);
14284 for (next=image; next; next=next->next)
14286 (void) WriteImage(package_info->image_info,next,exception);
14288 if (package_info->image_info->adjoin)
14293 if (package_info != (struct PackageInfo *) NULL)
14294 DestroyPackageInfo(package_info);
14295 InheritPerlException(exception,perl_exception);
14296 exception=DestroyExceptionInfo(exception);
14297 sv_setiv(perl_exception,(IV) number_images);
14298 SvPOK_on(perl_exception);
14299 ST(0)=sv_2mortal(perl_exception);