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-2017 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} } },
566 { "Colorspace", { {"colorspace", MagickColorspaceOptions} } },
570 *magick_registry = (SplayTreeInfo *) NULL;
573 Forward declarations.
576 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
579 strEQcase(const char *,const char *);
582 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586 % C l o n e P a c k a g e I n f o %
590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
592 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
595 % The format of the ClonePackageInfo routine is:
597 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
600 % A description of each parameter follows:
602 % o info: a structure of type info.
604 % o exception: Return any errors or warnings in this structure.
607 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
608 ExceptionInfo *exception)
613 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
614 if (clone_info == (struct PackageInfo *) NULL)
616 ThrowPerlException(exception,ResourceLimitError,
617 "UnableToClonePackageInfo",PackageName);
618 return((struct PackageInfo *) NULL);
620 if (info == (struct PackageInfo *) NULL)
622 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
626 clone_info->image_info=CloneImageInfo(info->image_info);
631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
641 % constant() returns a double value for the specified name.
643 % The format of the constant routine is:
645 % double constant(char *name,ssize_t sans)
647 % A description of each parameter follows:
649 % o value: Method constant returns a double value for the specified name.
651 % o name: The name of the constant.
653 % o sans: This integer value is not used.
656 static double constant(char *name,ssize_t sans)
664 if (strEQ(name,"BlobError"))
666 if (strEQ(name,"BlobWarning"))
672 if (strEQ(name,"CacheError"))
674 if (strEQ(name,"CacheWarning"))
675 return(CacheWarning);
676 if (strEQ(name,"CoderError"))
678 if (strEQ(name,"CoderWarning"))
679 return(CoderWarning);
680 if (strEQ(name,"ConfigureError"))
681 return(ConfigureError);
682 if (strEQ(name,"ConfigureWarning"))
683 return(ConfigureWarning);
684 if (strEQ(name,"CorruptImageError"))
685 return(CorruptImageError);
686 if (strEQ(name,"CorruptImageWarning"))
687 return(CorruptImageWarning);
692 if (strEQ(name,"DelegateError"))
693 return(DelegateError);
694 if (strEQ(name,"DelegateWarning"))
695 return(DelegateWarning);
696 if (strEQ(name,"DrawError"))
698 if (strEQ(name,"DrawWarning"))
704 if (strEQ(name,"ErrorException"))
705 return(ErrorException);
706 if (strEQ(name,"ExceptionError"))
708 if (strEQ(name,"ExceptionWarning"))
709 return(CoderWarning);
714 if (strEQ(name,"FatalErrorException"))
715 return(FatalErrorException);
716 if (strEQ(name,"FileOpenError"))
717 return(FileOpenError);
718 if (strEQ(name,"FileOpenWarning"))
719 return(FileOpenWarning);
724 if (strEQ(name,"ImageError"))
726 if (strEQ(name,"ImageWarning"))
727 return(ImageWarning);
732 if (strEQ(name,"MaxRGB"))
733 return(QuantumRange);
734 if (strEQ(name,"MissingDelegateError"))
735 return(MissingDelegateError);
736 if (strEQ(name,"MissingDelegateWarning"))
737 return(MissingDelegateWarning);
738 if (strEQ(name,"ModuleError"))
740 if (strEQ(name,"ModuleWarning"))
741 return(ModuleWarning);
746 if (strEQ(name,"Opaque"))
748 if (strEQ(name,"OptionError"))
750 if (strEQ(name,"OptionWarning"))
751 return(OptionWarning);
756 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
757 return(MAGICKCORE_QUANTUM_DEPTH);
758 if (strEQ(name,"QuantumDepth"))
759 return(MAGICKCORE_QUANTUM_DEPTH);
760 if (strEQ(name,"QuantumRange"))
761 return(QuantumRange);
766 if (strEQ(name,"ResourceLimitError"))
767 return(ResourceLimitError);
768 if (strEQ(name,"ResourceLimitWarning"))
769 return(ResourceLimitWarning);
770 if (strEQ(name,"RegistryError"))
771 return(RegistryError);
772 if (strEQ(name,"RegistryWarning"))
773 return(RegistryWarning);
778 if (strEQ(name,"StreamError"))
780 if (strEQ(name,"StreamWarning"))
781 return(StreamWarning);
782 if (strEQ(name,"Success"))
788 if (strEQ(name,"Transparent"))
789 return(TransparentAlpha);
790 if (strEQ(name,"TypeError"))
792 if (strEQ(name,"TypeWarning"))
798 if (strEQ(name,"WarningException"))
799 return(WarningException);
804 if (strEQ(name,"XServerError"))
805 return(XServerError);
806 if (strEQ(name,"XServerWarning"))
807 return(XServerWarning);
816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
820 % D e s t r o y P a c k a g e I n f o %
824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826 % Method DestroyPackageInfo frees a previously created info structure.
828 % The format of the DestroyPackageInfo routine is:
830 % DestroyPackageInfo(struct PackageInfo *info)
832 % A description of each parameter follows:
834 % o info: a structure of type info.
837 static void DestroyPackageInfo(struct PackageInfo *info)
839 info->image_info=DestroyImageInfo(info->image_info);
840 info=(struct PackageInfo *) RelinquishMagickMemory(info);
844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
852 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
854 % Method GetList is recursively called by SetupList to traverse the
855 % Image__Magick reference. If building an reference_vector (see SetupList),
856 % *current is the current position in *reference_vector and *last is the final
857 % entry in *reference_vector.
859 % The format of the GetList routine is:
863 % A description of each parameter follows:
865 % o info: a structure of type info.
868 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
869 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
874 if (reference == (SV *) NULL)
876 switch (SvTYPE(reference))
896 previous=(Image *) NULL;
900 for (i=0; i <= n; i++)
906 if (rv && *rv && sv_isobject(*rv))
908 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
910 if (image == (Image *) NULL)
912 if (image == previous)
914 image=CloneImage(image,0,0,MagickTrue,exception);
915 if (image == (Image *) NULL)
918 image->previous=previous;
919 *(previous ? &previous->next : &head)=image;
920 for (previous=image; previous->next; previous=previous->next) ;
928 Blessed scalar, one image.
930 image=INT2PTR(Image *,SvIV(reference));
931 if (image == (Image *) NULL)
933 image->previous=(Image *) NULL;
934 image->next=(Image *) NULL;
935 if (reference_vector)
937 if (*current == *last)
940 if (*reference_vector == (SV **) NULL)
941 *reference_vector=(SV **) AcquireQuantumMemory(*last,
942 sizeof(*reference_vector));
944 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
945 *last,sizeof(*reference_vector));
947 if (*reference_vector == (SV **) NULL)
949 ThrowPerlException(exception,ResourceLimitError,
950 "MemoryAllocationFailed",PackageName);
951 return((Image *) NULL);
953 (*reference_vector)[*current]=reference;
954 (*reference_vector)[++(*current)]=NULL;
961 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
962 (double) SvTYPE(reference));
963 return((Image *) NULL);
967 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
971 % G e t P a c k a g e I n f o %
975 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
977 % Method GetPackageInfo looks up or creates an info structure for the given
978 % Image__Magick reference. If it does create a new one, the information in
979 % package_info is used to initialize it.
981 % The format of the GetPackageInfo routine is:
983 % struct PackageInfo *GetPackageInfo(void *reference,
984 % struct PackageInfo *package_info,ExceptionInfo *exception)
986 % A description of each parameter follows:
988 % o info: a structure of type info.
990 % o exception: Return any errors or warnings in this structure.
993 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
994 struct PackageInfo *package_info,ExceptionInfo *exception)
997 message[MagickPathExtent];
1005 (void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p",
1006 PackageName,XS_VERSION,reference);
1007 sv=perl_get_sv(message,(TRUE | 0x02));
1008 if (sv == (SV *) NULL)
1010 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1012 return(package_info);
1014 if (SvREFCNT(sv) == 0)
1015 (void) SvREFCNT_inc(sv);
1016 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1018 clone_info=ClonePackageInfo(package_info,exception);
1019 sv_setiv(sv,PTR2IV(clone_info));
1024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1028 % S e t A t t r i b u t e %
1032 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1034 % SetAttribute() sets the attribute to the value in sval. This can change
1035 % either or both of image or info.
1037 % The format of the SetAttribute routine is:
1039 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1040 % SV *sval,ExceptionInfo *exception)
1042 % A description of each parameter follows:
1044 % o list: a list of strings.
1046 % o string: a character string.
1050 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1058 value=InterpretSiPrefixValue(string,&q);
1060 value*=interval/100.0;
1064 static inline double StringToDouble(const char *string,char **sentinal)
1066 return(InterpretLocaleValue(string,sentinal));
1069 static double StringToDoubleInterval(const char *string,const double interval)
1077 value=InterpretLocaleValue(string,&q);
1079 value*=interval/100.0;
1083 static inline ssize_t StringToLong(const char *value)
1085 return(strtol(value,(char **) NULL,10));
1088 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1089 const char *attribute,SV *sval,ExceptionInfo *exception)
1116 if (LocaleCompare(attribute,"adjoin") == 0)
1118 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1119 SvPV(sval,na)) : SvIV(sval);
1122 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1127 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1130 if (LocaleCompare(attribute,"alpha") == 0)
1132 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1133 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1136 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1140 for ( ; image; image=image->next)
1141 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1145 if (LocaleCompare(attribute,"antialias") == 0)
1147 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1148 SvPV(sval,na)) : SvIV(sval);
1151 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1156 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1159 if (LocaleCompare(attribute,"area-limit") == 0)
1164 limit=MagickResourceInfinity;
1165 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1166 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1168 (void) SetMagickResourceLimit(AreaResource,limit);
1171 if (LocaleCompare(attribute,"attenuate") == 0)
1174 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1177 if (LocaleCompare(attribute,"authenticate") == 0)
1180 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1184 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1185 for ( ; image; image=image->next)
1186 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1192 if (LocaleCompare(attribute,"background") == 0)
1194 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1197 info->image_info->background_color=target_color;
1198 for ( ; image; image=image->next)
1199 image->background_color=target_color;
1202 if (LocaleCompare(attribute,"blue-primary") == 0)
1204 for ( ; image; image=image->next)
1206 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1207 image->chromaticity.blue_primary.x=geometry_info.rho;
1208 image->chromaticity.blue_primary.y=geometry_info.sigma;
1209 if ((flags & SigmaValue) == 0)
1210 image->chromaticity.blue_primary.y=
1211 image->chromaticity.blue_primary.x;
1215 if (LocaleCompare(attribute,"bordercolor") == 0)
1217 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1220 info->image_info->border_color=target_color;
1221 for ( ; image; image=image->next)
1222 image->border_color=target_color;
1226 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1227 for ( ; image; image=image->next)
1228 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1234 if (LocaleCompare(attribute,"cache-threshold") == 0)
1236 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1237 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1238 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1239 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1242 if (LocaleCompare(attribute,"clip-mask") == 0)
1247 clip_mask=(Image *) NULL;
1249 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1250 for ( ; image; image=image->next)
1251 SetImageMask(image,ReadPixelMask,clip_mask,exception);
1254 if (LocaleNCompare(attribute,"colormap",8) == 0)
1256 for ( ; image; image=image->next)
1264 if (image->storage_class == DirectClass)
1267 items=sscanf(attribute,"%*[^[][%ld",&i);
1269 if (i > (ssize_t) image->colors)
1271 if ((strchr(SvPV(sval,na),',') == 0) ||
1272 (strchr(SvPV(sval,na),')') != 0))
1273 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1274 image->colormap+i,exception);
1277 color=image->colormap+i;
1278 pixel.red=color->red;
1279 pixel.green=color->green;
1280 pixel.blue=color->blue;
1281 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1282 pixel.red=geometry_info.rho;
1283 pixel.green=geometry_info.sigma;
1284 pixel.blue=geometry_info.xi;
1285 color->red=ClampToQuantum(pixel.red);
1286 color->green=ClampToQuantum(pixel.green);
1287 color->blue=ClampToQuantum(pixel.blue);
1292 if (LocaleCompare(attribute,"colorspace") == 0)
1294 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1295 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1298 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1302 for ( ; image; image=image->next)
1303 (void) SetImageColorspace(image,(ColorspaceType) sp,exception);
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;
1879 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1880 for ( ; image; image=image->next)
1881 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1887 if (LocaleCompare(attribute,"quality") == 0)
1890 info->image_info->quality=SvIV(sval);
1891 for ( ; image; image=image->next)
1892 image->quality=SvIV(sval);
1896 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1897 for ( ; image; image=image->next)
1898 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1904 if (LocaleCompare(attribute,"read-mask") == 0)
1909 mask=(Image *) NULL;
1911 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1912 for ( ; image; image=image->next)
1913 SetImageMask(image,ReadPixelMask,mask,exception);
1916 if (LocaleCompare(attribute,"red-primary") == 0)
1918 for ( ; image; image=image->next)
1920 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1921 image->chromaticity.red_primary.x=geometry_info.rho;
1922 image->chromaticity.red_primary.y=geometry_info.sigma;
1923 if ((flags & SigmaValue) == 0)
1924 image->chromaticity.red_primary.y=
1925 image->chromaticity.red_primary.x;
1929 if (LocaleCompare(attribute,"render") == 0)
1931 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1932 SvPV(sval,na)) : SvIV(sval);
1935 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1939 for ( ; image; image=image->next)
1940 image->rendering_intent=(RenderingIntent) sp;
1943 if (LocaleCompare(attribute,"repage") == 0)
1948 for ( ; image; image=image->next)
1950 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1951 if ((flags & WidthValue) != 0)
1953 if ((flags & HeightValue) == 0)
1954 geometry.height=geometry.width;
1955 image->page.width=geometry.width;
1956 image->page.height=geometry.height;
1958 if ((flags & AspectValue) != 0)
1960 if ((flags & XValue) != 0)
1961 image->page.x+=geometry.x;
1962 if ((flags & YValue) != 0)
1963 image->page.y+=geometry.y;
1967 if ((flags & XValue) != 0)
1969 image->page.x=geometry.x;
1970 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1971 image->page.width=image->columns+geometry.x;
1973 if ((flags & YValue) != 0)
1975 image->page.y=geometry.y;
1976 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1977 image->page.height=image->rows+geometry.y;
1984 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1985 for ( ; image; image=image->next)
1986 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1992 if (LocaleCompare(attribute,"sampling-factor") == 0)
1994 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1996 ThrowPerlException(exception,OptionError,"MissingGeometry",
2001 (void) CloneString(&info->image_info->sampling_factor,
2005 if (LocaleCompare(attribute,"scene") == 0)
2007 for ( ; image; image=image->next)
2008 image->scene=SvIV(sval);
2011 if (LocaleCompare(attribute,"server") == 0)
2013 if (LocaleCompare(attribute,"size") == 0)
2017 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2019 ThrowPerlException(exception,OptionError,"MissingGeometry",
2023 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2027 if (LocaleCompare(attribute,"stroke") == 0)
2030 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2034 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2035 for ( ; image; image=image->next)
2036 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2042 if (LocaleCompare(attribute,"texture") == 0)
2045 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2048 if (LocaleCompare(attribute,"thread-limit") == 0)
2053 limit=MagickResourceInfinity;
2054 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2055 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2057 (void) SetMagickResourceLimit(ThreadResource,limit);
2060 if (LocaleCompare(attribute,"tile-offset") == 0)
2065 geometry=GetPageGeometry(SvPV(sval,na));
2067 (void) CloneString(&info->image_info->page,geometry);
2068 for ( ; image; image=image->next)
2069 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2071 geometry=(char *) RelinquishMagickMemory(geometry);
2074 if (LocaleCompare(attribute,"time-limit") == 0)
2079 limit=MagickResourceInfinity;
2080 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2081 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2083 (void) SetMagickResourceLimit(TimeResource,limit);
2086 if (LocaleCompare(attribute,"transparent-color") == 0)
2088 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2091 info->image_info->transparent_color=target_color;
2092 for ( ; image; image=image->next)
2093 image->transparent_color=target_color;
2096 if (LocaleCompare(attribute,"type") == 0)
2098 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2099 SvPV(sval,na)) : SvIV(sval);
2102 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2107 info->image_info->type=(ImageType) sp;
2108 for ( ; image; image=image->next)
2109 SetImageType(image,(ImageType) sp,exception);
2113 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2114 for ( ; image; image=image->next)
2115 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2121 if (LocaleCompare(attribute,"units") == 0)
2123 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2124 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2127 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2132 info->image_info->units=(ResolutionType) sp;
2133 for ( ; image; image=image->next)
2138 units=(ResolutionType) sp;
2139 if (image->units != units)
2140 switch (image->units)
2142 case UndefinedResolution:
2143 case PixelsPerInchResolution:
2145 if (units == PixelsPerCentimeterResolution)
2147 image->resolution.x*=2.54;
2148 image->resolution.y*=2.54;
2152 case PixelsPerCentimeterResolution:
2154 if (units == PixelsPerInchResolution)
2156 image->resolution.x/=2.54;
2157 image->resolution.y/=2.54;
2167 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2168 for ( ; image; image=image->next)
2169 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2175 if (LocaleCompare(attribute,"verbose") == 0)
2177 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2178 SvPV(sval,na)) : SvIV(sval);
2181 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2186 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2189 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2191 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2192 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2195 ThrowPerlException(exception,OptionError,
2196 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2199 for ( ; image; image=image->next)
2200 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2204 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2205 for ( ; image; image=image->next)
2206 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2212 if (LocaleCompare(attribute,"white-point") == 0)
2214 for ( ; image; image=image->next)
2216 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2217 image->chromaticity.white_point.x=geometry_info.rho;
2218 image->chromaticity.white_point.y=geometry_info.sigma;
2219 if ((flags & SigmaValue) == 0)
2220 image->chromaticity.white_point.y=
2221 image->chromaticity.white_point.x;
2225 if (LocaleCompare(attribute,"write-mask") == 0)
2230 mask=(Image *) NULL;
2232 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2233 for ( ; image; image=image->next)
2234 SetImageMask(image,WritePixelMask,mask,exception);
2238 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2239 for ( ; image; image=image->next)
2240 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2246 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2247 for ( ; image; image=image->next)
2248 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2259 % S e t u p L i s t %
2263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2265 % Method SetupList returns the list of all the images linked by their
2266 % image->next and image->previous link lists for use with ImageMagick. If
2267 % info is non-NULL, an info structure is returned in *info. If
2268 % reference_vector is non-NULL,an array of SV* are returned in
2269 % *reference_vector. Reference_vector is used when the images are going to be
2270 % replaced with new Image*'s.
2272 % The format of the SetupList routine is:
2274 % Image *SetupList(SV *reference,struct PackageInfo **info,
2275 % SV ***reference_vector,ExceptionInfo *exception)
2277 % A description of each parameter follows:
2279 % o list: a list of strings.
2281 % o string: a character string.
2283 % o exception: Return any errors or warnings in this structure.
2286 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2287 SV ***reference_vector,ExceptionInfo *exception)
2296 if (reference_vector)
2297 *reference_vector=NULL;
2302 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2303 if (info && (SvTYPE(reference) == SVt_PVAV))
2304 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2310 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2314 % s t r E Q c a s e %
2318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2320 % strEQcase() compares two strings and returns 0 if they are the
2321 % same or if the second string runs out first. The comparison is case
2324 % The format of the strEQcase routine is:
2326 % ssize_t strEQcase(const char *p,const char *q)
2328 % A description of each parameter follows:
2330 % o p: a character string.
2332 % o q: a character string.
2336 static ssize_t strEQcase(const char *p,const char *q)
2344 for (i=0 ; (c=(*q)) != 0; i++)
2346 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2347 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2352 return(((*q == 0) && (*p == 0)) ? i : 0);
2356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2360 % I m a g e : : M a g i c k %
2364 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2368 MODULE = Image::Magick PACKAGE = Image::Magick
2373 MagickCoreGenesis("PerlMagick",MagickFalse);
2374 SetWarningHandler(NULL);
2375 SetErrorHandler(NULL);
2376 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2377 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2383 if (magick_registry != (SplayTreeInfo *) NULL)
2384 magick_registry=DestroySplayTree(magick_registry);
2385 MagickCoreTerminus();
2389 constant(name,argument)
2394 ###############################################################################
2402 ###############################################################################
2407 Image::Magick ref=NO_INIT
2431 PERL_UNUSED_VAR(ref);
2432 PERL_UNUSED_VAR(ix);
2433 exception=AcquireExceptionInfo();
2434 perl_exception=newSVpv("",0);
2435 package_info=(struct PackageInfo *) NULL;
2436 if (sv_isobject(ST(0)) == 0)
2438 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2442 reference=SvRV(ST(0));
2443 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2444 if (image == (Image *) NULL)
2446 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2450 package_info=ClonePackageInfo(info,exception);
2452 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2455 for (i=2; i < items; i+=2)
2456 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2458 (void) AnimateImages(package_info->image_info,image,exception);
2459 (void) CatchImageException(image);
2462 if (package_info != (struct PackageInfo *) NULL)
2463 DestroyPackageInfo(package_info);
2464 InheritPerlException(exception,perl_exception);
2465 exception=DestroyExceptionInfo(exception);
2466 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2467 SvPOK_on(perl_exception);
2468 ST(0)=sv_2mortal(perl_exception);
2473 ###############################################################################
2481 ###############################################################################
2486 Image::Magick ref=NO_INIT
2524 PERL_UNUSED_VAR(ref);
2525 PERL_UNUSED_VAR(ix);
2526 exception=AcquireExceptionInfo();
2527 perl_exception=newSVpv("",0);
2531 if (sv_isobject(ST(0)) == 0)
2533 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2537 reference=SvRV(ST(0));
2538 hv=SvSTASH(reference);
2540 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2542 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2543 if (image == (Image *) NULL)
2545 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2549 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2554 for (i=2; i < items; i+=2)
2556 attribute=(char *) SvPV(ST(i-1),na);
2562 if (LocaleCompare(attribute,"stack") == 0)
2564 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2568 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2574 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2586 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2587 if (image == (Image *) NULL)
2589 for ( ; image; image=image->next)
2591 AddImageToRegistry(sv,image);
2593 av_push(av,sv_bless(rv,hv));
2596 exception=DestroyExceptionInfo(exception);
2598 SvREFCNT_dec(perl_exception);
2602 InheritPerlException(exception,perl_exception);
2603 exception=DestroyExceptionInfo(exception);
2604 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2605 SvPOK_on(perl_exception);
2606 ST(0)=sv_2mortal(perl_exception);
2611 ###############################################################################
2619 ###############################################################################
2624 Image::Magick ref=NO_INIT
2655 PERL_UNUSED_VAR(ref);
2656 PERL_UNUSED_VAR(ix);
2657 exception=AcquireExceptionInfo();
2658 perl_exception=newSVpv("",0);
2660 if (sv_isobject(ST(0)) == 0)
2662 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2666 reference=SvRV(ST(0));
2667 hv=SvSTASH(reference);
2668 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2669 if (image == (Image *) NULL)
2671 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2675 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2676 if (image == (Image *) NULL)
2679 Create blessed Perl array for the returned image.
2682 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2684 AddImageToRegistry(sv,image);
2686 av_push(av,sv_bless(rv,hv));
2688 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2689 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2690 "average-%.*s",(int) (MagickPathExtent-9),
2691 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2692 (void) CopyMagickString(image->filename,info->image_info->filename,
2694 SetImageInfo(info->image_info,0,exception);
2695 exception=DestroyExceptionInfo(exception);
2696 SvREFCNT_dec(perl_exception);
2700 InheritPerlException(exception,perl_exception);
2701 exception=DestroyExceptionInfo(exception);
2702 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2703 SvPOK_on(perl_exception);
2704 ST(0)=sv_2mortal(perl_exception);
2709 ###############################################################################
2713 # B l o b T o I m a g e #
2717 ###############################################################################
2721 BlobToImage(ref,...)
2722 Image::Magick ref=NO_INIT
2768 PERL_UNUSED_VAR(ref);
2769 PERL_UNUSED_VAR(ix);
2770 exception=AcquireExceptionInfo();
2771 perl_exception=newSVpv("",0);
2774 ac=(items < 2) ? 1 : items-1;
2775 length=(STRLEN *) NULL;
2776 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2777 if (list == (char **) NULL)
2779 ThrowPerlException(exception,ResourceLimitError,
2780 "MemoryAllocationFailed",PackageName);
2783 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2784 if (length == (STRLEN *) NULL)
2786 ThrowPerlException(exception,ResourceLimitError,
2787 "MemoryAllocationFailed",PackageName);
2790 if (sv_isobject(ST(0)) == 0)
2792 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2796 reference=SvRV(ST(0));
2797 hv=SvSTASH(reference);
2798 if (SvTYPE(reference) != SVt_PVAV)
2800 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2804 av=(AV *) reference;
2805 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2810 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2813 for (n=0, i=0; i < ac; i++)
2815 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2816 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2818 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2823 list[n]=(char *) NULL;
2825 for (i=number_images=0; i < n; i++)
2827 image=BlobToImage(info->image_info,list[i],length[i],exception);
2828 if (image == (Image *) NULL)
2830 for ( ; image; image=image->next)
2832 AddImageToRegistry(sv,image);
2834 av_push(av,sv_bless(rv,hv));
2842 for (i=0; i < n; i++)
2843 if (list[i] != (char *) NULL)
2844 for (p=keep; list[i] != *p++; )
2845 if (*p == (char *) NULL)
2847 list[i]=(char *) RelinquishMagickMemory(list[i]);
2853 list=(char **) RelinquishMagickMemory(list);
2855 length=(STRLEN *) RelinquishMagickMemory(length);
2856 InheritPerlException(exception,perl_exception);
2857 exception=DestroyExceptionInfo(exception);
2858 sv_setiv(perl_exception,(IV) number_images);
2859 SvPOK_on(perl_exception);
2860 ST(0)=sv_2mortal(perl_exception);
2865 ###############################################################################
2869 # C h a n n e l F x #
2873 ###############################################################################
2878 Image::Magick ref=NO_INIT
2890 expression[MagickPathExtent];
2918 PERL_UNUSED_VAR(ref);
2919 PERL_UNUSED_VAR(ix);
2920 exception=AcquireExceptionInfo();
2921 perl_exception=newSVpv("",0);
2925 if (sv_isobject(ST(0)) == 0)
2927 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2931 reference=SvRV(ST(0));
2932 hv=SvSTASH(reference);
2934 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2936 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2937 if (image == (Image *) NULL)
2939 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2943 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2947 channel=DefaultChannels;
2948 (void) CopyMagickString(expression,"u",MagickPathExtent);
2950 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2952 for (i=2; i < items; i+=2)
2954 attribute=(char *) SvPV(ST(i-1),na);
2960 if (LocaleCompare(attribute,"channel") == 0)
2965 option=ParseChannelOption(SvPV(ST(i),na));
2968 ThrowPerlException(exception,OptionError,
2969 "UnrecognizedType",SvPV(ST(i),na));
2972 channel=(ChannelType) option;
2975 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2982 if (LocaleCompare(attribute,"expression") == 0)
2984 (void) CopyMagickString(expression,SvPV(ST(i),na),
2988 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2994 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3000 channel_mask=SetImageChannelMask(image,channel);
3001 image=ChannelFxImage(image,expression,exception);
3002 if (image != (Image *) NULL)
3003 (void) SetImageChannelMask(image,channel_mask);
3004 if (image == (Image *) NULL)
3006 for ( ; image; image=image->next)
3008 AddImageToRegistry(sv,image);
3010 av_push(av,sv_bless(rv,hv));
3013 exception=DestroyExceptionInfo(exception);
3015 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3019 InheritPerlException(exception,perl_exception);
3020 exception=DestroyExceptionInfo(exception);
3021 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3022 SvPOK_on(perl_exception);
3023 ST(0)=sv_2mortal(perl_exception);
3028 ###############################################################################
3036 ###############################################################################
3041 Image::Magick ref=NO_INIT
3074 PERL_UNUSED_VAR(ref);
3075 PERL_UNUSED_VAR(ix);
3076 exception=AcquireExceptionInfo();
3077 perl_exception=newSVpv("",0);
3079 if (sv_isobject(ST(0)) == 0)
3081 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3085 reference=SvRV(ST(0));
3086 hv=SvSTASH(reference);
3087 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3088 if (image == (Image *) NULL)
3090 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3095 Create blessed Perl array for the returned image.
3098 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3100 for ( ; image; image=image->next)
3102 clone=CloneImage(image,0,0,MagickTrue,exception);
3103 if (clone == (Image *) NULL)
3105 AddImageToRegistry(sv,clone);
3107 av_push(av,sv_bless(rv,hv));
3110 exception=DestroyExceptionInfo(exception);
3111 SvREFCNT_dec(perl_exception);
3115 InheritPerlException(exception,perl_exception);
3116 exception=DestroyExceptionInfo(exception);
3117 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3118 SvPOK_on(perl_exception);
3119 ST(0)=sv_2mortal(perl_exception);
3124 ###############################################################################
3132 ###############################################################################
3140 PERL_UNUSED_VAR(ref);
3141 if (magick_registry != (SplayTreeInfo *) NULL)
3146 ResetSplayTreeIterator(magick_registry);
3147 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3148 while (p != (Image *) NULL)
3151 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3157 ###############################################################################
3165 ###############################################################################
3170 Image::Magick ref=NO_INIT
3199 PERL_UNUSED_VAR(ref);
3200 PERL_UNUSED_VAR(ix);
3201 exception=AcquireExceptionInfo();
3202 perl_exception=newSVpv("",0);
3204 if (sv_isobject(ST(0)) == 0)
3206 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3210 reference=SvRV(ST(0));
3211 hv=SvSTASH(reference);
3213 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3215 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3216 if (image == (Image *) NULL)
3218 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3222 image=CoalesceImages(image,exception);
3223 if (image == (Image *) NULL)
3225 for ( ; image; image=image->next)
3227 AddImageToRegistry(sv,image);
3229 av_push(av,sv_bless(rv,hv));
3232 exception=DestroyExceptionInfo(exception);
3234 SvREFCNT_dec(perl_exception);
3238 InheritPerlException(exception,perl_exception);
3239 exception=DestroyExceptionInfo(exception);
3240 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3241 SvPOK_on(perl_exception);
3242 ST(0)=sv_2mortal(perl_exception);
3247 ###############################################################################
3255 ###############################################################################
3260 Image::Magick ref=NO_INIT
3306 PERL_UNUSED_VAR(ref);
3307 PERL_UNUSED_VAR(ix);
3308 exception=AcquireExceptionInfo();
3309 perl_exception=newSVpv("",0);
3313 if (sv_isobject(ST(0)) == 0)
3315 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3319 reference=SvRV(ST(0));
3320 hv=SvSTASH(reference);
3322 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3324 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3325 if (image == (Image *) NULL)
3327 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3331 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3335 reconstruct_image=image;
3336 metric=RootMeanSquaredErrorMetric;
3337 for (i=2; i < items; i+=2)
3339 attribute=(char *) SvPV(ST(i-1),na);
3345 if (LocaleCompare(attribute,"channel") == 0)
3350 option=ParseChannelOption(SvPV(ST(i),na));
3353 ThrowPerlException(exception,OptionError,
3354 "UnrecognizedType",SvPV(ST(i),na));
3357 (void) SetPixelChannelMask(image,(ChannelType) option);
3360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3367 if (LocaleCompare(attribute,"fuzz") == 0)
3369 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3379 if (LocaleCompare(attribute,"image") == 0)
3381 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3382 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3392 if (LocaleCompare(attribute,"metric") == 0)
3394 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3398 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3402 metric=(MetricType) option;
3405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3411 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3417 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3419 if (difference_image != (Image *) NULL)
3421 difference_image->error.mean_error_per_pixel=distortion;
3422 AddImageToRegistry(sv,difference_image);
3424 av_push(av,sv_bless(rv,hv));
3427 exception=DestroyExceptionInfo(exception);
3429 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3433 InheritPerlException(exception,perl_exception);
3434 exception=DestroyExceptionInfo(exception);
3435 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3436 SvPOK_on(perl_exception);
3437 ST(0)=sv_2mortal(perl_exception);
3442 ###############################################################################
3446 # C o m p l e x I m a g e s #
3450 ###############################################################################
3455 Image::Magick ref=NO_INIT
3492 PERL_UNUSED_VAR(ref);
3493 PERL_UNUSED_VAR(ix);
3494 exception=AcquireExceptionInfo();
3495 perl_exception=newSVpv("",0);
3497 if (sv_isobject(ST(0)) == 0)
3499 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3503 reference=SvRV(ST(0));
3504 hv=SvSTASH(reference);
3505 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3506 if (image == (Image *) NULL)
3508 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3512 op=UndefinedComplexOperator;
3518 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3522 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3526 op=(ComplexOperator) in;
3529 for (i=2; i < items; i+=2)
3531 attribute=(char *) SvPV(ST(i-1),na);
3537 if (LocaleCompare(attribute,"operator") == 0)
3542 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3543 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3546 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3550 op=(ComplexOperator) in;
3553 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3565 image=ComplexImages(image,op,exception);
3566 if (image == (Image *) NULL)
3569 Create blessed Perl array for the returned image.
3572 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3574 AddImageToRegistry(sv,image);
3576 av_push(av,sv_bless(rv,hv));
3578 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3579 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3580 "complex-%.*s",(int) (MagickPathExtent-9),
3581 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3582 (void) CopyMagickString(image->filename,info->image_info->filename,
3584 SetImageInfo(info->image_info,0,exception);
3585 exception=DestroyExceptionInfo(exception);
3586 SvREFCNT_dec(perl_exception);
3590 InheritPerlException(exception,perl_exception);
3591 exception=DestroyExceptionInfo(exception);
3592 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3593 SvPOK_on(perl_exception);
3594 ST(0)=sv_2mortal(perl_exception);
3599 ###############################################################################
3603 # C o m p a r e L a y e r s #
3607 ###############################################################################
3612 Image::Magick ref=NO_INIT
3614 CompareImagesLayers = 1
3616 compareimagelayers = 3
3653 PERL_UNUSED_VAR(ref);
3654 PERL_UNUSED_VAR(ix);
3655 exception=AcquireExceptionInfo();
3656 perl_exception=newSVpv("",0);
3658 if (sv_isobject(ST(0)) == 0)
3660 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3664 reference=SvRV(ST(0));
3665 hv=SvSTASH(reference);
3667 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3669 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3670 if (image == (Image *) NULL)
3672 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3676 method=CompareAnyLayer;
3677 for (i=2; i < items; i+=2)
3679 attribute=(char *) SvPV(ST(i-1),na);
3685 if (LocaleCompare(attribute,"method") == 0)
3687 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3691 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3695 method=(LayerMethod) option;
3698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3704 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3710 image=CompareImagesLayers(image,method,exception);
3711 if (image == (Image *) NULL)
3713 for ( ; image; image=image->next)
3715 AddImageToRegistry(sv,image);
3717 av_push(av,sv_bless(rv,hv));
3720 exception=DestroyExceptionInfo(exception);
3722 SvREFCNT_dec(perl_exception);
3726 InheritPerlException(exception,perl_exception);
3727 exception=DestroyExceptionInfo(exception);
3728 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3729 SvPOK_on(perl_exception);
3730 ST(0)=sv_2mortal(perl_exception);
3735 ###############################################################################
3743 ###############################################################################
3748 Image::Magick ref=NO_INIT
3754 PERL_UNUSED_VAR(ref);
3755 if (sv_isobject(ST(0)) == 0)
3756 croak("ReferenceIsNotMyType");
3757 reference=SvRV(ST(0));
3758 switch (SvTYPE(reference))
3763 message[MagickPathExtent];
3781 Array (AV *) reference
3783 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3784 XS_VERSION,reference);
3785 hv=gv_stashpv(PackageName, FALSE);
3788 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3792 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3794 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3795 DestroyPackageInfo(info);
3797 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3807 Blessed scalar = (Image *) SvIV(reference)
3809 image=INT2PTR(Image *,SvIV(reference));
3810 if (image != (Image *) NULL)
3811 DeleteImageFromRegistry(reference,image);
3820 ###############################################################################
3828 ###############################################################################
3833 Image::Magick ref=NO_INIT
3857 PERL_UNUSED_VAR(ref);
3858 PERL_UNUSED_VAR(ix);
3859 exception=AcquireExceptionInfo();
3860 perl_exception=newSVpv("",0);
3861 package_info=(struct PackageInfo *) NULL;
3862 if (sv_isobject(ST(0)) == 0)
3864 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3868 reference=SvRV(ST(0));
3869 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3870 if (image == (Image *) NULL)
3872 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3876 package_info=ClonePackageInfo(info,exception);
3878 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3881 for (i=2; i < items; i+=2)
3882 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3884 (void) DisplayImages(package_info->image_info,image,exception);
3885 (void) CatchImageException(image);
3888 if (package_info != (struct PackageInfo *) NULL)
3889 DestroyPackageInfo(package_info);
3890 InheritPerlException(exception,perl_exception);
3891 exception=DestroyExceptionInfo(exception);
3892 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3893 SvPOK_on(perl_exception);
3894 ST(0)=sv_2mortal(perl_exception);
3899 ###############################################################################
3903 # E v a l u a t e I m a g e s #
3907 ###############################################################################
3912 Image::Magick ref=NO_INIT
3934 MagickEvaluateOperator
3949 PERL_UNUSED_VAR(ref);
3950 PERL_UNUSED_VAR(ix);
3951 exception=AcquireExceptionInfo();
3952 perl_exception=newSVpv("",0);
3954 if (sv_isobject(ST(0)) == 0)
3956 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3960 reference=SvRV(ST(0));
3961 hv=SvSTASH(reference);
3962 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3963 if (image == (Image *) NULL)
3965 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3969 op=MeanEvaluateOperator;
3975 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3979 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3983 op=(MagickEvaluateOperator) in;
3986 for (i=2; i < items; i+=2)
3988 attribute=(char *) SvPV(ST(i-1),na);
3994 if (LocaleCompare(attribute,"operator") == 0)
3999 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4000 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4003 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4007 op=(MagickEvaluateOperator) in;
4010 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4016 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4022 image=EvaluateImages(image,op,exception);
4023 if (image == (Image *) NULL)
4026 Create blessed Perl array for the returned image.
4029 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4031 AddImageToRegistry(sv,image);
4033 av_push(av,sv_bless(rv,hv));
4035 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4036 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4037 "evaluate-%.*s",(int) (MagickPathExtent-9),
4038 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4039 (void) CopyMagickString(image->filename,info->image_info->filename,
4041 SetImageInfo(info->image_info,0,exception);
4042 exception=DestroyExceptionInfo(exception);
4043 SvREFCNT_dec(perl_exception);
4047 InheritPerlException(exception,perl_exception);
4048 exception=DestroyExceptionInfo(exception);
4049 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4050 SvPOK_on(perl_exception);
4051 ST(0)=sv_2mortal(perl_exception);
4056 ###############################################################################
4064 ###############################################################################
4069 Image::Magick ref=NO_INIT
4076 #define ChannelFeatures(channel,direction) \
4078 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4079 channel_features[channel].angular_second_moment[direction]); \
4080 PUSHs(sv_2mortal(newSVpv(message,0))); \
4081 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4082 channel_features[channel].contrast[direction]); \
4083 PUSHs(sv_2mortal(newSVpv(message,0))); \
4084 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4085 channel_features[channel].contrast[direction]); \
4086 PUSHs(sv_2mortal(newSVpv(message,0))); \
4087 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4088 channel_features[channel].variance_sum_of_squares[direction]); \
4089 PUSHs(sv_2mortal(newSVpv(message,0))); \
4090 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4091 channel_features[channel].inverse_difference_moment[direction]); \
4092 PUSHs(sv_2mortal(newSVpv(message,0))); \
4093 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4094 channel_features[channel].sum_average[direction]); \
4095 PUSHs(sv_2mortal(newSVpv(message,0))); \
4096 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4097 channel_features[channel].sum_variance[direction]); \
4098 PUSHs(sv_2mortal(newSVpv(message,0))); \
4099 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4100 channel_features[channel].sum_entropy[direction]); \
4101 PUSHs(sv_2mortal(newSVpv(message,0))); \
4102 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4103 channel_features[channel].entropy[direction]); \
4104 PUSHs(sv_2mortal(newSVpv(message,0))); \
4105 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4106 channel_features[channel].difference_variance[direction]); \
4107 PUSHs(sv_2mortal(newSVpv(message,0))); \
4108 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4109 channel_features[channel].difference_entropy[direction]); \
4110 PUSHs(sv_2mortal(newSVpv(message,0))); \
4111 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4112 channel_features[channel].measure_of_correlation_1[direction]); \
4113 PUSHs(sv_2mortal(newSVpv(message,0))); \
4114 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4115 channel_features[channel].measure_of_correlation_2[direction]); \
4116 PUSHs(sv_2mortal(newSVpv(message,0))); \
4117 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4118 channel_features[channel].maximum_correlation_coefficient[direction]); \
4119 PUSHs(sv_2mortal(newSVpv(message,0))); \
4127 message[MagickPathExtent];
4154 PERL_UNUSED_VAR(ref);
4155 PERL_UNUSED_VAR(ix);
4156 exception=AcquireExceptionInfo();
4157 perl_exception=newSVpv("",0);
4159 if (sv_isobject(ST(0)) == 0)
4161 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4165 reference=SvRV(ST(0));
4168 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4169 if (image == (Image *) NULL)
4171 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4176 for (i=2; i < items; i+=2)
4178 attribute=(char *) SvPV(ST(i-1),na);
4184 if (LocaleCompare(attribute,"distance") == 0)
4186 distance=StringToLong((char *) SvPV(ST(1),na));
4189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4195 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4202 for ( ; image; image=image->next)
4204 channel_features=GetImageFeatures(image,distance,exception);
4205 if (channel_features == (ChannelFeatures *) NULL)
4208 EXTEND(sp,280*count);
4209 for (i=0; i < 4; i++)
4211 ChannelFeatures(RedChannel,i);
4212 ChannelFeatures(GreenChannel,i);
4213 ChannelFeatures(BlueChannel,i);
4214 if (image->colorspace == CMYKColorspace)
4215 ChannelFeatures(BlackChannel,i);
4216 if (image->alpha_trait != UndefinedPixelTrait)
4217 ChannelFeatures(AlphaChannel,i);
4219 channel_features=(ChannelFeatures *)
4220 RelinquishMagickMemory(channel_features);
4224 InheritPerlException(exception,perl_exception);
4225 exception=DestroyExceptionInfo(exception);
4226 SvREFCNT_dec(perl_exception);
4230 ###############################################################################
4238 ###############################################################################
4243 Image::Magick ref=NO_INIT
4281 PERL_UNUSED_VAR(ref);
4282 PERL_UNUSED_VAR(ix);
4283 exception=AcquireExceptionInfo();
4284 perl_exception=newSVpv("",0);
4286 if (sv_isobject(ST(0)) == 0)
4288 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4292 reference=SvRV(ST(0));
4293 hv=SvSTASH(reference);
4294 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4295 if (image == (Image *) NULL)
4297 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4301 background_color=image->background_color;
4303 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4304 &background_color,exception);
4306 for (i=2; i < items; i+=2)
4308 attribute=(char *) SvPV(ST(i-1),na);
4314 if (LocaleCompare(attribute,"background") == 0)
4316 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4317 AllCompliance,&background_color,exception);
4320 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4326 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4332 image->background_color=background_color;
4333 image=MergeImageLayers(image,FlattenLayer,exception);
4334 if (image == (Image *) NULL)
4337 Create blessed Perl array for the returned image.
4340 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4342 AddImageToRegistry(sv,image);
4344 av_push(av,sv_bless(rv,hv));
4346 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4347 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4348 "flatten-%.*s",(int) (MagickPathExtent-9),
4349 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4350 (void) CopyMagickString(image->filename,info->image_info->filename,
4352 SetImageInfo(info->image_info,0,exception);
4353 exception=DestroyExceptionInfo(exception);
4354 SvREFCNT_dec(perl_exception);
4358 InheritPerlException(exception,perl_exception);
4359 exception=DestroyExceptionInfo(exception);
4360 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4361 SvPOK_on(perl_exception); /* return messages in string context */
4362 ST(0)=sv_2mortal(perl_exception);
4367 ###############################################################################
4375 ###############################################################################
4380 Image::Magick ref=NO_INIT
4392 expression[MagickPathExtent];
4420 PERL_UNUSED_VAR(ref);
4421 PERL_UNUSED_VAR(ix);
4422 exception=AcquireExceptionInfo();
4423 perl_exception=newSVpv("",0);
4427 if (sv_isobject(ST(0)) == 0)
4429 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4433 reference=SvRV(ST(0));
4434 hv=SvSTASH(reference);
4436 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4438 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4439 if (image == (Image *) NULL)
4441 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4445 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4449 channel=DefaultChannels;
4450 (void) CopyMagickString(expression,"u",MagickPathExtent);
4452 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4454 for (i=2; i < items; i+=2)
4456 attribute=(char *) SvPV(ST(i-1),na);
4462 if (LocaleCompare(attribute,"channel") == 0)
4467 option=ParseChannelOption(SvPV(ST(i),na));
4470 ThrowPerlException(exception,OptionError,
4471 "UnrecognizedType",SvPV(ST(i),na));
4474 channel=(ChannelType) option;
4477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4484 if (LocaleCompare(attribute,"expression") == 0)
4486 (void) CopyMagickString(expression,SvPV(ST(i),na),
4490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4496 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4502 channel_mask=SetImageChannelMask(image,channel);
4503 image=FxImage(image,expression,exception);
4504 if (image != (Image *) NULL)
4505 (void) SetImageChannelMask(image,channel_mask);
4506 if (image == (Image *) NULL)
4508 for ( ; image; image=image->next)
4510 AddImageToRegistry(sv,image);
4512 av_push(av,sv_bless(rv,hv));
4515 exception=DestroyExceptionInfo(exception);
4517 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4521 InheritPerlException(exception,perl_exception);
4522 exception=DestroyExceptionInfo(exception);
4523 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4524 SvPOK_on(perl_exception);
4525 ST(0)=sv_2mortal(perl_exception);
4530 ###############################################################################
4538 ###############################################################################
4543 Image::Magick ref=NO_INIT
4554 color[MagickPathExtent];
4579 PERL_UNUSED_VAR(ref);
4580 PERL_UNUSED_VAR(ix);
4581 exception=AcquireExceptionInfo();
4582 perl_exception=newSVpv("",0);
4583 if (sv_isobject(ST(0)) == 0)
4585 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4589 reference=SvRV(ST(0));
4590 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4591 if (image == (Image *) NULL && !info)
4594 for (i=1; i < items; i++)
4596 attribute=(char *) SvPV(ST(i),na);
4603 if (LocaleCompare(attribute,"adjoin") == 0)
4606 s=newSViv((ssize_t) info->image_info->adjoin);
4607 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4610 if (LocaleCompare(attribute,"antialias") == 0)
4613 s=newSViv((ssize_t) info->image_info->antialias);
4614 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4617 if (LocaleCompare(attribute,"area") == 0)
4619 s=newSViv(GetMagickResource(AreaResource));
4620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4623 if (LocaleCompare(attribute,"attenuate") == 0)
4628 value=GetImageProperty(image,attribute,exception);
4629 if (value != (const char *) NULL)
4631 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4634 if (LocaleCompare(attribute,"authenticate") == 0)
4641 option=GetImageOption(info->image_info,attribute);
4642 if (option != (const char *) NULL)
4643 s=newSVpv(option,0);
4645 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4648 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4655 if (LocaleCompare(attribute,"background") == 0)
4657 if (image == (Image *) NULL)
4659 (void) FormatLocaleString(color,MagickPathExtent,
4660 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4661 (double) image->background_color.green,
4662 (double) image->background_color.blue,
4663 (double) image->background_color.alpha);
4665 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4668 if (LocaleCompare(attribute,"base-columns") == 0)
4670 if (image != (Image *) NULL)
4671 s=newSViv((ssize_t) image->magick_columns);
4672 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4675 if (LocaleCompare(attribute,"base-filename") == 0)
4677 if (image != (Image *) NULL)
4678 s=newSVpv(image->magick_filename,0);
4679 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4682 if (LocaleCompare(attribute,"base-height") == 0)
4684 if (image != (Image *) NULL)
4685 s=newSViv((ssize_t) image->magick_rows);
4686 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4689 if (LocaleCompare(attribute,"base-rows") == 0)
4691 if (image != (Image *) NULL)
4692 s=newSViv((ssize_t) image->magick_rows);
4693 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4696 if (LocaleCompare(attribute,"base-width") == 0)
4698 if (image != (Image *) NULL)
4699 s=newSViv((ssize_t) image->magick_columns);
4700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4703 if (LocaleCompare(attribute,"blue-primary") == 0)
4705 if (image == (Image *) NULL)
4707 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4708 image->chromaticity.blue_primary.x,
4709 image->chromaticity.blue_primary.y);
4711 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4714 if (LocaleCompare(attribute,"bordercolor") == 0)
4716 if (image == (Image *) NULL)
4718 (void) FormatLocaleString(color,MagickPathExtent,
4719 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4720 (double) image->border_color.green,
4721 (double) image->border_color.blue,
4722 (double) image->border_color.alpha);
4724 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4727 if (LocaleCompare(attribute,"bounding-box") == 0)
4730 geometry[MagickPathExtent];
4735 if (image == (Image *) NULL)
4737 page=GetImageBoundingBox(image,exception);
4738 (void) FormatLocaleString(geometry,MagickPathExtent,
4739 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4740 page.height,(double) page.x,(double) page.y);
4741 s=newSVpv(geometry,0);
4742 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4745 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4752 if (LocaleCompare(attribute,"class") == 0)
4754 if (image == (Image *) NULL)
4756 s=newSViv(image->storage_class);
4757 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4758 image->storage_class));
4760 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4763 if (LocaleCompare(attribute,"clip-mask") == 0)
4765 if (image != (Image *) NULL)
4774 if (image->read_mask == MagickFalse)
4775 ClipImage(image,exception);
4776 mask_image=GetImageMask(image,ReadPixelMask,exception);
4777 if (mask_image != (Image *) NULL)
4779 AddImageToRegistry(sv,mask_image);
4780 s=sv_bless(newRV(sv),SvSTASH(reference));
4783 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4786 if (LocaleCompare(attribute,"clip-path") == 0)
4788 if (image != (Image *) NULL)
4797 if (image->read_mask != MagickFalse)
4798 ClipImage(image,exception);
4799 mask_image=GetImageMask(image,ReadPixelMask,exception);
4800 if (mask_image != (Image *) NULL)
4802 AddImageToRegistry(sv,mask_image);
4803 s=sv_bless(newRV(sv),SvSTASH(reference));
4806 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4809 if (LocaleCompare(attribute,"compression") == 0)
4811 j=info ? info->image_info->compression : image ?
4812 image->compression : UndefinedCompression;
4814 if (info->image_info->compression == UndefinedCompression)
4815 j=image->compression;
4817 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4820 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4823 if (LocaleCompare(attribute,"colorspace") == 0)
4825 j=image ? image->colorspace : RGBColorspace;
4827 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4830 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4833 if (LocaleCompare(attribute,"colors") == 0)
4835 if (image != (Image *) NULL)
4836 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4838 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4841 if (LocaleNCompare(attribute,"colormap",8) == 0)
4846 if (image == (Image *) NULL || !image->colormap)
4849 items=sscanf(attribute,"%*[^[][%ld",&j);
4851 if (j > (ssize_t) image->colors)
4853 (void) FormatLocaleString(color,MagickPathExtent,
4854 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4855 (double) image->colormap[j].green,
4856 (double) image->colormap[j].blue,
4857 (double) image->colormap[j].alpha);
4859 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4862 if (LocaleCompare(attribute,"columns") == 0)
4864 if (image != (Image *) NULL)
4865 s=newSViv((ssize_t) image->columns);
4866 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4869 if (LocaleCompare(attribute,"comment") == 0)
4874 value=GetImageProperty(image,attribute,exception);
4875 if (value != (const char *) NULL)
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 if (LocaleCompare(attribute,"copyright") == 0)
4882 s=newSVpv(GetMagickCopyright(),0);
4883 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4886 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4893 if (LocaleCompare(attribute,"density") == 0)
4896 geometry[MagickPathExtent];
4898 if (image == (Image *) NULL)
4900 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4901 image->resolution.x,image->resolution.y);
4902 s=newSVpv(geometry,0);
4903 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4906 if (LocaleCompare(attribute,"delay") == 0)
4908 if (image != (Image *) NULL)
4909 s=newSViv((ssize_t) image->delay);
4910 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4913 if (LocaleCompare(attribute,"depth") == 0)
4915 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4916 if (image != (Image *) NULL)
4917 s=newSViv((ssize_t) GetImageDepth(image,exception));
4918 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4921 if (LocaleCompare(attribute,"directory") == 0)
4923 if (image && image->directory)
4924 s=newSVpv(image->directory,0);
4925 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4928 if (LocaleCompare(attribute,"dispose") == 0)
4930 if (image == (Image *) NULL)
4933 s=newSViv(image->dispose);
4935 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"disk") == 0)
4942 s=newSViv(GetMagickResource(DiskResource));
4943 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4946 if (LocaleCompare(attribute,"dither") == 0)
4949 s=newSViv((ssize_t) info->image_info->dither);
4950 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4953 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4955 if (info && info->image_info->server_name)
4956 s=newSVpv(info->image_info->server_name,0);
4957 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4960 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4967 if (LocaleCompare(attribute,"elapsed-time") == 0)
4969 if (image != (Image *) NULL)
4970 s=newSVnv(GetElapsedTime(&image->timer));
4971 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4974 if (LocaleCompare(attribute,"endian") == 0)
4976 j=info ? info->image_info->endian : image ? image->endian :
4979 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4981 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4984 if (LocaleCompare(attribute,"error") == 0)
4986 if (image != (Image *) NULL)
4987 s=newSVnv(image->error.mean_error_per_pixel);
4988 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4991 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4998 if (LocaleCompare(attribute,"filesize") == 0)
5000 if (image != (Image *) NULL)
5001 s=newSViv((ssize_t) GetBlobSize(image));
5002 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5005 if (LocaleCompare(attribute,"filename") == 0)
5007 if (info && info->image_info->filename &&
5008 *info->image_info->filename)
5009 s=newSVpv(info->image_info->filename,0);
5010 if (image != (Image *) NULL)
5011 s=newSVpv(image->filename,0);
5012 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5015 if (LocaleCompare(attribute,"filter") == 0)
5017 s=image ? newSViv(image->filter) : newSViv(0);
5018 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5021 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5024 if (LocaleCompare(attribute,"font") == 0)
5026 if (info && info->image_info->font)
5027 s=newSVpv(info->image_info->font,0);
5028 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5031 if (LocaleCompare(attribute,"foreground") == 0)
5033 if (LocaleCompare(attribute,"format") == 0)
5038 magick_info=(const MagickInfo *) NULL;
5039 if (info && (*info->image_info->magick != '\0'))
5040 magick_info=GetMagickInfo(info->image_info->magick,exception);
5041 if (image != (Image *) NULL)
5042 magick_info=GetMagickInfo(image->magick,exception);
5043 if ((magick_info != (const MagickInfo *) NULL) &&
5044 (*magick_info->description != '\0'))
5045 s=newSVpv((char *) magick_info->description,0);
5046 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5049 if (LocaleCompare(attribute,"fuzz") == 0)
5052 s=newSVnv(info->image_info->fuzz);
5053 if (image != (Image *) NULL)
5054 s=newSVnv(image->fuzz);
5055 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5058 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5065 if (LocaleCompare(attribute,"gamma") == 0)
5067 if (image != (Image *) NULL)
5068 s=newSVnv(image->gamma);
5069 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5072 if (LocaleCompare(attribute,"geometry") == 0)
5074 if (image && image->geometry)
5075 s=newSVpv(image->geometry,0);
5076 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5079 if (LocaleCompare(attribute,"gravity") == 0)
5081 s=image ? newSViv(image->gravity) : newSViv(0);
5082 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5085 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5088 if (LocaleCompare(attribute,"green-primary") == 0)
5090 if (image == (Image *) NULL)
5092 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5093 image->chromaticity.green_primary.x,
5094 image->chromaticity.green_primary.y);
5096 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5099 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5106 if (LocaleCompare(attribute,"height") == 0)
5108 if (image != (Image *) NULL)
5109 s=newSViv((ssize_t) image->rows);
5110 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5113 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5120 if (LocaleCompare(attribute,"icc") == 0)
5122 if (image != (Image *) NULL)
5127 profile=GetImageProfile(image,"icc");
5128 if (profile != (StringInfo *) NULL)
5129 s=newSVpv((const char *) GetStringInfoDatum(profile),
5130 GetStringInfoLength(profile));
5132 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5135 if (LocaleCompare(attribute,"icm") == 0)
5137 if (image != (Image *) NULL)
5142 profile=GetImageProfile(image,"icm");
5143 if (profile != (const StringInfo *) NULL)
5144 s=newSVpv((const char *) GetStringInfoDatum(profile),
5145 GetStringInfoLength(profile));
5147 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5150 if (LocaleCompare(attribute,"id") == 0)
5152 if (image != (Image *) NULL)
5155 key[MagickPathExtent];
5163 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5165 status=SetImageRegistry(ImageRegistryType,key,image,
5170 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5173 if (LocaleNCompare(attribute,"index",5) == 0)
5176 name[MagickPathExtent];
5185 register const Quantum
5191 if (image == (Image *) NULL)
5193 if (image->storage_class != PseudoClass)
5197 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5199 image_view=AcquireVirtualCacheView(image,exception);
5200 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5201 if (p != (const Quantum *) NULL)
5203 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5204 GetPixelIndex(image,p));
5206 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5208 image_view=DestroyCacheView(image_view);
5211 if (LocaleCompare(attribute,"iptc") == 0)
5213 if (image != (Image *) NULL)
5218 profile=GetImageProfile(image,"iptc");
5219 if (profile != (const StringInfo *) NULL)
5220 s=newSVpv((const char *) GetStringInfoDatum(profile),
5221 GetStringInfoLength(profile));
5223 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5226 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5228 if (image != (Image *) NULL)
5229 s=newSViv((ssize_t) image->iterations);
5230 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5233 if (LocaleCompare(attribute,"interlace") == 0)
5235 j=info ? info->image_info->interlace : image ? image->interlace :
5238 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5241 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5244 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5251 if (LocaleCompare(attribute,"label") == 0)
5256 if (image == (Image *) NULL)
5258 value=GetImageProperty(image,"Label",exception);
5259 if (value != (const char *) NULL)
5261 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5264 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5266 if (image != (Image *) NULL)
5267 s=newSViv((ssize_t) image->iterations);
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5278 if (LocaleCompare(attribute,"magick") == 0)
5280 if (info && *info->image_info->magick)
5281 s=newSVpv(info->image_info->magick,0);
5282 if (image != (Image *) NULL)
5283 s=newSVpv(image->magick,0);
5284 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5287 if (LocaleCompare(attribute,"map") == 0)
5289 s=newSViv(GetMagickResource(MapResource));
5290 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5293 if (LocaleCompare(attribute,"maximum-error") == 0)
5295 if (image != (Image *) NULL)
5296 s=newSVnv(image->error.normalized_maximum_error);
5297 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5300 if (LocaleCompare(attribute,"memory") == 0)
5302 s=newSViv(GetMagickResource(MemoryResource));
5303 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5306 if (LocaleCompare(attribute,"mean-error") == 0)
5308 if (image != (Image *) NULL)
5309 s=newSVnv(image->error.normalized_mean_error);
5310 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5313 if (LocaleCompare(attribute,"mime") == 0)
5315 if (info && *info->image_info->magick)
5316 s=newSVpv(MagickToMime(info->image_info->magick),0);
5317 if (image != (Image *) NULL)
5318 s=newSVpv(MagickToMime(image->magick),0);
5319 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5322 if (LocaleCompare(attribute,"mattecolor") == 0)
5324 if (image == (Image *) NULL)
5326 (void) FormatLocaleString(color,MagickPathExtent,
5327 "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red,
5328 (double) image->alpha_color.green,
5329 (double) image->alpha_color.blue,
5330 (double) image->alpha_color.alpha);
5332 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5335 if (LocaleCompare(attribute,"matte") == 0)
5337 if (image != (Image *) NULL)
5338 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5340 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5343 if (LocaleCompare(attribute,"mime") == 0)
5349 if (info && *info->image_info->magick)
5350 magick=info->image_info->magick;
5351 if (image != (Image *) NULL)
5352 magick=image->magick;
5358 mime=MagickToMime(magick);
5360 mime=(char *) RelinquishMagickMemory(mime);
5362 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5365 if (LocaleCompare(attribute,"monochrome") == 0)
5367 if (image == (Image *) NULL)
5369 j=info ? info->image_info->monochrome :
5370 SetImageMonochrome(image,exception);
5372 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5375 if (LocaleCompare(attribute,"montage") == 0)
5377 if (image && image->montage)
5378 s=newSVpv(image->montage,0);
5379 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5382 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5389 if (LocaleCompare(attribute,"orientation") == 0)
5391 j=info ? info->image_info->orientation : image ?
5392 image->orientation : UndefinedOrientation;
5394 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5397 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5407 if (LocaleCompare(attribute,"page") == 0)
5409 if (info && info->image_info->page)
5410 s=newSVpv(info->image_info->page,0);
5411 if (image != (Image *) NULL)
5414 geometry[MagickPathExtent];
5416 (void) FormatLocaleString(geometry,MagickPathExtent,
5417 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5418 (double) image->page.height,(double) image->page.x,(double)
5420 s=newSVpv(geometry,0);
5422 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5425 if (LocaleCompare(attribute,"page.x") == 0)
5427 if (image != (Image *) NULL)
5428 s=newSViv((ssize_t) image->page.x);
5429 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5432 if (LocaleCompare(attribute,"page.y") == 0)
5434 if (image != (Image *) NULL)
5435 s=newSViv((ssize_t) image->page.y);
5436 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5439 if (LocaleNCompare(attribute,"pixel",5) == 0)
5442 tuple[MagickPathExtent];
5451 register const Quantum
5454 if (image == (Image *) NULL)
5458 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5460 p=GetVirtualPixels(image,x,y,1,1,exception);
5461 if (image->colorspace != CMYKColorspace)
5462 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5463 QuantumFormat "," QuantumFormat "," QuantumFormat,
5464 GetPixelRed(image,p),GetPixelGreen(image,p),
5465 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5467 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5468 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5469 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5470 GetPixelBlue(image,p),GetPixelBlack(image,p),
5471 GetPixelAlpha(image,p));
5473 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5476 if (LocaleCompare(attribute,"pointsize") == 0)
5479 s=newSViv((ssize_t) info->image_info->pointsize);
5480 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5483 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5490 if (LocaleCompare(attribute,"quality") == 0)
5493 s=newSViv((ssize_t) info->image_info->quality);
5494 if (image != (Image *) NULL)
5495 s=newSViv((ssize_t) image->quality);
5496 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5499 if (LocaleCompare(attribute,"quantum") == 0)
5502 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5503 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5513 if (LocaleCompare(attribute,"rendering-intent") == 0)
5515 s=newSViv(image->rendering_intent);
5516 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5517 image->rendering_intent));
5519 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5522 if (LocaleCompare(attribute,"red-primary") == 0)
5524 if (image == (Image *) NULL)
5526 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5527 image->chromaticity.red_primary.x,
5528 image->chromaticity.red_primary.y);
5530 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5533 if (LocaleCompare(attribute,"rows") == 0)
5535 if (image != (Image *) NULL)
5536 s=newSViv((ssize_t) image->rows);
5537 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5547 if (LocaleCompare(attribute,"sampling-factor") == 0)
5549 if (info && info->image_info->sampling_factor)
5550 s=newSVpv(info->image_info->sampling_factor,0);
5551 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5554 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5556 if (info && info->image_info->server_name)
5557 s=newSVpv(info->image_info->server_name,0);
5558 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5561 if (LocaleCompare(attribute,"size") == 0)
5563 if (info && info->image_info->size)
5564 s=newSVpv(info->image_info->size,0);
5565 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5568 if (LocaleCompare(attribute,"scene") == 0)
5570 if (image != (Image *) NULL)
5571 s=newSViv((ssize_t) image->scene);
5572 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5575 if (LocaleCompare(attribute,"scenes") == 0)
5577 if (image != (Image *) NULL)
5578 s=newSViv((ssize_t) info->image_info->number_scenes);
5579 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5582 if (LocaleCompare(attribute,"signature") == 0)
5587 if (image == (Image *) NULL)
5589 (void) SignatureImage(image,exception);
5590 value=GetImageProperty(image,"Signature",exception);
5591 if (value != (const char *) NULL)
5593 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5596 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5603 if (LocaleCompare(attribute,"taint") == 0)
5605 if (image != (Image *) NULL)
5606 s=newSViv((ssize_t) IsTaintImage(image));
5607 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5610 if (LocaleCompare(attribute,"texture") == 0)
5612 if (info && info->image_info->texture)
5613 s=newSVpv(info->image_info->texture,0);
5614 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5617 if (LocaleCompare(attribute,"total-ink-density") == 0)
5619 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5620 if (image != (Image *) NULL)
5621 s=newSVnv(GetImageTotalInkDensity(image,exception));
5622 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5625 if (LocaleCompare(attribute,"transparent-color") == 0)
5627 if (image == (Image *) NULL)
5629 (void) FormatLocaleString(color,MagickPathExtent,
5630 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5631 (double) image->transparent_color.green,
5632 (double) image->transparent_color.blue,
5633 (double) image->transparent_color.alpha);
5635 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5638 if (LocaleCompare(attribute,"type") == 0)
5640 if (image == (Image *) NULL)
5642 j=(ssize_t) GetImageType(image);
5644 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5646 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5649 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5656 if (LocaleCompare(attribute,"units") == 0)
5658 j=info ? info->image_info->units : image ? image->units :
5659 UndefinedResolution;
5660 if (info && (info->image_info->units == UndefinedResolution))
5663 if (j == UndefinedResolution)
5664 s=newSVpv("undefined units",0);
5666 if (j == PixelsPerInchResolution)
5667 s=newSVpv("pixels / inch",0);
5669 s=newSVpv("pixels / centimeter",0);
5670 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5673 if (LocaleCompare(attribute,"user-time") == 0)
5675 if (image != (Image *) NULL)
5676 s=newSVnv(GetUserTime(&image->timer));
5677 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5680 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5687 if (LocaleCompare(attribute,"verbose") == 0)
5690 s=newSViv((ssize_t) info->image_info->verbose);
5691 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5694 if (LocaleCompare(attribute,"version") == 0)
5696 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5700 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5702 if (image == (Image *) NULL)
5704 j=(ssize_t) GetImageVirtualPixelMethod(image);
5706 (void) sv_setpv(s,CommandOptionToMnemonic(
5707 MagickVirtualPixelOptions,j));
5709 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5719 if (LocaleCompare(attribute,"white-point") == 0)
5721 if (image == (Image *) NULL)
5723 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5724 image->chromaticity.white_point.x,
5725 image->chromaticity.white_point.y);
5727 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5730 if (LocaleCompare(attribute,"width") == 0)
5732 if (image != (Image *) NULL)
5733 s=newSViv((ssize_t) image->columns);
5734 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5737 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5744 if (LocaleCompare(attribute,"xmp") == 0)
5746 if (image != (Image *) NULL)
5751 profile=GetImageProfile(image,"xmp");
5752 if (profile != (StringInfo *) NULL)
5753 s=newSVpv((const char *) GetStringInfoDatum(profile),
5754 GetStringInfoLength(profile));
5756 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5759 if (LocaleCompare(attribute,"x-resolution") == 0)
5761 if (image != (Image *) NULL)
5762 s=newSVnv(image->resolution.x);
5763 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5766 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5773 if (LocaleCompare(attribute,"y-resolution") == 0)
5775 if (image != (Image *) NULL)
5776 s=newSVnv(image->resolution.y);
5777 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5780 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5787 if (image == (Image *) NULL)
5788 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5792 value=GetImageProperty(image,attribute,exception);
5793 if (value != (const char *) NULL)
5796 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5799 if (*attribute != '%')
5800 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5807 meta=InterpretImageProperties(info ? info->image_info :
5808 (ImageInfo *) NULL,image,attribute,exception);
5810 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5811 meta=(char *) RelinquishMagickMemory(meta);
5815 exception=DestroyExceptionInfo(exception);
5816 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5820 ###############################################################################
5824 # G e t A u t h e n t i c P i x e l s #
5828 ###############################################################################
5832 GetAuthenticPixels(ref,...)
5833 Image::Magick ref = NO_INIT
5835 getauthenticpixels = 1
5865 PERL_UNUSED_VAR(ref);
5866 PERL_UNUSED_VAR(ix);
5867 exception=AcquireExceptionInfo();
5868 perl_exception=newSVpv("",0);
5869 if (sv_isobject(ST(0)) == 0)
5871 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5875 reference=SvRV(ST(0));
5877 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5878 if (image == (Image *) NULL)
5880 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5887 region.width=image->columns;
5890 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5891 for (i=2; i < items; i+=2)
5893 attribute=(char *) SvPV(ST(i-1),na);
5899 if (LocaleCompare(attribute,"geometry") == 0)
5901 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5904 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5911 if (LocaleCompare(attribute,"height") == 0)
5913 region.height=SvIV(ST(i));
5916 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5923 if (LocaleCompare(attribute,"x") == 0)
5925 region.x=SvIV(ST(i));
5928 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5935 if (LocaleCompare(attribute,"y") == 0)
5937 region.y=SvIV(ST(i));
5940 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5947 if (LocaleCompare(attribute,"width") == 0)
5949 region.width=SvIV(ST(i));
5952 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5958 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5959 region.height,exception);
5960 if (blob != (void *) NULL)
5964 InheritPerlException(exception,perl_exception);
5965 exception=DestroyExceptionInfo(exception);
5966 SvREFCNT_dec(perl_exception); /* throw away all errors */
5975 ###############################################################################
5979 # G e t V i r t u a l P i x e l s #
5983 ###############################################################################
5987 GetVirtualPixels(ref,...)
5988 Image::Magick ref = NO_INIT
5990 getvirtualpixels = 1
5991 AcquireImagePixels = 2
5992 acquireimagepixels = 3
6020 PERL_UNUSED_VAR(ref);
6021 PERL_UNUSED_VAR(ix);
6022 exception=AcquireExceptionInfo();
6023 perl_exception=newSVpv("",0);
6024 if (sv_isobject(ST(0)) == 0)
6026 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6030 reference=SvRV(ST(0));
6032 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6033 if (image == (Image *) NULL)
6035 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6042 region.width=image->columns;
6045 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6046 for (i=2; i < items; i+=2)
6048 attribute=(char *) SvPV(ST(i-1),na);
6054 if (LocaleCompare(attribute,"geometry") == 0)
6056 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6066 if (LocaleCompare(attribute,"height") == 0)
6068 region.height=SvIV(ST(i));
6071 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6078 if (LocaleCompare(attribute,"x") == 0)
6080 region.x=SvIV(ST(i));
6083 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6090 if (LocaleCompare(attribute,"y") == 0)
6092 region.y=SvIV(ST(i));
6095 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6102 if (LocaleCompare(attribute,"width") == 0)
6104 region.width=SvIV(ST(i));
6107 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6113 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6114 region.height,exception);
6115 if (blob != (void *) NULL)
6119 InheritPerlException(exception,perl_exception);
6120 exception=DestroyExceptionInfo(exception);
6121 SvREFCNT_dec(perl_exception); /* throw away all errors */
6124 RETVAL = (void *) blob;
6130 ###############################################################################
6134 # G e t A u t h e n t i c M e t a c o n t e n t #
6138 ###############################################################################
6142 GetAuthenticMetacontent(ref,...)
6143 Image::Magick ref = NO_INIT
6145 getauthenticmetacontent = 1
6166 PERL_UNUSED_VAR(ref);
6167 PERL_UNUSED_VAR(ix);
6168 exception=AcquireExceptionInfo();
6169 perl_exception=newSVpv("",0);
6170 if (sv_isobject(ST(0)) == 0)
6172 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6176 reference=SvRV(ST(0));
6178 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6179 if (image == (Image *) NULL)
6181 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6186 blob=(void *) GetAuthenticMetacontent(image);
6187 if (blob != (void *) NULL)
6191 InheritPerlException(exception,perl_exception);
6192 exception=DestroyExceptionInfo(exception);
6193 SvREFCNT_dec(perl_exception); /* throw away all errors */
6202 ###############################################################################
6206 # G e t V i r t u a l M e t a c o n t e n t #
6210 ###############################################################################
6214 GetVirtualMetacontent(ref,...)
6215 Image::Magick ref = NO_INIT
6217 getvirtualmetacontent = 1
6236 PERL_UNUSED_VAR(ref);
6237 PERL_UNUSED_VAR(ix);
6238 exception=AcquireExceptionInfo();
6239 perl_exception=newSVpv("",0);
6240 if (sv_isobject(ST(0)) == 0)
6242 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6246 reference=SvRV(ST(0));
6248 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6249 if (image == (Image *) NULL)
6251 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6256 blob=(void *) GetVirtualMetacontent(image);
6257 if (blob != (void *) NULL)
6261 InheritPerlException(exception,perl_exception);
6262 exception=DestroyExceptionInfo(exception);
6263 SvREFCNT_dec(perl_exception); /* throw away all errors */
6272 ###############################################################################
6276 # H i s t o g r a m #
6280 ###############################################################################
6285 Image::Magick ref=NO_INIT
6296 message[MagickPathExtent];
6323 PERL_UNUSED_VAR(ref);
6324 PERL_UNUSED_VAR(ix);
6325 exception=AcquireExceptionInfo();
6326 perl_exception=newSVpv("",0);
6328 if (sv_isobject(ST(0)) == 0)
6330 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6334 reference=SvRV(ST(0));
6337 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6338 if (image == (Image *) NULL)
6340 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6345 for ( ; image; image=image->next)
6347 histogram=GetImageHistogram(image,&number_colors,exception);
6348 if (histogram == (PixelInfo *) NULL)
6350 count+=(ssize_t) number_colors;
6352 for (i=0; i < (ssize_t) number_colors; i++)
6354 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6356 PUSHs(sv_2mortal(newSVpv(message,0)));
6357 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6358 histogram[i].green);
6359 PUSHs(sv_2mortal(newSVpv(message,0)));
6360 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6362 PUSHs(sv_2mortal(newSVpv(message,0)));
6363 if (image->colorspace == CMYKColorspace)
6365 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6366 histogram[i].black);
6367 PUSHs(sv_2mortal(newSVpv(message,0)));
6369 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6370 histogram[i].alpha);
6371 PUSHs(sv_2mortal(newSVpv(message,0)));
6372 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6373 histogram[i].count);
6374 PUSHs(sv_2mortal(newSVpv(message,0)));
6376 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6380 InheritPerlException(exception,perl_exception);
6381 exception=DestroyExceptionInfo(exception);
6382 SvREFCNT_dec(perl_exception);
6386 ###############################################################################
6394 ###############################################################################
6399 Image::Magick ref=NO_INIT
6423 register const Quantum
6437 *reference; /* reference is the SV* of ref=SvIV(reference) */
6439 PERL_UNUSED_VAR(ref);
6440 PERL_UNUSED_VAR(ix);
6441 exception=AcquireExceptionInfo();
6442 perl_exception=newSVpv("",0);
6443 reference=SvRV(ST(0));
6444 av=(AV *) reference;
6445 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6447 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6448 if (image == (Image *) NULL)
6450 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6454 normalize=MagickTrue;
6457 region.width=image->columns;
6460 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6461 for (i=2; i < items; i+=2)
6463 attribute=(char *) SvPV(ST(i-1),na);
6469 if (LocaleCompare(attribute,"channel") == 0)
6474 option=ParseChannelOption(SvPV(ST(i),na));
6477 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6481 (void) SetPixelChannelMask(image,(ChannelType) option);
6484 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6491 if (LocaleCompare(attribute,"geometry") == 0)
6493 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6496 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6503 if (LocaleCompare(attribute,"normalize") == 0)
6505 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6509 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6513 normalize=option != 0 ? MagickTrue : MagickFalse;
6516 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6523 if (LocaleCompare(attribute,"x") == 0)
6525 region.x=SvIV(ST(i));
6528 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6535 if (LocaleCompare(attribute,"y") == 0)
6537 region.y=SvIV(ST(i));
6540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6546 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6552 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6553 if (p == (const Quantum *) NULL)
6561 if (normalize != MagickFalse)
6562 scale=1.0/QuantumRange;
6563 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6564 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6565 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6566 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6567 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6568 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6569 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6570 (image->colorspace == CMYKColorspace))
6571 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6572 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6573 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6577 InheritPerlException(exception,perl_exception);
6578 exception=DestroyExceptionInfo(exception);
6579 SvREFCNT_dec(perl_exception);
6583 ###############################################################################
6587 # G e t P i x e l s #
6591 ###############################################################################
6596 Image::Magick ref=NO_INIT
6635 *reference; /* reference is the SV* of ref=SvIV(reference) */
6637 PERL_UNUSED_VAR(ref);
6638 PERL_UNUSED_VAR(ix);
6639 exception=AcquireExceptionInfo();
6640 perl_exception=newSVpv("",0);
6641 reference=SvRV(ST(0));
6642 av=(AV *) reference;
6643 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6645 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6646 if (image == (Image *) NULL)
6648 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6653 if (image->alpha_trait != UndefinedPixelTrait)
6655 if (image->colorspace == CMYKColorspace)
6658 if (image->alpha_trait != UndefinedPixelTrait)
6661 normalize=MagickFalse;
6664 region.width=image->columns;
6667 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6668 for (i=2; i < items; i+=2)
6670 attribute=(char *) SvPV(ST(i-1),na);
6676 if (LocaleCompare(attribute,"geometry") == 0)
6678 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6688 if (LocaleCompare(attribute,"height") == 0)
6690 region.height=SvIV(ST(i));
6693 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6700 if (LocaleCompare(attribute,"map") == 0)
6705 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6712 if (LocaleCompare(attribute,"normalize") == 0)
6714 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6718 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6722 normalize=option != 0 ? MagickTrue : MagickFalse;
6725 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6732 if (LocaleCompare(attribute,"width") == 0)
6734 region.width=SvIV(ST(i));
6737 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6744 if (LocaleCompare(attribute,"x") == 0)
6746 region.x=SvIV(ST(i));
6749 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6756 if (LocaleCompare(attribute,"y") == 0)
6758 region.y=SvIV(ST(i));
6761 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6767 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6773 if (normalize != MagickFalse)
6778 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6779 region.height*sizeof(*pixels));
6780 if (pixels == (float *) NULL)
6782 ThrowPerlException(exception,ResourceLimitError,
6783 "MemoryAllocationFailed",PackageName);
6786 status=ExportImagePixels(image,region.x,region.y,region.width,
6787 region.height,map,FloatPixel,pixels,exception);
6788 if (status == MagickFalse)
6792 EXTEND(sp,strlen(map)*region.width*region.height);
6793 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6794 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6796 pixels=(float *) RelinquishMagickMemory(pixels);
6803 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6804 region.height*sizeof(*pixels));
6805 if (pixels == (Quantum *) NULL)
6807 ThrowPerlException(exception,ResourceLimitError,
6808 "MemoryAllocationFailed",PackageName);
6811 status=ExportImagePixels(image,region.x,region.y,region.width,
6812 region.height,map,QuantumPixel,pixels,exception);
6813 if (status == MagickFalse)
6817 EXTEND(sp,strlen(map)*region.width*region.height);
6818 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6819 PUSHs(sv_2mortal(newSViv(pixels[i])));
6821 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6825 InheritPerlException(exception,perl_exception);
6826 exception=DestroyExceptionInfo(exception);
6827 SvREFCNT_dec(perl_exception);
6831 ###############################################################################
6835 # I m a g e T o B l o b #
6839 ###############################################################################
6843 ImageToBlob(ref,...)
6844 Image::Magick ref=NO_INIT
6853 filename[MagickPathExtent];
6882 PERL_UNUSED_VAR(ref);
6883 PERL_UNUSED_VAR(ix);
6884 exception=AcquireExceptionInfo();
6885 perl_exception=newSVpv("",0);
6886 package_info=(struct PackageInfo *) NULL;
6887 if (sv_isobject(ST(0)) == 0)
6889 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6893 reference=SvRV(ST(0));
6894 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6895 if (image == (Image *) NULL)
6897 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6901 package_info=ClonePackageInfo(info,exception);
6902 for (i=2; i < items; i+=2)
6903 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6904 (void) CopyMagickString(filename,package_info->image_info->filename,
6907 for (next=image; next; next=next->next)
6909 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6910 next->scene=scene++;
6912 SetImageInfo(package_info->image_info,(unsigned int)
6913 GetImageListLength(image),exception);
6914 EXTEND(sp,(ssize_t) GetImageListLength(image));
6915 for ( ; image; image=image->next)
6918 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6919 if (blob != (char *) NULL)
6921 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6922 blob=(unsigned char *) RelinquishMagickMemory(blob);
6924 if (package_info->image_info->adjoin)
6929 if (package_info != (struct PackageInfo *) NULL)
6930 DestroyPackageInfo(package_info);
6931 InheritPerlException(exception,perl_exception);
6932 exception=DestroyExceptionInfo(exception);
6933 SvREFCNT_dec(perl_exception); /* throw away all errors */
6937 ###############################################################################
6945 ###############################################################################
6950 Image::Magick ref=NO_INIT
6954 OptimizeImageLayers = 3
6956 optimizeimagelayers = 5
6998 PERL_UNUSED_VAR(ref);
6999 PERL_UNUSED_VAR(ix);
7000 exception=AcquireExceptionInfo();
7001 perl_exception=newSVpv("",0);
7003 if (sv_isobject(ST(0)) == 0)
7005 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7009 reference=SvRV(ST(0));
7010 hv=SvSTASH(reference);
7012 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7014 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7015 if (image == (Image *) NULL)
7017 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7021 compose=image->compose;
7022 method=OptimizeLayer;
7023 for (i=2; i < items; i+=2)
7025 attribute=(char *) SvPV(ST(i-1),na);
7031 if (LocaleCompare(attribute,"compose") == 0)
7033 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7034 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7037 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7041 compose=(CompositeOperator) sp;
7044 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7051 if (LocaleCompare(attribute,"method") == 0)
7053 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7057 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7061 method=(LayerMethod) option;
7064 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7070 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7076 layers=(Image *) NULL;
7079 case CompareAnyLayer:
7080 case CompareClearLayer:
7081 case CompareOverlayLayer:
7084 layers=CompareImagesLayers(image,method,exception);
7091 layers=MergeImageLayers(image,method,exception);
7096 layers=DisposeImages(image,exception);
7099 case OptimizeImageLayer:
7101 layers=OptimizeImageLayers(image,exception);
7104 case OptimizePlusLayer:
7106 layers=OptimizePlusImageLayers(image,exception);
7109 case OptimizeTransLayer:
7111 OptimizeImageTransparency(image,exception);
7114 case RemoveDupsLayer:
7116 RemoveDuplicateLayers(&image,exception);
7119 case RemoveZeroLayer:
7121 RemoveZeroDelayLayers(&image,exception);
7130 General Purpose, GIF Animation Optimizer.
7132 layers=CoalesceImages(image,exception);
7133 if (layers == (Image *) NULL)
7136 layers=OptimizeImageLayers(image,exception);
7137 if (layers == (Image *) NULL)
7139 image=DestroyImageList(image);
7141 layers=(Image *) NULL;
7142 OptimizeImageTransparency(image,exception);
7143 quantize_info=AcquireQuantizeInfo(info->image_info);
7144 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7145 quantize_info=DestroyQuantizeInfo(quantize_info);
7148 case CompositeLayer:
7157 Split image sequence at the first 'NULL:' image.
7160 while (source != (Image *) NULL)
7162 source=GetNextImageInList(source);
7163 if ((source != (Image *) NULL) &&
7164 (LocaleCompare(source->magick,"NULL") == 0))
7167 if (source != (Image *) NULL)
7169 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7170 (GetNextImageInList(source) == (Image *) NULL))
7171 source=(Image *) NULL;
7175 Separate the two lists, junk the null: image.
7177 source=SplitImageList(source->previous);
7178 DeleteImageFromList(&source);
7181 if (source == (Image *) NULL)
7183 (void) ThrowMagickException(exception,GetMagickModule(),
7184 OptionError,"MissingNullSeparator","layers Composite");
7188 Adjust offset with gravity and virtual canvas.
7190 SetGeometry(image,&geometry);
7191 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7192 geometry.width=source->page.width != 0 ? source->page.width :
7194 geometry.height=source->page.height != 0 ? source->page.height :
7196 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7197 image->columns,image->page.height != 0 ? image->page.height :
7198 image->rows,image->gravity,&geometry);
7199 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7200 source=DestroyImageList(source);
7204 if (layers != (Image *) NULL)
7207 image=CloneImage(image,0,0,MagickTrue,exception);
7208 if (image == (Image *) NULL)
7210 for ( ; image; image=image->next)
7212 AddImageToRegistry(sv,image);
7214 av_push(av,sv_bless(rv,hv));
7217 exception=DestroyExceptionInfo(exception);
7219 SvREFCNT_dec(perl_exception);
7223 InheritPerlException(exception,perl_exception);
7224 exception=DestroyExceptionInfo(exception);
7225 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7226 SvPOK_on(perl_exception);
7227 ST(0)=sv_2mortal(perl_exception);
7232 ###############################################################################
7236 # M a g i c k T o M i m e #
7240 ###############################################################################
7244 MagickToMime(ref,name)
7245 Image::Magick ref=NO_INIT
7254 PERL_UNUSED_VAR(ref);
7255 PERL_UNUSED_VAR(ix);
7256 mime=MagickToMime(name);
7257 RETVAL=newSVpv(mime,0);
7258 mime=(char *) RelinquishMagickMemory(mime);
7264 ###############################################################################
7272 ###############################################################################
7277 Image::Magick ref=NO_INIT
7314 MedianConvolveImage = 36
7320 ReduceNoiseImage = 42
7346 ColorFloodfillImage= 68
7352 CycleColormapImage = 74
7362 MatteFloodfillImage= 84
7370 NumberColorsImage = 92
7380 SignatureImage = 102
7390 TransparentImage = 112
7392 ThresholdImage = 114
7406 DeconstructImage = 130
7408 GaussianBlurImage = 132
7414 UnsharpMaskImage = 138
7416 MotionBlurImage = 140
7418 OrderedDitherImage = 142
7425 AffineTransform = 149
7426 AffineTransformImage = 150
7428 DifferenceImage = 152
7429 AdaptiveThreshold = 153
7430 AdaptiveThresholdImage = 154
7435 BlackThreshold = 159
7436 BlackThresholdImage= 160
7437 WhiteThreshold = 161
7438 WhiteThresholdImage= 162
7439 RotationalBlur = 163
7440 RotationalBlurImage= 164
7442 ThumbnailImage = 166
7452 PosterizeImage = 176
7458 SepiaToneImage = 182
7459 SigmoidalContrast = 183
7460 SigmoidalContrastImage = 184
7465 ContrastStretch = 189
7466 ContrastStretchImage = 190
7471 AdaptiveSharpen = 195
7472 AdaptiveSharpenImage = 196
7474 TransposeImage = 198
7476 TransverseImage = 200
7478 AutoOrientImage = 202
7480 AdaptiveBlurImage = 204
7484 UniqueColorsImage = 208
7485 AdaptiveResize = 209
7486 AdaptiveResizeImage= 210
7490 LinearStretchImage = 214
7492 ColorMatrixImage = 216
7497 FloodfillPaint = 221
7498 FloodfillPaintImage= 222
7504 LiquidRescaleImage = 228
7514 SparseColorImage = 238
7518 SelectiveBlurImage = 242
7522 BlueShiftImage = 246
7523 ForwardFourierTransform = 247
7524 ForwardFourierTransformImage = 248
7525 InverseFourierTransform = 249
7526 InverseFourierTransformImage = 250
7527 ColorDecisionList = 251
7528 ColorDecisionListImage = 252
7530 AutoGammaImage = 254
7532 AutoLevelImage = 256
7534 LevelImageColors = 258
7537 BrightnessContrast = 261
7538 BrightnessContrastImage = 262
7540 MorphologyImage = 264
7544 StatisticImage = 268
7546 PerceptibleImage = 270
7550 GrayscaleImage = 274
7552 CannyEdgeImage = 276
7554 HoughLineImage = 278
7556 MeanShiftImage = 280
7559 ConnectedComponent = 283
7560 ConnectedComponentImage = 284
7562 CopyImagePixels = 286
7565 WaveletDenoise = 289
7566 WaveletDenoiseImage= 290
7568 ColorspaceImage = 292
7577 attribute_flag[MaxArguments],
7578 message[MagickPathExtent];
7639 argument_list[MaxArguments];
7641 PERL_UNUSED_VAR(ref);
7642 PERL_UNUSED_VAR(ix);
7643 exception=AcquireExceptionInfo();
7644 perl_exception=newSVpv("",0);
7645 reference_vector=NULL;
7649 if (sv_isobject(ST(0)) == 0)
7651 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7655 reference=SvRV(ST(0));
7656 region_info.width=0;
7657 region_info.height=0;
7660 region_image=(Image *) NULL;
7661 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7662 if (ix && (ix != 666))
7665 Called as Method(...)
7668 rp=(&Methods[ix-1]);
7674 Called as Mogrify("Method",...)
7676 attribute=(char *) SvPV(ST(1),na);
7679 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7680 attribute=(char *) SvPV(ST(2),na);
7683 for (rp=Methods; ; rp++)
7685 if (rp >= EndOf(Methods))
7687 ThrowPerlException(exception,OptionError,
7688 "UnrecognizedPerlMagickMethod",attribute);
7691 if (strEQcase(attribute,rp->name))
7697 if (image == (Image *) NULL)
7699 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7702 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7703 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7704 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7721 pp=(Arguments *) NULL;
7729 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7731 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7733 if (strEQcase(attribute,qq->method) > ssize_test)
7736 ssize_test=strEQcase(attribute,qq->method);
7739 if (pp == (Arguments *) NULL)
7741 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7743 goto continue_outer_loop;
7745 al=(&argument_list[pp-rp->arguments]);
7748 case ArrayReference:
7750 if (SvTYPE(sv) != SVt_RV)
7752 (void) FormatLocaleString(message,MagickPathExtent,
7753 "invalid %.60s value",pp->method);
7754 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7755 goto continue_outer_loop;
7757 al->array_reference=SvRV(sv);
7762 al->real_reference=SvNV(sv);
7767 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7770 case ImageReference:
7772 if (!sv_isobject(sv) ||
7773 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7774 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7776 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7782 case IntegerReference:
7784 al->integer_reference=SvIV(sv);
7787 case StringReference:
7789 al->string_reference=(char *) SvPV(sv,al->length);
7790 if (sv_isobject(sv))
7791 al->image_reference=SetupList(aTHX_ SvRV(sv),
7792 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7798 Is a string; look up name.
7800 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7802 al->string_reference=(char *) SvPV(sv,al->length);
7803 al->integer_reference=(-1);
7806 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7807 MagickFalse,SvPV(sv,na));
7808 if (pp->type == MagickChannelOptions)
7809 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7810 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7812 (void) FormatLocaleString(message,MagickPathExtent,
7813 "invalid %.60s value",pp->method);
7814 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7815 goto continue_outer_loop;
7820 attribute_flag[pp-rp->arguments]++;
7821 continue_outer_loop: ;
7823 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7824 pv=reference_vector;
7825 SetGeometryInfo(&geometry_info);
7826 channel=DefaultChannels;
7827 for (next=image; next; next=next->next)
7830 SetGeometry(image,&geometry);
7831 if ((region_info.width*region_info.height) != 0)
7834 image=CropImage(image,®ion_info,exception);
7840 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7841 ThrowPerlException(exception,OptionError,
7842 "UnrecognizedPerlMagickMethod",message);
7845 case 1: /* Comment */
7847 if (attribute_flag[0] == 0)
7848 argument_list[0].string_reference=(char *) NULL;
7849 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7850 info ? info->image_info : (ImageInfo *) NULL,image,
7851 argument_list[0].string_reference,exception),exception);
7856 if (attribute_flag[0] == 0)
7857 argument_list[0].string_reference=(char *) NULL;
7858 (void) SetImageProperty(image,"label",InterpretImageProperties(
7859 info ? info->image_info : (ImageInfo *) NULL,image,
7860 argument_list[0].string_reference,exception),exception);
7863 case 3: /* AddNoise */
7868 if (attribute_flag[0] == 0)
7869 argument_list[0].integer_reference=UniformNoise;
7871 if (attribute_flag[1] != 0)
7872 attenuate=argument_list[1].real_reference;
7873 if (attribute_flag[2] != 0)
7874 channel=(ChannelType) argument_list[2].integer_reference;
7875 channel_mask=SetImageChannelMask(image,channel);
7876 image=AddNoiseImage(image,(NoiseType)
7877 argument_list[0].integer_reference,attenuate,exception);
7878 if (image != (Image *) NULL)
7879 (void) SetImageChannelMask(image,channel_mask);
7882 case 4: /* Colorize */
7887 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7888 0,0,&target,exception);
7889 if (attribute_flag[0] != 0)
7890 (void) QueryColorCompliance(argument_list[0].string_reference,
7891 AllCompliance,&target,exception);
7892 if (attribute_flag[1] == 0)
7893 argument_list[1].string_reference="100%";
7894 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7898 case 5: /* Border */
7905 if (attribute_flag[0] != 0)
7906 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7907 &geometry,exception);
7908 if (attribute_flag[1] != 0)
7909 geometry.width=argument_list[1].integer_reference;
7910 if (attribute_flag[2] != 0)
7911 geometry.height=argument_list[2].integer_reference;
7912 if (attribute_flag[3] != 0)
7913 QueryColorCompliance(argument_list[3].string_reference,
7914 AllCompliance,&image->border_color,exception);
7915 if (attribute_flag[4] != 0)
7916 QueryColorCompliance(argument_list[4].string_reference,
7917 AllCompliance,&image->border_color,exception);
7918 if (attribute_flag[5] != 0)
7919 QueryColorCompliance(argument_list[5].string_reference,
7920 AllCompliance,&image->border_color,exception);
7921 compose=image->compose;
7922 if (attribute_flag[6] != 0)
7923 compose=(CompositeOperator) argument_list[6].integer_reference;
7924 image=BorderImage(image,&geometry,compose,exception);
7929 if (attribute_flag[0] != 0)
7931 flags=ParseGeometry(argument_list[0].string_reference,
7933 if ((flags & SigmaValue) == 0)
7934 geometry_info.sigma=1.0;
7936 if (attribute_flag[1] != 0)
7937 geometry_info.rho=argument_list[1].real_reference;
7938 if (attribute_flag[2] != 0)
7939 geometry_info.sigma=argument_list[2].real_reference;
7940 if (attribute_flag[3] != 0)
7941 channel=(ChannelType) argument_list[3].integer_reference;
7942 channel_mask=SetImageChannelMask(image,channel);
7943 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7945 if (image != (Image *) NULL)
7946 (void) SetImageChannelMask(image,channel_mask);
7951 if (attribute_flag[5] != 0)
7952 image->gravity=(GravityType) argument_list[5].integer_reference;
7953 if (attribute_flag[0] != 0)
7954 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7955 &geometry,exception);
7956 if (attribute_flag[1] != 0)
7957 geometry.width=argument_list[1].integer_reference;
7958 if (attribute_flag[2] != 0)
7959 geometry.height=argument_list[2].integer_reference;
7960 if (attribute_flag[3] != 0)
7961 geometry.x=argument_list[3].integer_reference;
7962 if (attribute_flag[4] != 0)
7963 geometry.y=argument_list[4].integer_reference;
7964 image=ChopImage(image,&geometry,exception);
7969 if (attribute_flag[6] != 0)
7970 image->gravity=(GravityType) argument_list[6].integer_reference;
7971 if (attribute_flag[0] != 0)
7972 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7973 &geometry,exception);
7974 if (attribute_flag[1] != 0)
7975 geometry.width=argument_list[1].integer_reference;
7976 if (attribute_flag[2] != 0)
7977 geometry.height=argument_list[2].integer_reference;
7978 if (attribute_flag[3] != 0)
7979 geometry.x=argument_list[3].integer_reference;
7980 if (attribute_flag[4] != 0)
7981 geometry.y=argument_list[4].integer_reference;
7982 if (attribute_flag[5] != 0)
7983 image->fuzz=StringToDoubleInterval(
7984 argument_list[5].string_reference,(double) QuantumRange+1.0);
7985 image=CropImage(image,&geometry,exception);
7988 case 9: /* Despeckle */
7990 image=DespeckleImage(image,exception);
7995 if (attribute_flag[0] != 0)
7996 geometry_info.rho=argument_list[0].real_reference;
7997 image=EdgeImage(image,geometry_info.rho,exception);
8000 case 11: /* Emboss */
8002 if (attribute_flag[0] != 0)
8004 flags=ParseGeometry(argument_list[0].string_reference,
8006 if ((flags & SigmaValue) == 0)
8007 geometry_info.sigma=1.0;
8009 if (attribute_flag[1] != 0)
8010 geometry_info.rho=argument_list[1].real_reference;
8011 if (attribute_flag[2] != 0)
8012 geometry_info.sigma=argument_list[2].real_reference;
8013 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8017 case 12: /* Enhance */
8019 image=EnhanceImage(image,exception);
8024 image=FlipImage(image,exception);
8029 image=FlopImage(image,exception);
8032 case 15: /* Frame */
8040 if (attribute_flag[0] != 0)
8042 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8043 &geometry,exception);
8044 frame_info.width=geometry.width;
8045 frame_info.height=geometry.height;
8046 frame_info.outer_bevel=geometry.x;
8047 frame_info.inner_bevel=geometry.y;
8049 if (attribute_flag[1] != 0)
8050 frame_info.width=argument_list[1].integer_reference;
8051 if (attribute_flag[2] != 0)
8052 frame_info.height=argument_list[2].integer_reference;
8053 if (attribute_flag[3] != 0)
8054 frame_info.inner_bevel=argument_list[3].integer_reference;
8055 if (attribute_flag[4] != 0)
8056 frame_info.outer_bevel=argument_list[4].integer_reference;
8057 if (attribute_flag[5] != 0)
8058 QueryColorCompliance(argument_list[5].string_reference,
8059 AllCompliance,&fill_color,exception);
8060 if (attribute_flag[6] != 0)
8061 QueryColorCompliance(argument_list[6].string_reference,
8062 AllCompliance,&fill_color,exception);
8063 frame_info.x=(ssize_t) frame_info.width;
8064 frame_info.y=(ssize_t) frame_info.height;
8065 frame_info.width=image->columns+2*frame_info.x;
8066 frame_info.height=image->rows+2*frame_info.y;
8067 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8068 image->alpha_color=fill_color;
8069 compose=image->compose;
8070 if (attribute_flag[7] != 0)
8071 compose=(CompositeOperator) argument_list[7].integer_reference;
8072 image=FrameImage(image,&frame_info,compose,exception);
8075 case 16: /* Implode */
8077 PixelInterpolateMethod
8080 if (attribute_flag[0] == 0)
8081 argument_list[0].real_reference=0.5;
8082 method=UndefinedInterpolatePixel;
8083 if (attribute_flag[1] != 0)
8084 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8085 image=ImplodeImage(image,argument_list[0].real_reference,
8089 case 17: /* Magnify */
8091 image=MagnifyImage(image,exception);
8094 case 18: /* MedianFilter */
8096 if (attribute_flag[0] != 0)
8098 flags=ParseGeometry(argument_list[0].string_reference,
8100 if ((flags & SigmaValue) == 0)
8101 geometry_info.sigma=geometry_info.rho;
8103 if (attribute_flag[1] != 0)
8104 geometry_info.rho=argument_list[1].real_reference;
8105 if (attribute_flag[2] != 0)
8106 geometry_info.sigma=argument_list[2].real_reference;
8107 if (attribute_flag[3] != 0)
8108 channel=(ChannelType) argument_list[3].integer_reference;
8109 channel_mask=SetImageChannelMask(image,channel);
8110 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8111 (size_t) geometry_info.sigma,exception);
8112 if (image != (Image *) NULL)
8113 (void) SetImageChannelMask(image,channel_mask);
8116 case 19: /* Minify */
8118 image=MinifyImage(image,exception);
8121 case 20: /* OilPaint */
8123 if (attribute_flag[0] == 0)
8124 argument_list[0].real_reference=0.0;
8125 if (attribute_flag[1] == 0)
8126 argument_list[1].real_reference=1.0;
8127 image=OilPaintImage(image,argument_list[0].real_reference,
8128 argument_list[1].real_reference,exception);
8131 case 21: /* ReduceNoise */
8133 if (attribute_flag[0] != 0)
8135 flags=ParseGeometry(argument_list[0].string_reference,
8137 if ((flags & SigmaValue) == 0)
8138 geometry_info.sigma=1.0;
8140 if (attribute_flag[1] != 0)
8141 geometry_info.rho=argument_list[1].real_reference;
8142 if (attribute_flag[2] != 0)
8143 geometry_info.sigma=argument_list[2].real_reference;
8144 if (attribute_flag[3] != 0)
8145 channel=(ChannelType) argument_list[3].integer_reference;
8146 channel_mask=SetImageChannelMask(image,channel);
8147 image=StatisticImage(image,NonpeakStatistic,(size_t)
8148 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8149 if (image != (Image *) NULL)
8150 (void) SetImageChannelMask(image,channel_mask);
8155 if (attribute_flag[0] != 0)
8156 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8157 &geometry,exception);
8158 if (attribute_flag[1] != 0)
8159 geometry.x=argument_list[1].integer_reference;
8160 if (attribute_flag[2] != 0)
8161 geometry.y=argument_list[2].integer_reference;
8162 image=RollImage(image,geometry.x,geometry.y,exception);
8165 case 23: /* Rotate */
8167 if (attribute_flag[0] == 0)
8168 argument_list[0].real_reference=90.0;
8169 if (attribute_flag[1] != 0)
8171 QueryColorCompliance(argument_list[1].string_reference,
8172 AllCompliance,&image->background_color,exception);
8173 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8174 (image->alpha_trait == UndefinedPixelTrait))
8175 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8177 image=RotateImage(image,argument_list[0].real_reference,exception);
8180 case 24: /* Sample */
8182 if (attribute_flag[0] != 0)
8183 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8184 &geometry,exception);
8185 if (attribute_flag[1] != 0)
8186 geometry.width=argument_list[1].integer_reference;
8187 if (attribute_flag[2] != 0)
8188 geometry.height=argument_list[2].integer_reference;
8189 image=SampleImage(image,geometry.width,geometry.height,exception);
8192 case 25: /* Scale */
8194 if (attribute_flag[0] != 0)
8195 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8196 &geometry,exception);
8197 if (attribute_flag[1] != 0)
8198 geometry.width=argument_list[1].integer_reference;
8199 if (attribute_flag[2] != 0)
8200 geometry.height=argument_list[2].integer_reference;
8201 image=ScaleImage(image,geometry.width,geometry.height,exception);
8204 case 26: /* Shade */
8206 if (attribute_flag[0] != 0)
8208 flags=ParseGeometry(argument_list[0].string_reference,
8210 if ((flags & SigmaValue) == 0)
8211 geometry_info.sigma=0.0;
8213 if (attribute_flag[1] != 0)
8214 geometry_info.rho=argument_list[1].real_reference;
8215 if (attribute_flag[2] != 0)
8216 geometry_info.sigma=argument_list[2].real_reference;
8217 image=ShadeImage(image,
8218 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8219 geometry_info.rho,geometry_info.sigma,exception);
8222 case 27: /* Sharpen */
8224 if (attribute_flag[0] != 0)
8226 flags=ParseGeometry(argument_list[0].string_reference,
8228 if ((flags & SigmaValue) == 0)
8229 geometry_info.sigma=1.0;
8231 if (attribute_flag[1] != 0)
8232 geometry_info.rho=argument_list[1].real_reference;
8233 if (attribute_flag[2] != 0)
8234 geometry_info.sigma=argument_list[2].real_reference;
8235 if (attribute_flag[3] != 0)
8236 channel=(ChannelType) argument_list[3].integer_reference;
8237 channel_mask=SetImageChannelMask(image,channel);
8238 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8240 if (image != (Image *) NULL)
8241 (void) SetImageChannelMask(image,channel_mask);
8244 case 28: /* Shear */
8246 if (attribute_flag[0] != 0)
8248 flags=ParseGeometry(argument_list[0].string_reference,
8250 if ((flags & SigmaValue) == 0)
8251 geometry_info.sigma=geometry_info.rho;
8253 if (attribute_flag[1] != 0)
8254 geometry_info.rho=argument_list[1].real_reference;
8255 if (attribute_flag[2] != 0)
8256 geometry_info.sigma=argument_list[2].real_reference;
8257 if (attribute_flag[3] != 0)
8258 QueryColorCompliance(argument_list[3].string_reference,
8259 AllCompliance,&image->background_color,exception);
8260 if (attribute_flag[4] != 0)
8261 QueryColorCompliance(argument_list[4].string_reference,
8262 AllCompliance,&image->background_color,exception);
8263 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8267 case 29: /* Spread */
8269 PixelInterpolateMethod
8272 if (attribute_flag[0] == 0)
8273 argument_list[0].real_reference=1.0;
8274 method=UndefinedInterpolatePixel;
8275 if (attribute_flag[1] != 0)
8276 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8277 image=SpreadImage(image,method,argument_list[0].real_reference,
8281 case 30: /* Swirl */
8283 PixelInterpolateMethod
8286 if (attribute_flag[0] == 0)
8287 argument_list[0].real_reference=50.0;
8288 method=UndefinedInterpolatePixel;
8289 if (attribute_flag[1] != 0)
8290 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8291 image=SwirlImage(image,argument_list[0].real_reference,
8295 case 31: /* Resize */
8298 if (attribute_flag[0] != 0)
8299 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8300 &geometry,exception);
8301 if (attribute_flag[1] != 0)
8302 geometry.width=argument_list[1].integer_reference;
8303 if (attribute_flag[2] != 0)
8304 geometry.height=argument_list[2].integer_reference;
8305 if (attribute_flag[3] == 0)
8306 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8307 if (attribute_flag[4] != 0)
8308 SetImageArtifact(image,"filter:support",
8309 argument_list[4].string_reference);
8310 image=ResizeImage(image,geometry.width,geometry.height,
8311 (FilterType) argument_list[3].integer_reference,
8315 case 33: /* Annotate */
8320 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8322 if (attribute_flag[0] != 0)
8327 text=InterpretImageProperties(info ? info->image_info :
8328 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8330 (void) CloneString(&draw_info->text,text);
8331 text=DestroyString(text);
8333 if (attribute_flag[1] != 0)
8334 (void) CloneString(&draw_info->font,
8335 argument_list[1].string_reference);
8336 if (attribute_flag[2] != 0)
8337 draw_info->pointsize=argument_list[2].real_reference;
8338 if (attribute_flag[3] != 0)
8339 (void) CloneString(&draw_info->density,
8340 argument_list[3].string_reference);
8341 if (attribute_flag[4] != 0)
8342 (void) QueryColorCompliance(argument_list[4].string_reference,
8343 AllCompliance,&draw_info->undercolor,exception);
8344 if (attribute_flag[5] != 0)
8346 (void) QueryColorCompliance(argument_list[5].string_reference,
8347 AllCompliance,&draw_info->stroke,exception);
8348 if (argument_list[5].image_reference != (Image *) NULL)
8349 draw_info->stroke_pattern=CloneImage(
8350 argument_list[5].image_reference,0,0,MagickTrue,exception);
8352 if (attribute_flag[6] != 0)
8354 (void) QueryColorCompliance(argument_list[6].string_reference,
8355 AllCompliance,&draw_info->fill,exception);
8356 if (argument_list[6].image_reference != (Image *) NULL)
8357 draw_info->fill_pattern=CloneImage(
8358 argument_list[6].image_reference,0,0,MagickTrue,exception);
8360 if (attribute_flag[7] != 0)
8362 (void) CloneString(&draw_info->geometry,
8363 argument_list[7].string_reference);
8364 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8365 &geometry,exception);
8366 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8367 geometry_info.sigma=geometry_info.xi;
8369 if (attribute_flag[8] != 0)
8370 (void) QueryColorCompliance(argument_list[8].string_reference,
8371 AllCompliance,&draw_info->fill,exception);
8372 if (attribute_flag[11] != 0)
8373 draw_info->gravity=(GravityType)
8374 argument_list[11].integer_reference;
8375 if (attribute_flag[25] != 0)
8380 av=(AV *) argument_list[25].array_reference;
8381 if ((av_len(av) != 3) && (av_len(av) != 5))
8383 ThrowPerlException(exception,OptionError,
8384 "affine matrix must have 4 or 6 elements",PackageName);
8387 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8388 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8389 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8390 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8391 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8392 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8394 ThrowPerlException(exception,OptionError,
8395 "affine matrix is singular",PackageName);
8398 if (av_len(av) == 5)
8400 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8401 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8404 for (j=12; j < 17; j++)
8406 if (attribute_flag[j] == 0)
8408 value=argument_list[j].string_reference;
8409 angle=argument_list[j].real_reference;
8410 current=draw_info->affine;
8411 GetAffineMatrix(&affine);
8419 flags=ParseGeometry(value,&geometry_info);
8420 affine.tx=geometry_info.xi;
8421 affine.ty=geometry_info.psi;
8422 if ((flags & PsiValue) == 0)
8423 affine.ty=affine.tx;
8431 flags=ParseGeometry(value,&geometry_info);
8432 affine.sx=geometry_info.rho;
8433 affine.sy=geometry_info.sigma;
8434 if ((flags & SigmaValue) == 0)
8435 affine.sy=affine.sx;
8445 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8446 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8447 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8448 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8456 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8464 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8468 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8469 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8470 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8471 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8472 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8474 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8477 if (attribute_flag[9] == 0)
8478 argument_list[9].real_reference=0.0;
8479 if (attribute_flag[10] == 0)
8480 argument_list[10].real_reference=0.0;
8481 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8484 geometry[MagickPathExtent];
8486 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8487 (double) argument_list[9].real_reference+draw_info->affine.tx,
8488 (double) argument_list[10].real_reference+draw_info->affine.ty);
8489 (void) CloneString(&draw_info->geometry,geometry);
8491 if (attribute_flag[17] != 0)
8492 draw_info->stroke_width=argument_list[17].real_reference;
8493 if (attribute_flag[18] != 0)
8495 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8496 MagickTrue : MagickFalse;
8497 draw_info->stroke_antialias=draw_info->text_antialias;
8499 if (attribute_flag[19] != 0)
8500 (void) CloneString(&draw_info->family,
8501 argument_list[19].string_reference);
8502 if (attribute_flag[20] != 0)
8503 draw_info->style=(StyleType) argument_list[20].integer_reference;
8504 if (attribute_flag[21] != 0)
8505 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8506 if (attribute_flag[22] != 0)
8507 draw_info->weight=argument_list[22].integer_reference;
8508 if (attribute_flag[23] != 0)
8509 draw_info->align=(AlignType) argument_list[23].integer_reference;
8510 if (attribute_flag[24] != 0)
8511 (void) CloneString(&draw_info->encoding,
8512 argument_list[24].string_reference);
8513 if (attribute_flag[25] != 0)
8514 draw_info->fill_pattern=CloneImage(
8515 argument_list[25].image_reference,0,0,MagickTrue,exception);
8516 if (attribute_flag[26] != 0)
8517 draw_info->fill_pattern=CloneImage(
8518 argument_list[26].image_reference,0,0,MagickTrue,exception);
8519 if (attribute_flag[27] != 0)
8520 draw_info->stroke_pattern=CloneImage(
8521 argument_list[27].image_reference,0,0,MagickTrue,exception);
8522 if (attribute_flag[29] != 0)
8523 draw_info->kerning=argument_list[29].real_reference;
8524 if (attribute_flag[30] != 0)
8525 draw_info->interline_spacing=argument_list[30].real_reference;
8526 if (attribute_flag[31] != 0)
8527 draw_info->interword_spacing=argument_list[31].real_reference;
8528 if (attribute_flag[32] != 0)
8529 draw_info->direction=(DirectionType)
8530 argument_list[32].integer_reference;
8531 (void) AnnotateImage(image,draw_info,exception);
8532 draw_info=DestroyDrawInfo(draw_info);
8535 case 34: /* ColorFloodfill */
8546 draw_info=CloneDrawInfo(info ? info->image_info :
8547 (ImageInfo *) NULL,(DrawInfo *) NULL);
8548 if (attribute_flag[0] != 0)
8549 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8550 &geometry,exception);
8551 if (attribute_flag[1] != 0)
8552 geometry.x=argument_list[1].integer_reference;
8553 if (attribute_flag[2] != 0)
8554 geometry.y=argument_list[2].integer_reference;
8555 if (attribute_flag[3] != 0)
8556 (void) QueryColorCompliance(argument_list[3].string_reference,
8557 AllCompliance,&draw_info->fill,exception);
8558 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8559 geometry.x,geometry.y,&target,exception);
8561 if (attribute_flag[4] != 0)
8563 QueryColorCompliance(argument_list[4].string_reference,
8564 AllCompliance,&target,exception);
8567 if (attribute_flag[5] != 0)
8568 image->fuzz=StringToDoubleInterval(
8569 argument_list[5].string_reference,(double) QuantumRange+1.0);
8570 if (attribute_flag[6] != 0)
8571 invert=(MagickBooleanType) argument_list[6].integer_reference;
8572 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8573 geometry.y,invert,exception);
8574 draw_info=DestroyDrawInfo(draw_info);
8577 case 35: /* Composite */
8580 composite_geometry[MagickPathExtent];
8589 compose=OverCompositeOp;
8590 if (attribute_flag[0] != 0)
8591 composite_image=argument_list[0].image_reference;
8594 ThrowPerlException(exception,OptionError,
8595 "CompositeImageRequired",PackageName);
8599 Parameter Handling used for BOTH normal and tiled composition.
8601 if (attribute_flag[1] != 0) /* compose */
8602 compose=(CompositeOperator) argument_list[1].integer_reference;
8603 if (attribute_flag[6] != 0) /* opacity */
8605 if (compose != DissolveCompositeOp)
8606 (void) SetImageAlpha(composite_image,(Quantum)
8607 StringToDoubleInterval(argument_list[6].string_reference,
8608 (double) QuantumRange+1.0),exception);
8630 Handle dissolve composite operator (patch by
8633 (void) CloneString(&image->geometry,
8634 argument_list[6].string_reference);
8635 opacity=(Quantum) StringToDoubleInterval(
8636 argument_list[6].string_reference,(double) QuantumRange+
8638 if (composite_image->alpha_trait != UndefinedPixelTrait)
8639 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8640 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8641 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8643 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8644 composite_image->columns,1,exception);
8645 for (x=0; x < (ssize_t) composite_image->columns; x++)
8647 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8648 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8650 q+=GetPixelChannels(composite_image);
8652 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8653 if (sync == MagickFalse)
8656 composite_view=DestroyCacheView(composite_view);
8659 if (attribute_flag[9] != 0) /* "color=>" */
8660 QueryColorCompliance(argument_list[9].string_reference,
8661 AllCompliance,&composite_image->background_color,exception);
8662 if (attribute_flag[12] != 0) /* "interpolate=>" */
8663 image->interpolate=(PixelInterpolateMethod)
8664 argument_list[12].integer_reference;
8665 if (attribute_flag[13] != 0) /* "args=>" */
8666 (void) SetImageArtifact(composite_image,"compose:args",
8667 argument_list[13].string_reference);
8668 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8669 (void) SetImageArtifact(composite_image,"compose:args",
8670 argument_list[14].string_reference);
8671 clip_to_self=MagickTrue;
8672 if (attribute_flag[15] != 0)
8673 clip_to_self=(MagickBooleanType)
8674 argument_list[15].integer_reference;
8676 Tiling Composition (with orthogonal rotate).
8678 rotate_image=(Image *) NULL;
8679 if (attribute_flag[8] != 0) /* "rotate=>" */
8684 rotate_image=RotateImage(composite_image,
8685 argument_list[8].real_reference,exception);
8686 if (rotate_image == (Image *) NULL)
8689 if ((attribute_flag[7] != 0) &&
8690 (argument_list[7].integer_reference != 0)) /* tile */
8697 Tile the composite image.
8699 if (attribute_flag[8] != 0) /* "tile=>" */
8700 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8703 (void) SetImageArtifact(composite_image,
8704 "compose:outside-overlay","false");
8705 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8706 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8708 if (attribute_flag[8] != 0) /* rotate */
8709 (void) CompositeImage(image,rotate_image,compose,
8710 MagickTrue,x,y,exception);
8712 (void) CompositeImage(image,composite_image,compose,
8713 MagickTrue,x,y,exception);
8715 if (attribute_flag[8] != 0) /* rotate */
8716 rotate_image=DestroyImage(rotate_image);
8720 Parameter Handling used used ONLY for normal composition.
8722 if (attribute_flag[5] != 0) /* gravity */
8723 image->gravity=(GravityType) argument_list[5].integer_reference;
8724 if (attribute_flag[2] != 0) /* geometry offset */
8726 SetGeometry(image,&geometry);
8727 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8729 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8732 if (attribute_flag[3] != 0) /* x offset */
8733 geometry.x=argument_list[3].integer_reference;
8734 if (attribute_flag[4] != 0) /* y offset */
8735 geometry.y=argument_list[4].integer_reference;
8736 if (attribute_flag[10] != 0) /* mask */
8738 if ((image->compose == DisplaceCompositeOp) ||
8739 (image->compose == DistortCompositeOp))
8742 Merge Y displacement into X displacement image.
8744 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8746 (void) CompositeImage(composite_image,
8747 argument_list[10].image_reference,CopyGreenCompositeOp,
8748 MagickTrue,0,0,exception);
8756 Set a blending mask for the composition.
8758 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8759 MagickTrue,exception);
8760 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8762 mask_image=DestroyImage(mask_image);
8765 if (attribute_flag[11] != 0) /* channel */
8766 channel=(ChannelType) argument_list[11].integer_reference;
8768 Composite two images (normal composition).
8770 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8771 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8772 (double) composite_image->rows,(double) geometry.x,(double)
8774 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8776 channel_mask=SetImageChannelMask(image,channel);
8777 if (attribute_flag[8] == 0) /* no rotate */
8778 CompositeImage(image,composite_image,compose,clip_to_self,
8779 geometry.x,geometry.y,exception);
8783 Position adjust rotated image then composite.
8785 geometry.x-=(ssize_t) (rotate_image->columns-
8786 composite_image->columns)/2;
8787 geometry.y-=(ssize_t) (rotate_image->rows-
8788 composite_image->rows)/2;
8789 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8790 geometry.y,exception);
8791 rotate_image=DestroyImage(rotate_image);
8793 if (attribute_flag[10] != 0) /* mask */
8795 if ((image->compose == DisplaceCompositeOp) ||
8796 (image->compose == DistortCompositeOp))
8797 composite_image=DestroyImage(composite_image);
8799 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8802 (void) SetImageChannelMask(image,channel_mask);
8805 case 36: /* Contrast */
8807 if (attribute_flag[0] == 0)
8808 argument_list[0].integer_reference=0;
8809 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8810 MagickTrue : MagickFalse,exception);
8813 case 37: /* CycleColormap */
8815 if (attribute_flag[0] == 0)
8816 argument_list[0].integer_reference=6;
8817 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8826 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8828 (void) CloneString(&draw_info->primitive,"point");
8829 if (attribute_flag[0] != 0)
8831 if (argument_list[0].integer_reference < 0)
8832 (void) CloneString(&draw_info->primitive,
8833 argument_list[0].string_reference);
8835 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8836 MagickPrimitiveOptions,argument_list[0].integer_reference));
8838 if (attribute_flag[1] != 0)
8840 if (LocaleCompare(draw_info->primitive,"path") == 0)
8842 (void) ConcatenateString(&draw_info->primitive," '");
8843 ConcatenateString(&draw_info->primitive,
8844 argument_list[1].string_reference);
8845 (void) ConcatenateString(&draw_info->primitive,"'");
8849 (void) ConcatenateString(&draw_info->primitive," ");
8850 ConcatenateString(&draw_info->primitive,
8851 argument_list[1].string_reference);
8854 if (attribute_flag[2] != 0)
8856 (void) ConcatenateString(&draw_info->primitive," ");
8857 (void) ConcatenateString(&draw_info->primitive,
8858 CommandOptionToMnemonic(MagickMethodOptions,
8859 argument_list[2].integer_reference));
8861 if (attribute_flag[3] != 0)
8863 (void) QueryColorCompliance(argument_list[3].string_reference,
8864 AllCompliance,&draw_info->stroke,exception);
8865 if (argument_list[3].image_reference != (Image *) NULL)
8866 draw_info->stroke_pattern=CloneImage(
8867 argument_list[3].image_reference,0,0,MagickTrue,exception);
8869 if (attribute_flag[4] != 0)
8871 (void) QueryColorCompliance(argument_list[4].string_reference,
8872 AllCompliance,&draw_info->fill,exception);
8873 if (argument_list[4].image_reference != (Image *) NULL)
8874 draw_info->fill_pattern=CloneImage(
8875 argument_list[4].image_reference,0,0,MagickTrue,exception);
8877 if (attribute_flag[5] != 0)
8878 draw_info->stroke_width=argument_list[5].real_reference;
8879 if (attribute_flag[6] != 0)
8880 (void) CloneString(&draw_info->font,
8881 argument_list[6].string_reference);
8882 if (attribute_flag[7] != 0)
8883 (void) QueryColorCompliance(argument_list[7].string_reference,
8884 AllCompliance,&draw_info->border_color,exception);
8885 if (attribute_flag[8] != 0)
8886 draw_info->affine.tx=argument_list[8].real_reference;
8887 if (attribute_flag[9] != 0)
8888 draw_info->affine.ty=argument_list[9].real_reference;
8889 if (attribute_flag[20] != 0)
8894 av=(AV *) argument_list[20].array_reference;
8895 if ((av_len(av) != 3) && (av_len(av) != 5))
8897 ThrowPerlException(exception,OptionError,
8898 "affine matrix must have 4 or 6 elements",PackageName);
8901 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8902 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8903 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8904 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8905 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8906 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8908 ThrowPerlException(exception,OptionError,
8909 "affine matrix is singular",PackageName);
8912 if (av_len(av) == 5)
8914 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8915 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8918 for (j=10; j < 15; j++)
8920 if (attribute_flag[j] == 0)
8922 value=argument_list[j].string_reference;
8923 angle=argument_list[j].real_reference;
8924 current=draw_info->affine;
8925 GetAffineMatrix(&affine);
8933 flags=ParseGeometry(value,&geometry_info);
8934 affine.tx=geometry_info.xi;
8935 affine.ty=geometry_info.psi;
8936 if ((flags & PsiValue) == 0)
8937 affine.ty=affine.tx;
8945 flags=ParseGeometry(value,&geometry_info);
8946 affine.sx=geometry_info.rho;
8947 affine.sy=geometry_info.sigma;
8948 if ((flags & SigmaValue) == 0)
8949 affine.sy=affine.sx;
8959 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8960 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8961 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8962 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8970 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8978 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8982 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8983 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8984 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8985 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8986 draw_info->affine.tx=
8987 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8988 draw_info->affine.ty=
8989 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8991 if (attribute_flag[15] != 0)
8992 draw_info->fill_pattern=CloneImage(
8993 argument_list[15].image_reference,0,0,MagickTrue,exception);
8994 if (attribute_flag[16] != 0)
8995 draw_info->pointsize=argument_list[16].real_reference;
8996 if (attribute_flag[17] != 0)
8998 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8999 ? MagickTrue : MagickFalse;
9000 draw_info->text_antialias=draw_info->stroke_antialias;
9002 if (attribute_flag[18] != 0)
9003 (void) CloneString(&draw_info->density,
9004 argument_list[18].string_reference);
9005 if (attribute_flag[19] != 0)
9006 draw_info->stroke_width=argument_list[19].real_reference;
9007 if (attribute_flag[21] != 0)
9008 draw_info->dash_offset=argument_list[21].real_reference;
9009 if (attribute_flag[22] != 0)
9014 av=(AV *) argument_list[22].array_reference;
9015 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9016 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9017 if (draw_info->dash_pattern != (double *) NULL)
9019 for (i=0; i <= av_len(av); i++)
9020 draw_info->dash_pattern[i]=(double)
9021 SvNV(*(av_fetch(av,i,0)));
9022 draw_info->dash_pattern[i]=0.0;
9025 if (attribute_flag[23] != 0)
9026 image->interpolate=(PixelInterpolateMethod)
9027 argument_list[23].integer_reference;
9028 if ((attribute_flag[24] != 0) &&
9029 (draw_info->fill_pattern != (Image *) NULL))
9030 flags=ParsePageGeometry(draw_info->fill_pattern,
9031 argument_list[24].string_reference,
9032 &draw_info->fill_pattern->tile_offset,exception);
9033 if (attribute_flag[25] != 0)
9035 (void) ConcatenateString(&draw_info->primitive," '");
9036 (void) ConcatenateString(&draw_info->primitive,
9037 argument_list[25].string_reference);
9038 (void) ConcatenateString(&draw_info->primitive,"'");
9040 if (attribute_flag[26] != 0)
9041 draw_info->fill_pattern=CloneImage(
9042 argument_list[26].image_reference,0,0,MagickTrue,exception);
9043 if (attribute_flag[27] != 0)
9044 draw_info->stroke_pattern=CloneImage(
9045 argument_list[27].image_reference,0,0,MagickTrue,exception);
9046 if (attribute_flag[28] != 0)
9047 (void) CloneString(&draw_info->primitive,
9048 argument_list[28].string_reference);
9049 if (attribute_flag[29] != 0)
9050 draw_info->kerning=argument_list[29].real_reference;
9051 if (attribute_flag[30] != 0)
9052 draw_info->interline_spacing=argument_list[30].real_reference;
9053 if (attribute_flag[31] != 0)
9054 draw_info->interword_spacing=argument_list[31].real_reference;
9055 if (attribute_flag[32] != 0)
9056 draw_info->direction=(DirectionType)
9057 argument_list[32].integer_reference;
9058 DrawImage(image,draw_info,exception);
9059 draw_info=DestroyDrawInfo(draw_info);
9062 case 39: /* Equalize */
9064 if (attribute_flag[0] != 0)
9065 channel=(ChannelType) argument_list[0].integer_reference;
9066 channel_mask=SetImageChannelMask(image,channel);
9067 EqualizeImage(image,exception);
9068 (void) SetImageChannelMask(image,channel_mask);
9071 case 40: /* Gamma */
9073 if (attribute_flag[1] != 0)
9074 channel=(ChannelType) argument_list[1].integer_reference;
9075 if (attribute_flag[2] == 0)
9076 argument_list[2].real_reference=1.0;
9077 if (attribute_flag[3] == 0)
9078 argument_list[3].real_reference=1.0;
9079 if (attribute_flag[4] == 0)
9080 argument_list[4].real_reference=1.0;
9081 if (attribute_flag[0] == 0)
9083 (void) FormatLocaleString(message,MagickPathExtent,
9084 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9085 (double) argument_list[3].real_reference,
9086 (double) argument_list[4].real_reference);
9087 argument_list[0].string_reference=message;
9089 (void) GammaImage(image,StringToDouble(
9090 argument_list[0].string_reference,(char **) NULL),exception);
9098 if (attribute_flag[0] == 0)
9100 ThrowPerlException(exception,OptionError,"MapImageRequired",
9104 quantize_info=AcquireQuantizeInfo(info->image_info);
9105 if (attribute_flag[1] != 0)
9106 quantize_info->dither_method=(DitherMethod)
9107 argument_list[1].integer_reference;
9108 (void) RemapImages(quantize_info,image,
9109 argument_list[0].image_reference,exception);
9110 quantize_info=DestroyQuantizeInfo(quantize_info);
9113 case 42: /* MatteFloodfill */
9124 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9126 if (attribute_flag[0] != 0)
9127 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9128 &geometry,exception);
9129 if (attribute_flag[1] != 0)
9130 geometry.x=argument_list[1].integer_reference;
9131 if (attribute_flag[2] != 0)
9132 geometry.y=argument_list[2].integer_reference;
9133 if (image->alpha_trait == UndefinedPixelTrait)
9134 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9135 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9136 geometry.x,geometry.y,&target,exception);
9137 if (attribute_flag[4] != 0)
9138 QueryColorCompliance(argument_list[4].string_reference,
9139 AllCompliance,&target,exception);
9140 if (attribute_flag[3] != 0)
9141 target.alpha=StringToDoubleInterval(
9142 argument_list[3].string_reference,(double) (double) QuantumRange+
9144 if (attribute_flag[5] != 0)
9145 image->fuzz=StringToDoubleInterval(
9146 argument_list[5].string_reference,(double) QuantumRange+1.0);
9148 if (attribute_flag[6] != 0)
9149 invert=(MagickBooleanType) argument_list[6].integer_reference;
9150 channel_mask=SetImageChannelMask(image,AlphaChannel);
9151 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9152 geometry.y,invert,exception);
9153 (void) SetImageChannelMask(image,channel_mask);
9154 draw_info=DestroyDrawInfo(draw_info);
9157 case 43: /* Modulate */
9160 modulate[MagickPathExtent];
9162 geometry_info.rho=100.0;
9163 geometry_info.sigma=100.0;
9164 geometry_info.xi=100.0;
9165 if (attribute_flag[0] != 0)
9166 (void)ParseGeometry(argument_list[0].string_reference,
9168 if (attribute_flag[1] != 0)
9169 geometry_info.xi=argument_list[1].real_reference;
9170 if (attribute_flag[2] != 0)
9171 geometry_info.sigma=argument_list[2].real_reference;
9172 if (attribute_flag[3] != 0)
9174 geometry_info.sigma=argument_list[3].real_reference;
9175 SetImageArtifact(image,"modulate:colorspace","HWB");
9177 if (attribute_flag[4] != 0)
9179 geometry_info.rho=argument_list[4].real_reference;
9180 SetImageArtifact(image,"modulate:colorspace","HSB");
9182 if (attribute_flag[5] != 0)
9184 geometry_info.sigma=argument_list[5].real_reference;
9185 SetImageArtifact(image,"modulate:colorspace","HSL");
9187 if (attribute_flag[6] != 0)
9189 geometry_info.rho=argument_list[6].real_reference;
9190 SetImageArtifact(image,"modulate:colorspace","HWB");
9192 (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g",
9193 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9194 (void) ModulateImage(image,modulate,exception);
9197 case 44: /* Negate */
9199 if (attribute_flag[0] == 0)
9200 argument_list[0].integer_reference=0;
9201 if (attribute_flag[1] != 0)
9202 channel=(ChannelType) argument_list[1].integer_reference;
9203 channel_mask=SetImageChannelMask(image,channel);
9204 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9205 MagickTrue : MagickFalse,exception);
9206 (void) SetImageChannelMask(image,channel_mask);
9209 case 45: /* Normalize */
9211 if (attribute_flag[0] != 0)
9212 channel=(ChannelType) argument_list[0].integer_reference;
9213 channel_mask=SetImageChannelMask(image,channel);
9214 NormalizeImage(image,exception);
9215 (void) SetImageChannelMask(image,channel_mask);
9218 case 46: /* NumberColors */
9220 case 47: /* Opaque */
9229 (void) QueryColorCompliance("none",AllCompliance,&target,
9231 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9233 if (attribute_flag[0] != 0)
9234 (void) QueryColorCompliance(argument_list[0].string_reference,
9235 AllCompliance,&target,exception);
9236 if (attribute_flag[1] != 0)
9237 (void) QueryColorCompliance(argument_list[1].string_reference,
9238 AllCompliance,&fill_color,exception);
9239 if (attribute_flag[2] != 0)
9240 image->fuzz=StringToDoubleInterval(
9241 argument_list[2].string_reference,(double) QuantumRange+1.0);
9242 if (attribute_flag[3] != 0)
9243 channel=(ChannelType) argument_list[3].integer_reference;
9245 if (attribute_flag[4] != 0)
9246 invert=(MagickBooleanType) argument_list[4].integer_reference;
9247 channel_mask=SetImageChannelMask(image,channel);
9248 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9249 (void) SetImageChannelMask(image,channel_mask);
9252 case 48: /* Quantize */
9257 quantize_info=AcquireQuantizeInfo(info->image_info);
9258 if (attribute_flag[0] != 0)
9259 quantize_info->number_colors=(size_t)
9260 argument_list[0].integer_reference;
9261 if (attribute_flag[1] != 0)
9262 quantize_info->tree_depth=(size_t)
9263 argument_list[1].integer_reference;
9264 if (attribute_flag[2] != 0)
9265 quantize_info->colorspace=(ColorspaceType)
9266 argument_list[2].integer_reference;
9267 if (attribute_flag[3] != 0)
9268 quantize_info->dither_method=(DitherMethod)
9269 argument_list[3].integer_reference;
9270 if (attribute_flag[4] != 0)
9271 quantize_info->measure_error=
9272 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9273 if (attribute_flag[6] != 0)
9274 (void) QueryColorCompliance(argument_list[6].string_reference,
9275 AllCompliance,&image->transparent_color,exception);
9276 if (attribute_flag[7] != 0)
9277 quantize_info->dither_method=(DitherMethod)
9278 argument_list[7].integer_reference;
9279 if (attribute_flag[5] && argument_list[5].integer_reference)
9280 (void) QuantizeImages(quantize_info,image,exception);
9282 if ((image->storage_class == DirectClass) ||
9283 (image->colors > quantize_info->number_colors) ||
9284 (quantize_info->colorspace == GRAYColorspace))
9285 (void) QuantizeImage(quantize_info,image,exception);
9287 CompressImageColormap(image,exception);
9288 quantize_info=DestroyQuantizeInfo(quantize_info);
9291 case 49: /* Raise */
9293 if (attribute_flag[0] != 0)
9294 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9295 &geometry,exception);
9296 if (attribute_flag[1] != 0)
9297 geometry.width=argument_list[1].integer_reference;
9298 if (attribute_flag[2] != 0)
9299 geometry.height=argument_list[2].integer_reference;
9300 if (attribute_flag[3] == 0)
9301 argument_list[3].integer_reference=1;
9302 (void) RaiseImage(image,&geometry,
9303 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9307 case 50: /* Segment */
9314 smoothing_threshold;
9319 cluster_threshold=1.0;
9320 smoothing_threshold=1.5;
9321 colorspace=sRGBColorspace;
9322 verbose=MagickFalse;
9323 if (attribute_flag[0] != 0)
9325 flags=ParseGeometry(argument_list[0].string_reference,
9327 cluster_threshold=geometry_info.rho;
9328 if (flags & SigmaValue)
9329 smoothing_threshold=geometry_info.sigma;
9331 if (attribute_flag[1] != 0)
9332 cluster_threshold=argument_list[1].real_reference;
9333 if (attribute_flag[2] != 0)
9334 smoothing_threshold=argument_list[2].real_reference;
9335 if (attribute_flag[3] != 0)
9336 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9337 if (attribute_flag[4] != 0)
9338 verbose=argument_list[4].integer_reference != 0 ?
9339 MagickTrue : MagickFalse;
9340 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9341 smoothing_threshold,exception);
9344 case 51: /* Signature */
9346 (void) SignatureImage(image,exception);
9349 case 52: /* Solarize */
9351 geometry_info.rho=QuantumRange/2.0;
9352 if (attribute_flag[0] != 0)
9353 flags=ParseGeometry(argument_list[0].string_reference,
9355 if (attribute_flag[1] != 0)
9356 geometry_info.rho=StringToDoubleInterval(
9357 argument_list[1].string_reference,(double) QuantumRange+1.0);
9358 (void) SolarizeImage(image,geometry_info.rho,exception);
9363 (void) SyncImage(image,exception);
9366 case 54: /* Texture */
9368 if (attribute_flag[0] == 0)
9370 TextureImage(image,argument_list[0].image_reference,exception);
9373 case 55: /* Evalute */
9375 MagickEvaluateOperator
9378 op=SetEvaluateOperator;
9379 if (attribute_flag[0] == MagickFalse)
9380 argument_list[0].real_reference=0.0;
9381 if (attribute_flag[1] != MagickFalse)
9382 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9383 if (attribute_flag[2] != MagickFalse)
9384 channel=(ChannelType) argument_list[2].integer_reference;
9385 channel_mask=SetImageChannelMask(image,channel);
9386 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9388 (void) SetImageChannelMask(image,channel_mask);
9391 case 56: /* Transparent */
9402 (void) QueryColorCompliance("none",AllCompliance,&target,
9404 if (attribute_flag[0] != 0)
9405 (void) QueryColorCompliance(argument_list[0].string_reference,
9406 AllCompliance,&target,exception);
9407 opacity=TransparentAlpha;
9408 if (attribute_flag[1] != 0)
9409 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9410 (double) QuantumRange+1.0);
9411 if (attribute_flag[2] != 0)
9412 image->fuzz=StringToDoubleInterval(
9413 argument_list[2].string_reference,(double) QuantumRange+1.0);
9414 if (attribute_flag[3] == 0)
9415 argument_list[3].integer_reference=0;
9417 if (attribute_flag[3] != 0)
9418 invert=(MagickBooleanType) argument_list[3].integer_reference;
9419 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9423 case 57: /* Threshold */
9428 if (attribute_flag[0] == 0)
9429 argument_list[0].string_reference="50%";
9430 if (attribute_flag[1] != 0)
9431 channel=(ChannelType) argument_list[1].integer_reference;
9432 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9433 (double) QuantumRange+1.0);
9434 channel_mask=SetImageChannelMask(image,channel);
9435 (void) BilevelImage(image,threshold,exception);
9436 (void) SetImageChannelMask(image,channel_mask);
9439 case 58: /* Charcoal */
9441 if (attribute_flag[0] != 0)
9443 flags=ParseGeometry(argument_list[0].string_reference,
9445 if ((flags & SigmaValue) == 0)
9446 geometry_info.sigma=1.0;
9448 if (attribute_flag[1] != 0)
9449 geometry_info.rho=argument_list[1].real_reference;
9450 if (attribute_flag[2] != 0)
9451 geometry_info.sigma=argument_list[2].real_reference;
9452 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9458 if (attribute_flag[0] != 0)
9459 image->fuzz=StringToDoubleInterval(
9460 argument_list[0].string_reference,(double) QuantumRange+1.0);
9461 image=TrimImage(image,exception);
9466 PixelInterpolateMethod
9469 if (attribute_flag[0] != 0)
9471 flags=ParseGeometry(argument_list[0].string_reference,
9473 if ((flags & SigmaValue) == 0)
9474 geometry_info.sigma=1.0;
9476 if (attribute_flag[1] != 0)
9477 geometry_info.rho=argument_list[1].real_reference;
9478 if (attribute_flag[2] != 0)
9479 geometry_info.sigma=argument_list[2].real_reference;
9480 method=UndefinedInterpolatePixel;
9481 if (attribute_flag[3] != 0)
9482 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9483 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9487 case 61: /* Separate */
9489 if (attribute_flag[0] != 0)
9490 channel=(ChannelType) argument_list[0].integer_reference;
9491 image=SeparateImage(image,channel,exception);
9494 case 63: /* Stereo */
9496 if (attribute_flag[0] == 0)
9498 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9502 if (attribute_flag[1] != 0)
9503 geometry.x=argument_list[1].integer_reference;
9504 if (attribute_flag[2] != 0)
9505 geometry.y=argument_list[2].integer_reference;
9506 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9507 geometry.x,geometry.y,exception);
9510 case 64: /* Stegano */
9512 if (attribute_flag[0] == 0)
9514 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9518 if (attribute_flag[1] == 0)
9519 argument_list[1].integer_reference=0;
9520 image->offset=argument_list[1].integer_reference;
9521 image=SteganoImage(image,argument_list[0].image_reference,exception);
9524 case 65: /* Deconstruct */
9526 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9529 case 66: /* GaussianBlur */
9531 if (attribute_flag[0] != 0)
9533 flags=ParseGeometry(argument_list[0].string_reference,
9535 if ((flags & SigmaValue) == 0)
9536 geometry_info.sigma=1.0;
9538 if (attribute_flag[1] != 0)
9539 geometry_info.rho=argument_list[1].real_reference;
9540 if (attribute_flag[2] != 0)
9541 geometry_info.sigma=argument_list[2].real_reference;
9542 if (attribute_flag[3] != 0)
9543 channel=(ChannelType) argument_list[3].integer_reference;
9544 channel_mask=SetImageChannelMask(image,channel);
9545 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9547 if (image != (Image *) NULL)
9548 (void) SetImageChannelMask(image,channel_mask);
9551 case 67: /* Convolve */
9556 kernel=(KernelInfo *) NULL;
9557 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9559 if (attribute_flag[0] != 0)
9567 kernel=AcquireKernelInfo((const char *) NULL,exception);
9568 if (kernel == (KernelInfo *) NULL)
9570 av=(AV *) argument_list[0].array_reference;
9571 order=(size_t) sqrt(av_len(av)+1);
9572 kernel->width=order;
9573 kernel->height=order;
9574 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9575 order*sizeof(*kernel->values));
9576 if (kernel->values == (MagickRealType *) NULL)
9578 kernel=DestroyKernelInfo(kernel);
9579 ThrowPerlException(exception,ResourceLimitFatalError,
9580 "MemoryAllocationFailed",PackageName);
9583 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9584 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9585 for ( ; j < (ssize_t) (order*order); j++)
9586 kernel->values[j]=0.0;
9588 if (attribute_flag[1] != 0)
9589 channel=(ChannelType) argument_list[1].integer_reference;
9590 if (attribute_flag[2] != 0)
9591 SetImageArtifact(image,"filter:blur",
9592 argument_list[2].string_reference);
9593 if (attribute_flag[3] != 0)
9595 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9597 if (kernel == (KernelInfo *) NULL)
9600 channel_mask=SetImageChannelMask(image,channel);
9601 image=ConvolveImage(image,kernel,exception);
9602 if (image != (Image *) NULL)
9603 (void) SetImageChannelMask(image,channel_mask);
9604 kernel=DestroyKernelInfo(kernel);
9607 case 68: /* Profile */
9622 if (attribute_flag[0] != 0)
9623 name=argument_list[0].string_reference;
9624 if (attribute_flag[2] != 0)
9625 image->rendering_intent=(RenderingIntent)
9626 argument_list[2].integer_reference;
9627 if (attribute_flag[3] != 0)
9628 image->black_point_compensation=
9629 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9630 if (attribute_flag[1] != 0)
9632 if (argument_list[1].length == 0)
9635 Remove a profile from the image.
9637 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9642 Associate user supplied profile with the image.
9644 profile=AcquireStringInfo(argument_list[1].length);
9645 SetStringInfoDatum(profile,(const unsigned char *)
9646 argument_list[1].string_reference);
9647 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9648 (size_t) GetStringInfoLength(profile),exception);
9649 profile=DestroyStringInfo(profile);
9653 Associate a profile with the image.
9655 profile_info=CloneImageInfo(info ? info->image_info :
9656 (ImageInfo *) NULL);
9657 profile_image=ReadImages(profile_info,name,exception);
9658 if (profile_image == (Image *) NULL)
9660 ResetImageProfileIterator(profile_image);
9661 name=GetNextImageProfile(profile_image);
9662 while (name != (const char *) NULL)
9667 profile=GetImageProfile(profile_image,name);
9668 if (profile != (const StringInfo *) NULL)
9669 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9670 (size_t) GetStringInfoLength(profile),exception);
9671 name=GetNextImageProfile(profile_image);
9673 profile_image=DestroyImage(profile_image);
9674 profile_info=DestroyImageInfo(profile_info);
9677 case 69: /* UnsharpMask */
9679 if (attribute_flag[0] != 0)
9681 flags=ParseGeometry(argument_list[0].string_reference,
9683 if ((flags & SigmaValue) == 0)
9684 geometry_info.sigma=1.0;
9685 if ((flags & XiValue) == 0)
9686 geometry_info.xi=1.0;
9687 if ((flags & PsiValue) == 0)
9688 geometry_info.psi=0.5;
9690 if (attribute_flag[1] != 0)
9691 geometry_info.rho=argument_list[1].real_reference;
9692 if (attribute_flag[2] != 0)
9693 geometry_info.sigma=argument_list[2].real_reference;
9694 if (attribute_flag[3] != 0)
9695 geometry_info.xi=argument_list[3].real_reference;
9696 if (attribute_flag[4] != 0)
9697 geometry_info.psi=argument_list[4].real_reference;
9698 if (attribute_flag[5] != 0)
9699 channel=(ChannelType) argument_list[5].integer_reference;
9700 channel_mask=SetImageChannelMask(image,channel);
9701 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9702 geometry_info.xi,geometry_info.psi,exception);
9703 if (image != (Image *) NULL)
9704 (void) SetImageChannelMask(image,channel_mask);
9707 case 70: /* MotionBlur */
9709 if (attribute_flag[0] != 0)
9711 flags=ParseGeometry(argument_list[0].string_reference,
9713 if ((flags & SigmaValue) == 0)
9714 geometry_info.sigma=1.0;
9715 if ((flags & XiValue) == 0)
9716 geometry_info.xi=1.0;
9718 if (attribute_flag[1] != 0)
9719 geometry_info.rho=argument_list[1].real_reference;
9720 if (attribute_flag[2] != 0)
9721 geometry_info.sigma=argument_list[2].real_reference;
9722 if (attribute_flag[3] != 0)
9723 geometry_info.xi=argument_list[3].real_reference;
9724 if (attribute_flag[4] != 0)
9725 channel=(ChannelType) argument_list[4].integer_reference;
9726 channel_mask=SetImageChannelMask(image,channel);
9727 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9728 geometry_info.xi,exception);
9729 if (image != (Image *) NULL)
9730 (void) SetImageChannelMask(image,channel_mask);
9733 case 71: /* OrderedDither */
9735 if (attribute_flag[0] == 0)
9736 argument_list[0].string_reference="o8x8";
9737 if (attribute_flag[1] != 0)
9738 channel=(ChannelType) argument_list[1].integer_reference;
9739 channel_mask=SetImageChannelMask(image,channel);
9740 (void) OrderedDitherImage(image,argument_list[0].string_reference,
9742 (void) SetImageChannelMask(image,channel_mask);
9745 case 72: /* Shave */
9747 if (attribute_flag[0] != 0)
9748 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9749 &geometry,exception);
9750 if (attribute_flag[1] != 0)
9751 geometry.width=argument_list[1].integer_reference;
9752 if (attribute_flag[2] != 0)
9753 geometry.height=argument_list[2].integer_reference;
9754 image=ShaveImage(image,&geometry,exception);
9757 case 73: /* Level */
9765 white_point=(double) image->columns*image->rows;
9767 if (attribute_flag[0] != 0)
9769 flags=ParseGeometry(argument_list[0].string_reference,
9771 black_point=geometry_info.rho;
9772 if ((flags & SigmaValue) != 0)
9773 white_point=geometry_info.sigma;
9774 if ((flags & XiValue) != 0)
9775 gamma=geometry_info.xi;
9776 if ((flags & PercentValue) != 0)
9778 black_point*=(double) (QuantumRange/100.0);
9779 white_point*=(double) (QuantumRange/100.0);
9781 if ((flags & SigmaValue) == 0)
9782 white_point=(double) QuantumRange-black_point;
9784 if (attribute_flag[1] != 0)
9785 black_point=argument_list[1].real_reference;
9786 if (attribute_flag[2] != 0)
9787 white_point=argument_list[2].real_reference;
9788 if (attribute_flag[3] != 0)
9789 gamma=argument_list[3].real_reference;
9790 if (attribute_flag[4] != 0)
9791 channel=(ChannelType) argument_list[4].integer_reference;
9792 if (attribute_flag[5] != 0)
9794 argument_list[0].real_reference=argument_list[5].real_reference;
9795 attribute_flag[0]=attribute_flag[5];
9797 channel_mask=SetImageChannelMask(image,channel);
9798 (void) LevelImage(image,black_point,white_point,gamma,exception);
9799 (void) SetImageChannelMask(image,channel_mask);
9804 if (attribute_flag[0] == 0)
9805 argument_list[0].string_reference="#1";
9806 if (attribute_flag[1] == 0)
9807 argument_list[1].integer_reference=MagickTrue;
9808 (void) ClipImagePath(image,argument_list[0].string_reference,
9809 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9813 case 75: /* AffineTransform */
9818 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9820 if (attribute_flag[0] != 0)
9825 av=(AV *) argument_list[0].array_reference;
9826 if ((av_len(av) != 3) && (av_len(av) != 5))
9828 ThrowPerlException(exception,OptionError,
9829 "affine matrix must have 4 or 6 elements",PackageName);
9832 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9833 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9834 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9835 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9836 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9837 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9839 ThrowPerlException(exception,OptionError,
9840 "affine matrix is singular",PackageName);
9843 if (av_len(av) == 5)
9845 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9846 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9849 for (j=1; j < 6; j++)
9851 if (attribute_flag[j] == 0)
9853 value=argument_list[j].string_reference;
9854 angle=argument_list[j].real_reference;
9855 current=draw_info->affine;
9856 GetAffineMatrix(&affine);
9864 flags=ParseGeometry(value,&geometry_info);
9865 affine.tx=geometry_info.xi;
9866 affine.ty=geometry_info.psi;
9867 if ((flags & PsiValue) == 0)
9868 affine.ty=affine.tx;
9876 flags=ParseGeometry(value,&geometry_info);
9877 affine.sx=geometry_info.rho;
9878 affine.sy=geometry_info.sigma;
9879 if ((flags & SigmaValue) == 0)
9880 affine.sy=affine.sx;
9890 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9891 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9892 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9893 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9901 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9909 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9913 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9914 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9915 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9916 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9917 draw_info->affine.tx=
9918 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9919 draw_info->affine.ty=
9920 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9922 if (attribute_flag[6] != 0)
9923 image->interpolate=(PixelInterpolateMethod)
9924 argument_list[6].integer_reference;
9925 if (attribute_flag[7] != 0)
9926 QueryColorCompliance(argument_list[7].string_reference,
9927 AllCompliance,&image->background_color,exception);
9928 image=AffineTransformImage(image,&draw_info->affine,exception);
9929 draw_info=DestroyDrawInfo(draw_info);
9932 case 76: /* Difference */
9934 if (attribute_flag[0] == 0)
9936 ThrowPerlException(exception,OptionError,
9937 "ReferenceImageRequired",PackageName);
9940 if (attribute_flag[1] != 0)
9941 image->fuzz=StringToDoubleInterval(
9942 argument_list[1].string_reference,(double) QuantumRange+1.0);
9943 (void) SetImageColorMetric(image,argument_list[0].image_reference,
9947 case 77: /* AdaptiveThreshold */
9949 if (attribute_flag[0] != 0)
9951 flags=ParseGeometry(argument_list[0].string_reference,
9953 if ((flags & PercentValue) != 0)
9954 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9956 if (attribute_flag[1] != 0)
9957 geometry_info.rho=argument_list[1].integer_reference;
9958 if (attribute_flag[2] != 0)
9959 geometry_info.sigma=argument_list[2].integer_reference;
9960 if (attribute_flag[3] != 0)
9961 geometry_info.xi=argument_list[3].integer_reference;;
9962 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9963 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9966 case 78: /* Resample */
9972 if (attribute_flag[0] != 0)
9974 flags=ParseGeometry(argument_list[0].string_reference,
9976 if ((flags & SigmaValue) == 0)
9977 geometry_info.sigma=geometry_info.rho;
9979 if (attribute_flag[1] != 0)
9980 geometry_info.rho=argument_list[1].real_reference;
9981 if (attribute_flag[2] != 0)
9982 geometry_info.sigma=argument_list[2].real_reference;
9983 if (attribute_flag[3] == 0)
9984 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9985 if (attribute_flag[4] == 0)
9986 SetImageArtifact(image,"filter:support",
9987 argument_list[4].string_reference);
9988 width=(size_t) (geometry_info.rho*image->columns/
9989 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9990 height=(size_t) (geometry_info.sigma*image->rows/
9991 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9992 image=ResizeImage(image,width,height,(FilterType)
9993 argument_list[3].integer_reference,exception);
9994 if (image != (Image *) NULL)
9996 image->resolution.x=geometry_info.rho;
9997 image->resolution.y=geometry_info.sigma;
10001 case 79: /* Describe */
10003 if (attribute_flag[0] == 0)
10004 argument_list[0].file_reference=(FILE *) NULL;
10005 if (attribute_flag[1] != 0)
10006 (void) SetImageArtifact(image,"identify:features",
10007 argument_list[1].string_reference);
10008 (void) IdentifyImage(image,argument_list[0].file_reference,
10009 MagickTrue,exception);
10012 case 80: /* BlackThreshold */
10014 if (attribute_flag[0] == 0)
10015 argument_list[0].string_reference="50%";
10016 if (attribute_flag[2] != 0)
10017 channel=(ChannelType) argument_list[2].integer_reference;
10018 channel_mask=SetImageChannelMask(image,channel);
10019 BlackThresholdImage(image,argument_list[0].string_reference,
10021 (void) SetImageChannelMask(image,channel_mask);
10024 case 81: /* WhiteThreshold */
10026 if (attribute_flag[0] == 0)
10027 argument_list[0].string_reference="50%";
10028 if (attribute_flag[2] != 0)
10029 channel=(ChannelType) argument_list[2].integer_reference;
10030 channel_mask=SetImageChannelMask(image,channel);
10031 WhiteThresholdImage(image,argument_list[0].string_reference,
10033 (void) SetImageChannelMask(image,channel_mask);
10036 case 82: /* RotationalBlur */
10038 if (attribute_flag[0] != 0)
10040 flags=ParseGeometry(argument_list[0].string_reference,
10043 if (attribute_flag[1] != 0)
10044 geometry_info.rho=argument_list[1].real_reference;
10045 if (attribute_flag[2] != 0)
10046 channel=(ChannelType) argument_list[2].integer_reference;
10047 channel_mask=SetImageChannelMask(image,channel);
10048 image=RotationalBlurImage(image,geometry_info.rho,exception);
10049 if (image != (Image *) NULL)
10050 (void) SetImageChannelMask(image,channel_mask);
10053 case 83: /* Thumbnail */
10055 if (attribute_flag[0] != 0)
10056 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10057 &geometry,exception);
10058 if (attribute_flag[1] != 0)
10059 geometry.width=argument_list[1].integer_reference;
10060 if (attribute_flag[2] != 0)
10061 geometry.height=argument_list[2].integer_reference;
10062 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10065 case 84: /* Strip */
10067 (void) StripImage(image,exception);
10070 case 85: /* Tint */
10075 GetPixelInfo(image,&tint);
10076 if (attribute_flag[0] != 0)
10077 (void) QueryColorCompliance(argument_list[0].string_reference,
10078 AllCompliance,&tint,exception);
10079 if (attribute_flag[1] == 0)
10080 argument_list[1].string_reference="100";
10081 image=TintImage(image,argument_list[1].string_reference,&tint,
10085 case 86: /* Channel */
10087 if (attribute_flag[0] != 0)
10088 channel=(ChannelType) argument_list[0].integer_reference;
10089 image=SeparateImage(image,channel,exception);
10092 case 87: /* Splice */
10094 if (attribute_flag[7] != 0)
10095 image->gravity=(GravityType) argument_list[7].integer_reference;
10096 if (attribute_flag[0] != 0)
10097 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10098 &geometry,exception);
10099 if (attribute_flag[1] != 0)
10100 geometry.width=argument_list[1].integer_reference;
10101 if (attribute_flag[2] != 0)
10102 geometry.height=argument_list[2].integer_reference;
10103 if (attribute_flag[3] != 0)
10104 geometry.x=argument_list[3].integer_reference;
10105 if (attribute_flag[4] != 0)
10106 geometry.y=argument_list[4].integer_reference;
10107 if (attribute_flag[5] != 0)
10108 image->fuzz=StringToDoubleInterval(
10109 argument_list[5].string_reference,(double) QuantumRange+1.0);
10110 if (attribute_flag[6] != 0)
10111 (void) QueryColorCompliance(argument_list[6].string_reference,
10112 AllCompliance,&image->background_color,exception);
10113 image=SpliceImage(image,&geometry,exception);
10116 case 88: /* Posterize */
10118 if (attribute_flag[0] == 0)
10119 argument_list[0].integer_reference=3;
10120 if (attribute_flag[1] == 0)
10121 argument_list[1].integer_reference=0;
10122 (void) PosterizeImage(image,argument_list[0].integer_reference,
10123 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10124 NoDitherMethod,exception);
10127 case 89: /* Shadow */
10129 if (attribute_flag[0] != 0)
10131 flags=ParseGeometry(argument_list[0].string_reference,
10133 if ((flags & SigmaValue) == 0)
10134 geometry_info.sigma=1.0;
10135 if ((flags & XiValue) == 0)
10136 geometry_info.xi=4.0;
10137 if ((flags & PsiValue) == 0)
10138 geometry_info.psi=4.0;
10140 if (attribute_flag[1] != 0)
10141 geometry_info.rho=argument_list[1].real_reference;
10142 if (attribute_flag[2] != 0)
10143 geometry_info.sigma=argument_list[2].real_reference;
10144 if (attribute_flag[3] != 0)
10145 geometry_info.xi=argument_list[3].integer_reference;
10146 if (attribute_flag[4] != 0)
10147 geometry_info.psi=argument_list[4].integer_reference;
10148 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10149 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10150 ceil(geometry_info.psi-0.5),exception);
10153 case 90: /* Identify */
10155 if (attribute_flag[0] == 0)
10156 argument_list[0].file_reference=(FILE *) NULL;
10157 if (attribute_flag[1] != 0)
10158 (void) SetImageArtifact(image,"identify:features",
10159 argument_list[1].string_reference);
10160 if ((attribute_flag[2] != 0) &&
10161 (argument_list[2].integer_reference != 0))
10162 (void) SetImageArtifact(image,"identify:unique","true");
10163 (void) IdentifyImage(image,argument_list[0].file_reference,
10164 MagickTrue,exception);
10167 case 91: /* SepiaTone */
10169 if (attribute_flag[0] == 0)
10170 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10171 image=SepiaToneImage(image,argument_list[0].real_reference,
10175 case 92: /* SigmoidalContrast */
10180 if (attribute_flag[0] != 0)
10182 flags=ParseGeometry(argument_list[0].string_reference,
10184 if ((flags & SigmaValue) == 0)
10185 geometry_info.sigma=QuantumRange/2.0;
10186 if ((flags & PercentValue) != 0)
10187 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10189 if (attribute_flag[1] != 0)
10190 geometry_info.rho=argument_list[1].real_reference;
10191 if (attribute_flag[2] != 0)
10192 geometry_info.sigma=argument_list[2].real_reference;
10193 if (attribute_flag[3] != 0)
10194 channel=(ChannelType) argument_list[3].integer_reference;
10195 sharpen=MagickTrue;
10196 if (attribute_flag[4] != 0)
10197 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10199 channel_mask=SetImageChannelMask(image,channel);
10200 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10201 geometry_info.sigma,exception);
10202 (void) SetImageChannelMask(image,channel_mask);
10205 case 93: /* Extent */
10207 if (attribute_flag[7] != 0)
10208 image->gravity=(GravityType) argument_list[7].integer_reference;
10209 if (attribute_flag[0] != 0)
10214 flags=ParseGravityGeometry(image,
10215 argument_list[0].string_reference,&geometry,exception);
10217 if (geometry.width == 0)
10218 geometry.width=image->columns;
10219 if (geometry.height == 0)
10220 geometry.height=image->rows;
10222 if (attribute_flag[1] != 0)
10223 geometry.width=argument_list[1].integer_reference;
10224 if (attribute_flag[2] != 0)
10225 geometry.height=argument_list[2].integer_reference;
10226 if (attribute_flag[3] != 0)
10227 geometry.x=argument_list[3].integer_reference;
10228 if (attribute_flag[4] != 0)
10229 geometry.y=argument_list[4].integer_reference;
10230 if (attribute_flag[5] != 0)
10231 image->fuzz=StringToDoubleInterval(
10232 argument_list[5].string_reference,(double) QuantumRange+1.0);
10233 if (attribute_flag[6] != 0)
10234 (void) QueryColorCompliance(argument_list[6].string_reference,
10235 AllCompliance,&image->background_color,exception);
10236 image=ExtentImage(image,&geometry,exception);
10239 case 94: /* Vignette */
10241 if (attribute_flag[0] != 0)
10243 flags=ParseGeometry(argument_list[0].string_reference,
10245 if ((flags & SigmaValue) == 0)
10246 geometry_info.sigma=1.0;
10247 if ((flags & XiValue) == 0)
10248 geometry_info.xi=0.1*image->columns;
10249 if ((flags & PsiValue) == 0)
10250 geometry_info.psi=0.1*image->rows;
10252 if (attribute_flag[1] != 0)
10253 geometry_info.rho=argument_list[1].real_reference;
10254 if (attribute_flag[2] != 0)
10255 geometry_info.sigma=argument_list[2].real_reference;
10256 if (attribute_flag[3] != 0)
10257 geometry_info.xi=argument_list[3].integer_reference;
10258 if (attribute_flag[4] != 0)
10259 geometry_info.psi=argument_list[4].integer_reference;
10260 if (attribute_flag[5] != 0)
10261 (void) QueryColorCompliance(argument_list[5].string_reference,
10262 AllCompliance,&image->background_color,exception);
10263 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10264 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10265 ceil(geometry_info.psi-0.5),exception);
10268 case 95: /* ContrastStretch */
10275 white_point=(double) image->columns*image->rows;
10276 if (attribute_flag[0] != 0)
10278 flags=ParseGeometry(argument_list[0].string_reference,
10280 black_point=geometry_info.rho;
10281 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10283 if ((flags & PercentValue) != 0)
10285 black_point*=(double) image->columns*image->rows/100.0;
10286 white_point*=(double) image->columns*image->rows/100.0;
10288 white_point=(double) image->columns*image->rows-
10291 if (attribute_flag[1] != 0)
10292 black_point=argument_list[1].real_reference;
10293 if (attribute_flag[2] != 0)
10294 white_point=argument_list[2].real_reference;
10295 if (attribute_flag[4] != 0)
10296 channel=(ChannelType) argument_list[4].integer_reference;
10297 channel_mask=SetImageChannelMask(image,channel);
10298 (void) ContrastStretchImage(image,black_point,white_point,exception);
10299 (void) SetImageChannelMask(image,channel_mask);
10302 case 96: /* Sans0 */
10306 case 97: /* Sans1 */
10310 case 98: /* AdaptiveSharpen */
10312 if (attribute_flag[0] != 0)
10314 flags=ParseGeometry(argument_list[0].string_reference,
10316 if ((flags & SigmaValue) == 0)
10317 geometry_info.sigma=1.0;
10318 if ((flags & XiValue) == 0)
10319 geometry_info.xi=0.0;
10321 if (attribute_flag[1] != 0)
10322 geometry_info.rho=argument_list[1].real_reference;
10323 if (attribute_flag[2] != 0)
10324 geometry_info.sigma=argument_list[2].real_reference;
10325 if (attribute_flag[3] != 0)
10326 geometry_info.xi=argument_list[3].real_reference;
10327 if (attribute_flag[4] != 0)
10328 channel=(ChannelType) argument_list[4].integer_reference;
10329 channel_mask=SetImageChannelMask(image,channel);
10330 image=AdaptiveSharpenImage(image,geometry_info.rho,
10331 geometry_info.sigma,exception);
10332 if (image != (Image *) NULL)
10333 (void) SetImageChannelMask(image,channel_mask);
10336 case 99: /* Transpose */
10338 image=TransposeImage(image,exception);
10341 case 100: /* Tranverse */
10343 image=TransverseImage(image,exception);
10346 case 101: /* AutoOrient */
10348 image=AutoOrientImage(image,image->orientation,exception);
10351 case 102: /* AdaptiveBlur */
10353 if (attribute_flag[0] != 0)
10355 flags=ParseGeometry(argument_list[0].string_reference,
10357 if ((flags & SigmaValue) == 0)
10358 geometry_info.sigma=1.0;
10359 if ((flags & XiValue) == 0)
10360 geometry_info.xi=0.0;
10362 if (attribute_flag[1] != 0)
10363 geometry_info.rho=argument_list[1].real_reference;
10364 if (attribute_flag[2] != 0)
10365 geometry_info.sigma=argument_list[2].real_reference;
10366 if (attribute_flag[3] != 0)
10367 channel=(ChannelType) argument_list[3].integer_reference;
10368 channel_mask=SetImageChannelMask(image,channel);
10369 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10371 if (image != (Image *) NULL)
10372 (void) SetImageChannelMask(image,channel_mask);
10375 case 103: /* Sketch */
10377 if (attribute_flag[0] != 0)
10379 flags=ParseGeometry(argument_list[0].string_reference,
10381 if ((flags & SigmaValue) == 0)
10382 geometry_info.sigma=1.0;
10383 if ((flags & XiValue) == 0)
10384 geometry_info.xi=1.0;
10386 if (attribute_flag[1] != 0)
10387 geometry_info.rho=argument_list[1].real_reference;
10388 if (attribute_flag[2] != 0)
10389 geometry_info.sigma=argument_list[2].real_reference;
10390 if (attribute_flag[3] != 0)
10391 geometry_info.xi=argument_list[3].real_reference;
10392 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10393 geometry_info.xi,exception);
10396 case 104: /* UniqueColors */
10398 image=UniqueImageColors(image,exception);
10401 case 105: /* AdaptiveResize */
10403 if (attribute_flag[0] != 0)
10404 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10405 &geometry,exception);
10406 if (attribute_flag[1] != 0)
10407 geometry.width=argument_list[1].integer_reference;
10408 if (attribute_flag[2] != 0)
10409 geometry.height=argument_list[2].integer_reference;
10410 if (attribute_flag[3] != 0)
10411 image->filter=(FilterType) argument_list[4].integer_reference;
10412 if (attribute_flag[4] != 0)
10413 SetImageArtifact(image,"filter:support",
10414 argument_list[4].string_reference);
10415 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10419 case 106: /* ClipMask */
10424 if (attribute_flag[0] == 0)
10426 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10428 goto PerlException;
10430 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10432 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10433 mask_image=DestroyImage(mask_image);
10436 case 107: /* LinearStretch */
10443 white_point=(double) image->columns*image->rows;
10444 if (attribute_flag[0] != 0)
10446 flags=ParseGeometry(argument_list[0].string_reference,
10448 if ((flags & SigmaValue) != 0)
10449 white_point=geometry_info.sigma;
10450 if ((flags & PercentValue) != 0)
10452 black_point*=(double) image->columns*image->rows/100.0;
10453 white_point*=(double) image->columns*image->rows/100.0;
10455 if ((flags & SigmaValue) == 0)
10456 white_point=(double) image->columns*image->rows-black_point;
10458 if (attribute_flag[1] != 0)
10459 black_point=argument_list[1].real_reference;
10460 if (attribute_flag[2] != 0)
10461 white_point=argument_list[2].real_reference;
10462 (void) LinearStretchImage(image,black_point,white_point,exception);
10465 case 108: /* ColorMatrix */
10479 if (attribute_flag[0] == 0)
10481 av=(AV *) argument_list[0].array_reference;
10482 order=(size_t) sqrt(av_len(av)+1);
10483 color_matrix=(double *) AcquireQuantumMemory(order,order*
10484 sizeof(*color_matrix));
10485 if (color_matrix == (double *) NULL)
10487 ThrowPerlException(exception,ResourceLimitFatalError,
10488 "MemoryAllocationFailed",PackageName);
10489 goto PerlException;
10491 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10492 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10493 for ( ; j < (ssize_t) (order*order); j++)
10494 color_matrix[j]=0.0;
10495 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10496 if (kernel_info == (KernelInfo *) NULL)
10498 kernel_info->width=order;
10499 kernel_info->height=order;
10500 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10501 order*sizeof(*kernel_info->values));
10502 if (kernel_info->values != (MagickRealType *) NULL)
10504 for (i=0; i < (ssize_t) (order*order); i++)
10505 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10506 image=ColorMatrixImage(image,kernel_info,exception);
10508 kernel_info=DestroyKernelInfo(kernel_info);
10509 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10512 case 109: /* Mask */
10517 if (attribute_flag[0] == 0)
10519 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10521 goto PerlException;
10523 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10524 MagickTrue,exception);
10525 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10526 mask_image=DestroyImage(mask_image);
10529 case 110: /* Polaroid */
10540 PixelInterpolateMethod
10543 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10544 (DrawInfo *) NULL);
10545 caption=(char *) NULL;
10546 if (attribute_flag[0] != 0)
10547 caption=InterpretImageProperties(info ? info->image_info :
10548 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10551 if (attribute_flag[1] != 0)
10552 angle=argument_list[1].real_reference;
10553 if (attribute_flag[2] != 0)
10554 (void) CloneString(&draw_info->font,
10555 argument_list[2].string_reference);
10556 if (attribute_flag[3] != 0)
10557 (void) QueryColorCompliance(argument_list[3].string_reference,
10558 AllCompliance,&draw_info->stroke,exception);
10559 if (attribute_flag[4] != 0)
10560 (void) QueryColorCompliance(argument_list[4].string_reference,
10561 AllCompliance,&draw_info->fill,exception);
10562 if (attribute_flag[5] != 0)
10563 draw_info->stroke_width=argument_list[5].real_reference;
10564 if (attribute_flag[6] != 0)
10565 draw_info->pointsize=argument_list[6].real_reference;
10566 if (attribute_flag[7] != 0)
10567 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10568 if (attribute_flag[8] != 0)
10569 (void) QueryColorCompliance(argument_list[8].string_reference,
10570 AllCompliance,&image->background_color,exception);
10571 method=UndefinedInterpolatePixel;
10572 if (attribute_flag[9] != 0)
10573 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10574 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10575 draw_info=DestroyDrawInfo(draw_info);
10576 if (caption != (char *) NULL)
10577 caption=DestroyString(caption);
10580 case 111: /* FloodfillPaint */
10591 draw_info=CloneDrawInfo(info ? info->image_info :
10592 (ImageInfo *) NULL,(DrawInfo *) NULL);
10593 if (attribute_flag[0] != 0)
10594 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10595 &geometry,exception);
10596 if (attribute_flag[1] != 0)
10597 geometry.x=argument_list[1].integer_reference;
10598 if (attribute_flag[2] != 0)
10599 geometry.y=argument_list[2].integer_reference;
10600 if (attribute_flag[3] != 0)
10601 (void) QueryColorCompliance(argument_list[3].string_reference,
10602 AllCompliance,&draw_info->fill,exception);
10603 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10604 geometry.x,geometry.y,&target,exception);
10605 if (attribute_flag[4] != 0)
10606 QueryColorCompliance(argument_list[4].string_reference,
10607 AllCompliance,&target,exception);
10608 if (attribute_flag[5] != 0)
10609 image->fuzz=StringToDoubleInterval(
10610 argument_list[5].string_reference,(double) QuantumRange+1.0);
10611 if (attribute_flag[6] != 0)
10612 channel=(ChannelType) argument_list[6].integer_reference;
10613 invert=MagickFalse;
10614 if (attribute_flag[7] != 0)
10615 invert=(MagickBooleanType) argument_list[7].integer_reference;
10616 channel_mask=SetImageChannelMask(image,channel);
10617 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10618 geometry.y,invert,exception);
10619 (void) SetImageChannelMask(image,channel_mask);
10620 draw_info=DestroyDrawInfo(draw_info);
10623 case 112: /* Distort */
10635 number_coordinates;
10640 if (attribute_flag[0] == 0)
10642 method=UndefinedDistortion;
10643 if (attribute_flag[1] != 0)
10644 method=(DistortMethod) argument_list[1].integer_reference;
10645 av=(AV *) argument_list[0].array_reference;
10646 number_coordinates=(size_t) av_len(av)+1;
10647 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10648 sizeof(*coordinates));
10649 if (coordinates == (double *) NULL)
10651 ThrowPerlException(exception,ResourceLimitFatalError,
10652 "MemoryAllocationFailed",PackageName);
10653 goto PerlException;
10655 for (j=0; j < (ssize_t) number_coordinates; j++)
10656 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10657 virtual_pixel=UndefinedVirtualPixelMethod;
10658 if (attribute_flag[2] != 0)
10659 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10660 argument_list[2].integer_reference,exception);
10661 image=DistortImage(image,method,number_coordinates,coordinates,
10662 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10664 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10665 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10667 coordinates=(double *) RelinquishMagickMemory(coordinates);
10670 case 113: /* Clut */
10672 PixelInterpolateMethod
10675 if (attribute_flag[0] == 0)
10677 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10679 goto PerlException;
10681 method=UndefinedInterpolatePixel;
10682 if (attribute_flag[1] != 0)
10683 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10684 if (attribute_flag[2] != 0)
10685 channel=(ChannelType) argument_list[2].integer_reference;
10686 channel_mask=SetImageChannelMask(image,channel);
10687 (void) ClutImage(image,argument_list[0].image_reference,method,
10689 (void) SetImageChannelMask(image,channel_mask);
10692 case 114: /* LiquidRescale */
10694 if (attribute_flag[0] != 0)
10695 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10696 &geometry,exception);
10697 if (attribute_flag[1] != 0)
10698 geometry.width=argument_list[1].integer_reference;
10699 if (attribute_flag[2] != 0)
10700 geometry.height=argument_list[2].integer_reference;
10701 if (attribute_flag[3] == 0)
10702 argument_list[3].real_reference=1.0;
10703 if (attribute_flag[4] == 0)
10704 argument_list[4].real_reference=0.0;
10705 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10706 argument_list[3].real_reference,argument_list[4].real_reference,
10710 case 115: /* EncipherImage */
10712 (void) EncipherImage(image,argument_list[0].string_reference,
10716 case 116: /* DecipherImage */
10718 (void) DecipherImage(image,argument_list[0].string_reference,
10722 case 117: /* Deskew */
10724 geometry_info.rho=QuantumRange/2.0;
10725 if (attribute_flag[0] != 0)
10726 flags=ParseGeometry(argument_list[0].string_reference,
10728 if (attribute_flag[1] != 0)
10729 geometry_info.rho=StringToDoubleInterval(
10730 argument_list[1].string_reference,(double) QuantumRange+1.0);
10731 image=DeskewImage(image,geometry_info.rho,exception);
10734 case 118: /* Remap */
10739 if (attribute_flag[0] == 0)
10741 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10743 goto PerlException;
10745 quantize_info=AcquireQuantizeInfo(info->image_info);
10746 if (attribute_flag[1] != 0)
10747 quantize_info->dither_method=(DitherMethod)
10748 argument_list[1].integer_reference;
10749 (void) RemapImages(quantize_info,image,
10750 argument_list[0].image_reference,exception);
10751 quantize_info=DestroyQuantizeInfo(quantize_info);
10754 case 119: /* SparseColor */
10766 number_coordinates;
10771 if (attribute_flag[0] == 0)
10773 method=UndefinedColorInterpolate;
10774 if (attribute_flag[1] != 0)
10775 method=(SparseColorMethod) argument_list[1].integer_reference;
10776 av=(AV *) argument_list[0].array_reference;
10777 number_coordinates=(size_t) av_len(av)+1;
10778 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10779 sizeof(*coordinates));
10780 if (coordinates == (double *) NULL)
10782 ThrowPerlException(exception,ResourceLimitFatalError,
10783 "MemoryAllocationFailed",PackageName);
10784 goto PerlException;
10786 for (j=0; j < (ssize_t) number_coordinates; j++)
10787 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10788 virtual_pixel=UndefinedVirtualPixelMethod;
10789 if (attribute_flag[2] != 0)
10790 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10791 argument_list[2].integer_reference,exception);
10792 if (attribute_flag[3] != 0)
10793 channel=(ChannelType) argument_list[3].integer_reference;
10794 channel_mask=SetImageChannelMask(image,channel);
10795 image=SparseColorImage(image,method,number_coordinates,coordinates,
10797 if (image != (Image *) NULL)
10798 (void) SetImageChannelMask(image,channel_mask);
10799 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10800 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10802 coordinates=(double *) RelinquishMagickMemory(coordinates);
10805 case 120: /* Function */
10822 if (attribute_flag[0] == 0)
10824 function=UndefinedFunction;
10825 if (attribute_flag[1] != 0)
10826 function=(MagickFunction) argument_list[1].integer_reference;
10827 av=(AV *) argument_list[0].array_reference;
10828 number_parameters=(size_t) av_len(av)+1;
10829 parameters=(double *) AcquireQuantumMemory(number_parameters,
10830 sizeof(*parameters));
10831 if (parameters == (double *) NULL)
10833 ThrowPerlException(exception,ResourceLimitFatalError,
10834 "MemoryAllocationFailed",PackageName);
10835 goto PerlException;
10837 for (j=0; j < (ssize_t) number_parameters; j++)
10838 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10839 virtual_pixel=UndefinedVirtualPixelMethod;
10840 if (attribute_flag[2] != 0)
10841 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10842 argument_list[2].integer_reference,exception);
10843 (void) FunctionImage(image,function,number_parameters,parameters,
10845 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10846 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10848 parameters=(double *) RelinquishMagickMemory(parameters);
10851 case 121: /* SelectiveBlur */
10853 if (attribute_flag[0] != 0)
10855 flags=ParseGeometry(argument_list[0].string_reference,
10857 if ((flags & SigmaValue) == 0)
10858 geometry_info.sigma=1.0;
10859 if ((flags & PercentValue) != 0)
10860 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10862 if (attribute_flag[1] != 0)
10863 geometry_info.rho=argument_list[1].real_reference;
10864 if (attribute_flag[2] != 0)
10865 geometry_info.sigma=argument_list[2].real_reference;
10866 if (attribute_flag[3] != 0)
10867 geometry_info.xi=argument_list[3].integer_reference;;
10868 if (attribute_flag[5] != 0)
10869 channel=(ChannelType) argument_list[5].integer_reference;
10870 channel_mask=SetImageChannelMask(image,channel);
10871 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10872 geometry_info.xi,exception);
10873 if (image != (Image *) NULL)
10874 (void) SetImageChannelMask(image,channel_mask);
10877 case 122: /* HaldClut */
10879 if (attribute_flag[0] == 0)
10881 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10883 goto PerlException;
10885 if (attribute_flag[1] != 0)
10886 channel=(ChannelType) argument_list[1].integer_reference;
10887 channel_mask=SetImageChannelMask(image,channel);
10888 (void) HaldClutImage(image,argument_list[0].image_reference,
10890 (void) SetImageChannelMask(image,channel_mask);
10893 case 123: /* BlueShift */
10895 if (attribute_flag[0] != 0)
10896 (void) ParseGeometry(argument_list[0].string_reference,
10898 image=BlueShiftImage(image,geometry_info.rho,exception);
10901 case 124: /* ForwardFourierTransformImage */
10903 image=ForwardFourierTransformImage(image,
10904 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10908 case 125: /* InverseFourierTransformImage */
10910 image=InverseFourierTransformImage(image,image->next,
10911 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10915 case 126: /* ColorDecisionList */
10917 if (attribute_flag[0] == 0)
10918 argument_list[0].string_reference=(char *) NULL;
10919 (void) ColorDecisionListImage(image,
10920 argument_list[0].string_reference,exception);
10923 case 127: /* AutoGamma */
10925 if (attribute_flag[0] != 0)
10926 channel=(ChannelType) argument_list[0].integer_reference;
10927 channel_mask=SetImageChannelMask(image,channel);
10928 (void) AutoGammaImage(image,exception);
10929 (void) SetImageChannelMask(image,channel_mask);
10932 case 128: /* AutoLevel */
10934 if (attribute_flag[0] != 0)
10935 channel=(ChannelType) argument_list[0].integer_reference;
10936 channel_mask=SetImageChannelMask(image,channel);
10937 (void) AutoLevelImage(image,exception);
10938 (void) SetImageChannelMask(image,channel_mask);
10941 case 129: /* LevelColors */
10947 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10949 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10951 if (attribute_flag[1] != 0)
10952 (void) QueryColorCompliance(
10953 argument_list[1].string_reference,AllCompliance,&black_point,
10955 if (attribute_flag[2] != 0)
10956 (void) QueryColorCompliance(
10957 argument_list[2].string_reference,AllCompliance,&white_point,
10959 if (attribute_flag[3] != 0)
10960 channel=(ChannelType) argument_list[3].integer_reference;
10961 channel_mask=SetImageChannelMask(image,channel);
10962 (void) LevelImageColors(image,&black_point,&white_point,
10963 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10965 (void) SetImageChannelMask(image,channel_mask);
10968 case 130: /* Clamp */
10970 if (attribute_flag[0] != 0)
10971 channel=(ChannelType) argument_list[0].integer_reference;
10972 channel_mask=SetImageChannelMask(image,channel);
10973 (void) ClampImage(image,exception);
10974 (void) SetImageChannelMask(image,channel_mask);
10977 case 131: /* BrightnessContrast */
10985 if (attribute_flag[0] != 0)
10987 flags=ParseGeometry(argument_list[0].string_reference,
10989 brightness=geometry_info.rho;
10990 if ((flags & SigmaValue) == 0)
10991 contrast=geometry_info.sigma;
10993 if (attribute_flag[1] != 0)
10994 brightness=argument_list[1].real_reference;
10995 if (attribute_flag[2] != 0)
10996 contrast=argument_list[2].real_reference;
10997 if (attribute_flag[4] != 0)
10998 channel=(ChannelType) argument_list[4].integer_reference;
10999 channel_mask=SetImageChannelMask(image,channel);
11000 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11001 (void) SetImageChannelMask(image,channel_mask);
11004 case 132: /* Morphology */
11015 if (attribute_flag[0] == 0)
11017 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11018 if (kernel == (KernelInfo *) NULL)
11020 if (attribute_flag[1] != 0)
11021 channel=(ChannelType) argument_list[1].integer_reference;
11022 method=UndefinedMorphology;
11023 if (attribute_flag[2] != 0)
11024 method=argument_list[2].integer_reference;
11026 if (attribute_flag[3] != 0)
11027 iterations=argument_list[3].integer_reference;
11028 channel_mask=SetImageChannelMask(image,channel);
11029 image=MorphologyImage(image,method,iterations,kernel,exception);
11030 if (image != (Image *) NULL)
11031 (void) SetImageChannelMask(image,channel_mask);
11032 kernel=DestroyKernelInfo(kernel);
11035 case 133: /* Mode */
11037 if (attribute_flag[0] != 0)
11039 flags=ParseGeometry(argument_list[0].string_reference,
11041 if ((flags & SigmaValue) == 0)
11042 geometry_info.sigma=1.0;
11044 if (attribute_flag[1] != 0)
11045 geometry_info.rho=argument_list[1].real_reference;
11046 if (attribute_flag[2] != 0)
11047 geometry_info.sigma=argument_list[2].real_reference;
11048 if (attribute_flag[3] != 0)
11049 channel=(ChannelType) argument_list[3].integer_reference;
11050 channel_mask=SetImageChannelMask(image,channel);
11051 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11052 (size_t) geometry_info.sigma,exception);
11053 if (image != (Image *) NULL)
11054 (void) SetImageChannelMask(image,channel_mask);
11057 case 134: /* Statistic */
11062 statistic=UndefinedStatistic;
11063 if (attribute_flag[0] != 0)
11065 flags=ParseGeometry(argument_list[0].string_reference,
11067 if ((flags & SigmaValue) == 0)
11068 geometry_info.sigma=1.0;
11070 if (attribute_flag[1] != 0)
11071 geometry_info.rho=argument_list[1].real_reference;
11072 if (attribute_flag[2] != 0)
11073 geometry_info.sigma=argument_list[2].real_reference;
11074 if (attribute_flag[3] != 0)
11075 channel=(ChannelType) argument_list[3].integer_reference;
11076 if (attribute_flag[4] != 0)
11077 statistic=(StatisticType) argument_list[4].integer_reference;
11078 channel_mask=SetImageChannelMask(image,channel);
11079 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11080 (size_t) geometry_info.sigma,exception);
11081 if (image != (Image *) NULL)
11082 (void) SetImageChannelMask(image,channel_mask);
11085 case 135: /* Perceptible */
11090 epsilon=MagickEpsilon;
11091 if (attribute_flag[0] != 0)
11092 epsilon=argument_list[0].real_reference;
11093 if (attribute_flag[1] != 0)
11094 channel=(ChannelType) argument_list[1].integer_reference;
11095 channel_mask=SetImageChannelMask(image,channel);
11096 (void) PerceptibleImage(image,epsilon,exception);
11097 (void) SetImageChannelMask(image,channel_mask);
11100 case 136: /* Poly */
11111 if (attribute_flag[0] == 0)
11113 if (attribute_flag[1] != 0)
11114 channel=(ChannelType) argument_list[1].integer_reference;
11115 av=(AV *) argument_list[0].array_reference;
11116 number_terms=(size_t) av_len(av);
11117 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11118 if (terms == (double *) NULL)
11120 ThrowPerlException(exception,ResourceLimitFatalError,
11121 "MemoryAllocationFailed",PackageName);
11122 goto PerlException;
11124 for (j=0; j < av_len(av); j++)
11125 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11126 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11127 terms=(double *) RelinquishMagickMemory(terms);
11130 case 137: /* Grayscale */
11132 PixelIntensityMethod
11135 method=UndefinedPixelIntensityMethod;
11136 if (attribute_flag[0] != 0)
11137 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11138 (void) GrayscaleImage(image,method,exception);
11141 case 138: /* Canny */
11143 if (attribute_flag[0] != 0)
11145 flags=ParseGeometry(argument_list[0].string_reference,
11147 if ((flags & SigmaValue) == 0)
11148 geometry_info.sigma=1.0;
11149 if ((flags & XiValue) == 0)
11150 geometry_info.xi=0.10;
11151 if ((flags & PsiValue) == 0)
11152 geometry_info.psi=0.30;
11153 if ((flags & PercentValue) != 0)
11155 geometry_info.xi/=100.0;
11156 geometry_info.psi/=100.0;
11159 if (attribute_flag[1] != 0)
11160 geometry_info.rho=argument_list[1].real_reference;
11161 if (attribute_flag[2] != 0)
11162 geometry_info.sigma=argument_list[2].real_reference;
11163 if (attribute_flag[3] != 0)
11164 geometry_info.xi=argument_list[3].real_reference;
11165 if (attribute_flag[4] != 0)
11166 geometry_info.psi=argument_list[4].real_reference;
11167 if (attribute_flag[5] != 0)
11168 channel=(ChannelType) argument_list[5].integer_reference;
11169 channel_mask=SetImageChannelMask(image,channel);
11170 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11171 geometry_info.xi,geometry_info.psi,exception);
11172 if (image != (Image *) NULL)
11173 (void) SetImageChannelMask(image,channel_mask);
11176 case 139: /* HoughLine */
11178 if (attribute_flag[0] != 0)
11180 flags=ParseGeometry(argument_list[0].string_reference,
11182 if ((flags & SigmaValue) == 0)
11183 geometry_info.sigma=geometry_info.rho;
11184 if ((flags & XiValue) == 0)
11185 geometry_info.xi=40;
11187 if (attribute_flag[1] != 0)
11188 geometry_info.rho=(double) argument_list[1].integer_reference;
11189 if (attribute_flag[2] != 0)
11190 geometry_info.sigma=(double) argument_list[2].integer_reference;
11191 if (attribute_flag[3] != 0)
11192 geometry_info.xi=(double) argument_list[3].integer_reference;
11193 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11194 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11197 case 140: /* MeanShift */
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=0.10*QuantumRange;
11207 if ((flags & PercentValue) != 0)
11208 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11210 if (attribute_flag[1] != 0)
11211 geometry_info.rho=(double) argument_list[1].integer_reference;
11212 if (attribute_flag[2] != 0)
11213 geometry_info.sigma=(double) argument_list[2].integer_reference;
11214 if (attribute_flag[3] != 0)
11215 geometry_info.xi=(double) argument_list[3].integer_reference;
11216 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11217 geometry_info.sigma,geometry_info.xi,exception);
11220 case 141: /* Kuwahara */
11222 if (attribute_flag[0] != 0)
11224 flags=ParseGeometry(argument_list[0].string_reference,
11226 if ((flags & SigmaValue) == 0)
11227 geometry_info.sigma=geometry_info.rho-0.5;
11229 if (attribute_flag[1] != 0)
11230 geometry_info.rho=argument_list[1].real_reference;
11231 if (attribute_flag[2] != 0)
11232 geometry_info.sigma=argument_list[2].real_reference;
11233 if (attribute_flag[3] != 0)
11234 channel=(ChannelType) argument_list[3].integer_reference;
11235 channel_mask=SetImageChannelMask(image,channel);
11236 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11238 if (image != (Image *) NULL)
11239 (void) SetImageChannelMask(image,channel_mask);
11242 case 142: /* ConnectedComponent */
11248 if (attribute_flag[0] != 0)
11249 connectivity=argument_list[0].integer_reference;
11250 image=ConnectedComponentsImage(image,connectivity,
11251 (CCObjectInfo **) NULL,exception);
11254 case 143: /* Copy */
11265 source_image=image;
11266 if (attribute_flag[0] != 0)
11267 source_image=argument_list[0].image_reference;
11268 SetGeometry(source_image,&geometry);
11269 if (attribute_flag[1] != 0)
11270 flags=ParseGravityGeometry(source_image,
11271 argument_list[1].string_reference,&geometry,exception);
11272 if (attribute_flag[2] != 0)
11273 geometry.width=argument_list[2].integer_reference;
11274 if (attribute_flag[3] != 0)
11275 geometry.height=argument_list[3].integer_reference;
11276 if (attribute_flag[4] != 0)
11277 geometry.x=argument_list[4].integer_reference;
11278 if (attribute_flag[5] != 0)
11279 geometry.y=argument_list[5].integer_reference;
11280 if (attribute_flag[6] != 0)
11281 image->gravity=(GravityType) argument_list[6].integer_reference;
11282 SetGeometry(image,&offset_geometry);
11283 if (attribute_flag[7] != 0)
11284 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11285 &offset_geometry,exception);
11286 offset.x=offset_geometry.x;
11287 offset.y=offset_geometry.y;
11288 if (attribute_flag[8] != 0)
11289 offset.x=argument_list[8].integer_reference;
11290 if (attribute_flag[9] != 0)
11291 offset.y=argument_list[9].integer_reference;
11292 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11296 case 144: /* Color */
11301 (void) QueryColorCompliance("none",AllCompliance,&color,exception);
11302 if (attribute_flag[0] != 0)
11303 (void) QueryColorCompliance(argument_list[0].string_reference,
11304 AllCompliance,&color,exception);
11305 (void) SetImageColor(image,&color,exception);
11308 case 145: /* WaveletDenoise */
11310 if (attribute_flag[0] != 0)
11312 flags=ParseGeometry(argument_list[0].string_reference,
11314 if ((flags & PercentValue) != 0)
11316 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
11317 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
11319 if ((flags & SigmaValue) == 0)
11320 geometry_info.sigma=0.0;
11322 if (attribute_flag[1] != 0)
11323 geometry_info.rho=argument_list[1].real_reference;
11324 if (attribute_flag[2] != 0)
11325 geometry_info.sigma=argument_list[2].real_reference;
11326 if (attribute_flag[3] != 0)
11327 channel=(ChannelType) argument_list[3].integer_reference;
11328 channel_mask=SetImageChannelMask(image,channel);
11329 image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma,
11331 if (image != (Image *) NULL)
11332 (void) SetImageChannelMask(image,channel_mask);
11335 case 146: /* Colorspace */
11340 colorspace=sRGBColorspace;
11341 if (attribute_flag[0] != 0)
11342 colorspace=(ColorspaceType) argument_list[0].integer_reference;
11343 (void) TransformImageColorspace(image,colorspace,exception);
11347 if (next != (Image *) NULL)
11348 (void) CatchImageException(next);
11349 if (region_image != (Image *) NULL)
11354 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11355 region_info.x,region_info.y,exception);
11357 (void) CatchImageException(region_image);
11358 image=DestroyImage(image);
11359 image=region_image;
11361 if (image != (Image *) NULL)
11364 if (next && (next != image))
11366 image->next=next->next;
11367 if (image->next != (Image *) NULL)
11368 image->next->previous=image;
11369 DeleteImageFromRegistry(*pv,next);
11371 sv_setiv(*pv,PTR2IV(image));
11379 if (reference_vector)
11380 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11381 InheritPerlException(exception,perl_exception);
11382 exception=DestroyExceptionInfo(exception);
11383 sv_setiv(perl_exception,(IV) number_images);
11384 SvPOK_on(perl_exception);
11385 ST(0)=sv_2mortal(perl_exception);
11390 ###############################################################################
11398 ###############################################################################
11403 Image::Magick ref=NO_INIT
11448 PERL_UNUSED_VAR(ref);
11449 PERL_UNUSED_VAR(ix);
11450 exception=AcquireExceptionInfo();
11451 perl_exception=newSVpv("",0);
11454 if (sv_isobject(ST(0)) == 0)
11456 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11458 goto PerlException;
11460 reference=SvRV(ST(0));
11461 hv=SvSTASH(reference);
11463 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11465 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11466 if (image == (Image *) NULL)
11468 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11470 goto PerlException;
11475 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11476 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11477 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11479 for (i=2; i < items; i+=2)
11481 attribute=(char *) SvPV(ST(i-1),na);
11482 switch (*attribute)
11487 if (LocaleCompare(attribute,"background") == 0)
11489 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11490 &montage_info->background_color,exception);
11491 for (next=image; next; next=next->next)
11492 next->background_color=montage_info->background_color;
11495 if (LocaleCompare(attribute,"border") == 0)
11497 montage_info->border_width=SvIV(ST(i));
11500 if (LocaleCompare(attribute,"bordercolor") == 0)
11502 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11503 &montage_info->border_color,exception);
11504 for (next=image; next; next=next->next)
11505 next->border_color=montage_info->border_color;
11508 if (LocaleCompare(attribute,"borderwidth") == 0)
11510 montage_info->border_width=SvIV(ST(i));
11513 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11520 if (LocaleCompare(attribute,"compose") == 0)
11522 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11523 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11526 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11530 for (next=image; next; next=next->next)
11531 next->compose=(CompositeOperator) sp;
11534 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11541 if (LocaleCompare(attribute,"fill") == 0)
11543 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11544 &montage_info->fill,exception);
11547 if (LocaleCompare(attribute,"font") == 0)
11549 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11552 if (LocaleCompare(attribute,"frame") == 0)
11558 if (IsGeometry(p) == MagickFalse)
11560 ThrowPerlException(exception,OptionError,"MissingGeometry",
11564 (void) CloneString(&montage_info->frame,p);
11566 montage_info->frame=(char *) NULL;
11569 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11576 if (LocaleCompare(attribute,"geometry") == 0)
11582 if (IsGeometry(p) == MagickFalse)
11584 ThrowPerlException(exception,OptionError,"MissingGeometry",
11588 (void) CloneString(&montage_info->geometry,p);
11590 montage_info->geometry=(char *) NULL;
11593 if (LocaleCompare(attribute,"gravity") == 0)
11598 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11599 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11602 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11606 montage_info->gravity=(GravityType) in;
11607 for (next=image; next; next=next->next)
11608 next->gravity=(GravityType) in;
11611 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11618 if (LocaleCompare(attribute,"label") == 0)
11620 for (next=image; next; next=next->next)
11621 (void) SetImageProperty(next,"label",InterpretImageProperties(
11622 info ? info->image_info : (ImageInfo *) NULL,next,
11623 SvPV(ST(i),na),exception),exception);
11626 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11633 if (LocaleCompare(attribute,"mattecolor") == 0)
11635 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11636 &montage_info->alpha_color,exception);
11637 for (next=image; next; next=next->next)
11638 next->alpha_color=montage_info->alpha_color;
11641 if (LocaleCompare(attribute,"mode") == 0)
11646 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11647 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11652 ThrowPerlException(exception,OptionError,
11653 "UnrecognizedModeType",SvPV(ST(i),na));
11658 (void) CloneString(&montage_info->frame,"15x15+3+3");
11659 montage_info->shadow=MagickTrue;
11664 montage_info->frame=(char *) NULL;
11665 montage_info->shadow=MagickFalse;
11666 montage_info->border_width=0;
11669 case ConcatenateMode:
11671 montage_info->frame=(char *) NULL;
11672 montage_info->shadow=MagickFalse;
11673 (void) CloneString(&montage_info->geometry,"+0+0");
11674 montage_info->border_width=0;
11679 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11686 if (LocaleCompare(attribute,"pointsize") == 0)
11688 montage_info->pointsize=SvIV(ST(i));
11691 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11698 if (LocaleCompare(attribute,"shadow") == 0)
11700 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11701 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11704 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11708 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11711 if (LocaleCompare(attribute,"stroke") == 0)
11713 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11714 &montage_info->stroke,exception);
11717 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11724 if (LocaleCompare(attribute,"texture") == 0)
11726 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11729 if (LocaleCompare(attribute,"tile") == 0)
11731 char *p=SvPV(ST(i),na);
11732 if (IsGeometry(p) == MagickFalse)
11734 ThrowPerlException(exception,OptionError,"MissingGeometry",
11738 (void) CloneString(&montage_info->tile,p);
11740 montage_info->tile=(char *) NULL;
11743 if (LocaleCompare(attribute,"title") == 0)
11745 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11748 if (LocaleCompare(attribute,"transparent") == 0)
11753 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11754 &transparent_color,exception);
11755 for (next=image; next; next=next->next)
11756 (void) TransparentPaintImage(next,&transparent_color,
11757 TransparentAlpha,MagickFalse,exception);
11760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11766 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11772 image=MontageImageList(info->image_info,montage_info,image,exception);
11773 montage_info=DestroyMontageInfo(montage_info);
11774 if (image == (Image *) NULL)
11775 goto PerlException;
11776 if (transparent_color.alpha != TransparentAlpha)
11777 for (next=image; next; next=next->next)
11778 (void) TransparentPaintImage(next,&transparent_color,
11779 TransparentAlpha,MagickFalse,exception);
11780 for ( ; image; image=image->next)
11782 AddImageToRegistry(sv,image);
11784 av_push(av,sv_bless(rv,hv));
11787 exception=DestroyExceptionInfo(exception);
11788 ST(0)=av_reference;
11789 SvREFCNT_dec(perl_exception);
11793 InheritPerlException(exception,perl_exception);
11794 exception=DestroyExceptionInfo(exception);
11795 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11796 SvPOK_on(perl_exception);
11797 ST(0)=sv_2mortal(perl_exception);
11802 ###############################################################################
11810 ###############################################################################
11815 Image::Magick ref=NO_INIT
11853 PERL_UNUSED_VAR(ref);
11854 PERL_UNUSED_VAR(ix);
11855 exception=AcquireExceptionInfo();
11856 perl_exception=newSVpv("",0);
11860 if (sv_isobject(ST(0)) == 0)
11862 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11864 goto PerlException;
11866 reference=SvRV(ST(0));
11867 hv=SvSTASH(reference);
11869 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11871 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11872 if (image == (Image *) NULL)
11874 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11876 goto PerlException;
11878 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11883 for (i=2; i < items; i+=2)
11885 attribute=(char *) SvPV(ST(i-1),na);
11886 switch (*attribute)
11891 if (LocaleCompare(attribute,"frames") == 0)
11893 number_frames=SvIV(ST(i));
11896 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11902 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11908 image=MorphImages(image,number_frames,exception);
11909 if (image == (Image *) NULL)
11910 goto PerlException;
11911 for ( ; image; image=image->next)
11913 AddImageToRegistry(sv,image);
11915 av_push(av,sv_bless(rv,hv));
11918 exception=DestroyExceptionInfo(exception);
11919 ST(0)=av_reference;
11920 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11924 InheritPerlException(exception,perl_exception);
11925 exception=DestroyExceptionInfo(exception);
11926 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11927 SvPOK_on(perl_exception);
11928 ST(0)=sv_2mortal(perl_exception);
11933 ###############################################################################
11941 ###############################################################################
11946 Image::Magick ref=NO_INIT
11974 PERL_UNUSED_VAR(ref);
11975 PERL_UNUSED_VAR(ix);
11976 exception=AcquireExceptionInfo();
11977 perl_exception=newSVpv("",0);
11979 if (sv_isobject(ST(0)) == 0)
11981 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11983 goto PerlException;
11985 reference=SvRV(ST(0));
11986 hv=SvSTASH(reference);
11987 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11988 if (image == (Image *) NULL)
11990 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11992 goto PerlException;
11994 image=MergeImageLayers(image,MosaicLayer,exception);
11996 Create blessed Perl array for the returned image.
11999 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12001 AddImageToRegistry(sv,image);
12003 av_push(av,sv_bless(rv,hv));
12005 (void) CopyMagickString(info->image_info->filename,image->filename,
12007 SetImageInfo(info->image_info,0,exception);
12008 exception=DestroyExceptionInfo(exception);
12009 SvREFCNT_dec(perl_exception);
12013 InheritPerlException(exception,perl_exception);
12014 exception=DestroyExceptionInfo(exception);
12015 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12016 SvPOK_on(perl_exception); /* return messages in string context */
12017 ST(0)=sv_2mortal(perl_exception);
12022 ###############################################################################
12030 ###############################################################################
12035 Image::Magick ref=NO_INIT
12085 PERL_UNUSED_VAR(ref);
12086 PERL_UNUSED_VAR(ix);
12087 exception=AcquireExceptionInfo();
12088 perl_exception=newSVpv("",0);
12089 package_info=(struct PackageInfo *) NULL;
12090 ac=(items < 2) ? 1 : items-1;
12091 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12093 length=(STRLEN *) NULL;
12094 if (list == (char **) NULL)
12096 ThrowPerlException(exception,ResourceLimitError,
12097 "MemoryAllocationFailed",PackageName);
12098 goto PerlException;
12101 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12102 if (length == (STRLEN *) NULL)
12104 ThrowPerlException(exception,ResourceLimitError,
12105 "MemoryAllocationFailed",PackageName);
12106 goto PerlException;
12108 if (sv_isobject(ST(0)) == 0)
12110 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12112 goto PerlException;
12114 reference=SvRV(ST(0));
12115 if (SvTYPE(reference) != SVt_PVAV)
12117 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12119 goto PerlException;
12121 av=(AV *) reference;
12122 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12124 package_info=ClonePackageInfo(info,exception);
12127 *list=(char *) (*package_info->image_info->filename ?
12128 package_info->image_info->filename : "XC:black");
12130 for (n=0, i=0; i < ac; i++)
12132 list[n]=(char *) SvPV(ST(i+1),length[n]);
12133 if ((items >= 3) && strEQcase(list[n],"blob"))
12139 blob=(void *) (SvPV(ST(i+1),length[n]));
12140 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12142 if ((items >= 3) && strEQcase(list[n],"filename"))
12144 if ((items >= 3) && strEQcase(list[n],"file"))
12153 io_info=IoIFP(sv_2io(ST(i+1)));
12154 if (io_info == (PerlIO *) NULL)
12156 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12160 file=PerlIO_findFILE(io_info);
12161 if (file == (FILE *) NULL)
12163 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12167 SetImageInfoFile(package_info->image_info,file);
12169 if ((items >= 3) && strEQcase(list[n],"magick"))
12173 list[n]=(char *) NULL;
12175 status=ExpandFilenames(&n,&list);
12176 if (status == MagickFalse)
12178 ThrowPerlException(exception,ResourceLimitError,
12179 "MemoryAllocationFailed",PackageName);
12180 goto PerlException;
12183 for (i=0; i < n; i++)
12185 (void) CopyMagickString(package_info->image_info->filename,list[i],
12187 image=PingImage(package_info->image_info,exception);
12188 if (image == (Image *) NULL)
12190 if ((package_info->image_info->file != (FILE *) NULL) ||
12191 (package_info->image_info->blob != (void *) NULL))
12192 DisassociateImageStream(image);
12193 count+=GetImageListLength(image);
12194 EXTEND(sp,4*count);
12195 for (next=image; next; next=next->next)
12197 PUSHs(sv_2mortal(newSViv(next->columns)));
12198 PUSHs(sv_2mortal(newSViv(next->rows)));
12199 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12200 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12202 image=DestroyImageList(image);
12207 for (i=0; i < n; i++)
12208 if (list[i] != (char *) NULL)
12209 for (p=keep; list[i] != *p++; )
12212 list[i]=(char *) RelinquishMagickMemory(list[i]);
12217 if (package_info != (struct PackageInfo *) NULL)
12218 DestroyPackageInfo(package_info);
12219 if (list && (list != keep))
12220 list=(char **) RelinquishMagickMemory(list);
12222 keep=(char **) RelinquishMagickMemory(keep);
12224 length=(STRLEN *) RelinquishMagickMemory(length);
12225 InheritPerlException(exception,perl_exception);
12226 exception=DestroyExceptionInfo(exception);
12227 SvREFCNT_dec(perl_exception); /* throw away all errors */
12231 ###############################################################################
12239 ###############################################################################
12244 Image::Magick ref=NO_INIT
12277 PERL_UNUSED_VAR(ref);
12278 PERL_UNUSED_VAR(ix);
12279 exception=AcquireExceptionInfo();
12280 perl_exception=newSVpv("",0);
12283 if (sv_isobject(ST(0)) == 0)
12285 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12287 goto PerlException;
12289 reference=SvRV(ST(0));
12290 hv=SvSTASH(reference);
12292 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12294 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12295 if (image == (Image *) NULL)
12297 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12299 goto PerlException;
12301 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12302 preview_type=GammaPreview;
12304 preview_type=(PreviewType)
12305 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12306 for ( ; image; image=image->next)
12308 preview_image=PreviewImage(image,preview_type,exception);
12309 if (preview_image == (Image *) NULL)
12310 goto PerlException;
12311 AddImageToRegistry(sv,preview_image);
12313 av_push(av,sv_bless(rv,hv));
12316 exception=DestroyExceptionInfo(exception);
12317 ST(0)=av_reference;
12318 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12322 InheritPerlException(exception,perl_exception);
12323 exception=DestroyExceptionInfo(exception);
12324 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12325 SvPOK_on(perl_exception);
12326 ST(0)=sv_2mortal(perl_exception);
12331 ###############################################################################
12335 # Q u e r y C o l o r #
12339 ###############################################################################
12343 QueryColor(ref,...)
12344 Image::Magick ref=NO_INIT
12364 PERL_UNUSED_VAR(ref);
12365 PERL_UNUSED_VAR(ix);
12366 exception=AcquireExceptionInfo();
12367 perl_exception=newSVpv("",0);
12376 colorlist=GetColorInfoList("*",&colors,exception);
12378 for (i=0; i < (ssize_t) colors; i++)
12380 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12382 colorlist=(const ColorInfo **)
12383 RelinquishMagickMemory((ColorInfo **) colorlist);
12384 goto PerlException;
12386 EXTEND(sp,5*items);
12387 for (i=1; i < items; i++)
12389 name=(char *) SvPV(ST(i),na);
12390 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12395 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12396 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12397 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12398 if (color.colorspace == CMYKColorspace)
12399 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12400 if (color.alpha_trait != UndefinedPixelTrait)
12401 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12405 InheritPerlException(exception,perl_exception);
12406 exception=DestroyExceptionInfo(exception);
12407 SvREFCNT_dec(perl_exception);
12411 ###############################################################################
12415 # Q u e r y C o l o r N a m e #
12419 ###############################################################################
12423 QueryColorname(ref,...)
12424 Image::Magick ref=NO_INIT
12433 message[MagickPathExtent];
12452 *reference; /* reference is the SV* of ref=SvIV(reference) */
12454 PERL_UNUSED_VAR(ref);
12455 PERL_UNUSED_VAR(ix);
12456 exception=AcquireExceptionInfo();
12457 perl_exception=newSVpv("",0);
12458 reference=SvRV(ST(0));
12459 av=(AV *) reference;
12460 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12462 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12463 if (image == (Image *) NULL)
12465 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12467 goto PerlException;
12470 for (i=1; i < items; i++)
12472 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12474 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12476 PUSHs(sv_2mortal(newSVpv(message,0)));
12480 InheritPerlException(exception,perl_exception);
12481 exception=DestroyExceptionInfo(exception);
12482 SvREFCNT_dec(perl_exception);
12486 ###############################################################################
12490 # Q u e r y F o n t #
12494 ###############################################################################
12499 Image::Magick ref=NO_INIT
12506 message[MagickPathExtent];
12517 volatile const TypeInfo
12520 PERL_UNUSED_VAR(ref);
12521 PERL_UNUSED_VAR(ix);
12522 exception=AcquireExceptionInfo();
12523 perl_exception=newSVpv("",0);
12532 typelist=GetTypeInfoList("*",&types,exception);
12534 for (i=0; i < (ssize_t) types; i++)
12536 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12538 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12540 goto PerlException;
12542 EXTEND(sp,10*items);
12543 for (i=1; i < items; i++)
12545 name=(char *) SvPV(ST(i),na);
12546 type_info=GetTypeInfo(name,exception);
12547 if (type_info == (TypeInfo *) NULL)
12552 if (type_info->name == (char *) NULL)
12555 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12556 if (type_info->description == (char *) NULL)
12559 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12560 if (type_info->family == (char *) NULL)
12563 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12564 if (type_info->style == UndefinedStyle)
12567 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12568 type_info->style),0)));
12569 if (type_info->stretch == UndefinedStretch)
12572 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12573 type_info->stretch),0)));
12574 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12575 type_info->weight);
12576 PUSHs(sv_2mortal(newSVpv(message,0)));
12577 if (type_info->encoding == (char *) NULL)
12580 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12581 if (type_info->foundry == (char *) NULL)
12584 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12585 if (type_info->format == (char *) NULL)
12588 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12589 if (type_info->metrics == (char *) NULL)
12592 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12593 if (type_info->glyphs == (char *) NULL)
12596 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12600 InheritPerlException(exception,perl_exception);
12601 exception=DestroyExceptionInfo(exception);
12602 SvREFCNT_dec(perl_exception);
12606 ###############################################################################
12610 # Q u e r y F o n t M e t r i c s #
12614 ###############################################################################
12618 QueryFontMetrics(ref,...)
12619 Image::Magick ref=NO_INIT
12621 queryfontmetrics = 1
12668 *reference; /* reference is the SV* of ref=SvIV(reference) */
12673 PERL_UNUSED_VAR(ref);
12674 PERL_UNUSED_VAR(ix);
12675 exception=AcquireExceptionInfo();
12676 package_info=(struct PackageInfo *) NULL;
12677 perl_exception=newSVpv("",0);
12678 reference=SvRV(ST(0));
12679 av=(AV *) reference;
12680 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12682 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12683 if (image == (Image *) NULL)
12685 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12687 goto PerlException;
12689 package_info=ClonePackageInfo(info,exception);
12690 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12691 CloneString(&draw_info->text,"");
12692 current=draw_info->affine;
12693 GetAffineMatrix(&affine);
12696 EXTEND(sp,7*items);
12697 for (i=2; i < items; i+=2)
12699 attribute=(char *) SvPV(ST(i-1),na);
12700 switch (*attribute)
12705 if (LocaleCompare(attribute,"antialias") == 0)
12707 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12711 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12715 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12718 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12725 if (LocaleCompare(attribute,"density") == 0)
12727 CloneString(&draw_info->density,SvPV(ST(i),na));
12730 if (LocaleCompare(attribute,"direction") == 0)
12732 draw_info->direction=(DirectionType) ParseCommandOption(
12733 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12736 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12743 if (LocaleCompare(attribute,"encoding") == 0)
12745 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12748 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12755 if (LocaleCompare(attribute,"family") == 0)
12757 CloneString(&draw_info->family,SvPV(ST(i),na));
12760 if (LocaleCompare(attribute,"fill") == 0)
12763 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12764 &draw_info->fill,exception);
12767 if (LocaleCompare(attribute,"font") == 0)
12769 CloneString(&draw_info->font,SvPV(ST(i),na));
12772 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12779 if (LocaleCompare(attribute,"geometry") == 0)
12781 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12784 if (LocaleCompare(attribute,"gravity") == 0)
12786 draw_info->gravity=(GravityType) ParseCommandOption(
12787 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12790 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12797 if (LocaleCompare(attribute,"interline-spacing") == 0)
12799 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12800 draw_info->interline_spacing=geometry_info.rho;
12803 if (LocaleCompare(attribute,"interword-spacing") == 0)
12805 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12806 draw_info->interword_spacing=geometry_info.rho;
12809 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12816 if (LocaleCompare(attribute,"kerning") == 0)
12818 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12819 draw_info->kerning=geometry_info.rho;
12822 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12829 if (LocaleCompare(attribute,"pointsize") == 0)
12831 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12832 draw_info->pointsize=geometry_info.rho;
12835 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12842 if (LocaleCompare(attribute,"rotate") == 0)
12844 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12845 affine.rx=geometry_info.rho;
12846 affine.ry=geometry_info.sigma;
12847 if ((flags & SigmaValue) == 0)
12848 affine.ry=affine.rx;
12851 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12858 if (LocaleCompare(attribute,"scale") == 0)
12860 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12861 affine.sx=geometry_info.rho;
12862 affine.sy=geometry_info.sigma;
12863 if ((flags & SigmaValue) == 0)
12864 affine.sy=affine.sx;
12867 if (LocaleCompare(attribute,"skew") == 0)
12873 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12874 x_angle=geometry_info.rho;
12875 y_angle=geometry_info.sigma;
12876 if ((flags & SigmaValue) == 0)
12878 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12879 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12882 if (LocaleCompare(attribute,"stroke") == 0)
12885 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12886 &draw_info->stroke,exception);
12889 if (LocaleCompare(attribute,"style") == 0)
12891 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12895 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12899 draw_info->style=(StyleType) type;
12902 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12909 if (LocaleCompare(attribute,"text") == 0)
12911 CloneString(&draw_info->text,SvPV(ST(i),na));
12914 if (LocaleCompare(attribute,"translate") == 0)
12916 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12917 affine.tx=geometry_info.rho;
12918 affine.ty=geometry_info.sigma;
12919 if ((flags & SigmaValue) == 0)
12920 affine.ty=affine.tx;
12923 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12930 if (LocaleCompare(attribute,"weight") == 0)
12932 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12933 draw_info->weight=(size_t) geometry_info.rho;
12936 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12943 if (LocaleCompare(attribute,"x") == 0)
12945 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12946 x=geometry_info.rho;
12949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12956 if (LocaleCompare(attribute,"y") == 0)
12958 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12959 y=geometry_info.rho;
12962 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12968 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12974 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12975 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12976 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12977 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12978 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12979 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12980 if (draw_info->geometry == (char *) NULL)
12982 draw_info->geometry=AcquireString((char *) NULL);
12983 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12984 "%.15g,%.15g",x,y);
12986 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12987 (void) CatchImageException(image);
12988 if (status == MagickFalse)
12992 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12993 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12994 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12995 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12996 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12997 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12998 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12999 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13000 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13001 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13002 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13003 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13004 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13006 draw_info=DestroyDrawInfo(draw_info);
13009 if (package_info != (struct PackageInfo *) NULL)
13010 DestroyPackageInfo(package_info);
13011 InheritPerlException(exception,perl_exception);
13012 exception=DestroyExceptionInfo(exception);
13013 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13017 ###############################################################################
13021 # 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 #
13025 ###############################################################################
13029 QueryMultilineFontMetrics(ref,...)
13030 Image::Magick ref=NO_INIT
13032 querymultilinefontmetrics = 1
13079 *reference; /* reference is the SV* of ref=SvIV(reference) */
13084 PERL_UNUSED_VAR(ref);
13085 PERL_UNUSED_VAR(ix);
13086 exception=AcquireExceptionInfo();
13087 package_info=(struct PackageInfo *) NULL;
13088 perl_exception=newSVpv("",0);
13089 reference=SvRV(ST(0));
13090 av=(AV *) reference;
13091 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13093 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13094 if (image == (Image *) NULL)
13096 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13098 goto PerlException;
13100 package_info=ClonePackageInfo(info,exception);
13101 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13102 CloneString(&draw_info->text,"");
13103 current=draw_info->affine;
13104 GetAffineMatrix(&affine);
13107 EXTEND(sp,7*items);
13108 for (i=2; i < items; i+=2)
13110 attribute=(char *) SvPV(ST(i-1),na);
13111 switch (*attribute)
13116 if (LocaleCompare(attribute,"antialias") == 0)
13118 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13122 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13126 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13136 if (LocaleCompare(attribute,"density") == 0)
13138 CloneString(&draw_info->density,SvPV(ST(i),na));
13141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13148 if (LocaleCompare(attribute,"encoding") == 0)
13150 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13160 if (LocaleCompare(attribute,"family") == 0)
13162 CloneString(&draw_info->family,SvPV(ST(i),na));
13165 if (LocaleCompare(attribute,"fill") == 0)
13168 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13169 &draw_info->fill,exception);
13172 if (LocaleCompare(attribute,"font") == 0)
13174 CloneString(&draw_info->font,SvPV(ST(i),na));
13177 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13184 if (LocaleCompare(attribute,"geometry") == 0)
13186 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13189 if (LocaleCompare(attribute,"gravity") == 0)
13191 draw_info->gravity=(GravityType) ParseCommandOption(
13192 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13195 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13202 if (LocaleCompare(attribute,"pointsize") == 0)
13204 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13205 draw_info->pointsize=geometry_info.rho;
13208 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13215 if (LocaleCompare(attribute,"rotate") == 0)
13217 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13218 affine.rx=geometry_info.rho;
13219 affine.ry=geometry_info.sigma;
13220 if ((flags & SigmaValue) == 0)
13221 affine.ry=affine.rx;
13224 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13231 if (LocaleCompare(attribute,"scale") == 0)
13233 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13234 affine.sx=geometry_info.rho;
13235 affine.sy=geometry_info.sigma;
13236 if ((flags & SigmaValue) == 0)
13237 affine.sy=affine.sx;
13240 if (LocaleCompare(attribute,"skew") == 0)
13246 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13247 x_angle=geometry_info.rho;
13248 y_angle=geometry_info.sigma;
13249 if ((flags & SigmaValue) == 0)
13251 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13252 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13255 if (LocaleCompare(attribute,"stroke") == 0)
13258 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13259 &draw_info->stroke,exception);
13262 if (LocaleCompare(attribute,"style") == 0)
13264 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13268 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13272 draw_info->style=(StyleType) type;
13275 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13282 if (LocaleCompare(attribute,"text") == 0)
13284 CloneString(&draw_info->text,SvPV(ST(i),na));
13287 if (LocaleCompare(attribute,"translate") == 0)
13289 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13290 affine.tx=geometry_info.rho;
13291 affine.ty=geometry_info.sigma;
13292 if ((flags & SigmaValue) == 0)
13293 affine.ty=affine.tx;
13296 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13303 if (LocaleCompare(attribute,"weight") == 0)
13305 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13306 draw_info->weight=(size_t) geometry_info.rho;
13309 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13316 if (LocaleCompare(attribute,"x") == 0)
13318 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13319 x=geometry_info.rho;
13322 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13329 if (LocaleCompare(attribute,"y") == 0)
13331 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13332 y=geometry_info.rho;
13335 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13341 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13347 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13348 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13349 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13350 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13351 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13352 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13353 if (draw_info->geometry == (char *) NULL)
13355 draw_info->geometry=AcquireString((char *) NULL);
13356 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13357 "%.15g,%.15g",x,y);
13359 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13360 (void) CatchException(exception);
13361 if (status == MagickFalse)
13365 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13366 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13367 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13368 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13369 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13370 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13371 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13372 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13373 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13374 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13375 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13376 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13377 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13379 draw_info=DestroyDrawInfo(draw_info);
13382 if (package_info != (struct PackageInfo *) NULL)
13383 DestroyPackageInfo(package_info);
13384 InheritPerlException(exception,perl_exception);
13385 exception=DestroyExceptionInfo(exception);
13386 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13390 ###############################################################################
13394 # Q u e r y F o r m a t #
13398 ###############################################################################
13402 QueryFormat(ref,...)
13403 Image::Magick ref=NO_INIT
13420 volatile const MagickInfo
13423 PERL_UNUSED_VAR(ref);
13424 PERL_UNUSED_VAR(ix);
13425 exception=AcquireExceptionInfo();
13426 perl_exception=newSVpv("",0);
13430 format[MagickPathExtent];
13438 format_list=GetMagickInfoList("*",&types,exception);
13440 for (i=0; i < (ssize_t) types; i++)
13442 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13443 LocaleLower(format);
13444 PUSHs(sv_2mortal(newSVpv(format,0)));
13446 format_list=(const MagickInfo **)
13447 RelinquishMagickMemory((MagickInfo *) format_list);
13448 goto PerlException;
13450 EXTEND(sp,8*items);
13451 for (i=1; i < items; i++)
13453 name=(char *) SvPV(ST(i),na);
13454 magick_info=GetMagickInfo(name,exception);
13455 if (magick_info == (const MagickInfo *) NULL)
13460 if (magick_info->description == (char *) NULL)
13463 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13464 if (magick_info->module == (char *) NULL)
13467 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13471 InheritPerlException(exception,perl_exception);
13472 exception=DestroyExceptionInfo(exception);
13473 SvREFCNT_dec(perl_exception);
13477 ###############################################################################
13481 # Q u e r y O p t i o n #
13485 ###############################################################################
13489 QueryOption(ref,...)
13490 Image::Magick ref=NO_INIT
13511 PERL_UNUSED_VAR(ref);
13512 PERL_UNUSED_VAR(ix);
13513 exception=AcquireExceptionInfo();
13514 perl_exception=newSVpv("",0);
13515 EXTEND(sp,8*items);
13516 for (i=1; i < items; i++)
13518 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13520 options=GetCommandOptions((CommandOption) option);
13521 if (options == (char **) NULL)
13525 for (j=0; options[j] != (char *) NULL; j++)
13526 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13527 options=DestroyStringList(options);
13531 InheritPerlException(exception,perl_exception);
13532 exception=DestroyExceptionInfo(exception);
13533 SvREFCNT_dec(perl_exception);
13537 ###############################################################################
13545 ###############################################################################
13550 Image::Magick ref=NO_INIT
13597 *perl_exception, /* Perl variable for storing messages */
13602 PERL_UNUSED_VAR(ref);
13603 PERL_UNUSED_VAR(ix);
13604 exception=AcquireExceptionInfo();
13605 perl_exception=newSVpv("",0);
13607 package_info=(struct PackageInfo *) NULL;
13609 ac=(items < 2) ? 1 : items-1;
13610 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13612 length=(STRLEN *) NULL;
13613 if (list == (char **) NULL)
13615 ThrowPerlException(exception,ResourceLimitError,
13616 "MemoryAllocationFailed",PackageName);
13617 goto PerlException;
13619 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13620 if (length == (STRLEN *) NULL)
13622 ThrowPerlException(exception,ResourceLimitError,
13623 "MemoryAllocationFailed",PackageName);
13624 goto PerlException;
13626 if (sv_isobject(ST(0)) == 0)
13628 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13630 goto PerlException;
13632 reference=SvRV(ST(0));
13633 hv=SvSTASH(reference);
13634 if (SvTYPE(reference) != SVt_PVAV)
13636 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13638 goto PerlException;
13640 av=(AV *) reference;
13641 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13643 package_info=ClonePackageInfo(info,exception);
13646 *list=(char *) (*package_info->image_info->filename ?
13647 package_info->image_info->filename : "XC:black");
13649 for (n=0, i=0; i < ac; i++)
13651 list[n]=(char *) SvPV(ST(i+1),length[n]);
13652 if ((items >= 3) && strEQcase(list[n],"blob"))
13658 blob=(void *) (SvPV(ST(i+1),length[n]));
13659 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13661 if ((items >= 3) && strEQcase(list[n],"filename"))
13663 if ((items >= 3) && strEQcase(list[n],"file"))
13672 io_info=IoIFP(sv_2io(ST(i+1)));
13673 if (io_info == (PerlIO *) NULL)
13675 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13679 file=PerlIO_findFILE(io_info);
13680 if (file == (FILE *) NULL)
13682 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13686 SetImageInfoFile(package_info->image_info,file);
13688 if ((items >= 3) && strEQcase(list[n],"magick"))
13692 list[n]=(char *) NULL;
13694 status=ExpandFilenames(&n,&list);
13695 if (status == MagickFalse)
13697 ThrowPerlException(exception,ResourceLimitError,
13698 "MemoryAllocationFailed",PackageName);
13699 goto PerlException;
13702 for (i=0; i < n; i++)
13704 if ((package_info->image_info->file == (FILE *) NULL) &&
13705 (package_info->image_info->blob == (void *) NULL))
13706 image=ReadImages(package_info->image_info,list[i],exception);
13709 image=ReadImages(package_info->image_info,
13710 package_info->image_info->filename,exception);
13711 if (image != (Image *) NULL)
13712 DisassociateImageStream(image);
13714 if (image == (Image *) NULL)
13716 for ( ; image; image=image->next)
13718 AddImageToRegistry(sv,image);
13720 av_push(av,sv_bless(rv,hv));
13728 for (i=0; i < n; i++)
13729 if (list[i] != (char *) NULL)
13730 for (p=keep; list[i] != *p++; )
13731 if (*p == (char *) NULL)
13733 list[i]=(char *) RelinquishMagickMemory(list[i]);
13738 if (package_info != (struct PackageInfo *) NULL)
13739 DestroyPackageInfo(package_info);
13740 if (list && (list != keep))
13741 list=(char **) RelinquishMagickMemory(list);
13743 keep=(char **) RelinquishMagickMemory(keep);
13745 length=(STRLEN *) RelinquishMagickMemory(length);
13746 InheritPerlException(exception,perl_exception);
13747 exception=DestroyExceptionInfo(exception);
13748 sv_setiv(perl_exception,(IV) number_images);
13749 SvPOK_on(perl_exception);
13750 ST(0)=sv_2mortal(perl_exception);
13755 ###############################################################################
13763 ###############################################################################
13768 Image::Magick ref=NO_INIT
13791 PERL_UNUSED_VAR(ref);
13792 PERL_UNUSED_VAR(ix);
13793 exception=AcquireExceptionInfo();
13794 perl_exception=newSVpv("",0);
13795 reference=SvRV(ST(0));
13796 av=(AV *) reference;
13797 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13799 for (i=1; i < items; i++)
13800 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13801 SvPV(ST(i),na),exception);
13802 InheritPerlException(exception,perl_exception);
13803 exception=DestroyExceptionInfo(exception);
13804 SvREFCNT_dec(perl_exception); /* throw away all errors */
13808 ###############################################################################
13816 ###############################################################################
13821 Image::Magick ref=NO_INIT
13844 *reference; /* reference is the SV* of ref=SvIV(reference) */
13846 PERL_UNUSED_VAR(ref);
13847 PERL_UNUSED_VAR(ix);
13848 exception=AcquireExceptionInfo();
13849 perl_exception=newSVpv("",0);
13850 if (sv_isobject(ST(0)) == 0)
13852 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13854 goto PerlException;
13856 reference=SvRV(ST(0));
13857 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13859 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13861 for (i=2; i < items; i+=2)
13862 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13865 InheritPerlException(exception,perl_exception);
13866 exception=DestroyExceptionInfo(exception);
13867 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13868 SvPOK_on(perl_exception);
13869 ST(0)=sv_2mortal(perl_exception);
13874 ###############################################################################
13878 # S e t P i x e l #
13882 ###############################################################################
13887 Image::Magick ref=NO_INIT
13929 *reference; /* reference is the SV* of ref=SvIV(reference) */
13931 PERL_UNUSED_VAR(ref);
13932 PERL_UNUSED_VAR(ix);
13933 exception=AcquireExceptionInfo();
13934 perl_exception=newSVpv("",0);
13935 reference=SvRV(ST(0));
13936 av=(AV *) reference;
13937 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13939 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13940 if (image == (Image *) NULL)
13942 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13944 goto PerlException;
13947 normalize=MagickTrue;
13950 region.width=image->columns;
13953 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13954 channel=DefaultChannels;
13955 for (i=2; i < items; i+=2)
13957 attribute=(char *) SvPV(ST(i-1),na);
13958 switch (*attribute)
13963 if (LocaleCompare(attribute,"channel") == 0)
13968 option=ParseChannelOption(SvPV(ST(i),na));
13971 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13975 channel=(ChannelType) option;
13978 if (LocaleCompare(attribute,"color") == 0)
13980 if (SvTYPE(ST(i)) != SVt_RV)
13983 message[MagickPathExtent];
13985 (void) FormatLocaleString(message,MagickPathExtent,
13986 "invalid %.60s value",attribute);
13987 ThrowPerlException(exception,OptionError,message,
13990 av=(AV *) SvRV(ST(i));
13993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14000 if (LocaleCompare(attribute,"geometry") == 0)
14002 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
14005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14012 if (LocaleCompare(attribute,"normalize") == 0)
14014 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14018 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14022 normalize=option != 0 ? MagickTrue : MagickFalse;
14025 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14032 if (LocaleCompare(attribute,"x") == 0)
14034 region.x=SvIV(ST(i));
14037 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14044 if (LocaleCompare(attribute,"y") == 0)
14046 region.y=SvIV(ST(i));
14049 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14055 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14061 (void) SetImageStorageClass(image,DirectClass,exception);
14062 channel_mask=SetImageChannelMask(image,channel);
14063 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14064 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14065 (SvTYPE(av) != SVt_PVAV))
14077 if (normalize != MagickFalse)
14078 scale=QuantumRange;
14079 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14082 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14083 av_fetch(av,i,0)))),q);
14086 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14089 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14090 av_fetch(av,i,0)))),q);
14093 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14096 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14097 av_fetch(av,i,0)))),q);
14100 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14101 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14103 SetPixelBlack(image,ClampToQuantum(scale*
14104 SvNV(*(av_fetch(av,i,0)))),q);
14107 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14110 SetPixelAlpha(image,ClampToQuantum(scale*
14111 SvNV(*(av_fetch(av,i,0)))),q);
14114 (void) SyncAuthenticPixels(image,exception);
14116 (void) SetImageChannelMask(image,channel_mask);
14119 InheritPerlException(exception,perl_exception);
14120 exception=DestroyExceptionInfo(exception);
14121 SvREFCNT_dec(perl_exception);
14125 ###############################################################################
14133 ###############################################################################
14138 Image::Magick ref=NO_INIT
14177 PERL_UNUSED_VAR(ref);
14178 PERL_UNUSED_VAR(ix);
14179 exception=AcquireExceptionInfo();
14180 perl_exception=newSVpv("",0);
14184 if (sv_isobject(ST(0)) == 0)
14186 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14188 goto PerlException;
14190 reference=SvRV(ST(0));
14191 hv=SvSTASH(reference);
14193 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14195 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14196 if (image == (Image *) NULL)
14198 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14200 goto PerlException;
14202 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14208 for (i=2; i < items; i+=2)
14210 attribute=(char *) SvPV(ST(i-1),na);
14211 switch (*attribute)
14216 if (LocaleCompare(attribute,"offset") == 0)
14218 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14221 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14228 if (LocaleCompare(attribute,"stack") == 0)
14230 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14234 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14240 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14246 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14252 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14254 if (image == (Image *) NULL)
14255 goto PerlException;
14256 for ( ; image; image=image->next)
14258 AddImageToRegistry(sv,image);
14260 av_push(av,sv_bless(rv,hv));
14263 exception=DestroyExceptionInfo(exception);
14264 ST(0)=av_reference;
14265 SvREFCNT_dec(perl_exception);
14269 InheritPerlException(exception,perl_exception);
14270 exception=DestroyExceptionInfo(exception);
14271 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14272 SvPOK_on(perl_exception);
14273 ST(0)=sv_2mortal(perl_exception);
14278 ###############################################################################
14282 # S t a t i s t i c s #
14286 ###############################################################################
14290 Statistics(ref,...)
14291 Image::Magick ref=NO_INIT
14293 StatisticsImage = 1
14295 statisticsimage = 3
14298 #define ChannelStatistics(channel) \
14300 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14301 (double) channel_statistics[channel].depth); \
14302 PUSHs(sv_2mortal(newSVpv(message,0))); \
14303 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14304 channel_statistics[channel].minima/scale); \
14305 PUSHs(sv_2mortal(newSVpv(message,0))); \
14306 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14307 channel_statistics[channel].maxima/scale); \
14308 PUSHs(sv_2mortal(newSVpv(message,0))); \
14309 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14310 channel_statistics[channel].mean/scale); \
14311 PUSHs(sv_2mortal(newSVpv(message,0))); \
14312 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14313 channel_statistics[channel].standard_deviation/scale); \
14314 PUSHs(sv_2mortal(newSVpv(message,0))); \
14315 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14316 channel_statistics[channel].kurtosis); \
14317 PUSHs(sv_2mortal(newSVpv(message,0))); \
14318 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14319 channel_statistics[channel].skewness); \
14320 PUSHs(sv_2mortal(newSVpv(message,0))); \
14321 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14322 channel_statistics[channel].entropy); \
14323 PUSHs(sv_2mortal(newSVpv(message,0))); \
14330 message[MagickPathExtent];
14333 *channel_statistics;
14354 PERL_UNUSED_VAR(ref);
14355 PERL_UNUSED_VAR(ix);
14356 exception=AcquireExceptionInfo();
14357 perl_exception=newSVpv("",0);
14359 if (sv_isobject(ST(0)) == 0)
14361 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14363 goto PerlException;
14365 reference=SvRV(ST(0));
14368 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14369 if (image == (Image *) NULL)
14371 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14373 goto PerlException;
14376 for ( ; image; image=image->next)
14378 channel_statistics=GetImageStatistics(image,exception);
14379 if (channel_statistics == (ChannelStatistics *) NULL)
14382 EXTEND(sp,35*count);
14383 scale=(double) QuantumRange;
14384 ChannelStatistics(RedChannel);
14385 ChannelStatistics(GreenChannel);
14386 ChannelStatistics(BlueChannel);
14387 if (image->colorspace == CMYKColorspace)
14388 ChannelStatistics(BlackChannel);
14389 if (image->alpha_trait != UndefinedPixelTrait)
14390 ChannelStatistics(AlphaChannel);
14391 channel_statistics=(ChannelStatistics *)
14392 RelinquishMagickMemory(channel_statistics);
14396 InheritPerlException(exception,perl_exception);
14397 exception=DestroyExceptionInfo(exception);
14398 SvREFCNT_dec(perl_exception);
14402 ###############################################################################
14406 # S y n c A u t h e n t i c P i x e l s #
14410 ###############################################################################
14414 SyncAuthenticPixels(ref,...)
14415 Image::Magick ref = NO_INIT
14417 Syncauthenticpixels = 1
14418 SyncImagePixels = 2
14419 syncimagepixels = 3
14438 PERL_UNUSED_VAR(ref);
14439 PERL_UNUSED_VAR(ix);
14440 exception=AcquireExceptionInfo();
14441 perl_exception=newSVpv("",0);
14442 if (sv_isobject(ST(0)) == 0)
14444 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14446 goto PerlException;
14449 reference=SvRV(ST(0));
14450 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14451 if (image == (Image *) NULL)
14453 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14455 goto PerlException;
14458 status=SyncAuthenticPixels(image,exception);
14459 if (status != MagickFalse)
14463 InheritPerlException(exception,perl_exception);
14464 exception=DestroyExceptionInfo(exception);
14465 SvREFCNT_dec(perl_exception); /* throw away all errors */
14469 ###############################################################################
14477 ###############################################################################
14482 Image::Magick ref=NO_INIT
14490 filename[MagickPathExtent];
14514 PERL_UNUSED_VAR(ref);
14515 PERL_UNUSED_VAR(ix);
14516 exception=AcquireExceptionInfo();
14517 perl_exception=newSVpv("",0);
14519 package_info=(struct PackageInfo *) NULL;
14520 if (sv_isobject(ST(0)) == 0)
14522 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14524 goto PerlException;
14526 reference=SvRV(ST(0));
14527 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14528 if (image == (Image *) NULL)
14530 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14532 goto PerlException;
14534 package_info=ClonePackageInfo(info,exception);
14536 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14539 for (i=2; i < items; i+=2)
14540 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14542 (void) CopyMagickString(filename,package_info->image_info->filename,
14545 for (next=image; next; next=next->next)
14547 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14548 next->scene=scene++;
14550 *package_info->image_info->magick='\0';
14551 SetImageInfo(package_info->image_info,(unsigned int)
14552 GetImageListLength(image),exception);
14553 for (next=image; next; next=next->next)
14555 (void) WriteImage(package_info->image_info,next,exception);
14557 if (package_info->image_info->adjoin)
14562 if (package_info != (struct PackageInfo *) NULL)
14563 DestroyPackageInfo(package_info);
14564 InheritPerlException(exception,perl_exception);
14565 exception=DestroyExceptionInfo(exception);
14566 sv_setiv(perl_exception,(IV) number_images);
14567 SvPOK_on(perl_exception);
14568 ST(0)=sv_2mortal(perl_exception);