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-2016 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
56 #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 MagickPI 3.14159265358979323846264338327950288419716939937510
78 #define MaxArguments 33
82 #define NumberOf(array) (sizeof(array)/sizeof(*array))
83 #define PackageName "Image::Magick"
86 #define PerlIO_importFILE(f, fl) (f)
87 #define PerlIO_findFILE(f) NULL
90 #define sv_undef PL_sv_undef
93 #define AddImageToRegistry(sv,image) \
95 if (magick_registry != (SplayTreeInfo *) NULL) \
97 (void) AddValueToSplayTree(magick_registry,image,image); \
98 (sv)=newSViv(PTR2IV(image)); \
102 #define DeleteImageFromRegistry(reference,image) \
104 if (magick_registry != (SplayTreeInfo *) NULL) \
106 if (GetImageReferenceCount(image) == 1) \
107 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
108 image=DestroyImage(image); \
109 sv_setiv(reference,0); \
113 #define InheritPerlException(exception,perl_exception) \
116 message[MagickPathExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MagickPathExtent,"Exception %d: %s%s%s%s",\
121 (exception)->severity, (exception)->reason ? \
122 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
123 "Unknown", (exception)->description ? " (" : "", \
124 (exception)->description ? GetLocaleExceptionMessage( \
125 (exception)->severity,(exception)->description) : "", \
126 (exception)->description ? ")" : ""); \
127 if ((perl_exception) != (SV *) NULL) \
129 if (SvCUR(perl_exception)) \
130 sv_catpv(perl_exception,"\n"); \
131 sv_catpv(perl_exception,message); \
136 #define ThrowPerlException(exception,severity,tag,reason) \
137 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
138 tag,"`%s'",reason); \
141 Typedef and structure declarations.
145 ArrayReference = (~0),
146 RealReference = (~0)-1,
147 FileReference = (~0)-2,
148 ImageReference = (~0)-3,
149 IntegerReference = (~0)-4,
150 StringReference = (~0)-5
153 typedef struct _Arguments
193 *Image__Magick; /* data type for the Image::Magick package */
205 arguments[MaxArguments];
208 { "Comment", { {"comment", StringReference} } },
209 { "Label", { {"label", StringReference} } },
210 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
211 {"channel", MagickChannelOptions} } },
212 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
213 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
214 {"height", IntegerReference}, {"fill", StringReference},
215 {"bordercolor", StringReference}, {"color", StringReference},
216 {"compose", MagickComposeOptions} } },
217 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
218 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference}, {"gravity", MagickGravityOptions} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference},
251 {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
260 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
261 {"y", RealReference}, { "fill", StringReference},
262 {"color", StringReference} } },
263 { "Spread", { {"radius", RealReference},
264 {"interpolate", MagickInterpolateOptions} } },
265 { "Swirl", { {"degrees", RealReference},
266 {"interpolate", MagickInterpolateOptions} } },
267 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
268 {"height", IntegerReference}, {"filter", MagickFilterOptions},
269 {"support", StringReference } } },
270 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", RealReference } } },
273 { "Annotate", { {"text", StringReference}, {"font", StringReference},
274 {"pointsize", RealReference}, {"density", StringReference},
275 {"undercolor", StringReference}, {"stroke", StringReference},
276 {"fill", StringReference}, {"geometry", StringReference},
277 {"sans", StringReference}, {"x", RealReference},
278 {"y", RealReference}, {"gravity", MagickGravityOptions},
279 {"translate", StringReference}, {"scale", StringReference},
280 {"rotate", RealReference}, {"skewX", RealReference},
281 {"skewY", RealReference}, {"strokewidth", RealReference},
282 {"antialias", MagickBooleanOptions}, {"family", StringReference},
283 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
284 {"weight", IntegerReference}, {"align", MagickAlignOptions},
285 {"encoding", StringReference}, {"affine", ArrayReference},
286 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
287 {"tile", ImageReference}, {"kerning", RealReference},
288 {"interline-spacing", RealReference},
289 {"interword-spacing", RealReference},
290 {"direction", MagickDirectionOptions} } },
291 { "ColorFloodfill", { {"geometry", StringReference},
292 {"x", IntegerReference}, {"y", IntegerReference},
293 {"fill", StringReference}, {"bordercolor", StringReference},
294 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
295 { "Composite", { {"image", ImageReference},
296 {"compose", MagickComposeOptions}, {"geometry", StringReference},
297 {"x", IntegerReference}, {"y", IntegerReference},
298 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
299 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
300 {"color", StringReference}, {"mask", ImageReference},
301 {"channel", MagickChannelOptions},
302 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
303 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
304 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
305 { "CycleColormap", { {"display", IntegerReference} } },
306 { "Draw", { {"primitive", MagickPrimitiveOptions},
307 {"points", StringReference}, {"method", MagickMethodOptions},
308 {"stroke", StringReference}, {"fill", StringReference},
309 {"strokewidth", RealReference}, {"font", StringReference},
310 {"bordercolor", StringReference}, {"x", RealReference},
311 {"y", RealReference}, {"translate", StringReference},
312 {"scale", StringReference}, {"rotate", RealReference},
313 {"skewX", RealReference}, {"skewY", RealReference},
314 {"tile", ImageReference}, {"pointsize", RealReference},
315 {"antialias", MagickBooleanOptions}, {"density", StringReference},
316 {"linewidth", RealReference}, {"affine", ArrayReference},
317 {"stroke-dashoffset", RealReference},
318 {"stroke-dasharray", ArrayReference},
319 {"interpolate", MagickInterpolateOptions},
320 {"origin", StringReference}, {"text", StringReference},
321 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
322 {"vector-graphics", StringReference}, {"kerning", RealReference},
323 {"interline-spacing", RealReference},
324 {"interword-spacing", RealReference},
325 {"direction", MagickDirectionOptions} } },
326 { "Equalize", { {"channel", MagickChannelOptions} } },
327 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
328 {"red", RealReference}, {"green", RealReference},
329 {"blue", RealReference} } },
330 { "Map", { {"image", ImageReference},
331 {"dither-method", MagickDitherOptions} } },
332 { "MatteFloodfill", { {"geometry", StringReference},
333 {"x", IntegerReference}, {"y", IntegerReference},
334 {"opacity", StringReference}, {"bordercolor", StringReference},
335 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
336 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
337 {"saturation", RealReference}, {"whiteness", RealReference},
338 {"brightness", RealReference}, {"lightness", RealReference},
339 {"blackness", RealReference} } },
340 { "Negate", { {"gray", MagickBooleanOptions},
341 {"channel", MagickChannelOptions} } },
342 { "Normalize", { {"channel", MagickChannelOptions} } },
344 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
345 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
346 {"invert", MagickBooleanOptions} } },
347 { "Quantize", { {"colors", IntegerReference},
348 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
349 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
350 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
351 {"dither-method", MagickDitherOptions} } },
352 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
353 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
354 { "Segment", { {"geometry", StringReference},
355 {"cluster-threshold", RealReference},
356 {"smoothing-threshold", RealReference},
357 {"colorspace", MagickColorspaceOptions},
358 {"verbose", MagickBooleanOptions} } },
360 { "Solarize", { {"geometry", StringReference},
361 {"threshold", StringReference} } },
363 { "Texture", { {"texture", ImageReference} } },
364 { "Evaluate", { {"value", RealReference},
365 {"operator", MagickEvaluateOptions},
366 {"channel", MagickChannelOptions} } },
367 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
368 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
369 { "Threshold", { {"threshold", StringReference},
370 {"channel", MagickChannelOptions} } },
371 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
372 {"sigma", RealReference} } },
373 { "Trim", { {"fuzz", StringReference} } },
374 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
375 {"wavelength", RealReference},
376 {"interpolate", MagickInterpolateOptions} } },
377 { "Separate", { {"channel", MagickChannelOptions} } },
379 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
380 {"y", IntegerReference} } },
381 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
383 { "GaussianBlur", { {"geometry", StringReference},
384 {"radius", RealReference}, {"sigma", RealReference},
385 {"channel", MagickChannelOptions} } },
386 { "Convolve", { {"coefficients", ArrayReference},
387 {"channel", MagickChannelOptions}, {"bias", StringReference},
388 {"kernel", StringReference} } },
389 { "Profile", { {"name", StringReference}, {"profile", StringReference},
390 { "rendering-intent", MagickIntentOptions},
391 { "black-point-compensation", MagickBooleanOptions} } },
392 { "UnsharpMask", { {"geometry", StringReference},
393 {"radius", RealReference}, {"sigma", RealReference},
394 {"gain", RealReference}, {"threshold", RealReference},
395 {"channel", MagickChannelOptions} } },
396 { "MotionBlur", { {"geometry", StringReference},
397 {"radius", RealReference}, {"sigma", RealReference},
398 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
399 { "OrderedDither", { {"threshold", StringReference},
400 {"channel", MagickChannelOptions} } },
401 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
402 {"height", IntegerReference} } },
403 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
404 {"white-point", RealReference}, {"gamma", RealReference},
405 {"channel", MagickChannelOptions}, {"level", StringReference} } },
406 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
407 { "AffineTransform", { {"affine", ArrayReference},
408 {"translate", StringReference}, {"scale", StringReference},
409 {"rotate", RealReference}, {"skewX", RealReference},
410 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
411 {"background", StringReference} } },
412 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
413 { "AdaptiveThreshold", { {"geometry", StringReference},
414 {"width", IntegerReference}, {"height", IntegerReference} } },
415 { "Resample", { {"density", StringReference}, {"x", RealReference},
416 {"y", RealReference}, {"filter", MagickFilterOptions},
417 {"support", RealReference } } },
418 { "Describe", { {"file", FileReference} } },
419 { "BlackThreshold", { {"threshold", StringReference},
420 {"channel", MagickChannelOptions} } },
421 { "WhiteThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "RotationalBlur", { {"geometry", StringReference},
424 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
425 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
426 {"height", IntegerReference} } },
428 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
429 { "Channel", { {"channel", MagickChannelOptions} } },
430 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
431 {"height", IntegerReference}, {"x", IntegerReference},
432 {"y", IntegerReference}, {"fuzz", StringReference},
433 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
434 { "Posterize", { {"levels", IntegerReference},
435 {"dither", MagickBooleanOptions} } },
436 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
437 {"sigma", RealReference}, {"x", IntegerReference},
438 {"y", IntegerReference} } },
439 { "Identify", { {"file", FileReference}, {"features", StringReference},
440 {"unique", MagickBooleanOptions} } },
441 { "SepiaTone", { {"threshold", RealReference} } },
442 { "SigmoidalContrast", { {"geometry", StringReference},
443 {"contrast", RealReference}, {"mid-point", RealReference},
444 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
445 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
446 {"height", IntegerReference}, {"x", IntegerReference},
447 {"y", IntegerReference}, {"fuzz", StringReference},
448 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
449 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
450 {"sigma", RealReference}, {"x", IntegerReference},
451 {"y", IntegerReference}, {"background", StringReference} } },
452 { "ContrastStretch", { {"levels", StringReference},
453 {"black-point", RealReference},{"white-point", RealReference},
454 {"channel", MagickChannelOptions} } },
457 { "AdaptiveSharpen", { {"geometry", StringReference},
458 {"radius", RealReference}, {"sigma", RealReference},
459 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
463 { "AdaptiveBlur", { {"geometry", StringReference},
464 {"radius", RealReference}, {"sigma", RealReference},
465 {"channel", MagickChannelOptions} } },
466 { "Sketch", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"angle", RealReference} } },
470 { "AdaptiveResize", { {"geometry", StringReference},
471 {"width", IntegerReference}, {"height", IntegerReference},
472 {"filter", MagickFilterOptions}, {"support", StringReference },
473 {"blur", RealReference } } },
474 { "ClipMask", { {"mask", ImageReference} } },
475 { "LinearStretch", { {"levels", StringReference},
476 {"black-point", RealReference},{"white-point", RealReference} } },
477 { "ColorMatrix", { {"matrix", ArrayReference} } },
478 { "Mask", { {"mask", ImageReference} } },
479 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
480 {"font", StringReference}, {"stroke", StringReference},
481 {"fill", StringReference}, {"strokewidth", RealReference},
482 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
483 {"background", StringReference},
484 {"interpolate", MagickInterpolateOptions} } },
485 { "FloodfillPaint", { {"geometry", StringReference},
486 {"x", IntegerReference}, {"y", IntegerReference},
487 {"fill", StringReference}, {"bordercolor", StringReference},
488 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
489 {"invert", MagickBooleanOptions} } },
490 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
491 {"virtual-pixel", MagickVirtualPixelOptions},
492 {"best-fit", MagickBooleanOptions} } },
493 { "Clut", { {"image", ImageReference},
494 {"interpolate", MagickInterpolateOptions},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "BrightnessContrast", { {"levels", StringReference},
529 {"brightness", RealReference},{"contrast", RealReference},
530 {"channel", MagickChannelOptions} } },
531 { "Morphology", { {"kernel", StringReference},
532 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
533 {"iterations", IntegerReference} } },
534 { "Mode", { {"geometry", StringReference},
535 {"width", IntegerReference},{"height", IntegerReference},
536 {"channel", MagickChannelOptions} } },
537 { "Statistic", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
540 { "Perceptible", { {"epsilon", RealReference},
541 {"channel", MagickChannelOptions} } },
542 { "Poly", { {"terms", ArrayReference},
543 {"channel", MagickChannelOptions} } },
544 { "Grayscale", { {"method", MagickNoiseOptions} } },
545 { "CannyEdge", { {"geometry", StringReference},
546 {"radius", RealReference}, {"sigma", RealReference},
547 {"lower-percent", RealReference}, {"upper-percent", RealReference} } },
548 { "HoughLine", { {"geometry", StringReference},
549 {"width", IntegerReference}, {"height", IntegerReference},
550 {"threshold", IntegerReference} } },
551 { "MeanShift", { {"geometry", StringReference},
552 {"width", IntegerReference}, {"height", IntegerReference},
553 {"distance", RealReference} } },
554 { "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference},
555 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
556 { "ConnectedComponents", { {"connectivity", IntegerReference} } },
557 { "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference},
558 {"width", IntegerReference}, {"height", IntegerReference},
559 {"x", IntegerReference}, {"y", IntegerReference},
560 {"gravity", MagickGravityOptions}, {"offset", StringReference},
561 {"dx", IntegerReference}, {"dy", IntegerReference} } },
562 { "Color", { {"color", StringReference} } },
563 { "WaveletDenoise", { {"geometry", StringReference},
564 {"threshold", RealReference}, {"softness", RealReference},
565 {"channel", MagickChannelOptions} } },
569 *magick_registry = (SplayTreeInfo *) NULL;
572 Forward declarations.
575 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
578 strEQcase(const char *,const char *);
581 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % C l o n e P a c k a g e I n f o %
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
591 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
594 % The format of the ClonePackageInfo routine is:
596 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
599 % A description of each parameter follows:
601 % o info: a structure of type info.
603 % o exception: Return any errors or warnings in this structure.
606 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
607 ExceptionInfo *exception)
612 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
613 if (clone_info == (struct PackageInfo *) NULL)
615 ThrowPerlException(exception,ResourceLimitError,
616 "UnableToClonePackageInfo",PackageName);
617 return((struct PackageInfo *) NULL);
619 if (info == (struct PackageInfo *) NULL)
621 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
625 clone_info->image_info=CloneImageInfo(info->image_info);
630 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
640 % constant() returns a double value for the specified name.
642 % The format of the constant routine is:
644 % double constant(char *name,ssize_t sans)
646 % A description of each parameter follows:
648 % o value: Method constant returns a double value for the specified name.
650 % o name: The name of the constant.
652 % o sans: This integer value is not used.
655 static double constant(char *name,ssize_t sans)
663 if (strEQ(name,"BlobError"))
665 if (strEQ(name,"BlobWarning"))
671 if (strEQ(name,"CacheError"))
673 if (strEQ(name,"CacheWarning"))
674 return(CacheWarning);
675 if (strEQ(name,"CoderError"))
677 if (strEQ(name,"CoderWarning"))
678 return(CoderWarning);
679 if (strEQ(name,"ConfigureError"))
680 return(ConfigureError);
681 if (strEQ(name,"ConfigureWarning"))
682 return(ConfigureWarning);
683 if (strEQ(name,"CorruptImageError"))
684 return(CorruptImageError);
685 if (strEQ(name,"CorruptImageWarning"))
686 return(CorruptImageWarning);
691 if (strEQ(name,"DelegateError"))
692 return(DelegateError);
693 if (strEQ(name,"DelegateWarning"))
694 return(DelegateWarning);
695 if (strEQ(name,"DrawError"))
697 if (strEQ(name,"DrawWarning"))
703 if (strEQ(name,"ErrorException"))
704 return(ErrorException);
705 if (strEQ(name,"ExceptionError"))
707 if (strEQ(name,"ExceptionWarning"))
708 return(CoderWarning);
713 if (strEQ(name,"FatalErrorException"))
714 return(FatalErrorException);
715 if (strEQ(name,"FileOpenError"))
716 return(FileOpenError);
717 if (strEQ(name,"FileOpenWarning"))
718 return(FileOpenWarning);
723 if (strEQ(name,"ImageError"))
725 if (strEQ(name,"ImageWarning"))
726 return(ImageWarning);
731 if (strEQ(name,"MaxRGB"))
732 return(QuantumRange);
733 if (strEQ(name,"MissingDelegateError"))
734 return(MissingDelegateError);
735 if (strEQ(name,"MissingDelegateWarning"))
736 return(MissingDelegateWarning);
737 if (strEQ(name,"ModuleError"))
739 if (strEQ(name,"ModuleWarning"))
740 return(ModuleWarning);
745 if (strEQ(name,"Opaque"))
747 if (strEQ(name,"OptionError"))
749 if (strEQ(name,"OptionWarning"))
750 return(OptionWarning);
755 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
756 return(MAGICKCORE_QUANTUM_DEPTH);
757 if (strEQ(name,"QuantumDepth"))
758 return(MAGICKCORE_QUANTUM_DEPTH);
759 if (strEQ(name,"QuantumRange"))
760 return(QuantumRange);
765 if (strEQ(name,"ResourceLimitError"))
766 return(ResourceLimitError);
767 if (strEQ(name,"ResourceLimitWarning"))
768 return(ResourceLimitWarning);
769 if (strEQ(name,"RegistryError"))
770 return(RegistryError);
771 if (strEQ(name,"RegistryWarning"))
772 return(RegistryWarning);
777 if (strEQ(name,"StreamError"))
779 if (strEQ(name,"StreamWarning"))
780 return(StreamWarning);
781 if (strEQ(name,"Success"))
787 if (strEQ(name,"Transparent"))
788 return(TransparentAlpha);
789 if (strEQ(name,"TypeError"))
791 if (strEQ(name,"TypeWarning"))
797 if (strEQ(name,"WarningException"))
798 return(WarningException);
803 if (strEQ(name,"XServerError"))
804 return(XServerError);
805 if (strEQ(name,"XServerWarning"))
806 return(XServerWarning);
815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
819 % D e s t r o y P a c k a g e I n f o %
823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
825 % Method DestroyPackageInfo frees a previously created info structure.
827 % The format of the DestroyPackageInfo routine is:
829 % DestroyPackageInfo(struct PackageInfo *info)
831 % A description of each parameter follows:
833 % o info: a structure of type info.
836 static void DestroyPackageInfo(struct PackageInfo *info)
838 info->image_info=DestroyImageInfo(info->image_info);
839 info=(struct PackageInfo *) RelinquishMagickMemory(info);
843 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
851 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
853 % Method GetList is recursively called by SetupList to traverse the
854 % Image__Magick reference. If building an reference_vector (see SetupList),
855 % *current is the current position in *reference_vector and *last is the final
856 % entry in *reference_vector.
858 % The format of the GetList routine is:
862 % A description of each parameter follows:
864 % o info: a structure of type info.
867 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
868 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
873 if (reference == (SV *) NULL)
875 switch (SvTYPE(reference))
895 previous=(Image *) NULL;
899 for (i=0; i <= n; i++)
905 if (rv && *rv && sv_isobject(*rv))
907 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
909 if (image == (Image *) NULL)
911 if (image == previous)
913 image=CloneImage(image,0,0,MagickTrue,exception);
914 if (image == (Image *) NULL)
917 image->previous=previous;
918 *(previous ? &previous->next : &head)=image;
919 for (previous=image; previous->next; previous=previous->next) ;
927 Blessed scalar, one image.
929 image=INT2PTR(Image *,SvIV(reference));
930 if (image == (Image *) NULL)
932 image->previous=(Image *) NULL;
933 image->next=(Image *) NULL;
934 if (reference_vector)
936 if (*current == *last)
939 if (*reference_vector == (SV **) NULL)
940 *reference_vector=(SV **) AcquireQuantumMemory(*last,
941 sizeof(*reference_vector));
943 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
944 *last,sizeof(*reference_vector));
946 if (*reference_vector == (SV **) NULL)
948 ThrowPerlException(exception,ResourceLimitError,
949 "MemoryAllocationFailed",PackageName);
950 return((Image *) NULL);
952 (*reference_vector)[*current]=reference;
953 (*reference_vector)[++(*current)]=NULL;
960 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
961 (double) SvTYPE(reference));
962 return((Image *) NULL);
966 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
970 % G e t P a c k a g e I n f o %
974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
976 % Method GetPackageInfo looks up or creates an info structure for the given
977 % Image__Magick reference. If it does create a new one, the information in
978 % package_info is used to initialize it.
980 % The format of the GetPackageInfo routine is:
982 % struct PackageInfo *GetPackageInfo(void *reference,
983 % struct PackageInfo *package_info,ExceptionInfo *exception)
985 % A description of each parameter follows:
987 % o info: a structure of type info.
989 % o exception: Return any errors or warnings in this structure.
992 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
993 struct PackageInfo *package_info,ExceptionInfo *exception)
996 message[MagickPathExtent];
1004 (void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p",
1005 PackageName,XS_VERSION,reference);
1006 sv=perl_get_sv(message,(TRUE | 0x02));
1007 if (sv == (SV *) NULL)
1009 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1011 return(package_info);
1013 if (SvREFCNT(sv) == 0)
1014 (void) SvREFCNT_inc(sv);
1015 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1017 clone_info=ClonePackageInfo(package_info,exception);
1018 sv_setiv(sv,PTR2IV(clone_info));
1023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1027 % S e t A t t r i b u t e %
1031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1033 % SetAttribute() sets the attribute to the value in sval. This can change
1034 % either or both of image or info.
1036 % The format of the SetAttribute routine is:
1038 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1039 % SV *sval,ExceptionInfo *exception)
1041 % A description of each parameter follows:
1043 % o list: a list of strings.
1045 % o string: a character string.
1049 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1057 value=InterpretSiPrefixValue(string,&q);
1059 value*=interval/100.0;
1063 static inline double StringToDouble(const char *string,char **sentinal)
1065 return(InterpretLocaleValue(string,sentinal));
1068 static double StringToDoubleInterval(const char *string,const double interval)
1076 value=InterpretLocaleValue(string,&q);
1078 value*=interval/100.0;
1082 static inline ssize_t StringToLong(const char *value)
1084 return(strtol(value,(char **) NULL,10));
1087 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1088 const char *attribute,SV *sval,ExceptionInfo *exception)
1115 if (LocaleCompare(attribute,"adjoin") == 0)
1117 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1118 SvPV(sval,na)) : SvIV(sval);
1121 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1126 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1129 if (LocaleCompare(attribute,"alpha") == 0)
1131 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1132 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1135 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1139 for ( ; image; image=image->next)
1140 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1144 if (LocaleCompare(attribute,"antialias") == 0)
1146 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1147 SvPV(sval,na)) : SvIV(sval);
1150 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1155 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1158 if (LocaleCompare(attribute,"area-limit") == 0)
1163 limit=MagickResourceInfinity;
1164 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1165 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1167 (void) SetMagickResourceLimit(AreaResource,limit);
1170 if (LocaleCompare(attribute,"attenuate") == 0)
1173 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1176 if (LocaleCompare(attribute,"authenticate") == 0)
1179 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1183 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1184 for ( ; image; image=image->next)
1185 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1191 if (LocaleCompare(attribute,"background") == 0)
1193 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1196 info->image_info->background_color=target_color;
1197 for ( ; image; image=image->next)
1198 image->background_color=target_color;
1201 if (LocaleCompare(attribute,"blue-primary") == 0)
1203 for ( ; image; image=image->next)
1205 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1206 image->chromaticity.blue_primary.x=geometry_info.rho;
1207 image->chromaticity.blue_primary.y=geometry_info.sigma;
1208 if ((flags & SigmaValue) == 0)
1209 image->chromaticity.blue_primary.y=
1210 image->chromaticity.blue_primary.x;
1214 if (LocaleCompare(attribute,"bordercolor") == 0)
1216 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1219 info->image_info->border_color=target_color;
1220 for ( ; image; image=image->next)
1221 image->border_color=target_color;
1225 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1226 for ( ; image; image=image->next)
1227 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1233 if (LocaleCompare(attribute,"cache-threshold") == 0)
1235 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1236 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1237 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1238 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1241 if (LocaleCompare(attribute,"clip-mask") == 0)
1246 clip_mask=(Image *) NULL;
1248 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1249 for ( ; image; image=image->next)
1250 SetImageMask(image,ReadPixelMask,clip_mask,exception);
1253 if (LocaleNCompare(attribute,"colormap",8) == 0)
1255 for ( ; image; image=image->next)
1263 if (image->storage_class == DirectClass)
1266 items=sscanf(attribute,"%*[^[][%ld",&i);
1268 if (i > (ssize_t) image->colors)
1270 if ((strchr(SvPV(sval,na),',') == 0) ||
1271 (strchr(SvPV(sval,na),')') != 0))
1272 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1273 image->colormap+i,exception);
1276 color=image->colormap+i;
1277 pixel.red=color->red;
1278 pixel.green=color->green;
1279 pixel.blue=color->blue;
1280 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1281 pixel.red=geometry_info.rho;
1282 pixel.green=geometry_info.sigma;
1283 pixel.blue=geometry_info.xi;
1284 color->red=ClampToQuantum(pixel.red);
1285 color->green=ClampToQuantum(pixel.green);
1286 color->blue=ClampToQuantum(pixel.blue);
1291 if (LocaleCompare(attribute,"colorspace") == 0)
1293 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1294 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1297 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1301 for ( ; image; image=image->next)
1302 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1306 if (LocaleCompare(attribute,"comment") == 0)
1308 for ( ; image; image=image->next)
1309 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1310 info ? info->image_info : (ImageInfo *) NULL,image,
1311 SvPV(sval,na),exception),exception);
1314 if (LocaleCompare(attribute,"compression") == 0)
1316 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1317 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1320 ThrowPerlException(exception,OptionError,
1321 "UnrecognizedImageCompression",SvPV(sval,na));
1325 info->image_info->compression=(CompressionType) sp;
1326 for ( ; image; image=image->next)
1327 image->compression=(CompressionType) sp;
1331 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1332 for ( ; image; image=image->next)
1333 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1339 if (LocaleCompare(attribute,"debug") == 0)
1341 SetLogEventMask(SvPV(sval,na));
1344 if (LocaleCompare(attribute,"delay") == 0)
1346 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1347 for ( ; image; image=image->next)
1349 image->delay=(size_t) floor(geometry_info.rho+0.5);
1350 if ((flags & SigmaValue) != 0)
1351 image->ticks_per_second=(ssize_t)
1352 floor(geometry_info.sigma+0.5);
1356 if (LocaleCompare(attribute,"disk-limit") == 0)
1361 limit=MagickResourceInfinity;
1362 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1363 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1365 (void) SetMagickResourceLimit(DiskResource,limit);
1368 if (LocaleCompare(attribute,"density") == 0)
1370 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1372 ThrowPerlException(exception,OptionError,"MissingGeometry",
1377 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1378 for ( ; image; image=image->next)
1380 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1381 image->resolution.x=geometry_info.rho;
1382 image->resolution.y=geometry_info.sigma;
1383 if ((flags & SigmaValue) == 0)
1384 image->resolution.y=image->resolution.x;
1388 if (LocaleCompare(attribute,"depth") == 0)
1391 info->image_info->depth=SvIV(sval);
1392 for ( ; image; image=image->next)
1393 (void) SetImageDepth(image,SvIV(sval),exception);
1396 if (LocaleCompare(attribute,"dispose") == 0)
1398 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1399 SvPV(sval,na)) : SvIV(sval);
1402 ThrowPerlException(exception,OptionError,
1403 "UnrecognizedDisposeMethod",SvPV(sval,na));
1406 for ( ; image; image=image->next)
1407 image->dispose=(DisposeType) sp;
1410 if (LocaleCompare(attribute,"dither") == 0)
1414 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1415 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1418 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1422 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1426 if (LocaleCompare(attribute,"display") == 0)
1430 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1434 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1435 for ( ; image; image=image->next)
1436 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1442 if (LocaleCompare(attribute,"endian") == 0)
1444 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1445 SvPV(sval,na)) : SvIV(sval);
1448 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1453 info->image_info->endian=(EndianType) sp;
1454 for ( ; image; image=image->next)
1455 image->endian=(EndianType) sp;
1458 if (LocaleCompare(attribute,"extract") == 0)
1461 Set image extract geometry.
1463 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1467 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1468 for ( ; image; image=image->next)
1469 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1475 if (LocaleCompare(attribute,"filename") == 0)
1478 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1480 for ( ; image; image=image->next)
1481 (void) CopyMagickString(image->filename,SvPV(sval,na),
1485 if (LocaleCompare(attribute,"file") == 0)
1493 if (info == (struct PackageInfo *) NULL)
1495 io_info=IoIFP(sv_2io(sval));
1496 if (io_info == (PerlIO *) NULL)
1498 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1502 file=PerlIO_findFILE(io_info);
1503 if (file == (FILE *) NULL)
1505 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1509 SetImageInfoFile(info->image_info,file);
1512 if (LocaleCompare(attribute,"fill") == 0)
1515 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1518 if (LocaleCompare(attribute,"font") == 0)
1521 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1524 if (LocaleCompare(attribute,"foreground") == 0)
1526 if (LocaleCompare(attribute,"fuzz") == 0)
1529 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1531 for ( ; image; image=image->next)
1532 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1537 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1538 for ( ; image; image=image->next)
1539 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1545 if (LocaleCompare(attribute,"gamma") == 0)
1547 for ( ; image; image=image->next)
1548 image->gamma=SvNV(sval);
1551 if (LocaleCompare(attribute,"gravity") == 0)
1553 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1554 SvPV(sval,na)) : SvIV(sval);
1557 ThrowPerlException(exception,OptionError,
1558 "UnrecognizedGravityType",SvPV(sval,na));
1562 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1563 for ( ; image; image=image->next)
1564 image->gravity=(GravityType) sp;
1567 if (LocaleCompare(attribute,"green-primary") == 0)
1569 for ( ; image; image=image->next)
1571 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1572 image->chromaticity.green_primary.x=geometry_info.rho;
1573 image->chromaticity.green_primary.y=geometry_info.sigma;
1574 if ((flags & SigmaValue) == 0)
1575 image->chromaticity.green_primary.y=
1576 image->chromaticity.green_primary.x;
1581 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1582 for ( ; image; image=image->next)
1583 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1589 if (LocaleNCompare(attribute,"index",5) == 0)
1603 for ( ; image; image=image->next)
1605 if (image->storage_class != PseudoClass)
1609 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1611 image_view=AcquireAuthenticCacheView(image,exception);
1612 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1613 if (q != (Quantum *) NULL)
1615 items=sscanf(SvPV(sval,na),"%ld",&index);
1616 if ((index >= 0) && (index < (ssize_t) image->colors))
1617 SetPixelIndex(image,index,q);
1618 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1620 image_view=DestroyCacheView(image_view);
1624 if (LocaleCompare(attribute,"iterations") == 0)
1627 for ( ; image; image=image->next)
1628 image->iterations=SvIV(sval);
1631 if (LocaleCompare(attribute,"interlace") == 0)
1633 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1634 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1637 ThrowPerlException(exception,OptionError,
1638 "UnrecognizedInterlaceType",SvPV(sval,na));
1642 info->image_info->interlace=(InterlaceType) sp;
1643 for ( ; image; image=image->next)
1644 image->interlace=(InterlaceType) sp;
1648 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1649 for ( ; image; image=image->next)
1650 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1656 if (LocaleCompare(attribute,"label") == 0)
1658 for ( ; image; image=image->next)
1659 (void) SetImageProperty(image,"label",InterpretImageProperties(
1660 info ? info->image_info : (ImageInfo *) NULL,image,
1661 SvPV(sval,na),exception),exception);
1664 if (LocaleCompare(attribute,"loop") == 0)
1667 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1668 for ( ; image; image=image->next)
1669 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1675 if (LocaleCompare(attribute,"magick") == 0)
1678 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
1679 "%s:",SvPV(sval,na));
1680 for ( ; image; image=image->next)
1681 (void) CopyMagickString(image->magick,SvPV(sval,na),MagickPathExtent);
1684 if (LocaleCompare(attribute,"map-limit") == 0)
1689 limit=MagickResourceInfinity;
1690 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1691 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1693 (void) SetMagickResourceLimit(MapResource,limit);
1696 if (LocaleCompare(attribute,"mask") == 0)
1701 mask=(Image *) NULL;
1703 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1704 for ( ; image; image=image->next)
1705 SetImageMask(image,ReadPixelMask,mask,exception);
1708 if (LocaleCompare(attribute,"mattecolor") == 0)
1710 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1713 info->image_info->alpha_color=target_color;
1714 for ( ; image; image=image->next)
1715 image->alpha_color=target_color;
1718 if (LocaleCompare(attribute,"matte") == 0)
1720 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1721 SvPV(sval,na)) : SvIV(sval);
1724 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1728 for ( ; image; image=image->next)
1729 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1732 if (LocaleCompare(attribute,"memory-limit") == 0)
1737 limit=MagickResourceInfinity;
1738 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1739 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1741 (void) SetMagickResourceLimit(MemoryResource,limit);
1744 if (LocaleCompare(attribute,"monochrome") == 0)
1746 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1747 SvPV(sval,na)) : SvIV(sval);
1750 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1755 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1756 for ( ; image; image=image->next)
1757 (void) SetImageType(image,BilevelType,exception);
1761 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1762 for ( ; image; image=image->next)
1763 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1769 if (LocaleCompare(attribute,"option") == 0)
1772 DefineImageOption(info->image_info,SvPV(sval,na));
1775 if (LocaleCompare(attribute,"orientation") == 0)
1777 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1778 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1781 ThrowPerlException(exception,OptionError,
1782 "UnrecognizedOrientationType",SvPV(sval,na));
1786 info->image_info->orientation=(OrientationType) sp;
1787 for ( ; image; image=image->next)
1788 image->orientation=(OrientationType) sp;
1792 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1793 for ( ; image; image=image->next)
1794 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1800 if (LocaleCompare(attribute,"page") == 0)
1805 geometry=GetPageGeometry(SvPV(sval,na));
1807 (void) CloneString(&info->image_info->page,geometry);
1808 for ( ; image; image=image->next)
1809 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1810 geometry=(char *) RelinquishMagickMemory(geometry);
1813 if (LocaleNCompare(attribute,"pixel",5) == 0)
1827 for ( ; image; image=image->next)
1829 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1833 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1835 image_view=AcquireVirtualCacheView(image,exception);
1836 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1837 if (q != (Quantum *) NULL)
1839 if ((strchr(SvPV(sval,na),',') == 0) ||
1840 (strchr(SvPV(sval,na),')') != 0))
1841 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1845 GetPixelInfo(image,&pixel);
1846 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1847 pixel.red=geometry_info.rho;
1848 if ((flags & SigmaValue) != 0)
1849 pixel.green=geometry_info.sigma;
1850 if ((flags & XiValue) != 0)
1851 pixel.blue=geometry_info.xi;
1852 if ((flags & PsiValue) != 0)
1853 pixel.alpha=geometry_info.psi;
1854 if ((flags & ChiValue) != 0)
1855 pixel.black=geometry_info.chi;
1857 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1858 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1859 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1860 if (image->colorspace == CMYKColorspace)
1861 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1862 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1863 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1865 image_view=DestroyCacheView(image_view);
1869 if (LocaleCompare(attribute,"pointsize") == 0)
1873 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1874 info->image_info->pointsize=geometry_info.rho;
1878 if (LocaleCompare(attribute,"preview") == 0)
1880 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1881 SvPV(sval,na)) : SvIV(sval);
1884 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1889 info->image_info->preview_type=(PreviewType) sp;
1893 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1894 for ( ; image; image=image->next)
1895 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1901 if (LocaleCompare(attribute,"quality") == 0)
1904 info->image_info->quality=SvIV(sval);
1905 for ( ; image; image=image->next)
1906 image->quality=SvIV(sval);
1910 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1911 for ( ; image; image=image->next)
1912 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1918 if (LocaleCompare(attribute,"read-mask") == 0)
1923 mask=(Image *) NULL;
1925 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1926 for ( ; image; image=image->next)
1927 SetImageMask(image,ReadPixelMask,mask,exception);
1930 if (LocaleCompare(attribute,"red-primary") == 0)
1932 for ( ; image; image=image->next)
1934 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1935 image->chromaticity.red_primary.x=geometry_info.rho;
1936 image->chromaticity.red_primary.y=geometry_info.sigma;
1937 if ((flags & SigmaValue) == 0)
1938 image->chromaticity.red_primary.y=
1939 image->chromaticity.red_primary.x;
1943 if (LocaleCompare(attribute,"render") == 0)
1945 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1946 SvPV(sval,na)) : SvIV(sval);
1949 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1953 for ( ; image; image=image->next)
1954 image->rendering_intent=(RenderingIntent) sp;
1957 if (LocaleCompare(attribute,"repage") == 0)
1962 for ( ; image; image=image->next)
1964 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1965 if ((flags & WidthValue) != 0)
1967 if ((flags & HeightValue) == 0)
1968 geometry.height=geometry.width;
1969 image->page.width=geometry.width;
1970 image->page.height=geometry.height;
1972 if ((flags & AspectValue) != 0)
1974 if ((flags & XValue) != 0)
1975 image->page.x+=geometry.x;
1976 if ((flags & YValue) != 0)
1977 image->page.y+=geometry.y;
1981 if ((flags & XValue) != 0)
1983 image->page.x=geometry.x;
1984 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1985 image->page.width=image->columns+geometry.x;
1987 if ((flags & YValue) != 0)
1989 image->page.y=geometry.y;
1990 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1991 image->page.height=image->rows+geometry.y;
1998 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1999 for ( ; image; image=image->next)
2000 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2006 if (LocaleCompare(attribute,"sampling-factor") == 0)
2008 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2010 ThrowPerlException(exception,OptionError,"MissingGeometry",
2015 (void) CloneString(&info->image_info->sampling_factor,
2019 if (LocaleCompare(attribute,"scene") == 0)
2021 for ( ; image; image=image->next)
2022 image->scene=SvIV(sval);
2025 if (LocaleCompare(attribute,"server") == 0)
2027 if (LocaleCompare(attribute,"size") == 0)
2031 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2033 ThrowPerlException(exception,OptionError,"MissingGeometry",
2037 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2041 if (LocaleCompare(attribute,"stroke") == 0)
2044 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2048 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2049 for ( ; image; image=image->next)
2050 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2056 if (LocaleCompare(attribute,"texture") == 0)
2059 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2062 if (LocaleCompare(attribute,"thread-limit") == 0)
2067 limit=MagickResourceInfinity;
2068 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2069 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2071 (void) SetMagickResourceLimit(ThreadResource,limit);
2074 if (LocaleCompare(attribute,"tile-offset") == 0)
2079 geometry=GetPageGeometry(SvPV(sval,na));
2081 (void) CloneString(&info->image_info->page,geometry);
2082 for ( ; image; image=image->next)
2083 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2085 geometry=(char *) RelinquishMagickMemory(geometry);
2088 if (LocaleCompare(attribute,"time-limit") == 0)
2093 limit=MagickResourceInfinity;
2094 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2095 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2097 (void) SetMagickResourceLimit(TimeResource,limit);
2100 if (LocaleCompare(attribute,"transparent-color") == 0)
2102 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2105 info->image_info->transparent_color=target_color;
2106 for ( ; image; image=image->next)
2107 image->transparent_color=target_color;
2110 if (LocaleCompare(attribute,"type") == 0)
2112 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2113 SvPV(sval,na)) : SvIV(sval);
2116 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2121 info->image_info->type=(ImageType) sp;
2122 for ( ; image; image=image->next)
2123 SetImageType(image,(ImageType) sp,exception);
2127 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2128 for ( ; image; image=image->next)
2129 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2135 if (LocaleCompare(attribute,"units") == 0)
2137 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2138 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2141 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2146 info->image_info->units=(ResolutionType) sp;
2147 for ( ; image; image=image->next)
2152 units=(ResolutionType) sp;
2153 if (image->units != units)
2154 switch (image->units)
2156 case UndefinedResolution:
2157 case PixelsPerInchResolution:
2159 if (units == PixelsPerCentimeterResolution)
2161 image->resolution.x*=2.54;
2162 image->resolution.y*=2.54;
2166 case PixelsPerCentimeterResolution:
2168 if (units == PixelsPerInchResolution)
2170 image->resolution.x/=2.54;
2171 image->resolution.y/=2.54;
2181 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2182 for ( ; image; image=image->next)
2183 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2189 if (LocaleCompare(attribute,"verbose") == 0)
2191 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2192 SvPV(sval,na)) : SvIV(sval);
2195 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2200 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2203 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2205 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2206 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2209 ThrowPerlException(exception,OptionError,
2210 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2213 for ( ; image; image=image->next)
2214 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2218 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2219 for ( ; image; image=image->next)
2220 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2226 if (LocaleCompare(attribute,"white-point") == 0)
2228 for ( ; image; image=image->next)
2230 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2231 image->chromaticity.white_point.x=geometry_info.rho;
2232 image->chromaticity.white_point.y=geometry_info.sigma;
2233 if ((flags & SigmaValue) == 0)
2234 image->chromaticity.white_point.y=
2235 image->chromaticity.white_point.x;
2239 if (LocaleCompare(attribute,"write-mask") == 0)
2244 mask=(Image *) NULL;
2246 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2247 for ( ; image; image=image->next)
2248 SetImageMask(image,WritePixelMask,mask,exception);
2252 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2253 for ( ; image; image=image->next)
2254 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2260 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2261 for ( ; image; image=image->next)
2262 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2273 % S e t u p L i s t %
2277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2279 % Method SetupList returns the list of all the images linked by their
2280 % image->next and image->previous link lists for use with ImageMagick. If
2281 % info is non-NULL, an info structure is returned in *info. If
2282 % reference_vector is non-NULL,an array of SV* are returned in
2283 % *reference_vector. Reference_vector is used when the images are going to be
2284 % replaced with new Image*'s.
2286 % The format of the SetupList routine is:
2288 % Image *SetupList(SV *reference,struct PackageInfo **info,
2289 % SV ***reference_vector,ExceptionInfo *exception)
2291 % A description of each parameter follows:
2293 % o list: a list of strings.
2295 % o string: a character string.
2297 % o exception: Return any errors or warnings in this structure.
2300 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2301 SV ***reference_vector,ExceptionInfo *exception)
2310 if (reference_vector)
2311 *reference_vector=NULL;
2316 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2317 if (info && (SvTYPE(reference) == SVt_PVAV))
2318 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2328 % s t r E Q c a s e %
2332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2334 % strEQcase() compares two strings and returns 0 if they are the
2335 % same or if the second string runs out first. The comparison is case
2338 % The format of the strEQcase routine is:
2340 % ssize_t strEQcase(const char *p,const char *q)
2342 % A description of each parameter follows:
2344 % o p: a character string.
2346 % o q: a character string.
2350 static ssize_t strEQcase(const char *p,const char *q)
2358 for (i=0 ; (c=(*q)) != 0; i++)
2360 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2361 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2366 return(((*q == 0) && (*p == 0)) ? i : 0);
2370 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2374 % I m a g e : : M a g i c k %
2378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2382 MODULE = Image::Magick PACKAGE = Image::Magick
2387 MagickCoreGenesis("PerlMagick",MagickFalse);
2388 SetWarningHandler(NULL);
2389 SetErrorHandler(NULL);
2390 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2391 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2397 if (magick_registry != (SplayTreeInfo *) NULL)
2398 magick_registry=DestroySplayTree(magick_registry);
2399 MagickCoreTerminus();
2403 constant(name,argument)
2408 ###############################################################################
2416 ###############################################################################
2421 Image::Magick ref=NO_INIT
2445 PERL_UNUSED_VAR(ref);
2446 PERL_UNUSED_VAR(ix);
2447 exception=AcquireExceptionInfo();
2448 perl_exception=newSVpv("",0);
2449 package_info=(struct PackageInfo *) NULL;
2450 if (sv_isobject(ST(0)) == 0)
2452 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2456 reference=SvRV(ST(0));
2457 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2458 if (image == (Image *) NULL)
2460 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2464 package_info=ClonePackageInfo(info,exception);
2466 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2469 for (i=2; i < items; i+=2)
2470 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2472 (void) AnimateImages(package_info->image_info,image,exception);
2473 (void) CatchImageException(image);
2476 if (package_info != (struct PackageInfo *) NULL)
2477 DestroyPackageInfo(package_info);
2478 InheritPerlException(exception,perl_exception);
2479 exception=DestroyExceptionInfo(exception);
2480 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2481 SvPOK_on(perl_exception);
2482 ST(0)=sv_2mortal(perl_exception);
2487 ###############################################################################
2495 ###############################################################################
2500 Image::Magick ref=NO_INIT
2538 PERL_UNUSED_VAR(ref);
2539 PERL_UNUSED_VAR(ix);
2540 exception=AcquireExceptionInfo();
2541 perl_exception=newSVpv("",0);
2545 if (sv_isobject(ST(0)) == 0)
2547 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2551 reference=SvRV(ST(0));
2552 hv=SvSTASH(reference);
2554 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2556 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2557 if (image == (Image *) NULL)
2559 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2563 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2568 for (i=2; i < items; i+=2)
2570 attribute=(char *) SvPV(ST(i-1),na);
2576 if (LocaleCompare(attribute,"stack") == 0)
2578 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2582 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2594 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2600 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2601 if (image == (Image *) NULL)
2603 for ( ; image; image=image->next)
2605 AddImageToRegistry(sv,image);
2607 av_push(av,sv_bless(rv,hv));
2610 exception=DestroyExceptionInfo(exception);
2612 SvREFCNT_dec(perl_exception);
2616 InheritPerlException(exception,perl_exception);
2617 exception=DestroyExceptionInfo(exception);
2618 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2619 SvPOK_on(perl_exception);
2620 ST(0)=sv_2mortal(perl_exception);
2625 ###############################################################################
2633 ###############################################################################
2638 Image::Magick ref=NO_INIT
2669 PERL_UNUSED_VAR(ref);
2670 PERL_UNUSED_VAR(ix);
2671 exception=AcquireExceptionInfo();
2672 perl_exception=newSVpv("",0);
2674 if (sv_isobject(ST(0)) == 0)
2676 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2680 reference=SvRV(ST(0));
2681 hv=SvSTASH(reference);
2682 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2683 if (image == (Image *) NULL)
2685 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2689 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2690 if (image == (Image *) NULL)
2693 Create blessed Perl array for the returned image.
2696 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2698 AddImageToRegistry(sv,image);
2700 av_push(av,sv_bless(rv,hv));
2702 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2703 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2704 "average-%.*s",(int) (MagickPathExtent-9),
2705 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2706 (void) CopyMagickString(image->filename,info->image_info->filename,
2708 SetImageInfo(info->image_info,0,exception);
2709 exception=DestroyExceptionInfo(exception);
2710 SvREFCNT_dec(perl_exception);
2714 InheritPerlException(exception,perl_exception);
2715 exception=DestroyExceptionInfo(exception);
2716 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2717 SvPOK_on(perl_exception);
2718 ST(0)=sv_2mortal(perl_exception);
2723 ###############################################################################
2727 # B l o b T o I m a g e #
2731 ###############################################################################
2735 BlobToImage(ref,...)
2736 Image::Magick ref=NO_INIT
2782 PERL_UNUSED_VAR(ref);
2783 PERL_UNUSED_VAR(ix);
2784 exception=AcquireExceptionInfo();
2785 perl_exception=newSVpv("",0);
2788 ac=(items < 2) ? 1 : items-1;
2789 length=(STRLEN *) NULL;
2790 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2791 if (list == (char **) NULL)
2793 ThrowPerlException(exception,ResourceLimitError,
2794 "MemoryAllocationFailed",PackageName);
2797 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2798 if (length == (STRLEN *) NULL)
2800 ThrowPerlException(exception,ResourceLimitError,
2801 "MemoryAllocationFailed",PackageName);
2804 if (sv_isobject(ST(0)) == 0)
2806 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2810 reference=SvRV(ST(0));
2811 hv=SvSTASH(reference);
2812 if (SvTYPE(reference) != SVt_PVAV)
2814 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2818 av=(AV *) reference;
2819 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2824 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2827 for (n=0, i=0; i < ac; i++)
2829 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2830 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2832 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2837 list[n]=(char *) NULL;
2839 for (i=number_images=0; i < n; i++)
2841 image=BlobToImage(info->image_info,list[i],length[i],exception);
2842 if (image == (Image *) NULL)
2844 for ( ; image; image=image->next)
2846 AddImageToRegistry(sv,image);
2848 av_push(av,sv_bless(rv,hv));
2856 for (i=0; i < n; i++)
2857 if (list[i] != (char *) NULL)
2858 for (p=keep; list[i] != *p++; )
2859 if (*p == (char *) NULL)
2861 list[i]=(char *) RelinquishMagickMemory(list[i]);
2867 list=(char **) RelinquishMagickMemory(list);
2869 length=(STRLEN *) RelinquishMagickMemory(length);
2870 InheritPerlException(exception,perl_exception);
2871 exception=DestroyExceptionInfo(exception);
2872 sv_setiv(perl_exception,(IV) number_images);
2873 SvPOK_on(perl_exception);
2874 ST(0)=sv_2mortal(perl_exception);
2879 ###############################################################################
2883 # C h a n n e l F x #
2887 ###############################################################################
2892 Image::Magick ref=NO_INIT
2904 expression[MagickPathExtent];
2932 PERL_UNUSED_VAR(ref);
2933 PERL_UNUSED_VAR(ix);
2934 exception=AcquireExceptionInfo();
2935 perl_exception=newSVpv("",0);
2939 if (sv_isobject(ST(0)) == 0)
2941 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2945 reference=SvRV(ST(0));
2946 hv=SvSTASH(reference);
2948 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2950 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2951 if (image == (Image *) NULL)
2953 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2957 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2961 channel=DefaultChannels;
2962 (void) CopyMagickString(expression,"u",MagickPathExtent);
2964 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2966 for (i=2; i < items; i+=2)
2968 attribute=(char *) SvPV(ST(i-1),na);
2974 if (LocaleCompare(attribute,"channel") == 0)
2979 option=ParseChannelOption(SvPV(ST(i),na));
2982 ThrowPerlException(exception,OptionError,
2983 "UnrecognizedType",SvPV(ST(i),na));
2986 channel=(ChannelType) option;
2989 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2996 if (LocaleCompare(attribute,"expression") == 0)
2998 (void) CopyMagickString(expression,SvPV(ST(i),na),
3002 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3008 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3014 channel_mask=SetImageChannelMask(image,channel);
3015 image=ChannelFxImage(image,expression,exception);
3016 if (image != (Image *) NULL)
3017 (void) SetImageChannelMask(image,channel_mask);
3018 if (image == (Image *) NULL)
3020 for ( ; image; image=image->next)
3022 AddImageToRegistry(sv,image);
3024 av_push(av,sv_bless(rv,hv));
3027 exception=DestroyExceptionInfo(exception);
3029 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3033 InheritPerlException(exception,perl_exception);
3034 exception=DestroyExceptionInfo(exception);
3035 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3036 SvPOK_on(perl_exception);
3037 ST(0)=sv_2mortal(perl_exception);
3042 ###############################################################################
3050 ###############################################################################
3055 Image::Magick ref=NO_INIT
3088 PERL_UNUSED_VAR(ref);
3089 PERL_UNUSED_VAR(ix);
3090 exception=AcquireExceptionInfo();
3091 perl_exception=newSVpv("",0);
3093 if (sv_isobject(ST(0)) == 0)
3095 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3099 reference=SvRV(ST(0));
3100 hv=SvSTASH(reference);
3101 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3102 if (image == (Image *) NULL)
3104 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3109 Create blessed Perl array for the returned image.
3112 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3114 for ( ; image; image=image->next)
3116 clone=CloneImage(image,0,0,MagickTrue,exception);
3117 if (clone == (Image *) NULL)
3119 AddImageToRegistry(sv,clone);
3121 av_push(av,sv_bless(rv,hv));
3124 exception=DestroyExceptionInfo(exception);
3125 SvREFCNT_dec(perl_exception);
3129 InheritPerlException(exception,perl_exception);
3130 exception=DestroyExceptionInfo(exception);
3131 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3132 SvPOK_on(perl_exception);
3133 ST(0)=sv_2mortal(perl_exception);
3138 ###############################################################################
3146 ###############################################################################
3154 PERL_UNUSED_VAR(ref);
3155 if (magick_registry != (SplayTreeInfo *) NULL)
3160 ResetSplayTreeIterator(magick_registry);
3161 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3162 while (p != (Image *) NULL)
3165 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3171 ###############################################################################
3179 ###############################################################################
3184 Image::Magick ref=NO_INIT
3213 PERL_UNUSED_VAR(ref);
3214 PERL_UNUSED_VAR(ix);
3215 exception=AcquireExceptionInfo();
3216 perl_exception=newSVpv("",0);
3218 if (sv_isobject(ST(0)) == 0)
3220 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3224 reference=SvRV(ST(0));
3225 hv=SvSTASH(reference);
3227 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3229 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3230 if (image == (Image *) NULL)
3232 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3236 image=CoalesceImages(image,exception);
3237 if (image == (Image *) NULL)
3239 for ( ; image; image=image->next)
3241 AddImageToRegistry(sv,image);
3243 av_push(av,sv_bless(rv,hv));
3246 exception=DestroyExceptionInfo(exception);
3248 SvREFCNT_dec(perl_exception);
3252 InheritPerlException(exception,perl_exception);
3253 exception=DestroyExceptionInfo(exception);
3254 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3255 SvPOK_on(perl_exception);
3256 ST(0)=sv_2mortal(perl_exception);
3261 ###############################################################################
3269 ###############################################################################
3274 Image::Magick ref=NO_INIT
3320 PERL_UNUSED_VAR(ref);
3321 PERL_UNUSED_VAR(ix);
3322 exception=AcquireExceptionInfo();
3323 perl_exception=newSVpv("",0);
3327 if (sv_isobject(ST(0)) == 0)
3329 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3333 reference=SvRV(ST(0));
3334 hv=SvSTASH(reference);
3336 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3338 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3339 if (image == (Image *) NULL)
3341 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3345 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3349 reconstruct_image=image;
3350 metric=RootMeanSquaredErrorMetric;
3351 for (i=2; i < items; i+=2)
3353 attribute=(char *) SvPV(ST(i-1),na);
3359 if (LocaleCompare(attribute,"channel") == 0)
3364 option=ParseChannelOption(SvPV(ST(i),na));
3367 ThrowPerlException(exception,OptionError,
3368 "UnrecognizedType",SvPV(ST(i),na));
3371 (void) SetPixelChannelMask(image,(ChannelType) option);
3374 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3381 if (LocaleCompare(attribute,"fuzz") == 0)
3383 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3386 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3393 if (LocaleCompare(attribute,"image") == 0)
3395 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3396 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3406 if (LocaleCompare(attribute,"metric") == 0)
3408 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3412 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3416 metric=(MetricType) option;
3419 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3425 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3431 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3433 if (difference_image != (Image *) NULL)
3435 difference_image->error.mean_error_per_pixel=distortion;
3436 AddImageToRegistry(sv,difference_image);
3438 av_push(av,sv_bless(rv,hv));
3441 exception=DestroyExceptionInfo(exception);
3443 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3447 InheritPerlException(exception,perl_exception);
3448 exception=DestroyExceptionInfo(exception);
3449 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3450 SvPOK_on(perl_exception);
3451 ST(0)=sv_2mortal(perl_exception);
3456 ###############################################################################
3460 # C o m p l e x I m a g e s #
3464 ###############################################################################
3469 Image::Magick ref=NO_INIT
3506 PERL_UNUSED_VAR(ref);
3507 PERL_UNUSED_VAR(ix);
3508 exception=AcquireExceptionInfo();
3509 perl_exception=newSVpv("",0);
3511 if (sv_isobject(ST(0)) == 0)
3513 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3517 reference=SvRV(ST(0));
3518 hv=SvSTASH(reference);
3519 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3520 if (image == (Image *) NULL)
3522 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3526 op=UndefinedComplexOperator;
3532 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3536 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3540 op=(ComplexOperator) in;
3543 for (i=2; i < items; i+=2)
3545 attribute=(char *) SvPV(ST(i-1),na);
3551 if (LocaleCompare(attribute,"operator") == 0)
3556 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3557 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3560 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3564 op=(ComplexOperator) in;
3567 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3573 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3579 image=ComplexImages(image,op,exception);
3580 if (image == (Image *) NULL)
3583 Create blessed Perl array for the returned image.
3586 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3588 AddImageToRegistry(sv,image);
3590 av_push(av,sv_bless(rv,hv));
3592 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3593 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3594 "complex-%.*s",(int) (MagickPathExtent-9),
3595 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3596 (void) CopyMagickString(image->filename,info->image_info->filename,
3598 SetImageInfo(info->image_info,0,exception);
3599 exception=DestroyExceptionInfo(exception);
3600 SvREFCNT_dec(perl_exception);
3604 InheritPerlException(exception,perl_exception);
3605 exception=DestroyExceptionInfo(exception);
3606 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3607 SvPOK_on(perl_exception);
3608 ST(0)=sv_2mortal(perl_exception);
3613 ###############################################################################
3617 # C o m p a r e L a y e r s #
3621 ###############################################################################
3626 Image::Magick ref=NO_INIT
3628 CompareImagesLayers = 1
3630 compareimagelayers = 3
3667 PERL_UNUSED_VAR(ref);
3668 PERL_UNUSED_VAR(ix);
3669 exception=AcquireExceptionInfo();
3670 perl_exception=newSVpv("",0);
3672 if (sv_isobject(ST(0)) == 0)
3674 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3678 reference=SvRV(ST(0));
3679 hv=SvSTASH(reference);
3681 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3683 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3684 if (image == (Image *) NULL)
3686 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3690 method=CompareAnyLayer;
3691 for (i=2; i < items; i+=2)
3693 attribute=(char *) SvPV(ST(i-1),na);
3699 if (LocaleCompare(attribute,"method") == 0)
3701 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3705 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3709 method=(LayerMethod) option;
3712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3718 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3724 image=CompareImagesLayers(image,method,exception);
3725 if (image == (Image *) NULL)
3727 for ( ; image; image=image->next)
3729 AddImageToRegistry(sv,image);
3731 av_push(av,sv_bless(rv,hv));
3734 exception=DestroyExceptionInfo(exception);
3736 SvREFCNT_dec(perl_exception);
3740 InheritPerlException(exception,perl_exception);
3741 exception=DestroyExceptionInfo(exception);
3742 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3743 SvPOK_on(perl_exception);
3744 ST(0)=sv_2mortal(perl_exception);
3749 ###############################################################################
3757 ###############################################################################
3762 Image::Magick ref=NO_INIT
3768 PERL_UNUSED_VAR(ref);
3769 if (sv_isobject(ST(0)) == 0)
3770 croak("ReferenceIsNotMyType");
3771 reference=SvRV(ST(0));
3772 switch (SvTYPE(reference))
3777 message[MagickPathExtent];
3795 Array (AV *) reference
3797 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3798 XS_VERSION,reference);
3799 hv=gv_stashpv(PackageName, FALSE);
3802 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3806 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3808 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3809 DestroyPackageInfo(info);
3811 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3821 Blessed scalar = (Image *) SvIV(reference)
3823 image=INT2PTR(Image *,SvIV(reference));
3824 if (image != (Image *) NULL)
3825 DeleteImageFromRegistry(reference,image);
3834 ###############################################################################
3842 ###############################################################################
3847 Image::Magick ref=NO_INIT
3871 PERL_UNUSED_VAR(ref);
3872 PERL_UNUSED_VAR(ix);
3873 exception=AcquireExceptionInfo();
3874 perl_exception=newSVpv("",0);
3875 package_info=(struct PackageInfo *) NULL;
3876 if (sv_isobject(ST(0)) == 0)
3878 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3882 reference=SvRV(ST(0));
3883 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3884 if (image == (Image *) NULL)
3886 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3890 package_info=ClonePackageInfo(info,exception);
3892 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3895 for (i=2; i < items; i+=2)
3896 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3898 (void) DisplayImages(package_info->image_info,image,exception);
3899 (void) CatchImageException(image);
3902 if (package_info != (struct PackageInfo *) NULL)
3903 DestroyPackageInfo(package_info);
3904 InheritPerlException(exception,perl_exception);
3905 exception=DestroyExceptionInfo(exception);
3906 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3907 SvPOK_on(perl_exception);
3908 ST(0)=sv_2mortal(perl_exception);
3913 ###############################################################################
3917 # E v a l u a t e I m a g e s #
3921 ###############################################################################
3926 Image::Magick ref=NO_INIT
3948 MagickEvaluateOperator
3963 PERL_UNUSED_VAR(ref);
3964 PERL_UNUSED_VAR(ix);
3965 exception=AcquireExceptionInfo();
3966 perl_exception=newSVpv("",0);
3968 if (sv_isobject(ST(0)) == 0)
3970 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3974 reference=SvRV(ST(0));
3975 hv=SvSTASH(reference);
3976 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3977 if (image == (Image *) NULL)
3979 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3983 op=MeanEvaluateOperator;
3989 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3993 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3997 op=(MagickEvaluateOperator) in;
4000 for (i=2; i < items; i+=2)
4002 attribute=(char *) SvPV(ST(i-1),na);
4008 if (LocaleCompare(attribute,"operator") == 0)
4013 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4014 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4017 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4021 op=(MagickEvaluateOperator) in;
4024 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4030 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4036 image=EvaluateImages(image,op,exception);
4037 if (image == (Image *) NULL)
4040 Create blessed Perl array for the returned image.
4043 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4045 AddImageToRegistry(sv,image);
4047 av_push(av,sv_bless(rv,hv));
4049 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4050 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4051 "evaluate-%.*s",(int) (MagickPathExtent-9),
4052 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4053 (void) CopyMagickString(image->filename,info->image_info->filename,
4055 SetImageInfo(info->image_info,0,exception);
4056 exception=DestroyExceptionInfo(exception);
4057 SvREFCNT_dec(perl_exception);
4061 InheritPerlException(exception,perl_exception);
4062 exception=DestroyExceptionInfo(exception);
4063 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4064 SvPOK_on(perl_exception);
4065 ST(0)=sv_2mortal(perl_exception);
4070 ###############################################################################
4078 ###############################################################################
4083 Image::Magick ref=NO_INIT
4090 #define ChannelFeatures(channel,direction) \
4092 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4093 channel_features[channel].angular_second_moment[direction]); \
4094 PUSHs(sv_2mortal(newSVpv(message,0))); \
4095 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4096 channel_features[channel].contrast[direction]); \
4097 PUSHs(sv_2mortal(newSVpv(message,0))); \
4098 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4099 channel_features[channel].contrast[direction]); \
4100 PUSHs(sv_2mortal(newSVpv(message,0))); \
4101 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4102 channel_features[channel].variance_sum_of_squares[direction]); \
4103 PUSHs(sv_2mortal(newSVpv(message,0))); \
4104 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4105 channel_features[channel].inverse_difference_moment[direction]); \
4106 PUSHs(sv_2mortal(newSVpv(message,0))); \
4107 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4108 channel_features[channel].sum_average[direction]); \
4109 PUSHs(sv_2mortal(newSVpv(message,0))); \
4110 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4111 channel_features[channel].sum_variance[direction]); \
4112 PUSHs(sv_2mortal(newSVpv(message,0))); \
4113 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4114 channel_features[channel].sum_entropy[direction]); \
4115 PUSHs(sv_2mortal(newSVpv(message,0))); \
4116 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4117 channel_features[channel].entropy[direction]); \
4118 PUSHs(sv_2mortal(newSVpv(message,0))); \
4119 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4120 channel_features[channel].difference_variance[direction]); \
4121 PUSHs(sv_2mortal(newSVpv(message,0))); \
4122 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4123 channel_features[channel].difference_entropy[direction]); \
4124 PUSHs(sv_2mortal(newSVpv(message,0))); \
4125 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4126 channel_features[channel].measure_of_correlation_1[direction]); \
4127 PUSHs(sv_2mortal(newSVpv(message,0))); \
4128 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4129 channel_features[channel].measure_of_correlation_2[direction]); \
4130 PUSHs(sv_2mortal(newSVpv(message,0))); \
4131 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4132 channel_features[channel].maximum_correlation_coefficient[direction]); \
4133 PUSHs(sv_2mortal(newSVpv(message,0))); \
4141 message[MagickPathExtent];
4168 PERL_UNUSED_VAR(ref);
4169 PERL_UNUSED_VAR(ix);
4170 exception=AcquireExceptionInfo();
4171 perl_exception=newSVpv("",0);
4173 if (sv_isobject(ST(0)) == 0)
4175 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4179 reference=SvRV(ST(0));
4182 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4183 if (image == (Image *) NULL)
4185 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4190 for (i=2; i < items; i+=2)
4192 attribute=(char *) SvPV(ST(i-1),na);
4198 if (LocaleCompare(attribute,"distance") == 0)
4200 distance=StringToLong((char *) SvPV(ST(1),na));
4203 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4209 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4216 for ( ; image; image=image->next)
4218 channel_features=GetImageFeatures(image,distance,exception);
4219 if (channel_features == (ChannelFeatures *) NULL)
4222 EXTEND(sp,280*count);
4223 for (i=0; i < 4; i++)
4225 ChannelFeatures(RedChannel,i);
4226 ChannelFeatures(GreenChannel,i);
4227 ChannelFeatures(BlueChannel,i);
4228 if (image->colorspace == CMYKColorspace)
4229 ChannelFeatures(BlackChannel,i);
4230 if (image->alpha_trait != UndefinedPixelTrait)
4231 ChannelFeatures(AlphaChannel,i);
4233 channel_features=(ChannelFeatures *)
4234 RelinquishMagickMemory(channel_features);
4238 InheritPerlException(exception,perl_exception);
4239 exception=DestroyExceptionInfo(exception);
4240 SvREFCNT_dec(perl_exception);
4244 ###############################################################################
4252 ###############################################################################
4257 Image::Magick ref=NO_INIT
4295 PERL_UNUSED_VAR(ref);
4296 PERL_UNUSED_VAR(ix);
4297 exception=AcquireExceptionInfo();
4298 perl_exception=newSVpv("",0);
4300 if (sv_isobject(ST(0)) == 0)
4302 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4306 reference=SvRV(ST(0));
4307 hv=SvSTASH(reference);
4308 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4309 if (image == (Image *) NULL)
4311 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4315 background_color=image->background_color;
4317 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4318 &background_color,exception);
4320 for (i=2; i < items; i+=2)
4322 attribute=(char *) SvPV(ST(i-1),na);
4328 if (LocaleCompare(attribute,"background") == 0)
4330 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4331 AllCompliance,&background_color,exception);
4334 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4340 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4346 image->background_color=background_color;
4347 image=MergeImageLayers(image,FlattenLayer,exception);
4348 if (image == (Image *) NULL)
4351 Create blessed Perl array for the returned image.
4354 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4356 AddImageToRegistry(sv,image);
4358 av_push(av,sv_bless(rv,hv));
4360 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4361 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4362 "flatten-%.*s",(int) (MagickPathExtent-9),
4363 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4364 (void) CopyMagickString(image->filename,info->image_info->filename,
4366 SetImageInfo(info->image_info,0,exception);
4367 exception=DestroyExceptionInfo(exception);
4368 SvREFCNT_dec(perl_exception);
4372 InheritPerlException(exception,perl_exception);
4373 exception=DestroyExceptionInfo(exception);
4374 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4375 SvPOK_on(perl_exception); /* return messages in string context */
4376 ST(0)=sv_2mortal(perl_exception);
4381 ###############################################################################
4389 ###############################################################################
4394 Image::Magick ref=NO_INIT
4406 expression[MagickPathExtent];
4434 PERL_UNUSED_VAR(ref);
4435 PERL_UNUSED_VAR(ix);
4436 exception=AcquireExceptionInfo();
4437 perl_exception=newSVpv("",0);
4441 if (sv_isobject(ST(0)) == 0)
4443 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4447 reference=SvRV(ST(0));
4448 hv=SvSTASH(reference);
4450 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4452 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4453 if (image == (Image *) NULL)
4455 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4459 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4463 channel=DefaultChannels;
4464 (void) CopyMagickString(expression,"u",MagickPathExtent);
4466 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4468 for (i=2; i < items; i+=2)
4470 attribute=(char *) SvPV(ST(i-1),na);
4476 if (LocaleCompare(attribute,"channel") == 0)
4481 option=ParseChannelOption(SvPV(ST(i),na));
4484 ThrowPerlException(exception,OptionError,
4485 "UnrecognizedType",SvPV(ST(i),na));
4488 channel=(ChannelType) option;
4491 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4498 if (LocaleCompare(attribute,"expression") == 0)
4500 (void) CopyMagickString(expression,SvPV(ST(i),na),
4504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4510 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4516 channel_mask=SetImageChannelMask(image,channel);
4517 image=FxImage(image,expression,exception);
4518 if (image != (Image *) NULL)
4519 (void) SetImageChannelMask(image,channel_mask);
4520 if (image == (Image *) NULL)
4522 for ( ; image; image=image->next)
4524 AddImageToRegistry(sv,image);
4526 av_push(av,sv_bless(rv,hv));
4529 exception=DestroyExceptionInfo(exception);
4531 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4535 InheritPerlException(exception,perl_exception);
4536 exception=DestroyExceptionInfo(exception);
4537 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4538 SvPOK_on(perl_exception);
4539 ST(0)=sv_2mortal(perl_exception);
4544 ###############################################################################
4552 ###############################################################################
4557 Image::Magick ref=NO_INIT
4568 color[MagickPathExtent];
4593 PERL_UNUSED_VAR(ref);
4594 PERL_UNUSED_VAR(ix);
4595 exception=AcquireExceptionInfo();
4596 perl_exception=newSVpv("",0);
4597 if (sv_isobject(ST(0)) == 0)
4599 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4603 reference=SvRV(ST(0));
4604 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4605 if (image == (Image *) NULL && !info)
4608 for (i=1; i < items; i++)
4610 attribute=(char *) SvPV(ST(i),na);
4617 if (LocaleCompare(attribute,"adjoin") == 0)
4620 s=newSViv((ssize_t) info->image_info->adjoin);
4621 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4624 if (LocaleCompare(attribute,"antialias") == 0)
4627 s=newSViv((ssize_t) info->image_info->antialias);
4628 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4631 if (LocaleCompare(attribute,"area") == 0)
4633 s=newSViv(GetMagickResource(AreaResource));
4634 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4637 if (LocaleCompare(attribute,"attenuate") == 0)
4642 value=GetImageProperty(image,attribute,exception);
4643 if (value != (const char *) NULL)
4645 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4648 if (LocaleCompare(attribute,"authenticate") == 0)
4655 option=GetImageOption(info->image_info,attribute);
4656 if (option != (const char *) NULL)
4657 s=newSVpv(option,0);
4659 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4662 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4669 if (LocaleCompare(attribute,"background") == 0)
4671 if (image == (Image *) NULL)
4673 (void) FormatLocaleString(color,MagickPathExtent,
4674 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4675 (double) image->background_color.green,
4676 (double) image->background_color.blue,
4677 (double) image->background_color.alpha);
4679 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4682 if (LocaleCompare(attribute,"base-columns") == 0)
4684 if (image != (Image *) NULL)
4685 s=newSViv((ssize_t) image->magick_columns);
4686 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4689 if (LocaleCompare(attribute,"base-filename") == 0)
4691 if (image != (Image *) NULL)
4692 s=newSVpv(image->magick_filename,0);
4693 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4696 if (LocaleCompare(attribute,"base-height") == 0)
4698 if (image != (Image *) NULL)
4699 s=newSViv((ssize_t) image->magick_rows);
4700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4703 if (LocaleCompare(attribute,"base-rows") == 0)
4705 if (image != (Image *) NULL)
4706 s=newSViv((ssize_t) image->magick_rows);
4707 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4710 if (LocaleCompare(attribute,"base-width") == 0)
4712 if (image != (Image *) NULL)
4713 s=newSViv((ssize_t) image->magick_columns);
4714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4717 if (LocaleCompare(attribute,"blue-primary") == 0)
4719 if (image == (Image *) NULL)
4721 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4722 image->chromaticity.blue_primary.x,
4723 image->chromaticity.blue_primary.y);
4725 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4728 if (LocaleCompare(attribute,"bordercolor") == 0)
4730 if (image == (Image *) NULL)
4732 (void) FormatLocaleString(color,MagickPathExtent,
4733 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4734 (double) image->border_color.green,
4735 (double) image->border_color.blue,
4736 (double) image->border_color.alpha);
4738 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4741 if (LocaleCompare(attribute,"bounding-box") == 0)
4744 geometry[MagickPathExtent];
4749 if (image == (Image *) NULL)
4751 page=GetImageBoundingBox(image,exception);
4752 (void) FormatLocaleString(geometry,MagickPathExtent,
4753 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4754 page.height,(double) page.x,(double) page.y);
4755 s=newSVpv(geometry,0);
4756 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4759 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4766 if (LocaleCompare(attribute,"class") == 0)
4768 if (image == (Image *) NULL)
4770 s=newSViv(image->storage_class);
4771 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4772 image->storage_class));
4774 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4777 if (LocaleCompare(attribute,"clip-mask") == 0)
4779 if (image != (Image *) NULL)
4788 if (image->read_mask == MagickFalse)
4789 ClipImage(image,exception);
4790 mask_image=GetImageMask(image,ReadPixelMask,exception);
4791 if (mask_image != (Image *) NULL)
4793 AddImageToRegistry(sv,mask_image);
4794 s=sv_bless(newRV(sv),SvSTASH(reference));
4797 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4800 if (LocaleCompare(attribute,"clip-path") == 0)
4802 if (image != (Image *) NULL)
4811 if (image->read_mask != MagickFalse)
4812 ClipImage(image,exception);
4813 mask_image=GetImageMask(image,ReadPixelMask,exception);
4814 if (mask_image != (Image *) NULL)
4816 AddImageToRegistry(sv,mask_image);
4817 s=sv_bless(newRV(sv),SvSTASH(reference));
4820 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4823 if (LocaleCompare(attribute,"compression") == 0)
4825 j=info ? info->image_info->compression : image ?
4826 image->compression : UndefinedCompression;
4828 if (info->image_info->compression == UndefinedCompression)
4829 j=image->compression;
4831 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4834 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4837 if (LocaleCompare(attribute,"colorspace") == 0)
4839 j=image ? image->colorspace : RGBColorspace;
4841 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4844 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4847 if (LocaleCompare(attribute,"colors") == 0)
4849 if (image != (Image *) NULL)
4850 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4852 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4855 if (LocaleNCompare(attribute,"colormap",8) == 0)
4860 if (image == (Image *) NULL || !image->colormap)
4863 items=sscanf(attribute,"%*[^[][%ld",&j);
4865 if (j > (ssize_t) image->colors)
4867 (void) FormatLocaleString(color,MagickPathExtent,
4868 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4869 (double) image->colormap[j].green,
4870 (double) image->colormap[j].blue,
4871 (double) image->colormap[j].alpha);
4873 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4876 if (LocaleCompare(attribute,"columns") == 0)
4878 if (image != (Image *) NULL)
4879 s=newSViv((ssize_t) image->columns);
4880 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4883 if (LocaleCompare(attribute,"comment") == 0)
4888 value=GetImageProperty(image,attribute,exception);
4889 if (value != (const char *) NULL)
4891 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4894 if (LocaleCompare(attribute,"copyright") == 0)
4896 s=newSVpv(GetMagickCopyright(),0);
4897 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4900 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4907 if (LocaleCompare(attribute,"density") == 0)
4910 geometry[MagickPathExtent];
4912 if (image == (Image *) NULL)
4914 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4915 image->resolution.x,image->resolution.y);
4916 s=newSVpv(geometry,0);
4917 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4920 if (LocaleCompare(attribute,"delay") == 0)
4922 if (image != (Image *) NULL)
4923 s=newSViv((ssize_t) image->delay);
4924 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4927 if (LocaleCompare(attribute,"depth") == 0)
4929 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4930 if (image != (Image *) NULL)
4931 s=newSViv((ssize_t) GetImageDepth(image,exception));
4932 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4935 if (LocaleCompare(attribute,"directory") == 0)
4937 if (image && image->directory)
4938 s=newSVpv(image->directory,0);
4939 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4942 if (LocaleCompare(attribute,"dispose") == 0)
4944 if (image == (Image *) NULL)
4947 s=newSViv(image->dispose);
4949 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4951 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4954 if (LocaleCompare(attribute,"disk") == 0)
4956 s=newSViv(GetMagickResource(DiskResource));
4957 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4960 if (LocaleCompare(attribute,"dither") == 0)
4963 s=newSViv((ssize_t) info->image_info->dither);
4964 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4967 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4969 if (info && info->image_info->server_name)
4970 s=newSVpv(info->image_info->server_name,0);
4971 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4974 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4981 if (LocaleCompare(attribute,"elapsed-time") == 0)
4983 if (image != (Image *) NULL)
4984 s=newSVnv(GetElapsedTime(&image->timer));
4985 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4988 if (LocaleCompare(attribute,"endian") == 0)
4990 j=info ? info->image_info->endian : image ? image->endian :
4993 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4995 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4998 if (LocaleCompare(attribute,"error") == 0)
5000 if (image != (Image *) NULL)
5001 s=newSVnv(image->error.mean_error_per_pixel);
5002 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5012 if (LocaleCompare(attribute,"filesize") == 0)
5014 if (image != (Image *) NULL)
5015 s=newSViv((ssize_t) GetBlobSize(image));
5016 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 if (LocaleCompare(attribute,"filename") == 0)
5021 if (info && info->image_info->filename &&
5022 *info->image_info->filename)
5023 s=newSVpv(info->image_info->filename,0);
5024 if (image != (Image *) NULL)
5025 s=newSVpv(image->filename,0);
5026 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5029 if (LocaleCompare(attribute,"filter") == 0)
5031 s=image ? newSViv(image->filter) : newSViv(0);
5032 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5035 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5038 if (LocaleCompare(attribute,"font") == 0)
5040 if (info && info->image_info->font)
5041 s=newSVpv(info->image_info->font,0);
5042 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5045 if (LocaleCompare(attribute,"foreground") == 0)
5047 if (LocaleCompare(attribute,"format") == 0)
5052 magick_info=(const MagickInfo *) NULL;
5053 if (info && (*info->image_info->magick != '\0'))
5054 magick_info=GetMagickInfo(info->image_info->magick,exception);
5055 if (image != (Image *) NULL)
5056 magick_info=GetMagickInfo(image->magick,exception);
5057 if ((magick_info != (const MagickInfo *) NULL) &&
5058 (*magick_info->description != '\0'))
5059 s=newSVpv((char *) magick_info->description,0);
5060 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5063 if (LocaleCompare(attribute,"fuzz") == 0)
5066 s=newSVnv(info->image_info->fuzz);
5067 if (image != (Image *) NULL)
5068 s=newSVnv(image->fuzz);
5069 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5072 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5079 if (LocaleCompare(attribute,"gamma") == 0)
5081 if (image != (Image *) NULL)
5082 s=newSVnv(image->gamma);
5083 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5086 if (LocaleCompare(attribute,"geometry") == 0)
5088 if (image && image->geometry)
5089 s=newSVpv(image->geometry,0);
5090 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5093 if (LocaleCompare(attribute,"gravity") == 0)
5095 s=image ? newSViv(image->gravity) : newSViv(0);
5096 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5099 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5102 if (LocaleCompare(attribute,"green-primary") == 0)
5104 if (image == (Image *) NULL)
5106 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5107 image->chromaticity.green_primary.x,
5108 image->chromaticity.green_primary.y);
5110 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5113 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5120 if (LocaleCompare(attribute,"height") == 0)
5122 if (image != (Image *) NULL)
5123 s=newSViv((ssize_t) image->rows);
5124 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5127 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5134 if (LocaleCompare(attribute,"icc") == 0)
5136 if (image != (Image *) NULL)
5141 profile=GetImageProfile(image,"icc");
5142 if (profile != (StringInfo *) NULL)
5143 s=newSVpv((const char *) GetStringInfoDatum(profile),
5144 GetStringInfoLength(profile));
5146 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5149 if (LocaleCompare(attribute,"icm") == 0)
5151 if (image != (Image *) NULL)
5156 profile=GetImageProfile(image,"icm");
5157 if (profile != (const StringInfo *) NULL)
5158 s=newSVpv((const char *) GetStringInfoDatum(profile),
5159 GetStringInfoLength(profile));
5161 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5164 if (LocaleCompare(attribute,"id") == 0)
5166 if (image != (Image *) NULL)
5169 key[MagickPathExtent];
5177 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5179 status=SetImageRegistry(ImageRegistryType,key,image,
5184 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5187 if (LocaleNCompare(attribute,"index",5) == 0)
5190 name[MagickPathExtent];
5199 register const Quantum
5205 if (image == (Image *) NULL)
5207 if (image->storage_class != PseudoClass)
5211 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5213 image_view=AcquireVirtualCacheView(image,exception);
5214 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5215 if (p != (const Quantum *) NULL)
5217 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5218 GetPixelIndex(image,p));
5220 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 image_view=DestroyCacheView(image_view);
5225 if (LocaleCompare(attribute,"iptc") == 0)
5227 if (image != (Image *) NULL)
5232 profile=GetImageProfile(image,"iptc");
5233 if (profile != (const StringInfo *) NULL)
5234 s=newSVpv((const char *) GetStringInfoDatum(profile),
5235 GetStringInfoLength(profile));
5237 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5240 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5242 if (image != (Image *) NULL)
5243 s=newSViv((ssize_t) image->iterations);
5244 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5247 if (LocaleCompare(attribute,"interlace") == 0)
5249 j=info ? info->image_info->interlace : image ? image->interlace :
5252 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5255 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5258 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5265 if (LocaleCompare(attribute,"label") == 0)
5270 if (image == (Image *) NULL)
5272 value=GetImageProperty(image,"Label",exception);
5273 if (value != (const char *) NULL)
5275 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5278 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5280 if (image != (Image *) NULL)
5281 s=newSViv((ssize_t) image->iterations);
5282 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5285 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5292 if (LocaleCompare(attribute,"magick") == 0)
5294 if (info && *info->image_info->magick)
5295 s=newSVpv(info->image_info->magick,0);
5296 if (image != (Image *) NULL)
5297 s=newSVpv(image->magick,0);
5298 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5301 if (LocaleCompare(attribute,"map") == 0)
5303 s=newSViv(GetMagickResource(MapResource));
5304 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5307 if (LocaleCompare(attribute,"maximum-error") == 0)
5309 if (image != (Image *) NULL)
5310 s=newSVnv(image->error.normalized_maximum_error);
5311 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5314 if (LocaleCompare(attribute,"memory") == 0)
5316 s=newSViv(GetMagickResource(MemoryResource));
5317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 if (LocaleCompare(attribute,"mean-error") == 0)
5322 if (image != (Image *) NULL)
5323 s=newSVnv(image->error.normalized_mean_error);
5324 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5327 if (LocaleCompare(attribute,"mime") == 0)
5329 if (info && *info->image_info->magick)
5330 s=newSVpv(MagickToMime(info->image_info->magick),0);
5331 if (image != (Image *) NULL)
5332 s=newSVpv(MagickToMime(image->magick),0);
5333 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5336 if (LocaleCompare(attribute,"mattecolor") == 0)
5338 if (image == (Image *) NULL)
5340 (void) FormatLocaleString(color,MagickPathExtent,
5341 "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red,
5342 (double) image->alpha_color.green,
5343 (double) image->alpha_color.blue,
5344 (double) image->alpha_color.alpha);
5346 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5349 if (LocaleCompare(attribute,"matte") == 0)
5351 if (image != (Image *) NULL)
5352 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5354 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5357 if (LocaleCompare(attribute,"mime") == 0)
5363 if (info && *info->image_info->magick)
5364 magick=info->image_info->magick;
5365 if (image != (Image *) NULL)
5366 magick=image->magick;
5372 mime=MagickToMime(magick);
5374 mime=(char *) RelinquishMagickMemory(mime);
5376 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5379 if (LocaleCompare(attribute,"monochrome") == 0)
5381 if (image == (Image *) NULL)
5383 j=info ? info->image_info->monochrome :
5384 SetImageMonochrome(image,exception);
5386 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5389 if (LocaleCompare(attribute,"montage") == 0)
5391 if (image && image->montage)
5392 s=newSVpv(image->montage,0);
5393 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5396 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5403 if (LocaleCompare(attribute,"orientation") == 0)
5405 j=info ? info->image_info->orientation : image ?
5406 image->orientation : UndefinedOrientation;
5408 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5411 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5414 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5421 if (LocaleCompare(attribute,"page") == 0)
5423 if (info && info->image_info->page)
5424 s=newSVpv(info->image_info->page,0);
5425 if (image != (Image *) NULL)
5428 geometry[MagickPathExtent];
5430 (void) FormatLocaleString(geometry,MagickPathExtent,
5431 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5432 (double) image->page.height,(double) image->page.x,(double)
5434 s=newSVpv(geometry,0);
5436 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5439 if (LocaleCompare(attribute,"page.x") == 0)
5441 if (image != (Image *) NULL)
5442 s=newSViv((ssize_t) image->page.x);
5443 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5446 if (LocaleCompare(attribute,"page.y") == 0)
5448 if (image != (Image *) NULL)
5449 s=newSViv((ssize_t) image->page.y);
5450 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5453 if (LocaleNCompare(attribute,"pixel",5) == 0)
5456 tuple[MagickPathExtent];
5465 register const Quantum
5468 if (image == (Image *) NULL)
5472 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5474 p=GetVirtualPixels(image,x,y,1,1,exception);
5475 if (image->colorspace != CMYKColorspace)
5476 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5477 QuantumFormat "," QuantumFormat "," QuantumFormat,
5478 GetPixelRed(image,p),GetPixelGreen(image,p),
5479 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5481 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5482 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5483 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5484 GetPixelBlue(image,p),GetPixelBlack(image,p),
5485 GetPixelAlpha(image,p));
5487 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5490 if (LocaleCompare(attribute,"pointsize") == 0)
5493 s=newSViv((ssize_t) info->image_info->pointsize);
5494 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5497 if (LocaleCompare(attribute,"preview") == 0)
5499 s=newSViv(info->image_info->preview_type);
5500 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5501 info->image_info->preview_type));
5503 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5513 if (LocaleCompare(attribute,"quality") == 0)
5516 s=newSViv((ssize_t) info->image_info->quality);
5517 if (image != (Image *) NULL)
5518 s=newSViv((ssize_t) image->quality);
5519 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5522 if (LocaleCompare(attribute,"quantum") == 0)
5525 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5526 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5529 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5536 if (LocaleCompare(attribute,"rendering-intent") == 0)
5538 s=newSViv(image->rendering_intent);
5539 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5540 image->rendering_intent));
5542 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5545 if (LocaleCompare(attribute,"red-primary") == 0)
5547 if (image == (Image *) NULL)
5549 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5550 image->chromaticity.red_primary.x,
5551 image->chromaticity.red_primary.y);
5553 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5556 if (LocaleCompare(attribute,"rows") == 0)
5558 if (image != (Image *) NULL)
5559 s=newSViv((ssize_t) image->rows);
5560 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5563 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5570 if (LocaleCompare(attribute,"sampling-factor") == 0)
5572 if (info && info->image_info->sampling_factor)
5573 s=newSVpv(info->image_info->sampling_factor,0);
5574 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5577 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5579 if (info && info->image_info->server_name)
5580 s=newSVpv(info->image_info->server_name,0);
5581 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5584 if (LocaleCompare(attribute,"size") == 0)
5586 if (info && info->image_info->size)
5587 s=newSVpv(info->image_info->size,0);
5588 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5591 if (LocaleCompare(attribute,"scene") == 0)
5593 if (image != (Image *) NULL)
5594 s=newSViv((ssize_t) image->scene);
5595 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5598 if (LocaleCompare(attribute,"scenes") == 0)
5600 if (image != (Image *) NULL)
5601 s=newSViv((ssize_t) info->image_info->number_scenes);
5602 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5605 if (LocaleCompare(attribute,"signature") == 0)
5610 if (image == (Image *) NULL)
5612 (void) SignatureImage(image,exception);
5613 value=GetImageProperty(image,"Signature",exception);
5614 if (value != (const char *) NULL)
5616 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5619 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5626 if (LocaleCompare(attribute,"taint") == 0)
5628 if (image != (Image *) NULL)
5629 s=newSViv((ssize_t) IsTaintImage(image));
5630 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5633 if (LocaleCompare(attribute,"texture") == 0)
5635 if (info && info->image_info->texture)
5636 s=newSVpv(info->image_info->texture,0);
5637 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5640 if (LocaleCompare(attribute,"total-ink-density") == 0)
5642 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5643 if (image != (Image *) NULL)
5644 s=newSVnv(GetImageTotalInkDensity(image,exception));
5645 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5648 if (LocaleCompare(attribute,"transparent-color") == 0)
5650 if (image == (Image *) NULL)
5652 (void) FormatLocaleString(color,MagickPathExtent,
5653 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5654 (double) image->transparent_color.green,
5655 (double) image->transparent_color.blue,
5656 (double) image->transparent_color.alpha);
5658 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5661 if (LocaleCompare(attribute,"type") == 0)
5663 if (image == (Image *) NULL)
5665 j=(ssize_t) GetImageType(image);
5667 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5669 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5672 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5679 if (LocaleCompare(attribute,"units") == 0)
5681 j=info ? info->image_info->units : image ? image->units :
5682 UndefinedResolution;
5683 if (info && (info->image_info->units == UndefinedResolution))
5686 if (j == UndefinedResolution)
5687 s=newSVpv("undefined units",0);
5689 if (j == PixelsPerInchResolution)
5690 s=newSVpv("pixels / inch",0);
5692 s=newSVpv("pixels / centimeter",0);
5693 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5696 if (LocaleCompare(attribute,"user-time") == 0)
5698 if (image != (Image *) NULL)
5699 s=newSVnv(GetUserTime(&image->timer));
5700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5703 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5710 if (LocaleCompare(attribute,"verbose") == 0)
5713 s=newSViv((ssize_t) info->image_info->verbose);
5714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5717 if (LocaleCompare(attribute,"version") == 0)
5719 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5720 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5723 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5725 if (image == (Image *) NULL)
5727 j=(ssize_t) GetImageVirtualPixelMethod(image);
5729 (void) sv_setpv(s,CommandOptionToMnemonic(
5730 MagickVirtualPixelOptions,j));
5732 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5735 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5742 if (LocaleCompare(attribute,"white-point") == 0)
5744 if (image == (Image *) NULL)
5746 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5747 image->chromaticity.white_point.x,
5748 image->chromaticity.white_point.y);
5750 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5753 if (LocaleCompare(attribute,"width") == 0)
5755 if (image != (Image *) NULL)
5756 s=newSViv((ssize_t) image->columns);
5757 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5767 if (LocaleCompare(attribute,"xmp") == 0)
5769 if (image != (Image *) NULL)
5774 profile=GetImageProfile(image,"xmp");
5775 if (profile != (StringInfo *) NULL)
5776 s=newSVpv((const char *) GetStringInfoDatum(profile),
5777 GetStringInfoLength(profile));
5779 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5782 if (LocaleCompare(attribute,"x-resolution") == 0)
5784 if (image != (Image *) NULL)
5785 s=newSVnv(image->resolution.x);
5786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5796 if (LocaleCompare(attribute,"y-resolution") == 0)
5798 if (image != (Image *) NULL)
5799 s=newSVnv(image->resolution.y);
5800 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5803 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5810 if (image == (Image *) NULL)
5811 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5815 value=GetImageProperty(image,attribute,exception);
5816 if (value != (const char *) NULL)
5819 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5822 if (*attribute != '%')
5823 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5830 meta=InterpretImageProperties(info ? info->image_info :
5831 (ImageInfo *) NULL,image,attribute,exception);
5833 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5834 meta=(char *) RelinquishMagickMemory(meta);
5838 exception=DestroyExceptionInfo(exception);
5839 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5843 ###############################################################################
5847 # G e t A u t h e n t i c P i x e l s #
5851 ###############################################################################
5855 GetAuthenticPixels(ref,...)
5856 Image::Magick ref = NO_INIT
5858 getauthenticpixels = 1
5888 PERL_UNUSED_VAR(ref);
5889 PERL_UNUSED_VAR(ix);
5890 exception=AcquireExceptionInfo();
5891 perl_exception=newSVpv("",0);
5892 if (sv_isobject(ST(0)) == 0)
5894 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5898 reference=SvRV(ST(0));
5900 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5901 if (image == (Image *) NULL)
5903 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5910 region.width=image->columns;
5913 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5914 for (i=2; i < items; i+=2)
5916 attribute=(char *) SvPV(ST(i-1),na);
5922 if (LocaleCompare(attribute,"geometry") == 0)
5924 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5927 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5934 if (LocaleCompare(attribute,"height") == 0)
5936 region.height=SvIV(ST(i));
5939 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5946 if (LocaleCompare(attribute,"x") == 0)
5948 region.x=SvIV(ST(i));
5951 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5958 if (LocaleCompare(attribute,"y") == 0)
5960 region.y=SvIV(ST(i));
5963 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5970 if (LocaleCompare(attribute,"width") == 0)
5972 region.width=SvIV(ST(i));
5975 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5981 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5982 region.height,exception);
5983 if (blob != (void *) NULL)
5987 InheritPerlException(exception,perl_exception);
5988 exception=DestroyExceptionInfo(exception);
5989 SvREFCNT_dec(perl_exception); /* throw away all errors */
5998 ###############################################################################
6002 # G e t V i r t u a l P i x e l s #
6006 ###############################################################################
6010 GetVirtualPixels(ref,...)
6011 Image::Magick ref = NO_INIT
6013 getvirtualpixels = 1
6014 AcquireImagePixels = 2
6015 acquireimagepixels = 3
6043 PERL_UNUSED_VAR(ref);
6044 PERL_UNUSED_VAR(ix);
6045 exception=AcquireExceptionInfo();
6046 perl_exception=newSVpv("",0);
6047 if (sv_isobject(ST(0)) == 0)
6049 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6053 reference=SvRV(ST(0));
6055 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6056 if (image == (Image *) NULL)
6058 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6065 region.width=image->columns;
6068 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6069 for (i=2; i < items; i+=2)
6071 attribute=(char *) SvPV(ST(i-1),na);
6077 if (LocaleCompare(attribute,"geometry") == 0)
6079 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6089 if (LocaleCompare(attribute,"height") == 0)
6091 region.height=SvIV(ST(i));
6094 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6101 if (LocaleCompare(attribute,"x") == 0)
6103 region.x=SvIV(ST(i));
6106 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6113 if (LocaleCompare(attribute,"y") == 0)
6115 region.y=SvIV(ST(i));
6118 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6125 if (LocaleCompare(attribute,"width") == 0)
6127 region.width=SvIV(ST(i));
6130 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6136 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6137 region.height,exception);
6138 if (blob != (void *) NULL)
6142 InheritPerlException(exception,perl_exception);
6143 exception=DestroyExceptionInfo(exception);
6144 SvREFCNT_dec(perl_exception); /* throw away all errors */
6147 RETVAL = (void *) blob;
6153 ###############################################################################
6157 # G e t A u t h e n t i c M e t a c o n t e n t #
6161 ###############################################################################
6165 GetAuthenticMetacontent(ref,...)
6166 Image::Magick ref = NO_INIT
6168 getauthenticmetacontent = 1
6189 PERL_UNUSED_VAR(ref);
6190 PERL_UNUSED_VAR(ix);
6191 exception=AcquireExceptionInfo();
6192 perl_exception=newSVpv("",0);
6193 if (sv_isobject(ST(0)) == 0)
6195 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6199 reference=SvRV(ST(0));
6201 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6202 if (image == (Image *) NULL)
6204 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6209 blob=(void *) GetAuthenticMetacontent(image);
6210 if (blob != (void *) NULL)
6214 InheritPerlException(exception,perl_exception);
6215 exception=DestroyExceptionInfo(exception);
6216 SvREFCNT_dec(perl_exception); /* throw away all errors */
6225 ###############################################################################
6229 # G e t V i r t u a l M e t a c o n t e n t #
6233 ###############################################################################
6237 GetVirtualMetacontent(ref,...)
6238 Image::Magick ref = NO_INIT
6240 getvirtualmetacontent = 1
6259 PERL_UNUSED_VAR(ref);
6260 PERL_UNUSED_VAR(ix);
6261 exception=AcquireExceptionInfo();
6262 perl_exception=newSVpv("",0);
6263 if (sv_isobject(ST(0)) == 0)
6265 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6269 reference=SvRV(ST(0));
6271 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6272 if (image == (Image *) NULL)
6274 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6279 blob=(void *) GetVirtualMetacontent(image);
6280 if (blob != (void *) NULL)
6284 InheritPerlException(exception,perl_exception);
6285 exception=DestroyExceptionInfo(exception);
6286 SvREFCNT_dec(perl_exception); /* throw away all errors */
6295 ###############################################################################
6299 # H i s t o g r a m #
6303 ###############################################################################
6308 Image::Magick ref=NO_INIT
6319 message[MagickPathExtent];
6346 PERL_UNUSED_VAR(ref);
6347 PERL_UNUSED_VAR(ix);
6348 exception=AcquireExceptionInfo();
6349 perl_exception=newSVpv("",0);
6351 if (sv_isobject(ST(0)) == 0)
6353 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6357 reference=SvRV(ST(0));
6360 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6361 if (image == (Image *) NULL)
6363 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6368 for ( ; image; image=image->next)
6370 histogram=GetImageHistogram(image,&number_colors,exception);
6371 if (histogram == (PixelInfo *) NULL)
6373 count+=(ssize_t) number_colors;
6375 for (i=0; i < (ssize_t) number_colors; i++)
6377 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6379 PUSHs(sv_2mortal(newSVpv(message,0)));
6380 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6381 histogram[i].green);
6382 PUSHs(sv_2mortal(newSVpv(message,0)));
6383 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6385 PUSHs(sv_2mortal(newSVpv(message,0)));
6386 if (image->colorspace == CMYKColorspace)
6388 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6389 histogram[i].black);
6390 PUSHs(sv_2mortal(newSVpv(message,0)));
6392 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6393 histogram[i].alpha);
6394 PUSHs(sv_2mortal(newSVpv(message,0)));
6395 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6396 histogram[i].count);
6397 PUSHs(sv_2mortal(newSVpv(message,0)));
6399 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6403 InheritPerlException(exception,perl_exception);
6404 exception=DestroyExceptionInfo(exception);
6405 SvREFCNT_dec(perl_exception);
6409 ###############################################################################
6417 ###############################################################################
6422 Image::Magick ref=NO_INIT
6446 register const Quantum
6460 *reference; /* reference is the SV* of ref=SvIV(reference) */
6462 PERL_UNUSED_VAR(ref);
6463 PERL_UNUSED_VAR(ix);
6464 exception=AcquireExceptionInfo();
6465 perl_exception=newSVpv("",0);
6466 reference=SvRV(ST(0));
6467 av=(AV *) reference;
6468 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6470 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6471 if (image == (Image *) NULL)
6473 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6477 normalize=MagickTrue;
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,"channel") == 0)
6497 option=ParseChannelOption(SvPV(ST(i),na));
6500 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6504 (void) SetPixelChannelMask(image,(ChannelType) option);
6507 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6514 if (LocaleCompare(attribute,"geometry") == 0)
6516 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6519 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6526 if (LocaleCompare(attribute,"normalize") == 0)
6528 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6532 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6536 normalize=option != 0 ? MagickTrue : MagickFalse;
6539 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6546 if (LocaleCompare(attribute,"x") == 0)
6548 region.x=SvIV(ST(i));
6551 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6558 if (LocaleCompare(attribute,"y") == 0)
6560 region.y=SvIV(ST(i));
6563 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6569 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6575 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6576 if (p == (const Quantum *) NULL)
6584 if (normalize != MagickFalse)
6585 scale=1.0/QuantumRange;
6586 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6587 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6588 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6589 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6590 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6591 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6592 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6593 (image->colorspace == CMYKColorspace))
6594 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6595 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6596 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6600 InheritPerlException(exception,perl_exception);
6601 exception=DestroyExceptionInfo(exception);
6602 SvREFCNT_dec(perl_exception);
6606 ###############################################################################
6610 # G e t P i x e l s #
6614 ###############################################################################
6619 Image::Magick ref=NO_INIT
6658 *reference; /* reference is the SV* of ref=SvIV(reference) */
6660 PERL_UNUSED_VAR(ref);
6661 PERL_UNUSED_VAR(ix);
6662 exception=AcquireExceptionInfo();
6663 perl_exception=newSVpv("",0);
6664 reference=SvRV(ST(0));
6665 av=(AV *) reference;
6666 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6668 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6669 if (image == (Image *) NULL)
6671 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6676 if (image->alpha_trait != UndefinedPixelTrait)
6678 if (image->colorspace == CMYKColorspace)
6681 if (image->alpha_trait != UndefinedPixelTrait)
6684 normalize=MagickFalse;
6687 region.width=image->columns;
6690 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6691 for (i=2; i < items; i+=2)
6693 attribute=(char *) SvPV(ST(i-1),na);
6699 if (LocaleCompare(attribute,"geometry") == 0)
6701 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6704 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6711 if (LocaleCompare(attribute,"height") == 0)
6713 region.height=SvIV(ST(i));
6716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6723 if (LocaleCompare(attribute,"map") == 0)
6728 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6735 if (LocaleCompare(attribute,"normalize") == 0)
6737 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6741 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6745 normalize=option != 0 ? MagickTrue : MagickFalse;
6748 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6755 if (LocaleCompare(attribute,"width") == 0)
6757 region.width=SvIV(ST(i));
6760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6767 if (LocaleCompare(attribute,"x") == 0)
6769 region.x=SvIV(ST(i));
6772 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6779 if (LocaleCompare(attribute,"y") == 0)
6781 region.y=SvIV(ST(i));
6784 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6790 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6796 if (normalize != MagickFalse)
6801 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6802 region.height*sizeof(*pixels));
6803 if (pixels == (float *) NULL)
6805 ThrowPerlException(exception,ResourceLimitError,
6806 "MemoryAllocationFailed",PackageName);
6809 status=ExportImagePixels(image,region.x,region.y,region.width,
6810 region.height,map,FloatPixel,pixels,exception);
6811 if (status == MagickFalse)
6815 EXTEND(sp,strlen(map)*region.width*region.height);
6816 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6817 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6819 pixels=(float *) RelinquishMagickMemory(pixels);
6826 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6827 region.height*sizeof(*pixels));
6828 if (pixels == (Quantum *) NULL)
6830 ThrowPerlException(exception,ResourceLimitError,
6831 "MemoryAllocationFailed",PackageName);
6834 status=ExportImagePixels(image,region.x,region.y,region.width,
6835 region.height,map,QuantumPixel,pixels,exception);
6836 if (status == MagickFalse)
6840 EXTEND(sp,strlen(map)*region.width*region.height);
6841 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6842 PUSHs(sv_2mortal(newSViv(pixels[i])));
6844 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6848 InheritPerlException(exception,perl_exception);
6849 exception=DestroyExceptionInfo(exception);
6850 SvREFCNT_dec(perl_exception);
6854 ###############################################################################
6858 # I m a g e T o B l o b #
6862 ###############################################################################
6866 ImageToBlob(ref,...)
6867 Image::Magick ref=NO_INIT
6876 filename[MagickPathExtent];
6905 PERL_UNUSED_VAR(ref);
6906 PERL_UNUSED_VAR(ix);
6907 exception=AcquireExceptionInfo();
6908 perl_exception=newSVpv("",0);
6909 package_info=(struct PackageInfo *) NULL;
6910 if (sv_isobject(ST(0)) == 0)
6912 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6916 reference=SvRV(ST(0));
6917 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6918 if (image == (Image *) NULL)
6920 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6924 package_info=ClonePackageInfo(info,exception);
6925 for (i=2; i < items; i+=2)
6926 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6927 (void) CopyMagickString(filename,package_info->image_info->filename,
6930 for (next=image; next; next=next->next)
6932 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6933 next->scene=scene++;
6935 SetImageInfo(package_info->image_info,(unsigned int)
6936 GetImageListLength(image),exception);
6937 EXTEND(sp,(ssize_t) GetImageListLength(image));
6938 for ( ; image; image=image->next)
6941 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6942 if (blob != (char *) NULL)
6944 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6945 blob=(unsigned char *) RelinquishMagickMemory(blob);
6947 if (package_info->image_info->adjoin)
6952 if (package_info != (struct PackageInfo *) NULL)
6953 DestroyPackageInfo(package_info);
6954 InheritPerlException(exception,perl_exception);
6955 exception=DestroyExceptionInfo(exception);
6956 SvREFCNT_dec(perl_exception); /* throw away all errors */
6960 ###############################################################################
6968 ###############################################################################
6973 Image::Magick ref=NO_INIT
6977 OptimizeImageLayers = 3
6979 optimizeimagelayers = 5
7021 PERL_UNUSED_VAR(ref);
7022 PERL_UNUSED_VAR(ix);
7023 exception=AcquireExceptionInfo();
7024 perl_exception=newSVpv("",0);
7026 if (sv_isobject(ST(0)) == 0)
7028 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7032 reference=SvRV(ST(0));
7033 hv=SvSTASH(reference);
7035 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7037 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7038 if (image == (Image *) NULL)
7040 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7044 compose=image->compose;
7045 method=OptimizeLayer;
7046 for (i=2; i < items; i+=2)
7048 attribute=(char *) SvPV(ST(i-1),na);
7054 if (LocaleCompare(attribute,"compose") == 0)
7056 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7057 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7060 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7064 compose=(CompositeOperator) sp;
7067 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7074 if (LocaleCompare(attribute,"method") == 0)
7076 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7080 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7084 method=(LayerMethod) option;
7087 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7093 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7099 layers=(Image *) NULL;
7102 case CompareAnyLayer:
7103 case CompareClearLayer:
7104 case CompareOverlayLayer:
7107 layers=CompareImagesLayers(image,method,exception);
7114 layers=MergeImageLayers(image,method,exception);
7119 layers=DisposeImages(image,exception);
7122 case OptimizeImageLayer:
7124 layers=OptimizeImageLayers(image,exception);
7127 case OptimizePlusLayer:
7129 layers=OptimizePlusImageLayers(image,exception);
7132 case OptimizeTransLayer:
7134 OptimizeImageTransparency(image,exception);
7137 case RemoveDupsLayer:
7139 RemoveDuplicateLayers(&image,exception);
7142 case RemoveZeroLayer:
7144 RemoveZeroDelayLayers(&image,exception);
7153 General Purpose, GIF Animation Optimizer.
7155 layers=CoalesceImages(image,exception);
7156 if (layers == (Image *) NULL)
7159 layers=OptimizeImageLayers(image,exception);
7160 if (layers == (Image *) NULL)
7162 image=DestroyImageList(image);
7164 layers=(Image *) NULL;
7165 OptimizeImageTransparency(image,exception);
7166 quantize_info=AcquireQuantizeInfo(info->image_info);
7167 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7168 quantize_info=DestroyQuantizeInfo(quantize_info);
7171 case CompositeLayer:
7180 Split image sequence at the first 'NULL:' image.
7183 while (source != (Image *) NULL)
7185 source=GetNextImageInList(source);
7186 if ((source != (Image *) NULL) &&
7187 (LocaleCompare(source->magick,"NULL") == 0))
7190 if (source != (Image *) NULL)
7192 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7193 (GetNextImageInList(source) == (Image *) NULL))
7194 source=(Image *) NULL;
7198 Separate the two lists, junk the null: image.
7200 source=SplitImageList(source->previous);
7201 DeleteImageFromList(&source);
7204 if (source == (Image *) NULL)
7206 (void) ThrowMagickException(exception,GetMagickModule(),
7207 OptionError,"MissingNullSeparator","layers Composite");
7211 Adjust offset with gravity and virtual canvas.
7213 SetGeometry(image,&geometry);
7214 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7215 geometry.width=source->page.width != 0 ? source->page.width :
7217 geometry.height=source->page.height != 0 ? source->page.height :
7219 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7220 image->columns,image->page.height != 0 ? image->page.height :
7221 image->rows,image->gravity,&geometry);
7222 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7223 source=DestroyImageList(source);
7227 if (layers != (Image *) NULL)
7230 image=CloneImage(image,0,0,MagickTrue,exception);
7231 if (image == (Image *) NULL)
7233 for ( ; image; image=image->next)
7235 AddImageToRegistry(sv,image);
7237 av_push(av,sv_bless(rv,hv));
7240 exception=DestroyExceptionInfo(exception);
7242 SvREFCNT_dec(perl_exception);
7246 InheritPerlException(exception,perl_exception);
7247 exception=DestroyExceptionInfo(exception);
7248 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7249 SvPOK_on(perl_exception);
7250 ST(0)=sv_2mortal(perl_exception);
7255 ###############################################################################
7259 # M a g i c k T o M i m e #
7263 ###############################################################################
7267 MagickToMime(ref,name)
7268 Image::Magick ref=NO_INIT
7277 PERL_UNUSED_VAR(ref);
7278 PERL_UNUSED_VAR(ix);
7279 mime=MagickToMime(name);
7280 RETVAL=newSVpv(mime,0);
7281 mime=(char *) RelinquishMagickMemory(mime);
7287 ###############################################################################
7295 ###############################################################################
7300 Image::Magick ref=NO_INIT
7337 MedianConvolveImage = 36
7343 ReduceNoiseImage = 42
7369 ColorFloodfillImage= 68
7375 CycleColormapImage = 74
7385 MatteFloodfillImage= 84
7393 NumberColorsImage = 92
7403 SignatureImage = 102
7413 TransparentImage = 112
7415 ThresholdImage = 114
7429 DeconstructImage = 130
7431 GaussianBlurImage = 132
7437 UnsharpMaskImage = 138
7439 MotionBlurImage = 140
7441 OrderedDitherImage = 142
7448 AffineTransform = 149
7449 AffineTransformImage = 150
7451 DifferenceImage = 152
7452 AdaptiveThreshold = 153
7453 AdaptiveThresholdImage = 154
7458 BlackThreshold = 159
7459 BlackThresholdImage= 160
7460 WhiteThreshold = 161
7461 WhiteThresholdImage= 162
7462 RotationalBlur = 163
7463 RotationalBlurImage= 164
7465 ThumbnailImage = 166
7475 PosterizeImage = 176
7481 SepiaToneImage = 182
7482 SigmoidalContrast = 183
7483 SigmoidalContrastImage = 184
7488 ContrastStretch = 189
7489 ContrastStretchImage = 190
7494 AdaptiveSharpen = 195
7495 AdaptiveSharpenImage = 196
7497 TransposeImage = 198
7499 TransverseImage = 200
7501 AutoOrientImage = 202
7503 AdaptiveBlurImage = 204
7507 UniqueColorsImage = 208
7508 AdaptiveResize = 209
7509 AdaptiveResizeImage= 210
7513 LinearStretchImage = 214
7515 ColorMatrixImage = 216
7520 FloodfillPaint = 221
7521 FloodfillPaintImage= 222
7527 LiquidRescaleImage = 228
7537 SparseColorImage = 238
7541 SelectiveBlurImage = 242
7545 BlueShiftImage = 246
7546 ForwardFourierTransform = 247
7547 ForwardFourierTransformImage = 248
7548 InverseFourierTransform = 249
7549 InverseFourierTransformImage = 250
7550 ColorDecisionList = 251
7551 ColorDecisionListImage = 252
7553 AutoGammaImage = 254
7555 AutoLevelImage = 256
7557 LevelImageColors = 258
7560 BrightnessContrast = 261
7561 BrightnessContrastImage = 262
7563 MorphologyImage = 264
7567 StatisticImage = 268
7569 PerceptibleImage = 270
7573 GrayscaleImage = 274
7575 CannyEdgeImage = 276
7577 HoughLineImage = 278
7579 MeanShiftImage = 280
7582 ConnectedComponent = 283
7583 ConnectedComponentImage = 284
7585 CopyImagePixels = 286
7588 WaveletDenoise = 289
7589 WaveletDenoiseImage= 290
7598 attribute_flag[MaxArguments],
7599 message[MagickPathExtent];
7660 argument_list[MaxArguments];
7662 PERL_UNUSED_VAR(ref);
7663 PERL_UNUSED_VAR(ix);
7664 exception=AcquireExceptionInfo();
7665 perl_exception=newSVpv("",0);
7666 reference_vector=NULL;
7670 if (sv_isobject(ST(0)) == 0)
7672 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7676 reference=SvRV(ST(0));
7677 region_info.width=0;
7678 region_info.height=0;
7681 region_image=(Image *) NULL;
7682 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7683 if (ix && (ix != 666))
7686 Called as Method(...)
7689 rp=(&Methods[ix-1]);
7695 Called as Mogrify("Method",...)
7697 attribute=(char *) SvPV(ST(1),na);
7700 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7701 attribute=(char *) SvPV(ST(2),na);
7704 for (rp=Methods; ; rp++)
7706 if (rp >= EndOf(Methods))
7708 ThrowPerlException(exception,OptionError,
7709 "UnrecognizedPerlMagickMethod",attribute);
7712 if (strEQcase(attribute,rp->name))
7718 if (image == (Image *) NULL)
7720 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7723 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7724 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7725 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7742 pp=(Arguments *) NULL;
7750 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7752 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7754 if (strEQcase(attribute,qq->method) > ssize_test)
7757 ssize_test=strEQcase(attribute,qq->method);
7760 if (pp == (Arguments *) NULL)
7762 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7764 goto continue_outer_loop;
7766 al=(&argument_list[pp-rp->arguments]);
7769 case ArrayReference:
7771 if (SvTYPE(sv) != SVt_RV)
7773 (void) FormatLocaleString(message,MagickPathExtent,
7774 "invalid %.60s value",pp->method);
7775 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7776 goto continue_outer_loop;
7778 al->array_reference=SvRV(sv);
7783 al->real_reference=SvNV(sv);
7788 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7791 case ImageReference:
7793 if (!sv_isobject(sv) ||
7794 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7795 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7797 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7803 case IntegerReference:
7805 al->integer_reference=SvIV(sv);
7808 case StringReference:
7810 al->string_reference=(char *) SvPV(sv,al->length);
7811 if (sv_isobject(sv))
7812 al->image_reference=SetupList(aTHX_ SvRV(sv),
7813 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7819 Is a string; look up name.
7821 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7823 al->string_reference=(char *) SvPV(sv,al->length);
7824 al->integer_reference=(-1);
7827 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7828 MagickFalse,SvPV(sv,na));
7829 if (pp->type == MagickChannelOptions)
7830 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7831 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7833 (void) FormatLocaleString(message,MagickPathExtent,
7834 "invalid %.60s value",pp->method);
7835 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7836 goto continue_outer_loop;
7841 attribute_flag[pp-rp->arguments]++;
7842 continue_outer_loop: ;
7844 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7845 pv=reference_vector;
7846 SetGeometryInfo(&geometry_info);
7847 channel=DefaultChannels;
7848 for (next=image; next; next=next->next)
7851 SetGeometry(image,&geometry);
7852 if ((region_info.width*region_info.height) != 0)
7855 image=CropImage(image,®ion_info,exception);
7861 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7862 ThrowPerlException(exception,OptionError,
7863 "UnrecognizedPerlMagickMethod",message);
7866 case 1: /* Comment */
7868 if (attribute_flag[0] == 0)
7869 argument_list[0].string_reference=(char *) NULL;
7870 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7871 info ? info->image_info : (ImageInfo *) NULL,image,
7872 argument_list[0].string_reference,exception),exception);
7877 if (attribute_flag[0] == 0)
7878 argument_list[0].string_reference=(char *) NULL;
7879 (void) SetImageProperty(image,"label",InterpretImageProperties(
7880 info ? info->image_info : (ImageInfo *) NULL,image,
7881 argument_list[0].string_reference,exception),exception);
7884 case 3: /* AddNoise */
7889 if (attribute_flag[0] == 0)
7890 argument_list[0].integer_reference=UniformNoise;
7892 if (attribute_flag[1] != 0)
7893 attenuate=argument_list[1].real_reference;
7894 if (attribute_flag[2] != 0)
7895 channel=(ChannelType) argument_list[2].integer_reference;
7896 channel_mask=SetImageChannelMask(image,channel);
7897 image=AddNoiseImage(image,(NoiseType)
7898 argument_list[0].integer_reference,attenuate,exception);
7899 if (image != (Image *) NULL)
7900 (void) SetImageChannelMask(image,channel_mask);
7903 case 4: /* Colorize */
7908 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7909 0,0,&target,exception);
7910 if (attribute_flag[0] != 0)
7911 (void) QueryColorCompliance(argument_list[0].string_reference,
7912 AllCompliance,&target,exception);
7913 if (attribute_flag[1] == 0)
7914 argument_list[1].string_reference="100%";
7915 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7919 case 5: /* Border */
7926 if (attribute_flag[0] != 0)
7927 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7928 &geometry,exception);
7929 if (attribute_flag[1] != 0)
7930 geometry.width=argument_list[1].integer_reference;
7931 if (attribute_flag[2] != 0)
7932 geometry.height=argument_list[2].integer_reference;
7933 if (attribute_flag[3] != 0)
7934 QueryColorCompliance(argument_list[3].string_reference,
7935 AllCompliance,&image->border_color,exception);
7936 if (attribute_flag[4] != 0)
7937 QueryColorCompliance(argument_list[4].string_reference,
7938 AllCompliance,&image->border_color,exception);
7939 if (attribute_flag[5] != 0)
7940 QueryColorCompliance(argument_list[5].string_reference,
7941 AllCompliance,&image->border_color,exception);
7942 compose=image->compose;
7943 if (attribute_flag[6] != 0)
7944 compose=(CompositeOperator) argument_list[6].integer_reference;
7945 image=BorderImage(image,&geometry,compose,exception);
7950 if (attribute_flag[0] != 0)
7952 flags=ParseGeometry(argument_list[0].string_reference,
7954 if ((flags & SigmaValue) == 0)
7955 geometry_info.sigma=1.0;
7957 if (attribute_flag[1] != 0)
7958 geometry_info.rho=argument_list[1].real_reference;
7959 if (attribute_flag[2] != 0)
7960 geometry_info.sigma=argument_list[2].real_reference;
7961 if (attribute_flag[3] != 0)
7962 channel=(ChannelType) argument_list[3].integer_reference;
7963 channel_mask=SetImageChannelMask(image,channel);
7964 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7966 if (image != (Image *) NULL)
7967 (void) SetImageChannelMask(image,channel_mask);
7972 if (attribute_flag[5] != 0)
7973 image->gravity=(GravityType) argument_list[5].integer_reference;
7974 if (attribute_flag[0] != 0)
7975 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7976 &geometry,exception);
7977 if (attribute_flag[1] != 0)
7978 geometry.width=argument_list[1].integer_reference;
7979 if (attribute_flag[2] != 0)
7980 geometry.height=argument_list[2].integer_reference;
7981 if (attribute_flag[3] != 0)
7982 geometry.x=argument_list[3].integer_reference;
7983 if (attribute_flag[4] != 0)
7984 geometry.y=argument_list[4].integer_reference;
7985 image=ChopImage(image,&geometry,exception);
7990 if (attribute_flag[6] != 0)
7991 image->gravity=(GravityType) argument_list[6].integer_reference;
7992 if (attribute_flag[0] != 0)
7993 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7994 &geometry,exception);
7995 if (attribute_flag[1] != 0)
7996 geometry.width=argument_list[1].integer_reference;
7997 if (attribute_flag[2] != 0)
7998 geometry.height=argument_list[2].integer_reference;
7999 if (attribute_flag[3] != 0)
8000 geometry.x=argument_list[3].integer_reference;
8001 if (attribute_flag[4] != 0)
8002 geometry.y=argument_list[4].integer_reference;
8003 if (attribute_flag[5] != 0)
8004 image->fuzz=StringToDoubleInterval(
8005 argument_list[5].string_reference,(double) QuantumRange+1.0);
8006 image=CropImage(image,&geometry,exception);
8009 case 9: /* Despeckle */
8011 image=DespeckleImage(image,exception);
8016 if (attribute_flag[0] != 0)
8017 geometry_info.rho=argument_list[0].real_reference;
8018 image=EdgeImage(image,geometry_info.rho,exception);
8021 case 11: /* Emboss */
8023 if (attribute_flag[0] != 0)
8025 flags=ParseGeometry(argument_list[0].string_reference,
8027 if ((flags & SigmaValue) == 0)
8028 geometry_info.sigma=1.0;
8030 if (attribute_flag[1] != 0)
8031 geometry_info.rho=argument_list[1].real_reference;
8032 if (attribute_flag[2] != 0)
8033 geometry_info.sigma=argument_list[2].real_reference;
8034 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8038 case 12: /* Enhance */
8040 image=EnhanceImage(image,exception);
8045 image=FlipImage(image,exception);
8050 image=FlopImage(image,exception);
8053 case 15: /* Frame */
8061 if (attribute_flag[0] != 0)
8063 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8064 &geometry,exception);
8065 frame_info.width=geometry.width;
8066 frame_info.height=geometry.height;
8067 frame_info.outer_bevel=geometry.x;
8068 frame_info.inner_bevel=geometry.y;
8070 if (attribute_flag[1] != 0)
8071 frame_info.width=argument_list[1].integer_reference;
8072 if (attribute_flag[2] != 0)
8073 frame_info.height=argument_list[2].integer_reference;
8074 if (attribute_flag[3] != 0)
8075 frame_info.inner_bevel=argument_list[3].integer_reference;
8076 if (attribute_flag[4] != 0)
8077 frame_info.outer_bevel=argument_list[4].integer_reference;
8078 if (attribute_flag[5] != 0)
8079 QueryColorCompliance(argument_list[5].string_reference,
8080 AllCompliance,&fill_color,exception);
8081 if (attribute_flag[6] != 0)
8082 QueryColorCompliance(argument_list[6].string_reference,
8083 AllCompliance,&fill_color,exception);
8084 frame_info.x=(ssize_t) frame_info.width;
8085 frame_info.y=(ssize_t) frame_info.height;
8086 frame_info.width=image->columns+2*frame_info.x;
8087 frame_info.height=image->rows+2*frame_info.y;
8088 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8089 image->alpha_color=fill_color;
8090 compose=image->compose;
8091 if (attribute_flag[7] != 0)
8092 compose=(CompositeOperator) argument_list[7].integer_reference;
8093 image=FrameImage(image,&frame_info,compose,exception);
8096 case 16: /* Implode */
8098 PixelInterpolateMethod
8101 if (attribute_flag[0] == 0)
8102 argument_list[0].real_reference=0.5;
8103 method=UndefinedInterpolatePixel;
8104 if (attribute_flag[1] != 0)
8105 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8106 image=ImplodeImage(image,argument_list[0].real_reference,
8110 case 17: /* Magnify */
8112 image=MagnifyImage(image,exception);
8115 case 18: /* MedianFilter */
8117 if (attribute_flag[0] != 0)
8119 flags=ParseGeometry(argument_list[0].string_reference,
8121 if ((flags & SigmaValue) == 0)
8122 geometry_info.sigma=geometry_info.rho;
8124 if (attribute_flag[1] != 0)
8125 geometry_info.rho=argument_list[1].real_reference;
8126 if (attribute_flag[2] != 0)
8127 geometry_info.sigma=argument_list[2].real_reference;
8128 if (attribute_flag[3] != 0)
8129 channel=(ChannelType) argument_list[3].integer_reference;
8130 channel_mask=SetImageChannelMask(image,channel);
8131 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8132 (size_t) geometry_info.sigma,exception);
8133 if (image != (Image *) NULL)
8134 (void) SetImageChannelMask(image,channel_mask);
8137 case 19: /* Minify */
8139 image=MinifyImage(image,exception);
8142 case 20: /* OilPaint */
8144 if (attribute_flag[0] == 0)
8145 argument_list[0].real_reference=0.0;
8146 if (attribute_flag[1] == 0)
8147 argument_list[1].real_reference=1.0;
8148 image=OilPaintImage(image,argument_list[0].real_reference,
8149 argument_list[1].real_reference,exception);
8152 case 21: /* ReduceNoise */
8154 if (attribute_flag[0] != 0)
8156 flags=ParseGeometry(argument_list[0].string_reference,
8158 if ((flags & SigmaValue) == 0)
8159 geometry_info.sigma=1.0;
8161 if (attribute_flag[1] != 0)
8162 geometry_info.rho=argument_list[1].real_reference;
8163 if (attribute_flag[2] != 0)
8164 geometry_info.sigma=argument_list[2].real_reference;
8165 if (attribute_flag[3] != 0)
8166 channel=(ChannelType) argument_list[3].integer_reference;
8167 channel_mask=SetImageChannelMask(image,channel);
8168 image=StatisticImage(image,NonpeakStatistic,(size_t)
8169 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8170 if (image != (Image *) NULL)
8171 (void) SetImageChannelMask(image,channel_mask);
8176 if (attribute_flag[0] != 0)
8177 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8178 &geometry,exception);
8179 if (attribute_flag[1] != 0)
8180 geometry.x=argument_list[1].integer_reference;
8181 if (attribute_flag[2] != 0)
8182 geometry.y=argument_list[2].integer_reference;
8183 image=RollImage(image,geometry.x,geometry.y,exception);
8186 case 23: /* Rotate */
8188 if (attribute_flag[0] == 0)
8189 argument_list[0].real_reference=90.0;
8190 if (attribute_flag[1] != 0)
8192 QueryColorCompliance(argument_list[1].string_reference,
8193 AllCompliance,&image->background_color,exception);
8194 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8195 (image->alpha_trait == UndefinedPixelTrait))
8196 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8198 image=RotateImage(image,argument_list[0].real_reference,exception);
8201 case 24: /* Sample */
8203 if (attribute_flag[0] != 0)
8204 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8205 &geometry,exception);
8206 if (attribute_flag[1] != 0)
8207 geometry.width=argument_list[1].integer_reference;
8208 if (attribute_flag[2] != 0)
8209 geometry.height=argument_list[2].integer_reference;
8210 image=SampleImage(image,geometry.width,geometry.height,exception);
8213 case 25: /* Scale */
8215 if (attribute_flag[0] != 0)
8216 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8217 &geometry,exception);
8218 if (attribute_flag[1] != 0)
8219 geometry.width=argument_list[1].integer_reference;
8220 if (attribute_flag[2] != 0)
8221 geometry.height=argument_list[2].integer_reference;
8222 image=ScaleImage(image,geometry.width,geometry.height,exception);
8225 case 26: /* Shade */
8227 if (attribute_flag[0] != 0)
8229 flags=ParseGeometry(argument_list[0].string_reference,
8231 if ((flags & SigmaValue) == 0)
8232 geometry_info.sigma=0.0;
8234 if (attribute_flag[1] != 0)
8235 geometry_info.rho=argument_list[1].real_reference;
8236 if (attribute_flag[2] != 0)
8237 geometry_info.sigma=argument_list[2].real_reference;
8238 image=ShadeImage(image,
8239 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8240 geometry_info.rho,geometry_info.sigma,exception);
8243 case 27: /* Sharpen */
8245 if (attribute_flag[0] != 0)
8247 flags=ParseGeometry(argument_list[0].string_reference,
8249 if ((flags & SigmaValue) == 0)
8250 geometry_info.sigma=1.0;
8252 if (attribute_flag[1] != 0)
8253 geometry_info.rho=argument_list[1].real_reference;
8254 if (attribute_flag[2] != 0)
8255 geometry_info.sigma=argument_list[2].real_reference;
8256 if (attribute_flag[3] != 0)
8257 channel=(ChannelType) argument_list[3].integer_reference;
8258 channel_mask=SetImageChannelMask(image,channel);
8259 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8261 if (image != (Image *) NULL)
8262 (void) SetImageChannelMask(image,channel_mask);
8265 case 28: /* Shear */
8267 if (attribute_flag[0] != 0)
8269 flags=ParseGeometry(argument_list[0].string_reference,
8271 if ((flags & SigmaValue) == 0)
8272 geometry_info.sigma=geometry_info.rho;
8274 if (attribute_flag[1] != 0)
8275 geometry_info.rho=argument_list[1].real_reference;
8276 if (attribute_flag[2] != 0)
8277 geometry_info.sigma=argument_list[2].real_reference;
8278 if (attribute_flag[3] != 0)
8279 QueryColorCompliance(argument_list[3].string_reference,
8280 AllCompliance,&image->background_color,exception);
8281 if (attribute_flag[4] != 0)
8282 QueryColorCompliance(argument_list[4].string_reference,
8283 AllCompliance,&image->background_color,exception);
8284 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8288 case 29: /* Spread */
8290 PixelInterpolateMethod
8293 if (attribute_flag[0] == 0)
8294 argument_list[0].real_reference=1.0;
8295 method=UndefinedInterpolatePixel;
8296 if (attribute_flag[1] != 0)
8297 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8298 image=SpreadImage(image,method,argument_list[0].real_reference,
8302 case 30: /* Swirl */
8304 PixelInterpolateMethod
8307 if (attribute_flag[0] == 0)
8308 argument_list[0].real_reference=50.0;
8309 method=UndefinedInterpolatePixel;
8310 if (attribute_flag[1] != 0)
8311 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8312 image=SwirlImage(image,argument_list[0].real_reference,
8316 case 31: /* Resize */
8319 if (attribute_flag[0] != 0)
8320 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8321 &geometry,exception);
8322 if (attribute_flag[1] != 0)
8323 geometry.width=argument_list[1].integer_reference;
8324 if (attribute_flag[2] != 0)
8325 geometry.height=argument_list[2].integer_reference;
8326 if (attribute_flag[3] == 0)
8327 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8328 if (attribute_flag[4] != 0)
8329 SetImageArtifact(image,"filter:support",
8330 argument_list[4].string_reference);
8331 image=ResizeImage(image,geometry.width,geometry.height,
8332 (FilterType) argument_list[3].integer_reference,
8336 case 33: /* Annotate */
8341 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8343 if (attribute_flag[0] != 0)
8348 text=InterpretImageProperties(info ? info->image_info :
8349 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8351 (void) CloneString(&draw_info->text,text);
8352 text=DestroyString(text);
8354 if (attribute_flag[1] != 0)
8355 (void) CloneString(&draw_info->font,
8356 argument_list[1].string_reference);
8357 if (attribute_flag[2] != 0)
8358 draw_info->pointsize=argument_list[2].real_reference;
8359 if (attribute_flag[3] != 0)
8360 (void) CloneString(&draw_info->density,
8361 argument_list[3].string_reference);
8362 if (attribute_flag[4] != 0)
8363 (void) QueryColorCompliance(argument_list[4].string_reference,
8364 AllCompliance,&draw_info->undercolor,exception);
8365 if (attribute_flag[5] != 0)
8367 (void) QueryColorCompliance(argument_list[5].string_reference,
8368 AllCompliance,&draw_info->stroke,exception);
8369 if (argument_list[5].image_reference != (Image *) NULL)
8370 draw_info->stroke_pattern=CloneImage(
8371 argument_list[5].image_reference,0,0,MagickTrue,exception);
8373 if (attribute_flag[6] != 0)
8375 (void) QueryColorCompliance(argument_list[6].string_reference,
8376 AllCompliance,&draw_info->fill,exception);
8377 if (argument_list[6].image_reference != (Image *) NULL)
8378 draw_info->fill_pattern=CloneImage(
8379 argument_list[6].image_reference,0,0,MagickTrue,exception);
8381 if (attribute_flag[7] != 0)
8383 (void) CloneString(&draw_info->geometry,
8384 argument_list[7].string_reference);
8385 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8386 &geometry,exception);
8387 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8388 geometry_info.sigma=geometry_info.xi;
8390 if (attribute_flag[8] != 0)
8391 (void) QueryColorCompliance(argument_list[8].string_reference,
8392 AllCompliance,&draw_info->fill,exception);
8393 if (attribute_flag[11] != 0)
8394 draw_info->gravity=(GravityType)
8395 argument_list[11].integer_reference;
8396 if (attribute_flag[25] != 0)
8401 av=(AV *) argument_list[25].array_reference;
8402 if ((av_len(av) != 3) && (av_len(av) != 5))
8404 ThrowPerlException(exception,OptionError,
8405 "affine matrix must have 4 or 6 elements",PackageName);
8408 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8409 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8410 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8411 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8412 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8413 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8415 ThrowPerlException(exception,OptionError,
8416 "affine matrix is singular",PackageName);
8419 if (av_len(av) == 5)
8421 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8422 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8425 for (j=12; j < 17; j++)
8427 if (attribute_flag[j] == 0)
8429 value=argument_list[j].string_reference;
8430 angle=argument_list[j].real_reference;
8431 current=draw_info->affine;
8432 GetAffineMatrix(&affine);
8440 flags=ParseGeometry(value,&geometry_info);
8441 affine.tx=geometry_info.xi;
8442 affine.ty=geometry_info.psi;
8443 if ((flags & PsiValue) == 0)
8444 affine.ty=affine.tx;
8452 flags=ParseGeometry(value,&geometry_info);
8453 affine.sx=geometry_info.rho;
8454 affine.sy=geometry_info.sigma;
8455 if ((flags & SigmaValue) == 0)
8456 affine.sy=affine.sx;
8466 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8467 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8468 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8469 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8477 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8485 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8489 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8490 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8491 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8492 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8493 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8495 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8498 if (attribute_flag[9] == 0)
8499 argument_list[9].real_reference=0.0;
8500 if (attribute_flag[10] == 0)
8501 argument_list[10].real_reference=0.0;
8502 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8505 geometry[MagickPathExtent];
8507 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8508 (double) argument_list[9].real_reference+draw_info->affine.tx,
8509 (double) argument_list[10].real_reference+draw_info->affine.ty);
8510 (void) CloneString(&draw_info->geometry,geometry);
8512 if (attribute_flag[17] != 0)
8513 draw_info->stroke_width=argument_list[17].real_reference;
8514 if (attribute_flag[18] != 0)
8516 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8517 MagickTrue : MagickFalse;
8518 draw_info->stroke_antialias=draw_info->text_antialias;
8520 if (attribute_flag[19] != 0)
8521 (void) CloneString(&draw_info->family,
8522 argument_list[19].string_reference);
8523 if (attribute_flag[20] != 0)
8524 draw_info->style=(StyleType) argument_list[20].integer_reference;
8525 if (attribute_flag[21] != 0)
8526 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8527 if (attribute_flag[22] != 0)
8528 draw_info->weight=argument_list[22].integer_reference;
8529 if (attribute_flag[23] != 0)
8530 draw_info->align=(AlignType) argument_list[23].integer_reference;
8531 if (attribute_flag[24] != 0)
8532 (void) CloneString(&draw_info->encoding,
8533 argument_list[24].string_reference);
8534 if (attribute_flag[25] != 0)
8535 draw_info->fill_pattern=CloneImage(
8536 argument_list[25].image_reference,0,0,MagickTrue,exception);
8537 if (attribute_flag[26] != 0)
8538 draw_info->fill_pattern=CloneImage(
8539 argument_list[26].image_reference,0,0,MagickTrue,exception);
8540 if (attribute_flag[27] != 0)
8541 draw_info->stroke_pattern=CloneImage(
8542 argument_list[27].image_reference,0,0,MagickTrue,exception);
8543 if (attribute_flag[29] != 0)
8544 draw_info->kerning=argument_list[29].real_reference;
8545 if (attribute_flag[30] != 0)
8546 draw_info->interline_spacing=argument_list[30].real_reference;
8547 if (attribute_flag[31] != 0)
8548 draw_info->interword_spacing=argument_list[31].real_reference;
8549 if (attribute_flag[32] != 0)
8550 draw_info->direction=(DirectionType)
8551 argument_list[32].integer_reference;
8552 (void) AnnotateImage(image,draw_info,exception);
8553 draw_info=DestroyDrawInfo(draw_info);
8556 case 34: /* ColorFloodfill */
8567 draw_info=CloneDrawInfo(info ? info->image_info :
8568 (ImageInfo *) NULL,(DrawInfo *) NULL);
8569 if (attribute_flag[0] != 0)
8570 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8571 &geometry,exception);
8572 if (attribute_flag[1] != 0)
8573 geometry.x=argument_list[1].integer_reference;
8574 if (attribute_flag[2] != 0)
8575 geometry.y=argument_list[2].integer_reference;
8576 if (attribute_flag[3] != 0)
8577 (void) QueryColorCompliance(argument_list[3].string_reference,
8578 AllCompliance,&draw_info->fill,exception);
8579 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8580 geometry.x,geometry.y,&target,exception);
8582 if (attribute_flag[4] != 0)
8584 QueryColorCompliance(argument_list[4].string_reference,
8585 AllCompliance,&target,exception);
8588 if (attribute_flag[5] != 0)
8589 image->fuzz=StringToDoubleInterval(
8590 argument_list[5].string_reference,(double) QuantumRange+1.0);
8591 if (attribute_flag[6] != 0)
8592 invert=(MagickBooleanType) argument_list[6].integer_reference;
8593 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8594 geometry.y,invert,exception);
8595 draw_info=DestroyDrawInfo(draw_info);
8598 case 35: /* Composite */
8601 composite_geometry[MagickPathExtent];
8610 compose=OverCompositeOp;
8611 if (attribute_flag[0] != 0)
8612 composite_image=argument_list[0].image_reference;
8615 ThrowPerlException(exception,OptionError,
8616 "CompositeImageRequired",PackageName);
8620 Parameter Handling used for BOTH normal and tiled composition.
8622 if (attribute_flag[1] != 0) /* compose */
8623 compose=(CompositeOperator) argument_list[1].integer_reference;
8624 if (attribute_flag[6] != 0) /* opacity */
8626 if (compose != DissolveCompositeOp)
8627 (void) SetImageAlpha(composite_image,(Quantum)
8628 StringToDoubleInterval(argument_list[6].string_reference,
8629 (double) QuantumRange+1.0),exception);
8651 Handle dissolve composite operator (patch by
8654 (void) CloneString(&image->geometry,
8655 argument_list[6].string_reference);
8656 opacity=(Quantum) StringToDoubleInterval(
8657 argument_list[6].string_reference,(double) QuantumRange+
8659 if (composite_image->alpha_trait != UndefinedPixelTrait)
8660 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8661 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8662 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8664 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8665 composite_image->columns,1,exception);
8666 for (x=0; x < (ssize_t) composite_image->columns; x++)
8668 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8669 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8671 q+=GetPixelChannels(composite_image);
8673 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8674 if (sync == MagickFalse)
8677 composite_view=DestroyCacheView(composite_view);
8680 if (attribute_flag[9] != 0) /* "color=>" */
8681 QueryColorCompliance(argument_list[9].string_reference,
8682 AllCompliance,&composite_image->background_color,exception);
8683 if (attribute_flag[12] != 0) /* "interpolate=>" */
8684 image->interpolate=(PixelInterpolateMethod)
8685 argument_list[12].integer_reference;
8686 if (attribute_flag[13] != 0) /* "args=>" */
8687 (void) SetImageArtifact(composite_image,"compose:args",
8688 argument_list[13].string_reference);
8689 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8690 (void) SetImageArtifact(composite_image,"compose:args",
8691 argument_list[14].string_reference);
8692 clip_to_self=MagickTrue;
8693 if (attribute_flag[15] != 0)
8694 clip_to_self=(MagickBooleanType)
8695 argument_list[15].integer_reference;
8697 Tiling Composition (with orthogonal rotate).
8699 rotate_image=(Image *) NULL;
8700 if (attribute_flag[8] != 0) /* "rotate=>" */
8705 rotate_image=RotateImage(composite_image,
8706 argument_list[8].real_reference,exception);
8707 if (rotate_image == (Image *) NULL)
8710 if ((attribute_flag[7] != 0) &&
8711 (argument_list[7].integer_reference != 0)) /* tile */
8718 Tile the composite image.
8720 if (attribute_flag[8] != 0) /* "tile=>" */
8721 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8724 (void) SetImageArtifact(composite_image,
8725 "compose:outside-overlay","false");
8726 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8727 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8729 if (attribute_flag[8] != 0) /* rotate */
8730 (void) CompositeImage(image,rotate_image,compose,
8731 MagickTrue,x,y,exception);
8733 (void) CompositeImage(image,composite_image,compose,
8734 MagickTrue,x,y,exception);
8736 if (attribute_flag[8] != 0) /* rotate */
8737 rotate_image=DestroyImage(rotate_image);
8741 Parameter Handling used used ONLY for normal composition.
8743 if (attribute_flag[5] != 0) /* gravity */
8744 image->gravity=(GravityType) argument_list[5].integer_reference;
8745 if (attribute_flag[2] != 0) /* geometry offset */
8747 SetGeometry(image,&geometry);
8748 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8750 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8753 if (attribute_flag[3] != 0) /* x offset */
8754 geometry.x=argument_list[3].integer_reference;
8755 if (attribute_flag[4] != 0) /* y offset */
8756 geometry.y=argument_list[4].integer_reference;
8757 if (attribute_flag[10] != 0) /* mask */
8759 if ((image->compose == DisplaceCompositeOp) ||
8760 (image->compose == DistortCompositeOp))
8763 Merge Y displacement into X displacement image.
8765 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8767 (void) CompositeImage(composite_image,
8768 argument_list[10].image_reference,CopyGreenCompositeOp,
8769 MagickTrue,0,0,exception);
8777 Set a blending mask for the composition.
8779 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8780 MagickTrue,exception);
8781 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8783 mask_image=DestroyImage(mask_image);
8786 if (attribute_flag[11] != 0) /* channel */
8787 channel=(ChannelType) argument_list[11].integer_reference;
8789 Composite two images (normal composition).
8791 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8792 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8793 (double) composite_image->rows,(double) geometry.x,(double)
8795 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8797 channel_mask=SetImageChannelMask(image,channel);
8798 if (attribute_flag[8] == 0) /* no rotate */
8799 CompositeImage(image,composite_image,compose,clip_to_self,
8800 geometry.x,geometry.y,exception);
8804 Position adjust rotated image then composite.
8806 geometry.x-=(ssize_t) (rotate_image->columns-
8807 composite_image->columns)/2;
8808 geometry.y-=(ssize_t) (rotate_image->rows-
8809 composite_image->rows)/2;
8810 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8811 geometry.y,exception);
8812 rotate_image=DestroyImage(rotate_image);
8814 if (attribute_flag[10] != 0) /* mask */
8816 if ((image->compose == DisplaceCompositeOp) ||
8817 (image->compose == DistortCompositeOp))
8818 composite_image=DestroyImage(composite_image);
8820 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8823 (void) SetImageChannelMask(image,channel_mask);
8826 case 36: /* Contrast */
8828 if (attribute_flag[0] == 0)
8829 argument_list[0].integer_reference=0;
8830 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8831 MagickTrue : MagickFalse,exception);
8834 case 37: /* CycleColormap */
8836 if (attribute_flag[0] == 0)
8837 argument_list[0].integer_reference=6;
8838 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8847 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8849 (void) CloneString(&draw_info->primitive,"point");
8850 if (attribute_flag[0] != 0)
8852 if (argument_list[0].integer_reference < 0)
8853 (void) CloneString(&draw_info->primitive,
8854 argument_list[0].string_reference);
8856 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8857 MagickPrimitiveOptions,argument_list[0].integer_reference));
8859 if (attribute_flag[1] != 0)
8861 if (LocaleCompare(draw_info->primitive,"path") == 0)
8863 (void) ConcatenateString(&draw_info->primitive," '");
8864 ConcatenateString(&draw_info->primitive,
8865 argument_list[1].string_reference);
8866 (void) ConcatenateString(&draw_info->primitive,"'");
8870 (void) ConcatenateString(&draw_info->primitive," ");
8871 ConcatenateString(&draw_info->primitive,
8872 argument_list[1].string_reference);
8875 if (attribute_flag[2] != 0)
8877 (void) ConcatenateString(&draw_info->primitive," ");
8878 (void) ConcatenateString(&draw_info->primitive,
8879 CommandOptionToMnemonic(MagickMethodOptions,
8880 argument_list[2].integer_reference));
8882 if (attribute_flag[3] != 0)
8884 (void) QueryColorCompliance(argument_list[3].string_reference,
8885 AllCompliance,&draw_info->stroke,exception);
8886 if (argument_list[3].image_reference != (Image *) NULL)
8887 draw_info->stroke_pattern=CloneImage(
8888 argument_list[3].image_reference,0,0,MagickTrue,exception);
8890 if (attribute_flag[4] != 0)
8892 (void) QueryColorCompliance(argument_list[4].string_reference,
8893 AllCompliance,&draw_info->fill,exception);
8894 if (argument_list[4].image_reference != (Image *) NULL)
8895 draw_info->fill_pattern=CloneImage(
8896 argument_list[4].image_reference,0,0,MagickTrue,exception);
8898 if (attribute_flag[5] != 0)
8899 draw_info->stroke_width=argument_list[5].real_reference;
8900 if (attribute_flag[6] != 0)
8901 (void) CloneString(&draw_info->font,
8902 argument_list[6].string_reference);
8903 if (attribute_flag[7] != 0)
8904 (void) QueryColorCompliance(argument_list[7].string_reference,
8905 AllCompliance,&draw_info->border_color,exception);
8906 if (attribute_flag[8] != 0)
8907 draw_info->affine.tx=argument_list[8].real_reference;
8908 if (attribute_flag[9] != 0)
8909 draw_info->affine.ty=argument_list[9].real_reference;
8910 if (attribute_flag[20] != 0)
8915 av=(AV *) argument_list[20].array_reference;
8916 if ((av_len(av) != 3) && (av_len(av) != 5))
8918 ThrowPerlException(exception,OptionError,
8919 "affine matrix must have 4 or 6 elements",PackageName);
8922 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8923 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8924 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8925 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8926 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8927 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8929 ThrowPerlException(exception,OptionError,
8930 "affine matrix is singular",PackageName);
8933 if (av_len(av) == 5)
8935 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8936 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8939 for (j=10; j < 15; j++)
8941 if (attribute_flag[j] == 0)
8943 value=argument_list[j].string_reference;
8944 angle=argument_list[j].real_reference;
8945 current=draw_info->affine;
8946 GetAffineMatrix(&affine);
8954 flags=ParseGeometry(value,&geometry_info);
8955 affine.tx=geometry_info.xi;
8956 affine.ty=geometry_info.psi;
8957 if ((flags & PsiValue) == 0)
8958 affine.ty=affine.tx;
8966 flags=ParseGeometry(value,&geometry_info);
8967 affine.sx=geometry_info.rho;
8968 affine.sy=geometry_info.sigma;
8969 if ((flags & SigmaValue) == 0)
8970 affine.sy=affine.sx;
8980 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8981 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8982 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8983 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8991 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8999 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9003 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9004 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9005 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9006 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9007 draw_info->affine.tx=
9008 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9009 draw_info->affine.ty=
9010 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9012 if (attribute_flag[15] != 0)
9013 draw_info->fill_pattern=CloneImage(
9014 argument_list[15].image_reference,0,0,MagickTrue,exception);
9015 if (attribute_flag[16] != 0)
9016 draw_info->pointsize=argument_list[16].real_reference;
9017 if (attribute_flag[17] != 0)
9019 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
9020 ? MagickTrue : MagickFalse;
9021 draw_info->text_antialias=draw_info->stroke_antialias;
9023 if (attribute_flag[18] != 0)
9024 (void) CloneString(&draw_info->density,
9025 argument_list[18].string_reference);
9026 if (attribute_flag[19] != 0)
9027 draw_info->stroke_width=argument_list[19].real_reference;
9028 if (attribute_flag[21] != 0)
9029 draw_info->dash_offset=argument_list[21].real_reference;
9030 if (attribute_flag[22] != 0)
9035 av=(AV *) argument_list[22].array_reference;
9036 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9037 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9038 if (draw_info->dash_pattern != (double *) NULL)
9040 for (i=0; i <= av_len(av); i++)
9041 draw_info->dash_pattern[i]=(double)
9042 SvNV(*(av_fetch(av,i,0)));
9043 draw_info->dash_pattern[i]=0.0;
9046 if (attribute_flag[23] != 0)
9047 image->interpolate=(PixelInterpolateMethod)
9048 argument_list[23].integer_reference;
9049 if ((attribute_flag[24] != 0) &&
9050 (draw_info->fill_pattern != (Image *) NULL))
9051 flags=ParsePageGeometry(draw_info->fill_pattern,
9052 argument_list[24].string_reference,
9053 &draw_info->fill_pattern->tile_offset,exception);
9054 if (attribute_flag[25] != 0)
9056 (void) ConcatenateString(&draw_info->primitive," '");
9057 (void) ConcatenateString(&draw_info->primitive,
9058 argument_list[25].string_reference);
9059 (void) ConcatenateString(&draw_info->primitive,"'");
9061 if (attribute_flag[26] != 0)
9062 draw_info->fill_pattern=CloneImage(
9063 argument_list[26].image_reference,0,0,MagickTrue,exception);
9064 if (attribute_flag[27] != 0)
9065 draw_info->stroke_pattern=CloneImage(
9066 argument_list[27].image_reference,0,0,MagickTrue,exception);
9067 if (attribute_flag[28] != 0)
9068 (void) CloneString(&draw_info->primitive,
9069 argument_list[28].string_reference);
9070 if (attribute_flag[29] != 0)
9071 draw_info->kerning=argument_list[29].real_reference;
9072 if (attribute_flag[30] != 0)
9073 draw_info->interline_spacing=argument_list[30].real_reference;
9074 if (attribute_flag[31] != 0)
9075 draw_info->interword_spacing=argument_list[31].real_reference;
9076 if (attribute_flag[32] != 0)
9077 draw_info->direction=(DirectionType)
9078 argument_list[32].integer_reference;
9079 DrawImage(image,draw_info,exception);
9080 draw_info=DestroyDrawInfo(draw_info);
9083 case 39: /* Equalize */
9085 if (attribute_flag[0] != 0)
9086 channel=(ChannelType) argument_list[0].integer_reference;
9087 channel_mask=SetImageChannelMask(image,channel);
9088 EqualizeImage(image,exception);
9089 (void) SetImageChannelMask(image,channel_mask);
9092 case 40: /* Gamma */
9094 if (attribute_flag[1] != 0)
9095 channel=(ChannelType) argument_list[1].integer_reference;
9096 if (attribute_flag[2] == 0)
9097 argument_list[2].real_reference=1.0;
9098 if (attribute_flag[3] == 0)
9099 argument_list[3].real_reference=1.0;
9100 if (attribute_flag[4] == 0)
9101 argument_list[4].real_reference=1.0;
9102 if (attribute_flag[0] == 0)
9104 (void) FormatLocaleString(message,MagickPathExtent,
9105 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9106 (double) argument_list[3].real_reference,
9107 (double) argument_list[4].real_reference);
9108 argument_list[0].string_reference=message;
9110 (void) GammaImage(image,StringToDouble(
9111 argument_list[0].string_reference,(char **) NULL),exception);
9119 if (attribute_flag[0] == 0)
9121 ThrowPerlException(exception,OptionError,"MapImageRequired",
9125 quantize_info=AcquireQuantizeInfo(info->image_info);
9126 if (attribute_flag[1] != 0)
9127 quantize_info->dither_method=(DitherMethod)
9128 argument_list[1].integer_reference;
9129 (void) RemapImages(quantize_info,image,
9130 argument_list[0].image_reference,exception);
9131 quantize_info=DestroyQuantizeInfo(quantize_info);
9134 case 42: /* MatteFloodfill */
9145 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9147 if (attribute_flag[0] != 0)
9148 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9149 &geometry,exception);
9150 if (attribute_flag[1] != 0)
9151 geometry.x=argument_list[1].integer_reference;
9152 if (attribute_flag[2] != 0)
9153 geometry.y=argument_list[2].integer_reference;
9154 if (image->alpha_trait == UndefinedPixelTrait)
9155 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9156 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9157 geometry.x,geometry.y,&target,exception);
9158 if (attribute_flag[4] != 0)
9159 QueryColorCompliance(argument_list[4].string_reference,
9160 AllCompliance,&target,exception);
9161 if (attribute_flag[3] != 0)
9162 target.alpha=StringToDoubleInterval(
9163 argument_list[3].string_reference,(double) (double) QuantumRange+
9165 if (attribute_flag[5] != 0)
9166 image->fuzz=StringToDoubleInterval(
9167 argument_list[5].string_reference,(double) QuantumRange+1.0);
9169 if (attribute_flag[6] != 0)
9170 invert=(MagickBooleanType) argument_list[6].integer_reference;
9171 channel_mask=SetImageChannelMask(image,AlphaChannel);
9172 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9173 geometry.y,invert,exception);
9174 (void) SetImageChannelMask(image,channel_mask);
9175 draw_info=DestroyDrawInfo(draw_info);
9178 case 43: /* Modulate */
9181 modulate[MagickPathExtent];
9183 geometry_info.rho=100.0;
9184 geometry_info.sigma=100.0;
9185 geometry_info.xi=100.0;
9186 if (attribute_flag[0] != 0)
9187 (void)ParseGeometry(argument_list[0].string_reference,
9189 if (attribute_flag[1] != 0)
9190 geometry_info.xi=argument_list[1].real_reference;
9191 if (attribute_flag[2] != 0)
9192 geometry_info.sigma=argument_list[2].real_reference;
9193 if (attribute_flag[3] != 0)
9195 geometry_info.sigma=argument_list[3].real_reference;
9196 SetImageArtifact(image,"modulate:colorspace","HWB");
9198 if (attribute_flag[4] != 0)
9200 geometry_info.rho=argument_list[4].real_reference;
9201 SetImageArtifact(image,"modulate:colorspace","HSB");
9203 if (attribute_flag[5] != 0)
9205 geometry_info.sigma=argument_list[5].real_reference;
9206 SetImageArtifact(image,"modulate:colorspace","HSL");
9208 if (attribute_flag[6] != 0)
9210 geometry_info.rho=argument_list[6].real_reference;
9211 SetImageArtifact(image,"modulate:colorspace","HWB");
9213 (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g",
9214 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9215 (void) ModulateImage(image,modulate,exception);
9218 case 44: /* Negate */
9220 if (attribute_flag[0] == 0)
9221 argument_list[0].integer_reference=0;
9222 if (attribute_flag[1] != 0)
9223 channel=(ChannelType) argument_list[1].integer_reference;
9224 channel_mask=SetImageChannelMask(image,channel);
9225 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9226 MagickTrue : MagickFalse,exception);
9227 (void) SetImageChannelMask(image,channel_mask);
9230 case 45: /* Normalize */
9232 if (attribute_flag[0] != 0)
9233 channel=(ChannelType) argument_list[0].integer_reference;
9234 channel_mask=SetImageChannelMask(image,channel);
9235 NormalizeImage(image,exception);
9236 (void) SetImageChannelMask(image,channel_mask);
9239 case 46: /* NumberColors */
9241 case 47: /* Opaque */
9250 (void) QueryColorCompliance("none",AllCompliance,&target,
9252 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9254 if (attribute_flag[0] != 0)
9255 (void) QueryColorCompliance(argument_list[0].string_reference,
9256 AllCompliance,&target,exception);
9257 if (attribute_flag[1] != 0)
9258 (void) QueryColorCompliance(argument_list[1].string_reference,
9259 AllCompliance,&fill_color,exception);
9260 if (attribute_flag[2] != 0)
9261 image->fuzz=StringToDoubleInterval(
9262 argument_list[2].string_reference,(double) QuantumRange+1.0);
9263 if (attribute_flag[3] != 0)
9264 channel=(ChannelType) argument_list[3].integer_reference;
9266 if (attribute_flag[4] != 0)
9267 invert=(MagickBooleanType) argument_list[4].integer_reference;
9268 channel_mask=SetImageChannelMask(image,channel);
9269 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9270 (void) SetImageChannelMask(image,channel_mask);
9273 case 48: /* Quantize */
9278 quantize_info=AcquireQuantizeInfo(info->image_info);
9279 if (attribute_flag[0] != 0)
9280 quantize_info->number_colors=(size_t)
9281 argument_list[0].integer_reference;
9282 if (attribute_flag[1] != 0)
9283 quantize_info->tree_depth=(size_t)
9284 argument_list[1].integer_reference;
9285 if (attribute_flag[2] != 0)
9286 quantize_info->colorspace=(ColorspaceType)
9287 argument_list[2].integer_reference;
9288 if (attribute_flag[3] != 0)
9289 quantize_info->dither_method=(DitherMethod)
9290 argument_list[3].integer_reference;
9291 if (attribute_flag[4] != 0)
9292 quantize_info->measure_error=
9293 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9294 if (attribute_flag[6] != 0)
9295 (void) QueryColorCompliance(argument_list[6].string_reference,
9296 AllCompliance,&image->transparent_color,exception);
9297 if (attribute_flag[7] != 0)
9298 quantize_info->dither_method=(DitherMethod)
9299 argument_list[7].integer_reference;
9300 if (attribute_flag[5] && argument_list[5].integer_reference)
9301 (void) QuantizeImages(quantize_info,image,exception);
9303 if ((image->storage_class == DirectClass) ||
9304 (image->colors > quantize_info->number_colors) ||
9305 (quantize_info->colorspace == GRAYColorspace))
9306 (void) QuantizeImage(quantize_info,image,exception);
9308 CompressImageColormap(image,exception);
9309 quantize_info=DestroyQuantizeInfo(quantize_info);
9312 case 49: /* Raise */
9314 if (attribute_flag[0] != 0)
9315 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9316 &geometry,exception);
9317 if (attribute_flag[1] != 0)
9318 geometry.width=argument_list[1].integer_reference;
9319 if (attribute_flag[2] != 0)
9320 geometry.height=argument_list[2].integer_reference;
9321 if (attribute_flag[3] == 0)
9322 argument_list[3].integer_reference=1;
9323 (void) RaiseImage(image,&geometry,
9324 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9328 case 50: /* Segment */
9335 smoothing_threshold;
9340 cluster_threshold=1.0;
9341 smoothing_threshold=1.5;
9342 colorspace=sRGBColorspace;
9343 verbose=MagickFalse;
9344 if (attribute_flag[0] != 0)
9346 flags=ParseGeometry(argument_list[0].string_reference,
9348 cluster_threshold=geometry_info.rho;
9349 if (flags & SigmaValue)
9350 smoothing_threshold=geometry_info.sigma;
9352 if (attribute_flag[1] != 0)
9353 cluster_threshold=argument_list[1].real_reference;
9354 if (attribute_flag[2] != 0)
9355 smoothing_threshold=argument_list[2].real_reference;
9356 if (attribute_flag[3] != 0)
9357 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9358 if (attribute_flag[4] != 0)
9359 verbose=argument_list[4].integer_reference != 0 ?
9360 MagickTrue : MagickFalse;
9361 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9362 smoothing_threshold,exception);
9365 case 51: /* Signature */
9367 (void) SignatureImage(image,exception);
9370 case 52: /* Solarize */
9372 geometry_info.rho=QuantumRange/2.0;
9373 if (attribute_flag[0] != 0)
9374 flags=ParseGeometry(argument_list[0].string_reference,
9376 if (attribute_flag[1] != 0)
9377 geometry_info.rho=StringToDoubleInterval(
9378 argument_list[1].string_reference,(double) QuantumRange+1.0);
9379 (void) SolarizeImage(image,geometry_info.rho,exception);
9384 (void) SyncImage(image,exception);
9387 case 54: /* Texture */
9389 if (attribute_flag[0] == 0)
9391 TextureImage(image,argument_list[0].image_reference,exception);
9394 case 55: /* Evalute */
9396 MagickEvaluateOperator
9399 op=SetEvaluateOperator;
9400 if (attribute_flag[0] == MagickFalse)
9401 argument_list[0].real_reference=0.0;
9402 if (attribute_flag[1] != MagickFalse)
9403 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9404 if (attribute_flag[2] != MagickFalse)
9405 channel=(ChannelType) argument_list[2].integer_reference;
9406 channel_mask=SetImageChannelMask(image,channel);
9407 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9409 (void) SetImageChannelMask(image,channel_mask);
9412 case 56: /* Transparent */
9423 (void) QueryColorCompliance("none",AllCompliance,&target,
9425 if (attribute_flag[0] != 0)
9426 (void) QueryColorCompliance(argument_list[0].string_reference,
9427 AllCompliance,&target,exception);
9428 opacity=TransparentAlpha;
9429 if (attribute_flag[1] != 0)
9430 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9431 (double) QuantumRange+1.0);
9432 if (attribute_flag[2] != 0)
9433 image->fuzz=StringToDoubleInterval(
9434 argument_list[2].string_reference,(double) QuantumRange+1.0);
9435 if (attribute_flag[3] == 0)
9436 argument_list[3].integer_reference=0;
9438 if (attribute_flag[3] != 0)
9439 invert=(MagickBooleanType) argument_list[3].integer_reference;
9440 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9444 case 57: /* Threshold */
9449 if (attribute_flag[0] == 0)
9450 argument_list[0].string_reference="50%";
9451 if (attribute_flag[1] != 0)
9452 channel=(ChannelType) argument_list[1].integer_reference;
9453 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9454 (double) QuantumRange+1.0);
9455 channel_mask=SetImageChannelMask(image,channel);
9456 (void) BilevelImage(image,threshold,exception);
9457 (void) SetImageChannelMask(image,channel_mask);
9460 case 58: /* Charcoal */
9462 if (attribute_flag[0] != 0)
9464 flags=ParseGeometry(argument_list[0].string_reference,
9466 if ((flags & SigmaValue) == 0)
9467 geometry_info.sigma=1.0;
9469 if (attribute_flag[1] != 0)
9470 geometry_info.rho=argument_list[1].real_reference;
9471 if (attribute_flag[2] != 0)
9472 geometry_info.sigma=argument_list[2].real_reference;
9473 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9479 if (attribute_flag[0] != 0)
9480 image->fuzz=StringToDoubleInterval(
9481 argument_list[0].string_reference,(double) QuantumRange+1.0);
9482 image=TrimImage(image,exception);
9487 PixelInterpolateMethod
9490 if (attribute_flag[0] != 0)
9492 flags=ParseGeometry(argument_list[0].string_reference,
9494 if ((flags & SigmaValue) == 0)
9495 geometry_info.sigma=1.0;
9497 if (attribute_flag[1] != 0)
9498 geometry_info.rho=argument_list[1].real_reference;
9499 if (attribute_flag[2] != 0)
9500 geometry_info.sigma=argument_list[2].real_reference;
9501 method=UndefinedInterpolatePixel;
9502 if (attribute_flag[3] != 0)
9503 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9504 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9508 case 61: /* Separate */
9510 if (attribute_flag[0] != 0)
9511 channel=(ChannelType) argument_list[0].integer_reference;
9512 image=SeparateImage(image,channel,exception);
9515 case 63: /* Stereo */
9517 if (attribute_flag[0] == 0)
9519 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9523 if (attribute_flag[1] != 0)
9524 geometry.x=argument_list[1].integer_reference;
9525 if (attribute_flag[2] != 0)
9526 geometry.y=argument_list[2].integer_reference;
9527 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9528 geometry.x,geometry.y,exception);
9531 case 64: /* Stegano */
9533 if (attribute_flag[0] == 0)
9535 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9539 if (attribute_flag[1] == 0)
9540 argument_list[1].integer_reference=0;
9541 image->offset=argument_list[1].integer_reference;
9542 image=SteganoImage(image,argument_list[0].image_reference,exception);
9545 case 65: /* Deconstruct */
9547 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9550 case 66: /* GaussianBlur */
9552 if (attribute_flag[0] != 0)
9554 flags=ParseGeometry(argument_list[0].string_reference,
9556 if ((flags & SigmaValue) == 0)
9557 geometry_info.sigma=1.0;
9559 if (attribute_flag[1] != 0)
9560 geometry_info.rho=argument_list[1].real_reference;
9561 if (attribute_flag[2] != 0)
9562 geometry_info.sigma=argument_list[2].real_reference;
9563 if (attribute_flag[3] != 0)
9564 channel=(ChannelType) argument_list[3].integer_reference;
9565 channel_mask=SetImageChannelMask(image,channel);
9566 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9568 if (image != (Image *) NULL)
9569 (void) SetImageChannelMask(image,channel_mask);
9572 case 67: /* Convolve */
9577 kernel=(KernelInfo *) NULL;
9578 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9580 if (attribute_flag[0] != 0)
9588 kernel=AcquireKernelInfo((const char *) NULL,exception);
9589 if (kernel == (KernelInfo *) NULL)
9591 av=(AV *) argument_list[0].array_reference;
9592 order=(size_t) sqrt(av_len(av)+1);
9593 kernel->width=order;
9594 kernel->height=order;
9595 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9596 order*sizeof(*kernel->values));
9597 if (kernel->values == (MagickRealType *) NULL)
9599 kernel=DestroyKernelInfo(kernel);
9600 ThrowPerlException(exception,ResourceLimitFatalError,
9601 "MemoryAllocationFailed",PackageName);
9604 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9605 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9606 for ( ; j < (ssize_t) (order*order); j++)
9607 kernel->values[j]=0.0;
9609 if (attribute_flag[1] != 0)
9610 channel=(ChannelType) argument_list[1].integer_reference;
9611 if (attribute_flag[2] != 0)
9612 SetImageArtifact(image,"filter:blur",
9613 argument_list[2].string_reference);
9614 if (attribute_flag[3] != 0)
9616 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9618 if (kernel == (KernelInfo *) NULL)
9621 channel_mask=SetImageChannelMask(image,channel);
9622 image=ConvolveImage(image,kernel,exception);
9623 if (image != (Image *) NULL)
9624 (void) SetImageChannelMask(image,channel_mask);
9625 kernel=DestroyKernelInfo(kernel);
9628 case 68: /* Profile */
9643 if (attribute_flag[0] != 0)
9644 name=argument_list[0].string_reference;
9645 if (attribute_flag[2] != 0)
9646 image->rendering_intent=(RenderingIntent)
9647 argument_list[2].integer_reference;
9648 if (attribute_flag[3] != 0)
9649 image->black_point_compensation=
9650 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9651 if (attribute_flag[1] != 0)
9653 if (argument_list[1].length == 0)
9656 Remove a profile from the image.
9658 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9663 Associate user supplied profile with the image.
9665 profile=AcquireStringInfo(argument_list[1].length);
9666 SetStringInfoDatum(profile,(const unsigned char *)
9667 argument_list[1].string_reference);
9668 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9669 (size_t) GetStringInfoLength(profile),exception);
9670 profile=DestroyStringInfo(profile);
9674 Associate a profile with the image.
9676 profile_info=CloneImageInfo(info ? info->image_info :
9677 (ImageInfo *) NULL);
9678 profile_image=ReadImages(profile_info,name,exception);
9679 if (profile_image == (Image *) NULL)
9681 ResetImageProfileIterator(profile_image);
9682 name=GetNextImageProfile(profile_image);
9683 while (name != (const char *) NULL)
9688 profile=GetImageProfile(profile_image,name);
9689 if (profile != (const StringInfo *) NULL)
9690 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9691 (size_t) GetStringInfoLength(profile),exception);
9692 name=GetNextImageProfile(profile_image);
9694 profile_image=DestroyImage(profile_image);
9695 profile_info=DestroyImageInfo(profile_info);
9698 case 69: /* UnsharpMask */
9700 if (attribute_flag[0] != 0)
9702 flags=ParseGeometry(argument_list[0].string_reference,
9704 if ((flags & SigmaValue) == 0)
9705 geometry_info.sigma=1.0;
9706 if ((flags & XiValue) == 0)
9707 geometry_info.xi=1.0;
9708 if ((flags & PsiValue) == 0)
9709 geometry_info.psi=0.5;
9711 if (attribute_flag[1] != 0)
9712 geometry_info.rho=argument_list[1].real_reference;
9713 if (attribute_flag[2] != 0)
9714 geometry_info.sigma=argument_list[2].real_reference;
9715 if (attribute_flag[3] != 0)
9716 geometry_info.xi=argument_list[3].real_reference;
9717 if (attribute_flag[4] != 0)
9718 geometry_info.psi=argument_list[4].real_reference;
9719 if (attribute_flag[5] != 0)
9720 channel=(ChannelType) argument_list[5].integer_reference;
9721 channel_mask=SetImageChannelMask(image,channel);
9722 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9723 geometry_info.xi,geometry_info.psi,exception);
9724 if (image != (Image *) NULL)
9725 (void) SetImageChannelMask(image,channel_mask);
9728 case 70: /* MotionBlur */
9730 if (attribute_flag[0] != 0)
9732 flags=ParseGeometry(argument_list[0].string_reference,
9734 if ((flags & SigmaValue) == 0)
9735 geometry_info.sigma=1.0;
9736 if ((flags & XiValue) == 0)
9737 geometry_info.xi=1.0;
9739 if (attribute_flag[1] != 0)
9740 geometry_info.rho=argument_list[1].real_reference;
9741 if (attribute_flag[2] != 0)
9742 geometry_info.sigma=argument_list[2].real_reference;
9743 if (attribute_flag[3] != 0)
9744 geometry_info.xi=argument_list[3].real_reference;
9745 if (attribute_flag[4] != 0)
9746 channel=(ChannelType) argument_list[4].integer_reference;
9747 channel_mask=SetImageChannelMask(image,channel);
9748 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9749 geometry_info.xi,exception);
9750 if (image != (Image *) NULL)
9751 (void) SetImageChannelMask(image,channel_mask);
9754 case 71: /* OrderedDither */
9756 if (attribute_flag[0] == 0)
9757 argument_list[0].string_reference="o8x8";
9758 if (attribute_flag[1] != 0)
9759 channel=(ChannelType) argument_list[1].integer_reference;
9760 channel_mask=SetImageChannelMask(image,channel);
9761 (void) OrderedDitherImage(image,argument_list[0].string_reference,
9763 (void) SetImageChannelMask(image,channel_mask);
9766 case 72: /* Shave */
9768 if (attribute_flag[0] != 0)
9769 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9770 &geometry,exception);
9771 if (attribute_flag[1] != 0)
9772 geometry.width=argument_list[1].integer_reference;
9773 if (attribute_flag[2] != 0)
9774 geometry.height=argument_list[2].integer_reference;
9775 image=ShaveImage(image,&geometry,exception);
9778 case 73: /* Level */
9786 white_point=(double) image->columns*image->rows;
9788 if (attribute_flag[0] != 0)
9790 flags=ParseGeometry(argument_list[0].string_reference,
9792 black_point=geometry_info.rho;
9793 if ((flags & SigmaValue) != 0)
9794 white_point=geometry_info.sigma;
9795 if ((flags & XiValue) != 0)
9796 gamma=geometry_info.xi;
9797 if ((flags & PercentValue) != 0)
9799 black_point*=(double) (QuantumRange/100.0);
9800 white_point*=(double) (QuantumRange/100.0);
9802 if ((flags & SigmaValue) == 0)
9803 white_point=(double) QuantumRange-black_point;
9805 if (attribute_flag[1] != 0)
9806 black_point=argument_list[1].real_reference;
9807 if (attribute_flag[2] != 0)
9808 white_point=argument_list[2].real_reference;
9809 if (attribute_flag[3] != 0)
9810 gamma=argument_list[3].real_reference;
9811 if (attribute_flag[4] != 0)
9812 channel=(ChannelType) argument_list[4].integer_reference;
9813 if (attribute_flag[5] != 0)
9815 argument_list[0].real_reference=argument_list[5].real_reference;
9816 attribute_flag[0]=attribute_flag[5];
9818 channel_mask=SetImageChannelMask(image,channel);
9819 (void) LevelImage(image,black_point,white_point,gamma,exception);
9820 (void) SetImageChannelMask(image,channel_mask);
9825 if (attribute_flag[0] == 0)
9826 argument_list[0].string_reference="#1";
9827 if (attribute_flag[1] == 0)
9828 argument_list[1].integer_reference=MagickTrue;
9829 (void) ClipImagePath(image,argument_list[0].string_reference,
9830 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9834 case 75: /* AffineTransform */
9839 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9841 if (attribute_flag[0] != 0)
9846 av=(AV *) argument_list[0].array_reference;
9847 if ((av_len(av) != 3) && (av_len(av) != 5))
9849 ThrowPerlException(exception,OptionError,
9850 "affine matrix must have 4 or 6 elements",PackageName);
9853 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9854 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9855 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9856 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9857 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9858 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9860 ThrowPerlException(exception,OptionError,
9861 "affine matrix is singular",PackageName);
9864 if (av_len(av) == 5)
9866 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9867 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9870 for (j=1; j < 6; j++)
9872 if (attribute_flag[j] == 0)
9874 value=argument_list[j].string_reference;
9875 angle=argument_list[j].real_reference;
9876 current=draw_info->affine;
9877 GetAffineMatrix(&affine);
9885 flags=ParseGeometry(value,&geometry_info);
9886 affine.tx=geometry_info.xi;
9887 affine.ty=geometry_info.psi;
9888 if ((flags & PsiValue) == 0)
9889 affine.ty=affine.tx;
9897 flags=ParseGeometry(value,&geometry_info);
9898 affine.sx=geometry_info.rho;
9899 affine.sy=geometry_info.sigma;
9900 if ((flags & SigmaValue) == 0)
9901 affine.sy=affine.sx;
9911 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9912 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9913 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9914 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9922 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9930 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9934 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9935 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9936 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9937 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9938 draw_info->affine.tx=
9939 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9940 draw_info->affine.ty=
9941 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9943 if (attribute_flag[6] != 0)
9944 image->interpolate=(PixelInterpolateMethod)
9945 argument_list[6].integer_reference;
9946 if (attribute_flag[7] != 0)
9947 QueryColorCompliance(argument_list[7].string_reference,
9948 AllCompliance,&image->background_color,exception);
9949 image=AffineTransformImage(image,&draw_info->affine,exception);
9950 draw_info=DestroyDrawInfo(draw_info);
9953 case 76: /* Difference */
9955 if (attribute_flag[0] == 0)
9957 ThrowPerlException(exception,OptionError,
9958 "ReferenceImageRequired",PackageName);
9961 if (attribute_flag[1] != 0)
9962 image->fuzz=StringToDoubleInterval(
9963 argument_list[1].string_reference,(double) QuantumRange+1.0);
9964 (void) SetImageColorMetric(image,argument_list[0].image_reference,
9968 case 77: /* AdaptiveThreshold */
9970 if (attribute_flag[0] != 0)
9972 flags=ParseGeometry(argument_list[0].string_reference,
9974 if ((flags & PercentValue) != 0)
9975 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9977 if (attribute_flag[1] != 0)
9978 geometry_info.rho=argument_list[1].integer_reference;
9979 if (attribute_flag[2] != 0)
9980 geometry_info.sigma=argument_list[2].integer_reference;
9981 if (attribute_flag[3] != 0)
9982 geometry_info.xi=argument_list[3].integer_reference;;
9983 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9984 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9987 case 78: /* Resample */
9993 if (attribute_flag[0] != 0)
9995 flags=ParseGeometry(argument_list[0].string_reference,
9997 if ((flags & SigmaValue) == 0)
9998 geometry_info.sigma=geometry_info.rho;
10000 if (attribute_flag[1] != 0)
10001 geometry_info.rho=argument_list[1].real_reference;
10002 if (attribute_flag[2] != 0)
10003 geometry_info.sigma=argument_list[2].real_reference;
10004 if (attribute_flag[3] == 0)
10005 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
10006 if (attribute_flag[4] == 0)
10007 SetImageArtifact(image,"filter:support",
10008 argument_list[4].string_reference);
10009 width=(size_t) (geometry_info.rho*image->columns/
10010 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
10011 height=(size_t) (geometry_info.sigma*image->rows/
10012 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
10013 image=ResizeImage(image,width,height,(FilterType)
10014 argument_list[3].integer_reference,exception);
10015 if (image != (Image *) NULL)
10017 image->resolution.x=geometry_info.rho;
10018 image->resolution.y=geometry_info.sigma;
10022 case 79: /* Describe */
10024 if (attribute_flag[0] == 0)
10025 argument_list[0].file_reference=(FILE *) NULL;
10026 if (attribute_flag[1] != 0)
10027 (void) SetImageArtifact(image,"identify:features",
10028 argument_list[1].string_reference);
10029 (void) IdentifyImage(image,argument_list[0].file_reference,
10030 MagickTrue,exception);
10033 case 80: /* BlackThreshold */
10035 if (attribute_flag[0] == 0)
10036 argument_list[0].string_reference="50%";
10037 if (attribute_flag[2] != 0)
10038 channel=(ChannelType) argument_list[2].integer_reference;
10039 channel_mask=SetImageChannelMask(image,channel);
10040 BlackThresholdImage(image,argument_list[0].string_reference,
10042 (void) SetImageChannelMask(image,channel_mask);
10045 case 81: /* WhiteThreshold */
10047 if (attribute_flag[0] == 0)
10048 argument_list[0].string_reference="50%";
10049 if (attribute_flag[2] != 0)
10050 channel=(ChannelType) argument_list[2].integer_reference;
10051 channel_mask=SetImageChannelMask(image,channel);
10052 WhiteThresholdImage(image,argument_list[0].string_reference,
10054 (void) SetImageChannelMask(image,channel_mask);
10057 case 82: /* RotationalBlur */
10059 if (attribute_flag[0] != 0)
10061 flags=ParseGeometry(argument_list[0].string_reference,
10064 if (attribute_flag[1] != 0)
10065 geometry_info.rho=argument_list[1].real_reference;
10066 if (attribute_flag[2] != 0)
10067 channel=(ChannelType) argument_list[2].integer_reference;
10068 channel_mask=SetImageChannelMask(image,channel);
10069 image=RotationalBlurImage(image,geometry_info.rho,exception);
10070 if (image != (Image *) NULL)
10071 (void) SetImageChannelMask(image,channel_mask);
10074 case 83: /* Thumbnail */
10076 if (attribute_flag[0] != 0)
10077 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10078 &geometry,exception);
10079 if (attribute_flag[1] != 0)
10080 geometry.width=argument_list[1].integer_reference;
10081 if (attribute_flag[2] != 0)
10082 geometry.height=argument_list[2].integer_reference;
10083 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10086 case 84: /* Strip */
10088 (void) StripImage(image,exception);
10091 case 85: /* Tint */
10096 GetPixelInfo(image,&tint);
10097 if (attribute_flag[0] != 0)
10098 (void) QueryColorCompliance(argument_list[0].string_reference,
10099 AllCompliance,&tint,exception);
10100 if (attribute_flag[1] == 0)
10101 argument_list[1].string_reference="100";
10102 image=TintImage(image,argument_list[1].string_reference,&tint,
10106 case 86: /* Channel */
10108 if (attribute_flag[0] != 0)
10109 channel=(ChannelType) argument_list[0].integer_reference;
10110 image=SeparateImage(image,channel,exception);
10113 case 87: /* Splice */
10115 if (attribute_flag[7] != 0)
10116 image->gravity=(GravityType) argument_list[7].integer_reference;
10117 if (attribute_flag[0] != 0)
10118 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10119 &geometry,exception);
10120 if (attribute_flag[1] != 0)
10121 geometry.width=argument_list[1].integer_reference;
10122 if (attribute_flag[2] != 0)
10123 geometry.height=argument_list[2].integer_reference;
10124 if (attribute_flag[3] != 0)
10125 geometry.x=argument_list[3].integer_reference;
10126 if (attribute_flag[4] != 0)
10127 geometry.y=argument_list[4].integer_reference;
10128 if (attribute_flag[5] != 0)
10129 image->fuzz=StringToDoubleInterval(
10130 argument_list[5].string_reference,(double) QuantumRange+1.0);
10131 if (attribute_flag[6] != 0)
10132 (void) QueryColorCompliance(argument_list[6].string_reference,
10133 AllCompliance,&image->background_color,exception);
10134 image=SpliceImage(image,&geometry,exception);
10137 case 88: /* Posterize */
10139 if (attribute_flag[0] == 0)
10140 argument_list[0].integer_reference=3;
10141 if (attribute_flag[1] == 0)
10142 argument_list[1].integer_reference=0;
10143 (void) PosterizeImage(image,argument_list[0].integer_reference,
10144 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10145 NoDitherMethod,exception);
10148 case 89: /* Shadow */
10150 if (attribute_flag[0] != 0)
10152 flags=ParseGeometry(argument_list[0].string_reference,
10154 if ((flags & SigmaValue) == 0)
10155 geometry_info.sigma=1.0;
10156 if ((flags & XiValue) == 0)
10157 geometry_info.xi=4.0;
10158 if ((flags & PsiValue) == 0)
10159 geometry_info.psi=4.0;
10161 if (attribute_flag[1] != 0)
10162 geometry_info.rho=argument_list[1].real_reference;
10163 if (attribute_flag[2] != 0)
10164 geometry_info.sigma=argument_list[2].real_reference;
10165 if (attribute_flag[3] != 0)
10166 geometry_info.xi=argument_list[3].integer_reference;
10167 if (attribute_flag[4] != 0)
10168 geometry_info.psi=argument_list[4].integer_reference;
10169 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10170 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10171 ceil(geometry_info.psi-0.5),exception);
10174 case 90: /* Identify */
10176 if (attribute_flag[0] == 0)
10177 argument_list[0].file_reference=(FILE *) NULL;
10178 if (attribute_flag[1] != 0)
10179 (void) SetImageArtifact(image,"identify:features",
10180 argument_list[1].string_reference);
10181 if ((attribute_flag[2] != 0) &&
10182 (argument_list[2].integer_reference != 0))
10183 (void) SetImageArtifact(image,"identify:unique","true");
10184 (void) IdentifyImage(image,argument_list[0].file_reference,
10185 MagickTrue,exception);
10188 case 91: /* SepiaTone */
10190 if (attribute_flag[0] == 0)
10191 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10192 image=SepiaToneImage(image,argument_list[0].real_reference,
10196 case 92: /* SigmoidalContrast */
10201 if (attribute_flag[0] != 0)
10203 flags=ParseGeometry(argument_list[0].string_reference,
10205 if ((flags & SigmaValue) == 0)
10206 geometry_info.sigma=QuantumRange/2.0;
10207 if ((flags & PercentValue) != 0)
10208 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10210 if (attribute_flag[1] != 0)
10211 geometry_info.rho=argument_list[1].real_reference;
10212 if (attribute_flag[2] != 0)
10213 geometry_info.sigma=argument_list[2].real_reference;
10214 if (attribute_flag[3] != 0)
10215 channel=(ChannelType) argument_list[3].integer_reference;
10216 sharpen=MagickTrue;
10217 if (attribute_flag[4] != 0)
10218 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10220 channel_mask=SetImageChannelMask(image,channel);
10221 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10222 geometry_info.sigma,exception);
10223 (void) SetImageChannelMask(image,channel_mask);
10226 case 93: /* Extent */
10228 if (attribute_flag[7] != 0)
10229 image->gravity=(GravityType) argument_list[7].integer_reference;
10230 if (attribute_flag[0] != 0)
10235 flags=ParseGravityGeometry(image,
10236 argument_list[0].string_reference,&geometry,exception);
10238 if (geometry.width == 0)
10239 geometry.width=image->columns;
10240 if (geometry.height == 0)
10241 geometry.height=image->rows;
10243 if (attribute_flag[1] != 0)
10244 geometry.width=argument_list[1].integer_reference;
10245 if (attribute_flag[2] != 0)
10246 geometry.height=argument_list[2].integer_reference;
10247 if (attribute_flag[3] != 0)
10248 geometry.x=argument_list[3].integer_reference;
10249 if (attribute_flag[4] != 0)
10250 geometry.y=argument_list[4].integer_reference;
10251 if (attribute_flag[5] != 0)
10252 image->fuzz=StringToDoubleInterval(
10253 argument_list[5].string_reference,(double) QuantumRange+1.0);
10254 if (attribute_flag[6] != 0)
10255 (void) QueryColorCompliance(argument_list[6].string_reference,
10256 AllCompliance,&image->background_color,exception);
10257 image=ExtentImage(image,&geometry,exception);
10260 case 94: /* Vignette */
10262 if (attribute_flag[0] != 0)
10264 flags=ParseGeometry(argument_list[0].string_reference,
10266 if ((flags & SigmaValue) == 0)
10267 geometry_info.sigma=1.0;
10268 if ((flags & XiValue) == 0)
10269 geometry_info.xi=0.1*image->columns;
10270 if ((flags & PsiValue) == 0)
10271 geometry_info.psi=0.1*image->rows;
10273 if (attribute_flag[1] != 0)
10274 geometry_info.rho=argument_list[1].real_reference;
10275 if (attribute_flag[2] != 0)
10276 geometry_info.sigma=argument_list[2].real_reference;
10277 if (attribute_flag[3] != 0)
10278 geometry_info.xi=argument_list[3].integer_reference;
10279 if (attribute_flag[4] != 0)
10280 geometry_info.psi=argument_list[4].integer_reference;
10281 if (attribute_flag[5] != 0)
10282 (void) QueryColorCompliance(argument_list[5].string_reference,
10283 AllCompliance,&image->background_color,exception);
10284 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10285 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10286 ceil(geometry_info.psi-0.5),exception);
10289 case 95: /* ContrastStretch */
10296 white_point=(double) image->columns*image->rows;
10297 if (attribute_flag[0] != 0)
10299 flags=ParseGeometry(argument_list[0].string_reference,
10301 black_point=geometry_info.rho;
10302 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10304 if ((flags & PercentValue) != 0)
10306 black_point*=(double) image->columns*image->rows/100.0;
10307 white_point*=(double) image->columns*image->rows/100.0;
10309 white_point=(double) image->columns*image->rows-
10312 if (attribute_flag[1] != 0)
10313 black_point=argument_list[1].real_reference;
10314 if (attribute_flag[2] != 0)
10315 white_point=argument_list[2].real_reference;
10316 if (attribute_flag[4] != 0)
10317 channel=(ChannelType) argument_list[4].integer_reference;
10318 channel_mask=SetImageChannelMask(image,channel);
10319 (void) ContrastStretchImage(image,black_point,white_point,exception);
10320 (void) SetImageChannelMask(image,channel_mask);
10323 case 96: /* Sans0 */
10327 case 97: /* Sans1 */
10331 case 98: /* AdaptiveSharpen */
10333 if (attribute_flag[0] != 0)
10335 flags=ParseGeometry(argument_list[0].string_reference,
10337 if ((flags & SigmaValue) == 0)
10338 geometry_info.sigma=1.0;
10339 if ((flags & XiValue) == 0)
10340 geometry_info.xi=0.0;
10342 if (attribute_flag[1] != 0)
10343 geometry_info.rho=argument_list[1].real_reference;
10344 if (attribute_flag[2] != 0)
10345 geometry_info.sigma=argument_list[2].real_reference;
10346 if (attribute_flag[3] != 0)
10347 geometry_info.xi=argument_list[3].real_reference;
10348 if (attribute_flag[4] != 0)
10349 channel=(ChannelType) argument_list[4].integer_reference;
10350 channel_mask=SetImageChannelMask(image,channel);
10351 image=AdaptiveSharpenImage(image,geometry_info.rho,
10352 geometry_info.sigma,exception);
10353 if (image != (Image *) NULL)
10354 (void) SetImageChannelMask(image,channel_mask);
10357 case 99: /* Transpose */
10359 image=TransposeImage(image,exception);
10362 case 100: /* Tranverse */
10364 image=TransverseImage(image,exception);
10367 case 101: /* AutoOrient */
10369 image=AutoOrientImage(image,image->orientation,exception);
10372 case 102: /* AdaptiveBlur */
10374 if (attribute_flag[0] != 0)
10376 flags=ParseGeometry(argument_list[0].string_reference,
10378 if ((flags & SigmaValue) == 0)
10379 geometry_info.sigma=1.0;
10380 if ((flags & XiValue) == 0)
10381 geometry_info.xi=0.0;
10383 if (attribute_flag[1] != 0)
10384 geometry_info.rho=argument_list[1].real_reference;
10385 if (attribute_flag[2] != 0)
10386 geometry_info.sigma=argument_list[2].real_reference;
10387 if (attribute_flag[3] != 0)
10388 channel=(ChannelType) argument_list[3].integer_reference;
10389 channel_mask=SetImageChannelMask(image,channel);
10390 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10392 if (image != (Image *) NULL)
10393 (void) SetImageChannelMask(image,channel_mask);
10396 case 103: /* Sketch */
10398 if (attribute_flag[0] != 0)
10400 flags=ParseGeometry(argument_list[0].string_reference,
10402 if ((flags & SigmaValue) == 0)
10403 geometry_info.sigma=1.0;
10404 if ((flags & XiValue) == 0)
10405 geometry_info.xi=1.0;
10407 if (attribute_flag[1] != 0)
10408 geometry_info.rho=argument_list[1].real_reference;
10409 if (attribute_flag[2] != 0)
10410 geometry_info.sigma=argument_list[2].real_reference;
10411 if (attribute_flag[3] != 0)
10412 geometry_info.xi=argument_list[3].real_reference;
10413 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10414 geometry_info.xi,exception);
10417 case 104: /* UniqueColors */
10419 image=UniqueImageColors(image,exception);
10422 case 105: /* AdaptiveResize */
10424 if (attribute_flag[0] != 0)
10425 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10426 &geometry,exception);
10427 if (attribute_flag[1] != 0)
10428 geometry.width=argument_list[1].integer_reference;
10429 if (attribute_flag[2] != 0)
10430 geometry.height=argument_list[2].integer_reference;
10431 if (attribute_flag[3] != 0)
10432 image->filter=(FilterType) argument_list[4].integer_reference;
10433 if (attribute_flag[4] != 0)
10434 SetImageArtifact(image,"filter:support",
10435 argument_list[4].string_reference);
10436 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10440 case 106: /* ClipMask */
10445 if (attribute_flag[0] == 0)
10447 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10449 goto PerlException;
10451 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10453 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10454 mask_image=DestroyImage(mask_image);
10457 case 107: /* LinearStretch */
10464 white_point=(double) image->columns*image->rows;
10465 if (attribute_flag[0] != 0)
10467 flags=ParseGeometry(argument_list[0].string_reference,
10469 if ((flags & SigmaValue) != 0)
10470 white_point=geometry_info.sigma;
10471 if ((flags & PercentValue) != 0)
10473 black_point*=(double) image->columns*image->rows/100.0;
10474 white_point*=(double) image->columns*image->rows/100.0;
10476 if ((flags & SigmaValue) == 0)
10477 white_point=(double) image->columns*image->rows-black_point;
10479 if (attribute_flag[1] != 0)
10480 black_point=argument_list[1].real_reference;
10481 if (attribute_flag[2] != 0)
10482 white_point=argument_list[2].real_reference;
10483 (void) LinearStretchImage(image,black_point,white_point,exception);
10486 case 108: /* ColorMatrix */
10500 if (attribute_flag[0] == 0)
10502 av=(AV *) argument_list[0].array_reference;
10503 order=(size_t) sqrt(av_len(av)+1);
10504 color_matrix=(double *) AcquireQuantumMemory(order,order*
10505 sizeof(*color_matrix));
10506 if (color_matrix == (double *) NULL)
10508 ThrowPerlException(exception,ResourceLimitFatalError,
10509 "MemoryAllocationFailed",PackageName);
10510 goto PerlException;
10512 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10513 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10514 for ( ; j < (ssize_t) (order*order); j++)
10515 color_matrix[j]=0.0;
10516 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10517 if (kernel_info == (KernelInfo *) NULL)
10519 kernel_info->width=order;
10520 kernel_info->height=order;
10521 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10522 order*sizeof(*kernel_info->values));
10523 if (kernel_info->values != (MagickRealType *) NULL)
10525 for (i=0; i < (ssize_t) (order*order); i++)
10526 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10527 image=ColorMatrixImage(image,kernel_info,exception);
10529 kernel_info=DestroyKernelInfo(kernel_info);
10530 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10533 case 109: /* Mask */
10538 if (attribute_flag[0] == 0)
10540 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10542 goto PerlException;
10544 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10545 MagickTrue,exception);
10546 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10547 mask_image=DestroyImage(mask_image);
10550 case 110: /* Polaroid */
10561 PixelInterpolateMethod
10564 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10565 (DrawInfo *) NULL);
10566 caption=(char *) NULL;
10567 if (attribute_flag[0] != 0)
10568 caption=InterpretImageProperties(info ? info->image_info :
10569 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10572 if (attribute_flag[1] != 0)
10573 angle=argument_list[1].real_reference;
10574 if (attribute_flag[2] != 0)
10575 (void) CloneString(&draw_info->font,
10576 argument_list[2].string_reference);
10577 if (attribute_flag[3] != 0)
10578 (void) QueryColorCompliance(argument_list[3].string_reference,
10579 AllCompliance,&draw_info->stroke,exception);
10580 if (attribute_flag[4] != 0)
10581 (void) QueryColorCompliance(argument_list[4].string_reference,
10582 AllCompliance,&draw_info->fill,exception);
10583 if (attribute_flag[5] != 0)
10584 draw_info->stroke_width=argument_list[5].real_reference;
10585 if (attribute_flag[6] != 0)
10586 draw_info->pointsize=argument_list[6].real_reference;
10587 if (attribute_flag[7] != 0)
10588 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10589 if (attribute_flag[8] != 0)
10590 (void) QueryColorCompliance(argument_list[8].string_reference,
10591 AllCompliance,&image->background_color,exception);
10592 method=UndefinedInterpolatePixel;
10593 if (attribute_flag[9] != 0)
10594 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10595 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10596 draw_info=DestroyDrawInfo(draw_info);
10597 if (caption != (char *) NULL)
10598 caption=DestroyString(caption);
10601 case 111: /* FloodfillPaint */
10612 draw_info=CloneDrawInfo(info ? info->image_info :
10613 (ImageInfo *) NULL,(DrawInfo *) NULL);
10614 if (attribute_flag[0] != 0)
10615 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10616 &geometry,exception);
10617 if (attribute_flag[1] != 0)
10618 geometry.x=argument_list[1].integer_reference;
10619 if (attribute_flag[2] != 0)
10620 geometry.y=argument_list[2].integer_reference;
10621 if (attribute_flag[3] != 0)
10622 (void) QueryColorCompliance(argument_list[3].string_reference,
10623 AllCompliance,&draw_info->fill,exception);
10624 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10625 geometry.x,geometry.y,&target,exception);
10626 if (attribute_flag[4] != 0)
10627 QueryColorCompliance(argument_list[4].string_reference,
10628 AllCompliance,&target,exception);
10629 if (attribute_flag[5] != 0)
10630 image->fuzz=StringToDoubleInterval(
10631 argument_list[5].string_reference,(double) QuantumRange+1.0);
10632 if (attribute_flag[6] != 0)
10633 channel=(ChannelType) argument_list[6].integer_reference;
10634 invert=MagickFalse;
10635 if (attribute_flag[7] != 0)
10636 invert=(MagickBooleanType) argument_list[7].integer_reference;
10637 channel_mask=SetImageChannelMask(image,channel);
10638 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10639 geometry.y,invert,exception);
10640 (void) SetImageChannelMask(image,channel_mask);
10641 draw_info=DestroyDrawInfo(draw_info);
10644 case 112: /* Distort */
10656 number_coordinates;
10661 if (attribute_flag[0] == 0)
10663 method=UndefinedDistortion;
10664 if (attribute_flag[1] != 0)
10665 method=(DistortMethod) argument_list[1].integer_reference;
10666 av=(AV *) argument_list[0].array_reference;
10667 number_coordinates=(size_t) av_len(av)+1;
10668 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10669 sizeof(*coordinates));
10670 if (coordinates == (double *) NULL)
10672 ThrowPerlException(exception,ResourceLimitFatalError,
10673 "MemoryAllocationFailed",PackageName);
10674 goto PerlException;
10676 for (j=0; j < (ssize_t) number_coordinates; j++)
10677 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10678 virtual_pixel=UndefinedVirtualPixelMethod;
10679 if (attribute_flag[2] != 0)
10680 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10681 argument_list[2].integer_reference,exception);
10682 image=DistortImage(image,method,number_coordinates,coordinates,
10683 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10685 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10686 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10688 coordinates=(double *) RelinquishMagickMemory(coordinates);
10691 case 113: /* Clut */
10693 PixelInterpolateMethod
10696 if (attribute_flag[0] == 0)
10698 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10700 goto PerlException;
10702 method=UndefinedInterpolatePixel;
10703 if (attribute_flag[1] != 0)
10704 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10705 if (attribute_flag[2] != 0)
10706 channel=(ChannelType) argument_list[2].integer_reference;
10707 channel_mask=SetImageChannelMask(image,channel);
10708 (void) ClutImage(image,argument_list[0].image_reference,method,
10710 (void) SetImageChannelMask(image,channel_mask);
10713 case 114: /* LiquidRescale */
10715 if (attribute_flag[0] != 0)
10716 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10717 &geometry,exception);
10718 if (attribute_flag[1] != 0)
10719 geometry.width=argument_list[1].integer_reference;
10720 if (attribute_flag[2] != 0)
10721 geometry.height=argument_list[2].integer_reference;
10722 if (attribute_flag[3] == 0)
10723 argument_list[3].real_reference=1.0;
10724 if (attribute_flag[4] == 0)
10725 argument_list[4].real_reference=0.0;
10726 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10727 argument_list[3].real_reference,argument_list[4].real_reference,
10731 case 115: /* EncipherImage */
10733 (void) EncipherImage(image,argument_list[0].string_reference,
10737 case 116: /* DecipherImage */
10739 (void) DecipherImage(image,argument_list[0].string_reference,
10743 case 117: /* Deskew */
10745 geometry_info.rho=QuantumRange/2.0;
10746 if (attribute_flag[0] != 0)
10747 flags=ParseGeometry(argument_list[0].string_reference,
10749 if (attribute_flag[1] != 0)
10750 geometry_info.rho=StringToDoubleInterval(
10751 argument_list[1].string_reference,(double) QuantumRange+1.0);
10752 image=DeskewImage(image,geometry_info.rho,exception);
10755 case 118: /* Remap */
10760 if (attribute_flag[0] == 0)
10762 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10764 goto PerlException;
10766 quantize_info=AcquireQuantizeInfo(info->image_info);
10767 if (attribute_flag[1] != 0)
10768 quantize_info->dither_method=(DitherMethod)
10769 argument_list[1].integer_reference;
10770 (void) RemapImages(quantize_info,image,
10771 argument_list[0].image_reference,exception);
10772 quantize_info=DestroyQuantizeInfo(quantize_info);
10775 case 119: /* SparseColor */
10787 number_coordinates;
10792 if (attribute_flag[0] == 0)
10794 method=UndefinedColorInterpolate;
10795 if (attribute_flag[1] != 0)
10796 method=(SparseColorMethod) argument_list[1].integer_reference;
10797 av=(AV *) argument_list[0].array_reference;
10798 number_coordinates=(size_t) av_len(av)+1;
10799 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10800 sizeof(*coordinates));
10801 if (coordinates == (double *) NULL)
10803 ThrowPerlException(exception,ResourceLimitFatalError,
10804 "MemoryAllocationFailed",PackageName);
10805 goto PerlException;
10807 for (j=0; j < (ssize_t) number_coordinates; j++)
10808 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10809 virtual_pixel=UndefinedVirtualPixelMethod;
10810 if (attribute_flag[2] != 0)
10811 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10812 argument_list[2].integer_reference,exception);
10813 if (attribute_flag[3] != 0)
10814 channel=(ChannelType) argument_list[3].integer_reference;
10815 channel_mask=SetImageChannelMask(image,channel);
10816 image=SparseColorImage(image,method,number_coordinates,coordinates,
10818 if (image != (Image *) NULL)
10819 (void) SetImageChannelMask(image,channel_mask);
10820 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10821 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10823 coordinates=(double *) RelinquishMagickMemory(coordinates);
10826 case 120: /* Function */
10843 if (attribute_flag[0] == 0)
10845 function=UndefinedFunction;
10846 if (attribute_flag[1] != 0)
10847 function=(MagickFunction) argument_list[1].integer_reference;
10848 av=(AV *) argument_list[0].array_reference;
10849 number_parameters=(size_t) av_len(av)+1;
10850 parameters=(double *) AcquireQuantumMemory(number_parameters,
10851 sizeof(*parameters));
10852 if (parameters == (double *) NULL)
10854 ThrowPerlException(exception,ResourceLimitFatalError,
10855 "MemoryAllocationFailed",PackageName);
10856 goto PerlException;
10858 for (j=0; j < (ssize_t) number_parameters; j++)
10859 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10860 virtual_pixel=UndefinedVirtualPixelMethod;
10861 if (attribute_flag[2] != 0)
10862 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10863 argument_list[2].integer_reference,exception);
10864 (void) FunctionImage(image,function,number_parameters,parameters,
10866 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10867 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10869 parameters=(double *) RelinquishMagickMemory(parameters);
10872 case 121: /* SelectiveBlur */
10874 if (attribute_flag[0] != 0)
10876 flags=ParseGeometry(argument_list[0].string_reference,
10878 if ((flags & SigmaValue) == 0)
10879 geometry_info.sigma=1.0;
10880 if ((flags & PercentValue) != 0)
10881 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10883 if (attribute_flag[1] != 0)
10884 geometry_info.rho=argument_list[1].real_reference;
10885 if (attribute_flag[2] != 0)
10886 geometry_info.sigma=argument_list[2].real_reference;
10887 if (attribute_flag[3] != 0)
10888 geometry_info.xi=argument_list[3].integer_reference;;
10889 if (attribute_flag[5] != 0)
10890 channel=(ChannelType) argument_list[5].integer_reference;
10891 channel_mask=SetImageChannelMask(image,channel);
10892 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10893 geometry_info.xi,exception);
10894 if (image != (Image *) NULL)
10895 (void) SetImageChannelMask(image,channel_mask);
10898 case 122: /* HaldClut */
10900 if (attribute_flag[0] == 0)
10902 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10904 goto PerlException;
10906 if (attribute_flag[1] != 0)
10907 channel=(ChannelType) argument_list[1].integer_reference;
10908 channel_mask=SetImageChannelMask(image,channel);
10909 (void) HaldClutImage(image,argument_list[0].image_reference,
10911 (void) SetImageChannelMask(image,channel_mask);
10914 case 123: /* BlueShift */
10916 if (attribute_flag[0] != 0)
10917 (void) ParseGeometry(argument_list[0].string_reference,
10919 image=BlueShiftImage(image,geometry_info.rho,exception);
10922 case 124: /* ForwardFourierTransformImage */
10924 image=ForwardFourierTransformImage(image,
10925 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10929 case 125: /* InverseFourierTransformImage */
10931 image=InverseFourierTransformImage(image,image->next,
10932 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10936 case 126: /* ColorDecisionList */
10938 if (attribute_flag[0] == 0)
10939 argument_list[0].string_reference=(char *) NULL;
10940 (void) ColorDecisionListImage(image,
10941 argument_list[0].string_reference,exception);
10944 case 127: /* AutoGamma */
10946 if (attribute_flag[0] != 0)
10947 channel=(ChannelType) argument_list[0].integer_reference;
10948 channel_mask=SetImageChannelMask(image,channel);
10949 (void) AutoGammaImage(image,exception);
10950 (void) SetImageChannelMask(image,channel_mask);
10953 case 128: /* AutoLevel */
10955 if (attribute_flag[0] != 0)
10956 channel=(ChannelType) argument_list[0].integer_reference;
10957 channel_mask=SetImageChannelMask(image,channel);
10958 (void) AutoLevelImage(image,exception);
10959 (void) SetImageChannelMask(image,channel_mask);
10962 case 129: /* LevelColors */
10968 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10970 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10972 if (attribute_flag[1] != 0)
10973 (void) QueryColorCompliance(
10974 argument_list[1].string_reference,AllCompliance,&black_point,
10976 if (attribute_flag[2] != 0)
10977 (void) QueryColorCompliance(
10978 argument_list[2].string_reference,AllCompliance,&white_point,
10980 if (attribute_flag[3] != 0)
10981 channel=(ChannelType) argument_list[3].integer_reference;
10982 channel_mask=SetImageChannelMask(image,channel);
10983 (void) LevelImageColors(image,&black_point,&white_point,
10984 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10986 (void) SetImageChannelMask(image,channel_mask);
10989 case 130: /* Clamp */
10991 if (attribute_flag[0] != 0)
10992 channel=(ChannelType) argument_list[0].integer_reference;
10993 channel_mask=SetImageChannelMask(image,channel);
10994 (void) ClampImage(image,exception);
10995 (void) SetImageChannelMask(image,channel_mask);
10998 case 131: /* BrightnessContrast */
11006 if (attribute_flag[0] != 0)
11008 flags=ParseGeometry(argument_list[0].string_reference,
11010 brightness=geometry_info.rho;
11011 if ((flags & SigmaValue) == 0)
11012 contrast=geometry_info.sigma;
11014 if (attribute_flag[1] != 0)
11015 brightness=argument_list[1].real_reference;
11016 if (attribute_flag[2] != 0)
11017 contrast=argument_list[2].real_reference;
11018 if (attribute_flag[4] != 0)
11019 channel=(ChannelType) argument_list[4].integer_reference;
11020 channel_mask=SetImageChannelMask(image,channel);
11021 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11022 (void) SetImageChannelMask(image,channel_mask);
11025 case 132: /* Morphology */
11036 if (attribute_flag[0] == 0)
11038 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11039 if (kernel == (KernelInfo *) NULL)
11041 if (attribute_flag[1] != 0)
11042 channel=(ChannelType) argument_list[1].integer_reference;
11043 method=UndefinedMorphology;
11044 if (attribute_flag[2] != 0)
11045 method=argument_list[2].integer_reference;
11047 if (attribute_flag[3] != 0)
11048 iterations=argument_list[3].integer_reference;
11049 channel_mask=SetImageChannelMask(image,channel);
11050 image=MorphologyImage(image,method,iterations,kernel,exception);
11051 if (image != (Image *) NULL)
11052 (void) SetImageChannelMask(image,channel_mask);
11053 kernel=DestroyKernelInfo(kernel);
11056 case 133: /* Mode */
11058 if (attribute_flag[0] != 0)
11060 flags=ParseGeometry(argument_list[0].string_reference,
11062 if ((flags & SigmaValue) == 0)
11063 geometry_info.sigma=1.0;
11065 if (attribute_flag[1] != 0)
11066 geometry_info.rho=argument_list[1].real_reference;
11067 if (attribute_flag[2] != 0)
11068 geometry_info.sigma=argument_list[2].real_reference;
11069 if (attribute_flag[3] != 0)
11070 channel=(ChannelType) argument_list[3].integer_reference;
11071 channel_mask=SetImageChannelMask(image,channel);
11072 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11073 (size_t) geometry_info.sigma,exception);
11074 if (image != (Image *) NULL)
11075 (void) SetImageChannelMask(image,channel_mask);
11078 case 134: /* Statistic */
11083 statistic=UndefinedStatistic;
11084 if (attribute_flag[0] != 0)
11086 flags=ParseGeometry(argument_list[0].string_reference,
11088 if ((flags & SigmaValue) == 0)
11089 geometry_info.sigma=1.0;
11091 if (attribute_flag[1] != 0)
11092 geometry_info.rho=argument_list[1].real_reference;
11093 if (attribute_flag[2] != 0)
11094 geometry_info.sigma=argument_list[2].real_reference;
11095 if (attribute_flag[3] != 0)
11096 channel=(ChannelType) argument_list[3].integer_reference;
11097 if (attribute_flag[4] != 0)
11098 statistic=(StatisticType) argument_list[4].integer_reference;
11099 channel_mask=SetImageChannelMask(image,channel);
11100 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11101 (size_t) geometry_info.sigma,exception);
11102 if (image != (Image *) NULL)
11103 (void) SetImageChannelMask(image,channel_mask);
11106 case 135: /* Perceptible */
11111 epsilon=MagickEpsilon;
11112 if (attribute_flag[0] != 0)
11113 epsilon=argument_list[0].real_reference;
11114 if (attribute_flag[1] != 0)
11115 channel=(ChannelType) argument_list[1].integer_reference;
11116 channel_mask=SetImageChannelMask(image,channel);
11117 (void) PerceptibleImage(image,epsilon,exception);
11118 (void) SetImageChannelMask(image,channel_mask);
11121 case 136: /* Poly */
11132 if (attribute_flag[0] == 0)
11134 if (attribute_flag[1] != 0)
11135 channel=(ChannelType) argument_list[1].integer_reference;
11136 av=(AV *) argument_list[0].array_reference;
11137 number_terms=(size_t) av_len(av);
11138 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11139 if (terms == (double *) NULL)
11141 ThrowPerlException(exception,ResourceLimitFatalError,
11142 "MemoryAllocationFailed",PackageName);
11143 goto PerlException;
11145 for (j=0; j < av_len(av); j++)
11146 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11147 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11148 terms=(double *) RelinquishMagickMemory(terms);
11151 case 137: /* Grayscale */
11153 PixelIntensityMethod
11156 method=UndefinedPixelIntensityMethod;
11157 if (attribute_flag[0] != 0)
11158 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11159 (void) GrayscaleImage(image,method,exception);
11162 case 138: /* Canny */
11164 if (attribute_flag[0] != 0)
11166 flags=ParseGeometry(argument_list[0].string_reference,
11168 if ((flags & SigmaValue) == 0)
11169 geometry_info.sigma=1.0;
11170 if ((flags & XiValue) == 0)
11171 geometry_info.xi=0.10;
11172 if ((flags & PsiValue) == 0)
11173 geometry_info.psi=0.30;
11174 if ((flags & PercentValue) != 0)
11176 geometry_info.xi/=100.0;
11177 geometry_info.psi/=100.0;
11180 if (attribute_flag[1] != 0)
11181 geometry_info.rho=argument_list[1].real_reference;
11182 if (attribute_flag[2] != 0)
11183 geometry_info.sigma=argument_list[2].real_reference;
11184 if (attribute_flag[3] != 0)
11185 geometry_info.xi=argument_list[3].real_reference;
11186 if (attribute_flag[4] != 0)
11187 geometry_info.psi=argument_list[4].real_reference;
11188 if (attribute_flag[5] != 0)
11189 channel=(ChannelType) argument_list[5].integer_reference;
11190 channel_mask=SetImageChannelMask(image,channel);
11191 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11192 geometry_info.xi,geometry_info.psi,exception);
11193 if (image != (Image *) NULL)
11194 (void) SetImageChannelMask(image,channel_mask);
11197 case 139: /* HoughLine */
11199 if (attribute_flag[0] != 0)
11201 flags=ParseGeometry(argument_list[0].string_reference,
11203 if ((flags & SigmaValue) == 0)
11204 geometry_info.sigma=geometry_info.rho;
11205 if ((flags & XiValue) == 0)
11206 geometry_info.xi=40;
11208 if (attribute_flag[1] != 0)
11209 geometry_info.rho=(double) argument_list[1].integer_reference;
11210 if (attribute_flag[2] != 0)
11211 geometry_info.sigma=(double) argument_list[2].integer_reference;
11212 if (attribute_flag[3] != 0)
11213 geometry_info.xi=(double) argument_list[3].integer_reference;
11214 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11215 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11218 case 140: /* MeanShift */
11220 if (attribute_flag[0] != 0)
11222 flags=ParseGeometry(argument_list[0].string_reference,
11224 if ((flags & SigmaValue) == 0)
11225 geometry_info.sigma=geometry_info.rho;
11226 if ((flags & XiValue) == 0)
11227 geometry_info.xi=0.10*QuantumRange;
11228 if ((flags & PercentValue) != 0)
11229 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11231 if (attribute_flag[1] != 0)
11232 geometry_info.rho=(double) argument_list[1].integer_reference;
11233 if (attribute_flag[2] != 0)
11234 geometry_info.sigma=(double) argument_list[2].integer_reference;
11235 if (attribute_flag[3] != 0)
11236 geometry_info.xi=(double) argument_list[3].integer_reference;
11237 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11238 geometry_info.sigma,geometry_info.xi,exception);
11241 case 141: /* Kuwahara */
11243 if (attribute_flag[0] != 0)
11245 flags=ParseGeometry(argument_list[0].string_reference,
11247 if ((flags & SigmaValue) == 0)
11248 geometry_info.sigma=geometry_info.rho-0.5;
11250 if (attribute_flag[1] != 0)
11251 geometry_info.rho=argument_list[1].real_reference;
11252 if (attribute_flag[2] != 0)
11253 geometry_info.sigma=argument_list[2].real_reference;
11254 if (attribute_flag[3] != 0)
11255 channel=(ChannelType) argument_list[3].integer_reference;
11256 channel_mask=SetImageChannelMask(image,channel);
11257 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11259 if (image != (Image *) NULL)
11260 (void) SetImageChannelMask(image,channel_mask);
11263 case 142: /* ConnectedComponent */
11269 if (attribute_flag[0] != 0)
11270 connectivity=argument_list[0].integer_reference;
11271 image=ConnectedComponentsImage(image,connectivity,
11272 (CCObjectInfo **) NULL,exception);
11275 case 143: /* Copy */
11286 source_image=image;
11287 if (attribute_flag[0] != 0)
11288 source_image=argument_list[0].image_reference;
11289 SetGeometry(source_image,&geometry);
11290 if (attribute_flag[1] != 0)
11291 flags=ParseGravityGeometry(source_image,
11292 argument_list[1].string_reference,&geometry,exception);
11293 if (attribute_flag[2] != 0)
11294 geometry.width=argument_list[2].integer_reference;
11295 if (attribute_flag[3] != 0)
11296 geometry.height=argument_list[3].integer_reference;
11297 if (attribute_flag[4] != 0)
11298 geometry.x=argument_list[4].integer_reference;
11299 if (attribute_flag[5] != 0)
11300 geometry.y=argument_list[5].integer_reference;
11301 if (attribute_flag[6] != 0)
11302 image->gravity=(GravityType) argument_list[6].integer_reference;
11303 SetGeometry(image,&offset_geometry);
11304 if (attribute_flag[7] != 0)
11305 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11306 &offset_geometry,exception);
11307 offset.x=offset_geometry.x;
11308 offset.y=offset_geometry.y;
11309 if (attribute_flag[8] != 0)
11310 offset.x=argument_list[8].integer_reference;
11311 if (attribute_flag[9] != 0)
11312 offset.y=argument_list[9].integer_reference;
11313 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11317 case 144: /* Color */
11322 (void) QueryColorCompliance("none",AllCompliance,&color,exception);
11323 if (attribute_flag[0] != 0)
11324 (void) QueryColorCompliance(argument_list[0].string_reference,
11325 AllCompliance,&color,exception);
11326 (void) SetImageColor(image,&color,exception);
11329 case 145: /* WaveletDenoise */
11331 if (attribute_flag[0] != 0)
11333 flags=ParseGeometry(argument_list[0].string_reference,
11335 if ((flags & PercentValue) != 0)
11337 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
11338 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
11340 if ((flags & SigmaValue) == 0)
11341 geometry_info.sigma=0.0;
11343 if (attribute_flag[1] != 0)
11344 geometry_info.rho=argument_list[1].real_reference;
11345 if (attribute_flag[2] != 0)
11346 geometry_info.sigma=argument_list[2].real_reference;
11347 if (attribute_flag[3] != 0)
11348 channel=(ChannelType) argument_list[3].integer_reference;
11349 channel_mask=SetImageChannelMask(image,channel);
11350 image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma,
11352 if (image != (Image *) NULL)
11353 (void) SetImageChannelMask(image,channel_mask);
11357 if (next != (Image *) NULL)
11358 (void) CatchImageException(next);
11359 if (region_image != (Image *) NULL)
11364 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11365 region_info.x,region_info.y,exception);
11367 (void) CatchImageException(region_image);
11368 image=DestroyImage(image);
11369 image=region_image;
11371 if (image != (Image *) NULL)
11374 if (next && (next != image))
11376 image->next=next->next;
11377 if (image->next != (Image *) NULL)
11378 image->next->previous=image;
11379 DeleteImageFromRegistry(*pv,next);
11381 sv_setiv(*pv,PTR2IV(image));
11389 if (reference_vector)
11390 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11391 InheritPerlException(exception,perl_exception);
11392 exception=DestroyExceptionInfo(exception);
11393 sv_setiv(perl_exception,(IV) number_images);
11394 SvPOK_on(perl_exception);
11395 ST(0)=sv_2mortal(perl_exception);
11400 ###############################################################################
11408 ###############################################################################
11413 Image::Magick ref=NO_INIT
11458 PERL_UNUSED_VAR(ref);
11459 PERL_UNUSED_VAR(ix);
11460 exception=AcquireExceptionInfo();
11461 perl_exception=newSVpv("",0);
11464 if (sv_isobject(ST(0)) == 0)
11466 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11468 goto PerlException;
11470 reference=SvRV(ST(0));
11471 hv=SvSTASH(reference);
11473 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11475 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11476 if (image == (Image *) NULL)
11478 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11480 goto PerlException;
11485 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11486 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11487 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11489 for (i=2; i < items; i+=2)
11491 attribute=(char *) SvPV(ST(i-1),na);
11492 switch (*attribute)
11497 if (LocaleCompare(attribute,"background") == 0)
11499 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11500 &montage_info->background_color,exception);
11501 for (next=image; next; next=next->next)
11502 next->background_color=montage_info->background_color;
11505 if (LocaleCompare(attribute,"border") == 0)
11507 montage_info->border_width=SvIV(ST(i));
11510 if (LocaleCompare(attribute,"bordercolor") == 0)
11512 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11513 &montage_info->border_color,exception);
11514 for (next=image; next; next=next->next)
11515 next->border_color=montage_info->border_color;
11518 if (LocaleCompare(attribute,"borderwidth") == 0)
11520 montage_info->border_width=SvIV(ST(i));
11523 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11530 if (LocaleCompare(attribute,"compose") == 0)
11532 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11533 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11536 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11540 for (next=image; next; next=next->next)
11541 next->compose=(CompositeOperator) sp;
11544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11551 if (LocaleCompare(attribute,"fill") == 0)
11553 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11554 &montage_info->fill,exception);
11557 if (LocaleCompare(attribute,"font") == 0)
11559 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11562 if (LocaleCompare(attribute,"frame") == 0)
11568 if (IsGeometry(p) == MagickFalse)
11570 ThrowPerlException(exception,OptionError,"MissingGeometry",
11574 (void) CloneString(&montage_info->frame,p);
11576 montage_info->frame=(char *) NULL;
11579 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11586 if (LocaleCompare(attribute,"geometry") == 0)
11592 if (IsGeometry(p) == MagickFalse)
11594 ThrowPerlException(exception,OptionError,"MissingGeometry",
11598 (void) CloneString(&montage_info->geometry,p);
11600 montage_info->geometry=(char *) NULL;
11603 if (LocaleCompare(attribute,"gravity") == 0)
11608 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11609 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11612 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11616 montage_info->gravity=(GravityType) in;
11617 for (next=image; next; next=next->next)
11618 next->gravity=(GravityType) in;
11621 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11628 if (LocaleCompare(attribute,"label") == 0)
11630 for (next=image; next; next=next->next)
11631 (void) SetImageProperty(next,"label",InterpretImageProperties(
11632 info ? info->image_info : (ImageInfo *) NULL,next,
11633 SvPV(ST(i),na),exception),exception);
11636 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11643 if (LocaleCompare(attribute,"mattecolor") == 0)
11645 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11646 &montage_info->alpha_color,exception);
11647 for (next=image; next; next=next->next)
11648 next->alpha_color=montage_info->alpha_color;
11651 if (LocaleCompare(attribute,"mode") == 0)
11656 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11657 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11662 ThrowPerlException(exception,OptionError,
11663 "UnrecognizedModeType",SvPV(ST(i),na));
11668 (void) CloneString(&montage_info->frame,"15x15+3+3");
11669 montage_info->shadow=MagickTrue;
11674 montage_info->frame=(char *) NULL;
11675 montage_info->shadow=MagickFalse;
11676 montage_info->border_width=0;
11679 case ConcatenateMode:
11681 montage_info->frame=(char *) NULL;
11682 montage_info->shadow=MagickFalse;
11683 (void) CloneString(&montage_info->geometry,"+0+0");
11684 montage_info->border_width=0;
11689 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11696 if (LocaleCompare(attribute,"pointsize") == 0)
11698 montage_info->pointsize=SvIV(ST(i));
11701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11708 if (LocaleCompare(attribute,"shadow") == 0)
11710 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11711 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11714 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11718 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11721 if (LocaleCompare(attribute,"stroke") == 0)
11723 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11724 &montage_info->stroke,exception);
11727 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11734 if (LocaleCompare(attribute,"texture") == 0)
11736 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11739 if (LocaleCompare(attribute,"tile") == 0)
11741 char *p=SvPV(ST(i),na);
11742 if (IsGeometry(p) == MagickFalse)
11744 ThrowPerlException(exception,OptionError,"MissingGeometry",
11748 (void) CloneString(&montage_info->tile,p);
11750 montage_info->tile=(char *) NULL;
11753 if (LocaleCompare(attribute,"title") == 0)
11755 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11758 if (LocaleCompare(attribute,"transparent") == 0)
11763 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11764 &transparent_color,exception);
11765 for (next=image; next; next=next->next)
11766 (void) TransparentPaintImage(next,&transparent_color,
11767 TransparentAlpha,MagickFalse,exception);
11770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11782 image=MontageImageList(info->image_info,montage_info,image,exception);
11783 montage_info=DestroyMontageInfo(montage_info);
11784 if (image == (Image *) NULL)
11785 goto PerlException;
11786 if (transparent_color.alpha != TransparentAlpha)
11787 for (next=image; next; next=next->next)
11788 (void) TransparentPaintImage(next,&transparent_color,
11789 TransparentAlpha,MagickFalse,exception);
11790 for ( ; image; image=image->next)
11792 AddImageToRegistry(sv,image);
11794 av_push(av,sv_bless(rv,hv));
11797 exception=DestroyExceptionInfo(exception);
11798 ST(0)=av_reference;
11799 SvREFCNT_dec(perl_exception);
11803 InheritPerlException(exception,perl_exception);
11804 exception=DestroyExceptionInfo(exception);
11805 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11806 SvPOK_on(perl_exception);
11807 ST(0)=sv_2mortal(perl_exception);
11812 ###############################################################################
11820 ###############################################################################
11825 Image::Magick ref=NO_INIT
11863 PERL_UNUSED_VAR(ref);
11864 PERL_UNUSED_VAR(ix);
11865 exception=AcquireExceptionInfo();
11866 perl_exception=newSVpv("",0);
11870 if (sv_isobject(ST(0)) == 0)
11872 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11874 goto PerlException;
11876 reference=SvRV(ST(0));
11877 hv=SvSTASH(reference);
11879 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11881 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11882 if (image == (Image *) NULL)
11884 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11886 goto PerlException;
11888 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11893 for (i=2; i < items; i+=2)
11895 attribute=(char *) SvPV(ST(i-1),na);
11896 switch (*attribute)
11901 if (LocaleCompare(attribute,"frames") == 0)
11903 number_frames=SvIV(ST(i));
11906 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11912 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11918 image=MorphImages(image,number_frames,exception);
11919 if (image == (Image *) NULL)
11920 goto PerlException;
11921 for ( ; image; image=image->next)
11923 AddImageToRegistry(sv,image);
11925 av_push(av,sv_bless(rv,hv));
11928 exception=DestroyExceptionInfo(exception);
11929 ST(0)=av_reference;
11930 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11934 InheritPerlException(exception,perl_exception);
11935 exception=DestroyExceptionInfo(exception);
11936 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11937 SvPOK_on(perl_exception);
11938 ST(0)=sv_2mortal(perl_exception);
11943 ###############################################################################
11951 ###############################################################################
11956 Image::Magick ref=NO_INIT
11984 PERL_UNUSED_VAR(ref);
11985 PERL_UNUSED_VAR(ix);
11986 exception=AcquireExceptionInfo();
11987 perl_exception=newSVpv("",0);
11989 if (sv_isobject(ST(0)) == 0)
11991 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11993 goto PerlException;
11995 reference=SvRV(ST(0));
11996 hv=SvSTASH(reference);
11997 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11998 if (image == (Image *) NULL)
12000 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12002 goto PerlException;
12004 image=MergeImageLayers(image,MosaicLayer,exception);
12006 Create blessed Perl array for the returned image.
12009 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12011 AddImageToRegistry(sv,image);
12013 av_push(av,sv_bless(rv,hv));
12015 (void) CopyMagickString(info->image_info->filename,image->filename,
12017 SetImageInfo(info->image_info,0,exception);
12018 exception=DestroyExceptionInfo(exception);
12019 SvREFCNT_dec(perl_exception);
12023 InheritPerlException(exception,perl_exception);
12024 exception=DestroyExceptionInfo(exception);
12025 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12026 SvPOK_on(perl_exception); /* return messages in string context */
12027 ST(0)=sv_2mortal(perl_exception);
12032 ###############################################################################
12040 ###############################################################################
12045 Image::Magick ref=NO_INIT
12095 PERL_UNUSED_VAR(ref);
12096 PERL_UNUSED_VAR(ix);
12097 exception=AcquireExceptionInfo();
12098 perl_exception=newSVpv("",0);
12099 package_info=(struct PackageInfo *) NULL;
12100 ac=(items < 2) ? 1 : items-1;
12101 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12103 length=(STRLEN *) NULL;
12104 if (list == (char **) NULL)
12106 ThrowPerlException(exception,ResourceLimitError,
12107 "MemoryAllocationFailed",PackageName);
12108 goto PerlException;
12111 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12112 if (length == (STRLEN *) NULL)
12114 ThrowPerlException(exception,ResourceLimitError,
12115 "MemoryAllocationFailed",PackageName);
12116 goto PerlException;
12118 if (sv_isobject(ST(0)) == 0)
12120 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12122 goto PerlException;
12124 reference=SvRV(ST(0));
12125 if (SvTYPE(reference) != SVt_PVAV)
12127 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12129 goto PerlException;
12131 av=(AV *) reference;
12132 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12134 package_info=ClonePackageInfo(info,exception);
12137 *list=(char *) (*package_info->image_info->filename ?
12138 package_info->image_info->filename : "XC:black");
12140 for (n=0, i=0; i < ac; i++)
12142 list[n]=(char *) SvPV(ST(i+1),length[n]);
12143 if ((items >= 3) && strEQcase(list[n],"blob"))
12149 blob=(void *) (SvPV(ST(i+1),length[n]));
12150 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12152 if ((items >= 3) && strEQcase(list[n],"filename"))
12154 if ((items >= 3) && strEQcase(list[n],"file"))
12163 io_info=IoIFP(sv_2io(ST(i+1)));
12164 if (io_info == (PerlIO *) NULL)
12166 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12170 file=PerlIO_findFILE(io_info);
12171 if (file == (FILE *) NULL)
12173 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12177 SetImageInfoFile(package_info->image_info,file);
12179 if ((items >= 3) && strEQcase(list[n],"magick"))
12183 list[n]=(char *) NULL;
12185 status=ExpandFilenames(&n,&list);
12186 if (status == MagickFalse)
12188 ThrowPerlException(exception,ResourceLimitError,
12189 "MemoryAllocationFailed",PackageName);
12190 goto PerlException;
12193 for (i=0; i < n; i++)
12195 (void) CopyMagickString(package_info->image_info->filename,list[i],
12197 image=PingImage(package_info->image_info,exception);
12198 if (image == (Image *) NULL)
12200 if ((package_info->image_info->file != (FILE *) NULL) ||
12201 (package_info->image_info->blob != (void *) NULL))
12202 DisassociateImageStream(image);
12203 count+=GetImageListLength(image);
12204 EXTEND(sp,4*count);
12205 for (next=image; next; next=next->next)
12207 PUSHs(sv_2mortal(newSViv(next->columns)));
12208 PUSHs(sv_2mortal(newSViv(next->rows)));
12209 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12210 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12212 image=DestroyImageList(image);
12217 for (i=0; i < n; i++)
12218 if (list[i] != (char *) NULL)
12219 for (p=keep; list[i] != *p++; )
12222 list[i]=(char *) RelinquishMagickMemory(list[i]);
12227 if (package_info != (struct PackageInfo *) NULL)
12228 DestroyPackageInfo(package_info);
12229 if (list && (list != keep))
12230 list=(char **) RelinquishMagickMemory(list);
12232 keep=(char **) RelinquishMagickMemory(keep);
12234 length=(STRLEN *) RelinquishMagickMemory(length);
12235 InheritPerlException(exception,perl_exception);
12236 exception=DestroyExceptionInfo(exception);
12237 SvREFCNT_dec(perl_exception); /* throw away all errors */
12241 ###############################################################################
12249 ###############################################################################
12254 Image::Magick ref=NO_INIT
12287 PERL_UNUSED_VAR(ref);
12288 PERL_UNUSED_VAR(ix);
12289 exception=AcquireExceptionInfo();
12290 perl_exception=newSVpv("",0);
12293 if (sv_isobject(ST(0)) == 0)
12295 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12297 goto PerlException;
12299 reference=SvRV(ST(0));
12300 hv=SvSTASH(reference);
12302 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12304 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12305 if (image == (Image *) NULL)
12307 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12309 goto PerlException;
12311 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12312 preview_type=GammaPreview;
12314 preview_type=(PreviewType)
12315 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12316 for ( ; image; image=image->next)
12318 preview_image=PreviewImage(image,preview_type,exception);
12319 if (preview_image == (Image *) NULL)
12320 goto PerlException;
12321 AddImageToRegistry(sv,preview_image);
12323 av_push(av,sv_bless(rv,hv));
12326 exception=DestroyExceptionInfo(exception);
12327 ST(0)=av_reference;
12328 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12332 InheritPerlException(exception,perl_exception);
12333 exception=DestroyExceptionInfo(exception);
12334 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12335 SvPOK_on(perl_exception);
12336 ST(0)=sv_2mortal(perl_exception);
12341 ###############################################################################
12345 # Q u e r y C o l o r #
12349 ###############################################################################
12353 QueryColor(ref,...)
12354 Image::Magick ref=NO_INIT
12374 PERL_UNUSED_VAR(ref);
12375 PERL_UNUSED_VAR(ix);
12376 exception=AcquireExceptionInfo();
12377 perl_exception=newSVpv("",0);
12386 colorlist=GetColorInfoList("*",&colors,exception);
12388 for (i=0; i < (ssize_t) colors; i++)
12390 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12392 colorlist=(const ColorInfo **)
12393 RelinquishMagickMemory((ColorInfo **) colorlist);
12394 goto PerlException;
12396 EXTEND(sp,5*items);
12397 for (i=1; i < items; i++)
12399 name=(char *) SvPV(ST(i),na);
12400 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12405 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12406 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12407 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12408 if (color.colorspace == CMYKColorspace)
12409 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12410 if (color.alpha_trait != UndefinedPixelTrait)
12411 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12415 InheritPerlException(exception,perl_exception);
12416 exception=DestroyExceptionInfo(exception);
12417 SvREFCNT_dec(perl_exception);
12421 ###############################################################################
12425 # Q u e r y C o l o r N a m e #
12429 ###############################################################################
12433 QueryColorname(ref,...)
12434 Image::Magick ref=NO_INIT
12443 message[MagickPathExtent];
12462 *reference; /* reference is the SV* of ref=SvIV(reference) */
12464 PERL_UNUSED_VAR(ref);
12465 PERL_UNUSED_VAR(ix);
12466 exception=AcquireExceptionInfo();
12467 perl_exception=newSVpv("",0);
12468 reference=SvRV(ST(0));
12469 av=(AV *) reference;
12470 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12472 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12473 if (image == (Image *) NULL)
12475 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12477 goto PerlException;
12480 for (i=1; i < items; i++)
12482 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12484 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12486 PUSHs(sv_2mortal(newSVpv(message,0)));
12490 InheritPerlException(exception,perl_exception);
12491 exception=DestroyExceptionInfo(exception);
12492 SvREFCNT_dec(perl_exception);
12496 ###############################################################################
12500 # Q u e r y F o n t #
12504 ###############################################################################
12509 Image::Magick ref=NO_INIT
12516 message[MagickPathExtent];
12527 volatile const TypeInfo
12530 PERL_UNUSED_VAR(ref);
12531 PERL_UNUSED_VAR(ix);
12532 exception=AcquireExceptionInfo();
12533 perl_exception=newSVpv("",0);
12542 typelist=GetTypeInfoList("*",&types,exception);
12544 for (i=0; i < (ssize_t) types; i++)
12546 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12548 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12550 goto PerlException;
12552 EXTEND(sp,10*items);
12553 for (i=1; i < items; i++)
12555 name=(char *) SvPV(ST(i),na);
12556 type_info=GetTypeInfo(name,exception);
12557 if (type_info == (TypeInfo *) NULL)
12562 if (type_info->name == (char *) NULL)
12565 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12566 if (type_info->description == (char *) NULL)
12569 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12570 if (type_info->family == (char *) NULL)
12573 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12574 if (type_info->style == UndefinedStyle)
12577 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12578 type_info->style),0)));
12579 if (type_info->stretch == UndefinedStretch)
12582 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12583 type_info->stretch),0)));
12584 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12585 type_info->weight);
12586 PUSHs(sv_2mortal(newSVpv(message,0)));
12587 if (type_info->encoding == (char *) NULL)
12590 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12591 if (type_info->foundry == (char *) NULL)
12594 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12595 if (type_info->format == (char *) NULL)
12598 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12599 if (type_info->metrics == (char *) NULL)
12602 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12603 if (type_info->glyphs == (char *) NULL)
12606 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12610 InheritPerlException(exception,perl_exception);
12611 exception=DestroyExceptionInfo(exception);
12612 SvREFCNT_dec(perl_exception);
12616 ###############################################################################
12620 # Q u e r y F o n t M e t r i c s #
12624 ###############################################################################
12628 QueryFontMetrics(ref,...)
12629 Image::Magick ref=NO_INIT
12631 queryfontmetrics = 1
12678 *reference; /* reference is the SV* of ref=SvIV(reference) */
12683 PERL_UNUSED_VAR(ref);
12684 PERL_UNUSED_VAR(ix);
12685 exception=AcquireExceptionInfo();
12686 package_info=(struct PackageInfo *) NULL;
12687 perl_exception=newSVpv("",0);
12688 reference=SvRV(ST(0));
12689 av=(AV *) reference;
12690 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12692 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12693 if (image == (Image *) NULL)
12695 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12697 goto PerlException;
12699 package_info=ClonePackageInfo(info,exception);
12700 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12701 CloneString(&draw_info->text,"");
12702 current=draw_info->affine;
12703 GetAffineMatrix(&affine);
12706 EXTEND(sp,7*items);
12707 for (i=2; i < items; i+=2)
12709 attribute=(char *) SvPV(ST(i-1),na);
12710 switch (*attribute)
12715 if (LocaleCompare(attribute,"antialias") == 0)
12717 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12721 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12725 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12728 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12735 if (LocaleCompare(attribute,"density") == 0)
12737 CloneString(&draw_info->density,SvPV(ST(i),na));
12740 if (LocaleCompare(attribute,"direction") == 0)
12742 draw_info->direction=(DirectionType) ParseCommandOption(
12743 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12753 if (LocaleCompare(attribute,"encoding") == 0)
12755 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12758 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12765 if (LocaleCompare(attribute,"family") == 0)
12767 CloneString(&draw_info->family,SvPV(ST(i),na));
12770 if (LocaleCompare(attribute,"fill") == 0)
12773 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12774 &draw_info->fill,exception);
12777 if (LocaleCompare(attribute,"font") == 0)
12779 CloneString(&draw_info->font,SvPV(ST(i),na));
12782 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12789 if (LocaleCompare(attribute,"geometry") == 0)
12791 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12794 if (LocaleCompare(attribute,"gravity") == 0)
12796 draw_info->gravity=(GravityType) ParseCommandOption(
12797 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12800 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12807 if (LocaleCompare(attribute,"interline-spacing") == 0)
12809 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12810 draw_info->interline_spacing=geometry_info.rho;
12813 if (LocaleCompare(attribute,"interword-spacing") == 0)
12815 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12816 draw_info->interword_spacing=geometry_info.rho;
12819 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12826 if (LocaleCompare(attribute,"kerning") == 0)
12828 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12829 draw_info->kerning=geometry_info.rho;
12832 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12839 if (LocaleCompare(attribute,"pointsize") == 0)
12841 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12842 draw_info->pointsize=geometry_info.rho;
12845 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12852 if (LocaleCompare(attribute,"rotate") == 0)
12854 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12855 affine.rx=geometry_info.rho;
12856 affine.ry=geometry_info.sigma;
12857 if ((flags & SigmaValue) == 0)
12858 affine.ry=affine.rx;
12861 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12868 if (LocaleCompare(attribute,"scale") == 0)
12870 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12871 affine.sx=geometry_info.rho;
12872 affine.sy=geometry_info.sigma;
12873 if ((flags & SigmaValue) == 0)
12874 affine.sy=affine.sx;
12877 if (LocaleCompare(attribute,"skew") == 0)
12883 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12884 x_angle=geometry_info.rho;
12885 y_angle=geometry_info.sigma;
12886 if ((flags & SigmaValue) == 0)
12888 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12889 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12892 if (LocaleCompare(attribute,"stroke") == 0)
12895 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12896 &draw_info->stroke,exception);
12899 if (LocaleCompare(attribute,"style") == 0)
12901 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12905 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12909 draw_info->style=(StyleType) type;
12912 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12919 if (LocaleCompare(attribute,"text") == 0)
12921 CloneString(&draw_info->text,SvPV(ST(i),na));
12924 if (LocaleCompare(attribute,"translate") == 0)
12926 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12927 affine.tx=geometry_info.rho;
12928 affine.ty=geometry_info.sigma;
12929 if ((flags & SigmaValue) == 0)
12930 affine.ty=affine.tx;
12933 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12940 if (LocaleCompare(attribute,"weight") == 0)
12942 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12943 draw_info->weight=(size_t) geometry_info.rho;
12946 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12953 if (LocaleCompare(attribute,"x") == 0)
12955 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12956 x=geometry_info.rho;
12959 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12966 if (LocaleCompare(attribute,"y") == 0)
12968 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12969 y=geometry_info.rho;
12972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12984 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12985 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12986 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12987 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12988 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12989 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12990 if (draw_info->geometry == (char *) NULL)
12992 draw_info->geometry=AcquireString((char *) NULL);
12993 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12994 "%.15g,%.15g",x,y);
12996 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12997 (void) CatchImageException(image);
12998 if (status == MagickFalse)
13002 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13003 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13004 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13005 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13006 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13007 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13008 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13009 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13010 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13011 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13012 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13013 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13014 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13016 draw_info=DestroyDrawInfo(draw_info);
13019 if (package_info != (struct PackageInfo *) NULL)
13020 DestroyPackageInfo(package_info);
13021 InheritPerlException(exception,perl_exception);
13022 exception=DestroyExceptionInfo(exception);
13023 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13027 ###############################################################################
13031 # 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 #
13035 ###############################################################################
13039 QueryMultilineFontMetrics(ref,...)
13040 Image::Magick ref=NO_INIT
13042 querymultilinefontmetrics = 1
13089 *reference; /* reference is the SV* of ref=SvIV(reference) */
13094 PERL_UNUSED_VAR(ref);
13095 PERL_UNUSED_VAR(ix);
13096 exception=AcquireExceptionInfo();
13097 package_info=(struct PackageInfo *) NULL;
13098 perl_exception=newSVpv("",0);
13099 reference=SvRV(ST(0));
13100 av=(AV *) reference;
13101 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13103 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13104 if (image == (Image *) NULL)
13106 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13108 goto PerlException;
13110 package_info=ClonePackageInfo(info,exception);
13111 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13112 CloneString(&draw_info->text,"");
13113 current=draw_info->affine;
13114 GetAffineMatrix(&affine);
13117 EXTEND(sp,7*items);
13118 for (i=2; i < items; i+=2)
13120 attribute=(char *) SvPV(ST(i-1),na);
13121 switch (*attribute)
13126 if (LocaleCompare(attribute,"antialias") == 0)
13128 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13132 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13136 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13139 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13146 if (LocaleCompare(attribute,"density") == 0)
13148 CloneString(&draw_info->density,SvPV(ST(i),na));
13151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13158 if (LocaleCompare(attribute,"encoding") == 0)
13160 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13163 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13170 if (LocaleCompare(attribute,"family") == 0)
13172 CloneString(&draw_info->family,SvPV(ST(i),na));
13175 if (LocaleCompare(attribute,"fill") == 0)
13178 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13179 &draw_info->fill,exception);
13182 if (LocaleCompare(attribute,"font") == 0)
13184 CloneString(&draw_info->font,SvPV(ST(i),na));
13187 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13194 if (LocaleCompare(attribute,"geometry") == 0)
13196 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13199 if (LocaleCompare(attribute,"gravity") == 0)
13201 draw_info->gravity=(GravityType) ParseCommandOption(
13202 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13212 if (LocaleCompare(attribute,"pointsize") == 0)
13214 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13215 draw_info->pointsize=geometry_info.rho;
13218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13225 if (LocaleCompare(attribute,"rotate") == 0)
13227 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13228 affine.rx=geometry_info.rho;
13229 affine.ry=geometry_info.sigma;
13230 if ((flags & SigmaValue) == 0)
13231 affine.ry=affine.rx;
13234 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13241 if (LocaleCompare(attribute,"scale") == 0)
13243 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13244 affine.sx=geometry_info.rho;
13245 affine.sy=geometry_info.sigma;
13246 if ((flags & SigmaValue) == 0)
13247 affine.sy=affine.sx;
13250 if (LocaleCompare(attribute,"skew") == 0)
13256 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13257 x_angle=geometry_info.rho;
13258 y_angle=geometry_info.sigma;
13259 if ((flags & SigmaValue) == 0)
13261 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13262 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13265 if (LocaleCompare(attribute,"stroke") == 0)
13268 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13269 &draw_info->stroke,exception);
13272 if (LocaleCompare(attribute,"style") == 0)
13274 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13278 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13282 draw_info->style=(StyleType) type;
13285 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13292 if (LocaleCompare(attribute,"text") == 0)
13294 CloneString(&draw_info->text,SvPV(ST(i),na));
13297 if (LocaleCompare(attribute,"translate") == 0)
13299 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13300 affine.tx=geometry_info.rho;
13301 affine.ty=geometry_info.sigma;
13302 if ((flags & SigmaValue) == 0)
13303 affine.ty=affine.tx;
13306 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13313 if (LocaleCompare(attribute,"weight") == 0)
13315 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13316 draw_info->weight=(size_t) geometry_info.rho;
13319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13326 if (LocaleCompare(attribute,"x") == 0)
13328 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13329 x=geometry_info.rho;
13332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13339 if (LocaleCompare(attribute,"y") == 0)
13341 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13342 y=geometry_info.rho;
13345 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13351 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13357 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13358 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13359 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13360 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13361 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13362 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13363 if (draw_info->geometry == (char *) NULL)
13365 draw_info->geometry=AcquireString((char *) NULL);
13366 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13367 "%.15g,%.15g",x,y);
13369 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13370 (void) CatchException(exception);
13371 if (status == MagickFalse)
13375 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13376 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13377 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13378 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13379 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13380 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13381 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13382 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13383 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13384 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13385 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13386 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13387 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13389 draw_info=DestroyDrawInfo(draw_info);
13392 if (package_info != (struct PackageInfo *) NULL)
13393 DestroyPackageInfo(package_info);
13394 InheritPerlException(exception,perl_exception);
13395 exception=DestroyExceptionInfo(exception);
13396 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13400 ###############################################################################
13404 # Q u e r y F o r m a t #
13408 ###############################################################################
13412 QueryFormat(ref,...)
13413 Image::Magick ref=NO_INIT
13430 volatile const MagickInfo
13433 PERL_UNUSED_VAR(ref);
13434 PERL_UNUSED_VAR(ix);
13435 exception=AcquireExceptionInfo();
13436 perl_exception=newSVpv("",0);
13440 format[MagickPathExtent];
13448 format_list=GetMagickInfoList("*",&types,exception);
13450 for (i=0; i < (ssize_t) types; i++)
13452 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13453 LocaleLower(format);
13454 PUSHs(sv_2mortal(newSVpv(format,0)));
13456 format_list=(const MagickInfo **)
13457 RelinquishMagickMemory((MagickInfo *) format_list);
13458 goto PerlException;
13460 EXTEND(sp,8*items);
13461 for (i=1; i < items; i++)
13463 name=(char *) SvPV(ST(i),na);
13464 magick_info=GetMagickInfo(name,exception);
13465 if (magick_info == (const MagickInfo *) NULL)
13470 if (magick_info->description == (char *) NULL)
13473 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13474 if (magick_info->module == (char *) NULL)
13477 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13481 InheritPerlException(exception,perl_exception);
13482 exception=DestroyExceptionInfo(exception);
13483 SvREFCNT_dec(perl_exception);
13487 ###############################################################################
13491 # Q u e r y O p t i o n #
13495 ###############################################################################
13499 QueryOption(ref,...)
13500 Image::Magick ref=NO_INIT
13521 PERL_UNUSED_VAR(ref);
13522 PERL_UNUSED_VAR(ix);
13523 exception=AcquireExceptionInfo();
13524 perl_exception=newSVpv("",0);
13525 EXTEND(sp,8*items);
13526 for (i=1; i < items; i++)
13528 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13530 options=GetCommandOptions((CommandOption) option);
13531 if (options == (char **) NULL)
13535 for (j=0; options[j] != (char *) NULL; j++)
13536 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13537 options=DestroyStringList(options);
13541 InheritPerlException(exception,perl_exception);
13542 exception=DestroyExceptionInfo(exception);
13543 SvREFCNT_dec(perl_exception);
13547 ###############################################################################
13555 ###############################################################################
13560 Image::Magick ref=NO_INIT
13607 *perl_exception, /* Perl variable for storing messages */
13612 PERL_UNUSED_VAR(ref);
13613 PERL_UNUSED_VAR(ix);
13614 exception=AcquireExceptionInfo();
13615 perl_exception=newSVpv("",0);
13617 package_info=(struct PackageInfo *) NULL;
13619 ac=(items < 2) ? 1 : items-1;
13620 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13622 length=(STRLEN *) NULL;
13623 if (list == (char **) NULL)
13625 ThrowPerlException(exception,ResourceLimitError,
13626 "MemoryAllocationFailed",PackageName);
13627 goto PerlException;
13629 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13630 if (length == (STRLEN *) NULL)
13632 ThrowPerlException(exception,ResourceLimitError,
13633 "MemoryAllocationFailed",PackageName);
13634 goto PerlException;
13636 if (sv_isobject(ST(0)) == 0)
13638 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13640 goto PerlException;
13642 reference=SvRV(ST(0));
13643 hv=SvSTASH(reference);
13644 if (SvTYPE(reference) != SVt_PVAV)
13646 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13648 goto PerlException;
13650 av=(AV *) reference;
13651 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13653 package_info=ClonePackageInfo(info,exception);
13656 *list=(char *) (*package_info->image_info->filename ?
13657 package_info->image_info->filename : "XC:black");
13659 for (n=0, i=0; i < ac; i++)
13661 list[n]=(char *) SvPV(ST(i+1),length[n]);
13662 if ((items >= 3) && strEQcase(list[n],"blob"))
13668 blob=(void *) (SvPV(ST(i+1),length[n]));
13669 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13671 if ((items >= 3) && strEQcase(list[n],"filename"))
13673 if ((items >= 3) && strEQcase(list[n],"file"))
13682 io_info=IoIFP(sv_2io(ST(i+1)));
13683 if (io_info == (PerlIO *) NULL)
13685 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13689 file=PerlIO_findFILE(io_info);
13690 if (file == (FILE *) NULL)
13692 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13696 SetImageInfoFile(package_info->image_info,file);
13698 if ((items >= 3) && strEQcase(list[n],"magick"))
13702 list[n]=(char *) NULL;
13704 status=ExpandFilenames(&n,&list);
13705 if (status == MagickFalse)
13707 ThrowPerlException(exception,ResourceLimitError,
13708 "MemoryAllocationFailed",PackageName);
13709 goto PerlException;
13712 for (i=0; i < n; i++)
13714 if ((package_info->image_info->file == (FILE *) NULL) &&
13715 (package_info->image_info->blob == (void *) NULL))
13716 image=ReadImages(package_info->image_info,list[i],exception);
13719 image=ReadImages(package_info->image_info,
13720 package_info->image_info->filename,exception);
13721 if (image != (Image *) NULL)
13722 DisassociateImageStream(image);
13724 if (image == (Image *) NULL)
13726 for ( ; image; image=image->next)
13728 AddImageToRegistry(sv,image);
13730 av_push(av,sv_bless(rv,hv));
13738 for (i=0; i < n; i++)
13739 if (list[i] != (char *) NULL)
13740 for (p=keep; list[i] != *p++; )
13741 if (*p == (char *) NULL)
13743 list[i]=(char *) RelinquishMagickMemory(list[i]);
13748 if (package_info != (struct PackageInfo *) NULL)
13749 DestroyPackageInfo(package_info);
13750 if (list && (list != keep))
13751 list=(char **) RelinquishMagickMemory(list);
13753 keep=(char **) RelinquishMagickMemory(keep);
13755 length=(STRLEN *) RelinquishMagickMemory(length);
13756 InheritPerlException(exception,perl_exception);
13757 exception=DestroyExceptionInfo(exception);
13758 sv_setiv(perl_exception,(IV) number_images);
13759 SvPOK_on(perl_exception);
13760 ST(0)=sv_2mortal(perl_exception);
13765 ###############################################################################
13773 ###############################################################################
13778 Image::Magick ref=NO_INIT
13801 PERL_UNUSED_VAR(ref);
13802 PERL_UNUSED_VAR(ix);
13803 exception=AcquireExceptionInfo();
13804 perl_exception=newSVpv("",0);
13805 reference=SvRV(ST(0));
13806 av=(AV *) reference;
13807 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13809 for (i=1; i < items; i++)
13810 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13811 SvPV(ST(i),na),exception);
13812 InheritPerlException(exception,perl_exception);
13813 exception=DestroyExceptionInfo(exception);
13814 SvREFCNT_dec(perl_exception); /* throw away all errors */
13818 ###############################################################################
13826 ###############################################################################
13831 Image::Magick ref=NO_INIT
13854 *reference; /* reference is the SV* of ref=SvIV(reference) */
13856 PERL_UNUSED_VAR(ref);
13857 PERL_UNUSED_VAR(ix);
13858 exception=AcquireExceptionInfo();
13859 perl_exception=newSVpv("",0);
13860 if (sv_isobject(ST(0)) == 0)
13862 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13864 goto PerlException;
13866 reference=SvRV(ST(0));
13867 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13869 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13871 for (i=2; i < items; i+=2)
13872 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13875 InheritPerlException(exception,perl_exception);
13876 exception=DestroyExceptionInfo(exception);
13877 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13878 SvPOK_on(perl_exception);
13879 ST(0)=sv_2mortal(perl_exception);
13884 ###############################################################################
13888 # S e t P i x e l #
13892 ###############################################################################
13897 Image::Magick ref=NO_INIT
13939 *reference; /* reference is the SV* of ref=SvIV(reference) */
13941 PERL_UNUSED_VAR(ref);
13942 PERL_UNUSED_VAR(ix);
13943 exception=AcquireExceptionInfo();
13944 perl_exception=newSVpv("",0);
13945 reference=SvRV(ST(0));
13946 av=(AV *) reference;
13947 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13949 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13950 if (image == (Image *) NULL)
13952 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13954 goto PerlException;
13957 normalize=MagickTrue;
13960 region.width=image->columns;
13963 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13964 channel=DefaultChannels;
13965 for (i=2; i < items; i+=2)
13967 attribute=(char *) SvPV(ST(i-1),na);
13968 switch (*attribute)
13973 if (LocaleCompare(attribute,"channel") == 0)
13978 option=ParseChannelOption(SvPV(ST(i),na));
13981 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13985 channel=(ChannelType) option;
13988 if (LocaleCompare(attribute,"color") == 0)
13990 if (SvTYPE(ST(i)) != SVt_RV)
13993 message[MagickPathExtent];
13995 (void) FormatLocaleString(message,MagickPathExtent,
13996 "invalid %.60s value",attribute);
13997 ThrowPerlException(exception,OptionError,message,
14000 av=(AV *) SvRV(ST(i));
14003 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14010 if (LocaleCompare(attribute,"geometry") == 0)
14012 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
14015 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14022 if (LocaleCompare(attribute,"normalize") == 0)
14024 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14028 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14032 normalize=option != 0 ? MagickTrue : MagickFalse;
14035 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14042 if (LocaleCompare(attribute,"x") == 0)
14044 region.x=SvIV(ST(i));
14047 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14054 if (LocaleCompare(attribute,"y") == 0)
14056 region.y=SvIV(ST(i));
14059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14065 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14071 (void) SetImageStorageClass(image,DirectClass,exception);
14072 channel_mask=SetImageChannelMask(image,channel);
14073 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14074 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14075 (SvTYPE(av) != SVt_PVAV))
14087 if (normalize != MagickFalse)
14088 scale=QuantumRange;
14089 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14092 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14093 av_fetch(av,i,0)))),q);
14096 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14099 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14100 av_fetch(av,i,0)))),q);
14103 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14106 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14107 av_fetch(av,i,0)))),q);
14110 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14111 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14113 SetPixelBlack(image,ClampToQuantum(scale*
14114 SvNV(*(av_fetch(av,i,0)))),q);
14117 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14120 SetPixelAlpha(image,ClampToQuantum(scale*
14121 SvNV(*(av_fetch(av,i,0)))),q);
14124 (void) SyncAuthenticPixels(image,exception);
14126 (void) SetImageChannelMask(image,channel_mask);
14129 InheritPerlException(exception,perl_exception);
14130 exception=DestroyExceptionInfo(exception);
14131 SvREFCNT_dec(perl_exception);
14135 ###############################################################################
14143 ###############################################################################
14148 Image::Magick ref=NO_INIT
14187 PERL_UNUSED_VAR(ref);
14188 PERL_UNUSED_VAR(ix);
14189 exception=AcquireExceptionInfo();
14190 perl_exception=newSVpv("",0);
14194 if (sv_isobject(ST(0)) == 0)
14196 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14198 goto PerlException;
14200 reference=SvRV(ST(0));
14201 hv=SvSTASH(reference);
14203 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14205 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14206 if (image == (Image *) NULL)
14208 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14210 goto PerlException;
14212 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14218 for (i=2; i < items; i+=2)
14220 attribute=(char *) SvPV(ST(i-1),na);
14221 switch (*attribute)
14226 if (LocaleCompare(attribute,"offset") == 0)
14228 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14231 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14238 if (LocaleCompare(attribute,"stack") == 0)
14240 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14244 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14250 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14256 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14262 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14264 if (image == (Image *) NULL)
14265 goto PerlException;
14266 for ( ; image; image=image->next)
14268 AddImageToRegistry(sv,image);
14270 av_push(av,sv_bless(rv,hv));
14273 exception=DestroyExceptionInfo(exception);
14274 ST(0)=av_reference;
14275 SvREFCNT_dec(perl_exception);
14279 InheritPerlException(exception,perl_exception);
14280 exception=DestroyExceptionInfo(exception);
14281 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14282 SvPOK_on(perl_exception);
14283 ST(0)=sv_2mortal(perl_exception);
14288 ###############################################################################
14292 # S t a t i s t i c s #
14296 ###############################################################################
14300 Statistics(ref,...)
14301 Image::Magick ref=NO_INIT
14303 StatisticsImage = 1
14305 statisticsimage = 3
14308 #define ChannelStatistics(channel) \
14310 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14311 (double) channel_statistics[channel].depth); \
14312 PUSHs(sv_2mortal(newSVpv(message,0))); \
14313 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14314 channel_statistics[channel].minima/scale); \
14315 PUSHs(sv_2mortal(newSVpv(message,0))); \
14316 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14317 channel_statistics[channel].maxima/scale); \
14318 PUSHs(sv_2mortal(newSVpv(message,0))); \
14319 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14320 channel_statistics[channel].mean/scale); \
14321 PUSHs(sv_2mortal(newSVpv(message,0))); \
14322 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14323 channel_statistics[channel].standard_deviation/scale); \
14324 PUSHs(sv_2mortal(newSVpv(message,0))); \
14325 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14326 channel_statistics[channel].kurtosis); \
14327 PUSHs(sv_2mortal(newSVpv(message,0))); \
14328 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14329 channel_statistics[channel].skewness); \
14330 PUSHs(sv_2mortal(newSVpv(message,0))); \
14331 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14332 channel_statistics[channel].entropy); \
14333 PUSHs(sv_2mortal(newSVpv(message,0))); \
14340 message[MagickPathExtent];
14343 *channel_statistics;
14364 PERL_UNUSED_VAR(ref);
14365 PERL_UNUSED_VAR(ix);
14366 exception=AcquireExceptionInfo();
14367 perl_exception=newSVpv("",0);
14369 if (sv_isobject(ST(0)) == 0)
14371 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14373 goto PerlException;
14375 reference=SvRV(ST(0));
14378 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14379 if (image == (Image *) NULL)
14381 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14383 goto PerlException;
14386 for ( ; image; image=image->next)
14388 channel_statistics=GetImageStatistics(image,exception);
14389 if (channel_statistics == (ChannelStatistics *) NULL)
14392 EXTEND(sp,35*count);
14393 scale=(double) QuantumRange;
14394 ChannelStatistics(RedChannel);
14395 ChannelStatistics(GreenChannel);
14396 ChannelStatistics(BlueChannel);
14397 if (image->colorspace == CMYKColorspace)
14398 ChannelStatistics(BlackChannel);
14399 if (image->alpha_trait != UndefinedPixelTrait)
14400 ChannelStatistics(AlphaChannel);
14401 channel_statistics=(ChannelStatistics *)
14402 RelinquishMagickMemory(channel_statistics);
14406 InheritPerlException(exception,perl_exception);
14407 exception=DestroyExceptionInfo(exception);
14408 SvREFCNT_dec(perl_exception);
14412 ###############################################################################
14416 # S y n c A u t h e n t i c P i x e l s #
14420 ###############################################################################
14424 SyncAuthenticPixels(ref,...)
14425 Image::Magick ref = NO_INIT
14427 Syncauthenticpixels = 1
14428 SyncImagePixels = 2
14429 syncimagepixels = 3
14448 PERL_UNUSED_VAR(ref);
14449 PERL_UNUSED_VAR(ix);
14450 exception=AcquireExceptionInfo();
14451 perl_exception=newSVpv("",0);
14452 if (sv_isobject(ST(0)) == 0)
14454 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14456 goto PerlException;
14459 reference=SvRV(ST(0));
14460 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14461 if (image == (Image *) NULL)
14463 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14465 goto PerlException;
14468 status=SyncAuthenticPixels(image,exception);
14469 if (status != MagickFalse)
14473 InheritPerlException(exception,perl_exception);
14474 exception=DestroyExceptionInfo(exception);
14475 SvREFCNT_dec(perl_exception); /* throw away all errors */
14479 ###############################################################################
14487 ###############################################################################
14492 Image::Magick ref=NO_INIT
14500 filename[MagickPathExtent];
14524 PERL_UNUSED_VAR(ref);
14525 PERL_UNUSED_VAR(ix);
14526 exception=AcquireExceptionInfo();
14527 perl_exception=newSVpv("",0);
14529 package_info=(struct PackageInfo *) NULL;
14530 if (sv_isobject(ST(0)) == 0)
14532 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14534 goto PerlException;
14536 reference=SvRV(ST(0));
14537 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14538 if (image == (Image *) NULL)
14540 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14542 goto PerlException;
14544 package_info=ClonePackageInfo(info,exception);
14546 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14549 for (i=2; i < items; i+=2)
14550 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14552 (void) CopyMagickString(filename,package_info->image_info->filename,
14555 for (next=image; next; next=next->next)
14557 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14558 next->scene=scene++;
14560 *package_info->image_info->magick='\0';
14561 SetImageInfo(package_info->image_info,(unsigned int)
14562 GetImageListLength(image),exception);
14563 for (next=image; next; next=next->next)
14565 (void) WriteImage(package_info->image_info,next,exception);
14567 if (package_info->image_info->adjoin)
14572 if (package_info != (struct PackageInfo *) NULL)
14573 DestroyPackageInfo(package_info);
14574 InheritPerlException(exception,perl_exception);
14575 exception=DestroyExceptionInfo(exception);
14576 sv_setiv(perl_exception,(IV) number_images);
14577 SvPOK_on(perl_exception);
14578 ST(0)=sv_2mortal(perl_exception);