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,"%.20g", \
4079 channel_features[channel].angular_second_moment[direction]); \
4080 PUSHs(sv_2mortal(newSVpv(message,0))); \
4081 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4082 channel_features[channel].contrast[direction]); \
4083 PUSHs(sv_2mortal(newSVpv(message,0))); \
4084 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4085 channel_features[channel].contrast[direction]); \
4086 PUSHs(sv_2mortal(newSVpv(message,0))); \
4087 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4088 channel_features[channel].variance_sum_of_squares[direction]); \
4089 PUSHs(sv_2mortal(newSVpv(message,0))); \
4090 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4091 channel_features[channel].inverse_difference_moment[direction]); \
4092 PUSHs(sv_2mortal(newSVpv(message,0))); \
4093 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4094 channel_features[channel].sum_average[direction]); \
4095 PUSHs(sv_2mortal(newSVpv(message,0))); \
4096 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4097 channel_features[channel].sum_variance[direction]); \
4098 PUSHs(sv_2mortal(newSVpv(message,0))); \
4099 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4100 channel_features[channel].sum_entropy[direction]); \
4101 PUSHs(sv_2mortal(newSVpv(message,0))); \
4102 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4103 channel_features[channel].entropy[direction]); \
4104 PUSHs(sv_2mortal(newSVpv(message,0))); \
4105 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4106 channel_features[channel].difference_variance[direction]); \
4107 PUSHs(sv_2mortal(newSVpv(message,0))); \
4108 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4109 channel_features[channel].difference_entropy[direction]); \
4110 PUSHs(sv_2mortal(newSVpv(message,0))); \
4111 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4112 channel_features[channel].measure_of_correlation_1[direction]); \
4113 PUSHs(sv_2mortal(newSVpv(message,0))); \
4114 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4115 channel_features[channel].measure_of_correlation_2[direction]); \
4116 PUSHs(sv_2mortal(newSVpv(message,0))); \
4117 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
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)
4207 channel_features=GetImageFeatures(image,distance,exception);
4208 if (channel_features == (ChannelFeatures *) NULL)
4211 for (j=0; j < 4; j++)
4213 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
4215 PixelChannel channel=GetPixelChannelChannel(image,i);
4216 PixelTrait traits=GetPixelChannelTraits(image,channel);
4217 if (traits == UndefinedPixelTrait)
4219 EXTEND(sp,14*(i+1)*count);
4220 ChannelFeatures(channel,j);
4223 channel_features=(ChannelFeatures *)
4224 RelinquishMagickMemory(channel_features);
4228 InheritPerlException(exception,perl_exception);
4229 exception=DestroyExceptionInfo(exception);
4230 SvREFCNT_dec(perl_exception);
4234 ###############################################################################
4242 ###############################################################################
4247 Image::Magick ref=NO_INIT
4285 PERL_UNUSED_VAR(ref);
4286 PERL_UNUSED_VAR(ix);
4287 exception=AcquireExceptionInfo();
4288 perl_exception=newSVpv("",0);
4290 if (sv_isobject(ST(0)) == 0)
4292 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4296 reference=SvRV(ST(0));
4297 hv=SvSTASH(reference);
4298 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4299 if (image == (Image *) NULL)
4301 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4305 background_color=image->background_color;
4307 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4308 &background_color,exception);
4310 for (i=2; i < items; i+=2)
4312 attribute=(char *) SvPV(ST(i-1),na);
4318 if (LocaleCompare(attribute,"background") == 0)
4320 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4321 AllCompliance,&background_color,exception);
4324 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4330 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4336 image->background_color=background_color;
4337 image=MergeImageLayers(image,FlattenLayer,exception);
4338 if (image == (Image *) NULL)
4341 Create blessed Perl array for the returned image.
4344 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4346 AddImageToRegistry(sv,image);
4348 av_push(av,sv_bless(rv,hv));
4350 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4351 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4352 "flatten-%.*s",(int) (MagickPathExtent-9),
4353 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4354 (void) CopyMagickString(image->filename,info->image_info->filename,
4356 SetImageInfo(info->image_info,0,exception);
4357 exception=DestroyExceptionInfo(exception);
4358 SvREFCNT_dec(perl_exception);
4362 InheritPerlException(exception,perl_exception);
4363 exception=DestroyExceptionInfo(exception);
4364 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4365 SvPOK_on(perl_exception); /* return messages in string context */
4366 ST(0)=sv_2mortal(perl_exception);
4371 ###############################################################################
4379 ###############################################################################
4384 Image::Magick ref=NO_INIT
4396 expression[MagickPathExtent];
4424 PERL_UNUSED_VAR(ref);
4425 PERL_UNUSED_VAR(ix);
4426 exception=AcquireExceptionInfo();
4427 perl_exception=newSVpv("",0);
4431 if (sv_isobject(ST(0)) == 0)
4433 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4437 reference=SvRV(ST(0));
4438 hv=SvSTASH(reference);
4440 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4442 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4443 if (image == (Image *) NULL)
4445 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4449 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4453 channel=DefaultChannels;
4454 (void) CopyMagickString(expression,"u",MagickPathExtent);
4456 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4458 for (i=2; i < items; i+=2)
4460 attribute=(char *) SvPV(ST(i-1),na);
4466 if (LocaleCompare(attribute,"channel") == 0)
4471 option=ParseChannelOption(SvPV(ST(i),na));
4474 ThrowPerlException(exception,OptionError,
4475 "UnrecognizedType",SvPV(ST(i),na));
4478 channel=(ChannelType) option;
4481 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4488 if (LocaleCompare(attribute,"expression") == 0)
4490 (void) CopyMagickString(expression,SvPV(ST(i),na),
4494 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4500 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4506 channel_mask=SetImageChannelMask(image,channel);
4507 image=FxImage(image,expression,exception);
4508 if (image != (Image *) NULL)
4509 (void) SetImageChannelMask(image,channel_mask);
4510 if (image == (Image *) NULL)
4512 for ( ; image; image=image->next)
4514 AddImageToRegistry(sv,image);
4516 av_push(av,sv_bless(rv,hv));
4519 exception=DestroyExceptionInfo(exception);
4521 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4525 InheritPerlException(exception,perl_exception);
4526 exception=DestroyExceptionInfo(exception);
4527 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4528 SvPOK_on(perl_exception);
4529 ST(0)=sv_2mortal(perl_exception);
4534 ###############################################################################
4542 ###############################################################################
4547 Image::Magick ref=NO_INIT
4558 color[MagickPathExtent];
4583 PERL_UNUSED_VAR(ref);
4584 PERL_UNUSED_VAR(ix);
4585 exception=AcquireExceptionInfo();
4586 perl_exception=newSVpv("",0);
4587 if (sv_isobject(ST(0)) == 0)
4589 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4593 reference=SvRV(ST(0));
4594 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4595 if (image == (Image *) NULL && !info)
4598 for (i=1; i < items; i++)
4600 attribute=(char *) SvPV(ST(i),na);
4607 if (LocaleCompare(attribute,"adjoin") == 0)
4610 s=newSViv((ssize_t) info->image_info->adjoin);
4611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4614 if (LocaleCompare(attribute,"antialias") == 0)
4617 s=newSViv((ssize_t) info->image_info->antialias);
4618 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4621 if (LocaleCompare(attribute,"area") == 0)
4623 s=newSViv(GetMagickResource(AreaResource));
4624 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4627 if (LocaleCompare(attribute,"attenuate") == 0)
4632 value=GetImageProperty(image,attribute,exception);
4633 if (value != (const char *) NULL)
4635 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4638 if (LocaleCompare(attribute,"authenticate") == 0)
4645 option=GetImageOption(info->image_info,attribute);
4646 if (option != (const char *) NULL)
4647 s=newSVpv(option,0);
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4659 if (LocaleCompare(attribute,"background") == 0)
4661 if (image == (Image *) NULL)
4663 (void) FormatLocaleString(color,MagickPathExtent,
4664 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4665 (double) image->background_color.green,
4666 (double) image->background_color.blue,
4667 (double) image->background_color.alpha);
4669 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4672 if (LocaleCompare(attribute,"base-columns") == 0)
4674 if (image != (Image *) NULL)
4675 s=newSViv((ssize_t) image->magick_columns);
4676 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4679 if (LocaleCompare(attribute,"base-filename") == 0)
4681 if (image != (Image *) NULL)
4682 s=newSVpv(image->magick_filename,0);
4683 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4686 if (LocaleCompare(attribute,"base-height") == 0)
4688 if (image != (Image *) NULL)
4689 s=newSViv((ssize_t) image->magick_rows);
4690 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4693 if (LocaleCompare(attribute,"base-rows") == 0)
4695 if (image != (Image *) NULL)
4696 s=newSViv((ssize_t) image->magick_rows);
4697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4700 if (LocaleCompare(attribute,"base-width") == 0)
4702 if (image != (Image *) NULL)
4703 s=newSViv((ssize_t) image->magick_columns);
4704 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4707 if (LocaleCompare(attribute,"blue-primary") == 0)
4709 if (image == (Image *) NULL)
4711 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
4712 image->chromaticity.blue_primary.x,
4713 image->chromaticity.blue_primary.y);
4715 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4718 if (LocaleCompare(attribute,"bordercolor") == 0)
4720 if (image == (Image *) NULL)
4722 (void) FormatLocaleString(color,MagickPathExtent,
4723 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4724 (double) image->border_color.green,
4725 (double) image->border_color.blue,
4726 (double) image->border_color.alpha);
4728 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4731 if (LocaleCompare(attribute,"bounding-box") == 0)
4734 geometry[MagickPathExtent];
4739 if (image == (Image *) NULL)
4741 page=GetImageBoundingBox(image,exception);
4742 (void) FormatLocaleString(geometry,MagickPathExtent,
4743 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4744 page.height,(double) page.x,(double) page.y);
4745 s=newSVpv(geometry,0);
4746 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4749 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4756 if (LocaleCompare(attribute,"class") == 0)
4758 if (image == (Image *) NULL)
4760 s=newSViv(image->storage_class);
4761 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4762 image->storage_class));
4764 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4767 if (LocaleCompare(attribute,"clip-mask") == 0)
4769 if (image != (Image *) NULL)
4778 if (image->read_mask == MagickFalse)
4779 ClipImage(image,exception);
4780 mask_image=GetImageMask(image,ReadPixelMask,exception);
4781 if (mask_image != (Image *) NULL)
4783 AddImageToRegistry(sv,mask_image);
4784 s=sv_bless(newRV(sv),SvSTASH(reference));
4787 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4790 if (LocaleCompare(attribute,"clip-path") == 0)
4792 if (image != (Image *) NULL)
4801 if (image->read_mask != MagickFalse)
4802 ClipImage(image,exception);
4803 mask_image=GetImageMask(image,ReadPixelMask,exception);
4804 if (mask_image != (Image *) NULL)
4806 AddImageToRegistry(sv,mask_image);
4807 s=sv_bless(newRV(sv),SvSTASH(reference));
4810 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4813 if (LocaleCompare(attribute,"compression") == 0)
4815 j=info ? info->image_info->compression : image ?
4816 image->compression : UndefinedCompression;
4818 if (info->image_info->compression == UndefinedCompression)
4819 j=image->compression;
4821 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4824 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4827 if (LocaleCompare(attribute,"colorspace") == 0)
4829 j=image ? image->colorspace : RGBColorspace;
4831 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4834 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4837 if (LocaleCompare(attribute,"colors") == 0)
4839 if (image != (Image *) NULL)
4840 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4842 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4845 if (LocaleNCompare(attribute,"colormap",8) == 0)
4850 if (image == (Image *) NULL || !image->colormap)
4853 items=sscanf(attribute,"%*[^[][%ld",&j);
4855 if (j > (ssize_t) image->colors)
4857 (void) FormatLocaleString(color,MagickPathExtent,
4858 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4859 (double) image->colormap[j].green,
4860 (double) image->colormap[j].blue,
4861 (double) image->colormap[j].alpha);
4863 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4866 if (LocaleCompare(attribute,"columns") == 0)
4868 if (image != (Image *) NULL)
4869 s=newSViv((ssize_t) image->columns);
4870 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4873 if (LocaleCompare(attribute,"comment") == 0)
4878 value=GetImageProperty(image,attribute,exception);
4879 if (value != (const char *) NULL)
4881 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4884 if (LocaleCompare(attribute,"copyright") == 0)
4886 s=newSVpv(GetMagickCopyright(),0);
4887 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4890 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4897 if (LocaleCompare(attribute,"density") == 0)
4900 geometry[MagickPathExtent];
4902 if (image == (Image *) NULL)
4904 (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g",
4905 image->resolution.x,image->resolution.y);
4906 s=newSVpv(geometry,0);
4907 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4910 if (LocaleCompare(attribute,"delay") == 0)
4912 if (image != (Image *) NULL)
4913 s=newSViv((ssize_t) image->delay);
4914 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4917 if (LocaleCompare(attribute,"depth") == 0)
4919 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4920 if (image != (Image *) NULL)
4921 s=newSViv((ssize_t) GetImageDepth(image,exception));
4922 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4925 if (LocaleCompare(attribute,"directory") == 0)
4927 if (image && image->directory)
4928 s=newSVpv(image->directory,0);
4929 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4932 if (LocaleCompare(attribute,"dispose") == 0)
4934 if (image == (Image *) NULL)
4937 s=newSViv(image->dispose);
4939 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4941 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4944 if (LocaleCompare(attribute,"disk") == 0)
4946 s=newSViv(GetMagickResource(DiskResource));
4947 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4950 if (LocaleCompare(attribute,"dither") == 0)
4953 s=newSViv((ssize_t) info->image_info->dither);
4954 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4957 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4959 if (info && info->image_info->server_name)
4960 s=newSVpv(info->image_info->server_name,0);
4961 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4964 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4971 if (LocaleCompare(attribute,"elapsed-time") == 0)
4973 if (image != (Image *) NULL)
4974 s=newSVnv(GetElapsedTime(&image->timer));
4975 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4978 if (LocaleCompare(attribute,"endian") == 0)
4980 j=info ? info->image_info->endian : image ? image->endian :
4983 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4985 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4988 if (LocaleCompare(attribute,"error") == 0)
4990 if (image != (Image *) NULL)
4991 s=newSVnv(image->error.mean_error_per_pixel);
4992 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4995 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5002 if (LocaleCompare(attribute,"filesize") == 0)
5004 if (image != (Image *) NULL)
5005 s=newSViv((ssize_t) GetBlobSize(image));
5006 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5009 if (LocaleCompare(attribute,"filename") == 0)
5011 if (info && info->image_info->filename &&
5012 *info->image_info->filename)
5013 s=newSVpv(info->image_info->filename,0);
5014 if (image != (Image *) NULL)
5015 s=newSVpv(image->filename,0);
5016 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 if (LocaleCompare(attribute,"filter") == 0)
5021 s=image ? newSViv(image->filter) : newSViv(0);
5022 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5025 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5028 if (LocaleCompare(attribute,"font") == 0)
5030 if (info && info->image_info->font)
5031 s=newSVpv(info->image_info->font,0);
5032 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5035 if (LocaleCompare(attribute,"foreground") == 0)
5037 if (LocaleCompare(attribute,"format") == 0)
5042 magick_info=(const MagickInfo *) NULL;
5043 if (info && (*info->image_info->magick != '\0'))
5044 magick_info=GetMagickInfo(info->image_info->magick,exception);
5045 if (image != (Image *) NULL)
5046 magick_info=GetMagickInfo(image->magick,exception);
5047 if ((magick_info != (const MagickInfo *) NULL) &&
5048 (*magick_info->description != '\0'))
5049 s=newSVpv((char *) magick_info->description,0);
5050 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5053 if (LocaleCompare(attribute,"fuzz") == 0)
5056 s=newSVnv(info->image_info->fuzz);
5057 if (image != (Image *) NULL)
5058 s=newSVnv(image->fuzz);
5059 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5062 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5069 if (LocaleCompare(attribute,"gamma") == 0)
5071 if (image != (Image *) NULL)
5072 s=newSVnv(image->gamma);
5073 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5076 if (LocaleCompare(attribute,"geometry") == 0)
5078 if (image && image->geometry)
5079 s=newSVpv(image->geometry,0);
5080 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5083 if (LocaleCompare(attribute,"gravity") == 0)
5085 s=image ? newSViv(image->gravity) : newSViv(0);
5086 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5089 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5092 if (LocaleCompare(attribute,"green-primary") == 0)
5094 if (image == (Image *) NULL)
5096 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
5097 image->chromaticity.green_primary.x,
5098 image->chromaticity.green_primary.y);
5100 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5103 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5110 if (LocaleCompare(attribute,"height") == 0)
5112 if (image != (Image *) NULL)
5113 s=newSViv((ssize_t) image->rows);
5114 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5117 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5124 if (LocaleCompare(attribute,"icc") == 0)
5126 if (image != (Image *) NULL)
5131 profile=GetImageProfile(image,"icc");
5132 if (profile != (StringInfo *) NULL)
5133 s=newSVpv((const char *) GetStringInfoDatum(profile),
5134 GetStringInfoLength(profile));
5136 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5139 if (LocaleCompare(attribute,"icm") == 0)
5141 if (image != (Image *) NULL)
5146 profile=GetImageProfile(image,"icm");
5147 if (profile != (const StringInfo *) NULL)
5148 s=newSVpv((const char *) GetStringInfoDatum(profile),
5149 GetStringInfoLength(profile));
5151 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5154 if (LocaleCompare(attribute,"id") == 0)
5156 if (image != (Image *) NULL)
5159 key[MagickPathExtent];
5167 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5169 status=SetImageRegistry(ImageRegistryType,key,image,
5174 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5177 if (LocaleNCompare(attribute,"index",5) == 0)
5180 name[MagickPathExtent];
5189 register const Quantum
5195 if (image == (Image *) NULL)
5197 if (image->storage_class != PseudoClass)
5201 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5203 image_view=AcquireVirtualCacheView(image,exception);
5204 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5205 if (p != (const Quantum *) NULL)
5207 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5208 GetPixelIndex(image,p));
5210 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5212 image_view=DestroyCacheView(image_view);
5215 if (LocaleCompare(attribute,"iptc") == 0)
5217 if (image != (Image *) NULL)
5222 profile=GetImageProfile(image,"iptc");
5223 if (profile != (const StringInfo *) NULL)
5224 s=newSVpv((const char *) GetStringInfoDatum(profile),
5225 GetStringInfoLength(profile));
5227 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5230 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5232 if (image != (Image *) NULL)
5233 s=newSViv((ssize_t) image->iterations);
5234 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5237 if (LocaleCompare(attribute,"interlace") == 0)
5239 j=info ? info->image_info->interlace : image ? image->interlace :
5242 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5245 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5248 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5255 if (LocaleCompare(attribute,"label") == 0)
5260 if (image == (Image *) NULL)
5262 value=GetImageProperty(image,"Label",exception);
5263 if (value != (const char *) NULL)
5265 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5268 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5270 if (image != (Image *) NULL)
5271 s=newSViv((ssize_t) image->iterations);
5272 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5275 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5282 if (LocaleCompare(attribute,"magick") == 0)
5284 if (info && *info->image_info->magick)
5285 s=newSVpv(info->image_info->magick,0);
5286 if (image != (Image *) NULL)
5287 s=newSVpv(image->magick,0);
5288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5291 if (LocaleCompare(attribute,"map") == 0)
5293 s=newSViv(GetMagickResource(MapResource));
5294 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5297 if (LocaleCompare(attribute,"maximum-error") == 0)
5299 if (image != (Image *) NULL)
5300 s=newSVnv(image->error.normalized_maximum_error);
5301 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5304 if (LocaleCompare(attribute,"memory") == 0)
5306 s=newSViv(GetMagickResource(MemoryResource));
5307 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5310 if (LocaleCompare(attribute,"mean-error") == 0)
5312 if (image != (Image *) NULL)
5313 s=newSVnv(image->error.normalized_mean_error);
5314 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5317 if (LocaleCompare(attribute,"mime") == 0)
5319 if (info && *info->image_info->magick)
5320 s=newSVpv(MagickToMime(info->image_info->magick),0);
5321 if (image != (Image *) NULL)
5322 s=newSVpv(MagickToMime(image->magick),0);
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 if (LocaleCompare(attribute,"mattecolor") == 0)
5328 if (image == (Image *) NULL)
5330 (void) FormatLocaleString(color,MagickPathExtent,
5331 "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red,
5332 (double) image->alpha_color.green,
5333 (double) image->alpha_color.blue,
5334 (double) image->alpha_color.alpha);
5336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5339 if (LocaleCompare(attribute,"matte") == 0)
5341 if (image != (Image *) NULL)
5342 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"mime") == 0)
5353 if (info && *info->image_info->magick)
5354 magick=info->image_info->magick;
5355 if (image != (Image *) NULL)
5356 magick=image->magick;
5362 mime=MagickToMime(magick);
5364 mime=(char *) RelinquishMagickMemory(mime);
5366 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5369 if (LocaleCompare(attribute,"monochrome") == 0)
5371 if (image == (Image *) NULL)
5373 j=info ? info->image_info->monochrome :
5374 SetImageMonochrome(image,exception);
5376 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5379 if (LocaleCompare(attribute,"montage") == 0)
5381 if (image && image->montage)
5382 s=newSVpv(image->montage,0);
5383 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5386 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5393 if (LocaleCompare(attribute,"orientation") == 0)
5395 j=info ? info->image_info->orientation : image ?
5396 image->orientation : UndefinedOrientation;
5398 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5401 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5411 if (LocaleCompare(attribute,"page") == 0)
5413 if (info && info->image_info->page)
5414 s=newSVpv(info->image_info->page,0);
5415 if (image != (Image *) NULL)
5418 geometry[MagickPathExtent];
5420 (void) FormatLocaleString(geometry,MagickPathExtent,
5421 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5422 (double) image->page.height,(double) image->page.x,(double)
5424 s=newSVpv(geometry,0);
5426 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5429 if (LocaleCompare(attribute,"page.x") == 0)
5431 if (image != (Image *) NULL)
5432 s=newSViv((ssize_t) image->page.x);
5433 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5436 if (LocaleCompare(attribute,"page.y") == 0)
5438 if (image != (Image *) NULL)
5439 s=newSViv((ssize_t) image->page.y);
5440 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5443 if (LocaleNCompare(attribute,"pixel",5) == 0)
5446 tuple[MagickPathExtent];
5455 register const Quantum
5458 if (image == (Image *) NULL)
5462 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5464 p=GetVirtualPixels(image,x,y,1,1,exception);
5465 if (image->colorspace != CMYKColorspace)
5466 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5467 QuantumFormat "," QuantumFormat "," QuantumFormat,
5468 GetPixelRed(image,p),GetPixelGreen(image,p),
5469 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5471 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5472 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5473 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5474 GetPixelBlue(image,p),GetPixelBlack(image,p),
5475 GetPixelAlpha(image,p));
5477 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5480 if (LocaleCompare(attribute,"pointsize") == 0)
5483 s=newSViv((ssize_t) info->image_info->pointsize);
5484 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5487 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5494 if (LocaleCompare(attribute,"quality") == 0)
5497 s=newSViv((ssize_t) info->image_info->quality);
5498 if (image != (Image *) NULL)
5499 s=newSViv((ssize_t) image->quality);
5500 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5503 if (LocaleCompare(attribute,"quantum") == 0)
5506 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5510 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5517 if (LocaleCompare(attribute,"rendering-intent") == 0)
5519 s=newSViv(image->rendering_intent);
5520 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5521 image->rendering_intent));
5523 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5526 if (LocaleCompare(attribute,"red-primary") == 0)
5528 if (image == (Image *) NULL)
5530 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
5531 image->chromaticity.red_primary.x,
5532 image->chromaticity.red_primary.y);
5534 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5537 if (LocaleCompare(attribute,"rows") == 0)
5539 if (image != (Image *) NULL)
5540 s=newSViv((ssize_t) image->rows);
5541 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5551 if (LocaleCompare(attribute,"sampling-factor") == 0)
5553 if (info && info->image_info->sampling_factor)
5554 s=newSVpv(info->image_info->sampling_factor,0);
5555 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5558 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5560 if (info && info->image_info->server_name)
5561 s=newSVpv(info->image_info->server_name,0);
5562 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5565 if (LocaleCompare(attribute,"size") == 0)
5567 if (info && info->image_info->size)
5568 s=newSVpv(info->image_info->size,0);
5569 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5572 if (LocaleCompare(attribute,"scene") == 0)
5574 if (image != (Image *) NULL)
5575 s=newSViv((ssize_t) image->scene);
5576 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5579 if (LocaleCompare(attribute,"scenes") == 0)
5581 if (image != (Image *) NULL)
5582 s=newSViv((ssize_t) info->image_info->number_scenes);
5583 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5586 if (LocaleCompare(attribute,"signature") == 0)
5591 if (image == (Image *) NULL)
5593 (void) SignatureImage(image,exception);
5594 value=GetImageProperty(image,"Signature",exception);
5595 if (value != (const char *) NULL)
5597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5600 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5607 if (LocaleCompare(attribute,"taint") == 0)
5609 if (image != (Image *) NULL)
5610 s=newSViv((ssize_t) IsTaintImage(image));
5611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5614 if (LocaleCompare(attribute,"texture") == 0)
5616 if (info && info->image_info->texture)
5617 s=newSVpv(info->image_info->texture,0);
5618 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5621 if (LocaleCompare(attribute,"total-ink-density") == 0)
5623 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5624 if (image != (Image *) NULL)
5625 s=newSVnv(GetImageTotalInkDensity(image,exception));
5626 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5629 if (LocaleCompare(attribute,"transparent-color") == 0)
5631 if (image == (Image *) NULL)
5633 (void) FormatLocaleString(color,MagickPathExtent,
5634 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5635 (double) image->transparent_color.green,
5636 (double) image->transparent_color.blue,
5637 (double) image->transparent_color.alpha);
5639 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5642 if (LocaleCompare(attribute,"type") == 0)
5644 if (image == (Image *) NULL)
5646 j=(ssize_t) GetImageType(image);
5648 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5650 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5653 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5660 if (LocaleCompare(attribute,"units") == 0)
5662 j=info ? info->image_info->units : image ? image->units :
5663 UndefinedResolution;
5664 if (info && (info->image_info->units == UndefinedResolution))
5667 if (j == UndefinedResolution)
5668 s=newSVpv("undefined units",0);
5670 if (j == PixelsPerInchResolution)
5671 s=newSVpv("pixels / inch",0);
5673 s=newSVpv("pixels / centimeter",0);
5674 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5677 if (LocaleCompare(attribute,"user-time") == 0)
5679 if (image != (Image *) NULL)
5680 s=newSVnv(GetUserTime(&image->timer));
5681 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5684 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5691 if (LocaleCompare(attribute,"verbose") == 0)
5694 s=newSViv((ssize_t) info->image_info->verbose);
5695 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5698 if (LocaleCompare(attribute,"version") == 0)
5700 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5701 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5704 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5706 if (image == (Image *) NULL)
5708 j=(ssize_t) GetImageVirtualPixelMethod(image);
5710 (void) sv_setpv(s,CommandOptionToMnemonic(
5711 MagickVirtualPixelOptions,j));
5713 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5723 if (LocaleCompare(attribute,"white-point") == 0)
5725 if (image == (Image *) NULL)
5727 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
5728 image->chromaticity.white_point.x,
5729 image->chromaticity.white_point.y);
5731 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5734 if (LocaleCompare(attribute,"width") == 0)
5736 if (image != (Image *) NULL)
5737 s=newSViv((ssize_t) image->columns);
5738 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5741 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5748 if (LocaleCompare(attribute,"xmp") == 0)
5750 if (image != (Image *) NULL)
5755 profile=GetImageProfile(image,"xmp");
5756 if (profile != (StringInfo *) NULL)
5757 s=newSVpv((const char *) GetStringInfoDatum(profile),
5758 GetStringInfoLength(profile));
5760 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5763 if (LocaleCompare(attribute,"x-resolution") == 0)
5765 if (image != (Image *) NULL)
5766 s=newSVnv(image->resolution.x);
5767 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5777 if (LocaleCompare(attribute,"y-resolution") == 0)
5779 if (image != (Image *) NULL)
5780 s=newSVnv(image->resolution.y);
5781 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5784 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5791 if (image == (Image *) NULL)
5792 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5796 value=GetImageProperty(image,attribute,exception);
5797 if (value != (const char *) NULL)
5800 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5803 if (*attribute != '%')
5804 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5811 meta=InterpretImageProperties(info ? info->image_info :
5812 (ImageInfo *) NULL,image,attribute,exception);
5814 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5815 meta=(char *) RelinquishMagickMemory(meta);
5819 exception=DestroyExceptionInfo(exception);
5820 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5824 ###############################################################################
5828 # G e t A u t h e n t i c P i x e l s #
5832 ###############################################################################
5836 GetAuthenticPixels(ref,...)
5837 Image::Magick ref = NO_INIT
5839 getauthenticpixels = 1
5869 PERL_UNUSED_VAR(ref);
5870 PERL_UNUSED_VAR(ix);
5871 exception=AcquireExceptionInfo();
5872 perl_exception=newSVpv("",0);
5873 if (sv_isobject(ST(0)) == 0)
5875 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5879 reference=SvRV(ST(0));
5881 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5882 if (image == (Image *) NULL)
5884 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5891 region.width=image->columns;
5894 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5895 for (i=2; i < items; i+=2)
5897 attribute=(char *) SvPV(ST(i-1),na);
5903 if (LocaleCompare(attribute,"geometry") == 0)
5905 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5908 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5915 if (LocaleCompare(attribute,"height") == 0)
5917 region.height=SvIV(ST(i));
5920 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5927 if (LocaleCompare(attribute,"x") == 0)
5929 region.x=SvIV(ST(i));
5932 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5939 if (LocaleCompare(attribute,"y") == 0)
5941 region.y=SvIV(ST(i));
5944 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5951 if (LocaleCompare(attribute,"width") == 0)
5953 region.width=SvIV(ST(i));
5956 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5962 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5963 region.height,exception);
5964 if (blob != (void *) NULL)
5968 InheritPerlException(exception,perl_exception);
5969 exception=DestroyExceptionInfo(exception);
5970 SvREFCNT_dec(perl_exception); /* throw away all errors */
5979 ###############################################################################
5983 # G e t V i r t u a l P i x e l s #
5987 ###############################################################################
5991 GetVirtualPixels(ref,...)
5992 Image::Magick ref = NO_INIT
5994 getvirtualpixels = 1
5995 AcquireImagePixels = 2
5996 acquireimagepixels = 3
6024 PERL_UNUSED_VAR(ref);
6025 PERL_UNUSED_VAR(ix);
6026 exception=AcquireExceptionInfo();
6027 perl_exception=newSVpv("",0);
6028 if (sv_isobject(ST(0)) == 0)
6030 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6034 reference=SvRV(ST(0));
6036 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6037 if (image == (Image *) NULL)
6039 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6046 region.width=image->columns;
6049 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6050 for (i=2; i < items; i+=2)
6052 attribute=(char *) SvPV(ST(i-1),na);
6058 if (LocaleCompare(attribute,"geometry") == 0)
6060 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6063 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6070 if (LocaleCompare(attribute,"height") == 0)
6072 region.height=SvIV(ST(i));
6075 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6082 if (LocaleCompare(attribute,"x") == 0)
6084 region.x=SvIV(ST(i));
6087 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6094 if (LocaleCompare(attribute,"y") == 0)
6096 region.y=SvIV(ST(i));
6099 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6106 if (LocaleCompare(attribute,"width") == 0)
6108 region.width=SvIV(ST(i));
6111 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6117 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6118 region.height,exception);
6119 if (blob != (void *) NULL)
6123 InheritPerlException(exception,perl_exception);
6124 exception=DestroyExceptionInfo(exception);
6125 SvREFCNT_dec(perl_exception); /* throw away all errors */
6128 RETVAL = (void *) blob;
6134 ###############################################################################
6138 # G e t A u t h e n t i c M e t a c o n t e n t #
6142 ###############################################################################
6146 GetAuthenticMetacontent(ref,...)
6147 Image::Magick ref = NO_INIT
6149 getauthenticmetacontent = 1
6170 PERL_UNUSED_VAR(ref);
6171 PERL_UNUSED_VAR(ix);
6172 exception=AcquireExceptionInfo();
6173 perl_exception=newSVpv("",0);
6174 if (sv_isobject(ST(0)) == 0)
6176 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6180 reference=SvRV(ST(0));
6182 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6183 if (image == (Image *) NULL)
6185 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6190 blob=(void *) GetAuthenticMetacontent(image);
6191 if (blob != (void *) NULL)
6195 InheritPerlException(exception,perl_exception);
6196 exception=DestroyExceptionInfo(exception);
6197 SvREFCNT_dec(perl_exception); /* throw away all errors */
6206 ###############################################################################
6210 # G e t V i r t u a l M e t a c o n t e n t #
6214 ###############################################################################
6218 GetVirtualMetacontent(ref,...)
6219 Image::Magick ref = NO_INIT
6221 getvirtualmetacontent = 1
6240 PERL_UNUSED_VAR(ref);
6241 PERL_UNUSED_VAR(ix);
6242 exception=AcquireExceptionInfo();
6243 perl_exception=newSVpv("",0);
6244 if (sv_isobject(ST(0)) == 0)
6246 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6250 reference=SvRV(ST(0));
6252 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6253 if (image == (Image *) NULL)
6255 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6260 blob=(void *) GetVirtualMetacontent(image);
6261 if (blob != (void *) NULL)
6265 InheritPerlException(exception,perl_exception);
6266 exception=DestroyExceptionInfo(exception);
6267 SvREFCNT_dec(perl_exception); /* throw away all errors */
6276 ###############################################################################
6280 # H i s t o g r a m #
6284 ###############################################################################
6289 Image::Magick ref=NO_INIT
6300 message[MagickPathExtent];
6327 PERL_UNUSED_VAR(ref);
6328 PERL_UNUSED_VAR(ix);
6329 exception=AcquireExceptionInfo();
6330 perl_exception=newSVpv("",0);
6332 if (sv_isobject(ST(0)) == 0)
6334 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6338 reference=SvRV(ST(0));
6341 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6342 if (image == (Image *) NULL)
6344 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6349 for ( ; image; image=image->next)
6351 histogram=GetImageHistogram(image,&number_colors,exception);
6352 if (histogram == (PixelInfo *) NULL)
6354 count+=(ssize_t) number_colors;
6356 for (i=0; i < (ssize_t) number_colors; i++)
6358 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6360 PUSHs(sv_2mortal(newSVpv(message,0)));
6361 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6362 histogram[i].green);
6363 PUSHs(sv_2mortal(newSVpv(message,0)));
6364 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6366 PUSHs(sv_2mortal(newSVpv(message,0)));
6367 if (image->colorspace == CMYKColorspace)
6369 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6370 histogram[i].black);
6371 PUSHs(sv_2mortal(newSVpv(message,0)));
6373 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6374 histogram[i].alpha);
6375 PUSHs(sv_2mortal(newSVpv(message,0)));
6376 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6377 histogram[i].count);
6378 PUSHs(sv_2mortal(newSVpv(message,0)));
6380 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6384 InheritPerlException(exception,perl_exception);
6385 exception=DestroyExceptionInfo(exception);
6386 SvREFCNT_dec(perl_exception);
6390 ###############################################################################
6398 ###############################################################################
6403 Image::Magick ref=NO_INIT
6427 register const Quantum
6441 *reference; /* reference is the SV* of ref=SvIV(reference) */
6443 PERL_UNUSED_VAR(ref);
6444 PERL_UNUSED_VAR(ix);
6445 exception=AcquireExceptionInfo();
6446 perl_exception=newSVpv("",0);
6447 reference=SvRV(ST(0));
6448 av=(AV *) reference;
6449 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6451 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6452 if (image == (Image *) NULL)
6454 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6458 normalize=MagickTrue;
6461 region.width=image->columns;
6464 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6465 for (i=2; i < items; i+=2)
6467 attribute=(char *) SvPV(ST(i-1),na);
6473 if (LocaleCompare(attribute,"channel") == 0)
6478 option=ParseChannelOption(SvPV(ST(i),na));
6481 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6485 (void) SetPixelChannelMask(image,(ChannelType) option);
6488 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6495 if (LocaleCompare(attribute,"geometry") == 0)
6497 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6500 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6507 if (LocaleCompare(attribute,"normalize") == 0)
6509 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6513 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6517 normalize=option != 0 ? MagickTrue : MagickFalse;
6520 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6527 if (LocaleCompare(attribute,"x") == 0)
6529 region.x=SvIV(ST(i));
6532 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6539 if (LocaleCompare(attribute,"y") == 0)
6541 region.y=SvIV(ST(i));
6544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6556 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6557 if (p == (const Quantum *) NULL)
6565 if (normalize != MagickFalse)
6566 scale=1.0/QuantumRange;
6567 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6568 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6569 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6570 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6571 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6572 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6573 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6574 (image->colorspace == CMYKColorspace))
6575 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6576 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6577 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6581 InheritPerlException(exception,perl_exception);
6582 exception=DestroyExceptionInfo(exception);
6583 SvREFCNT_dec(perl_exception);
6587 ###############################################################################
6591 # G e t P i x e l s #
6595 ###############################################################################
6600 Image::Magick ref=NO_INIT
6639 *reference; /* reference is the SV* of ref=SvIV(reference) */
6641 PERL_UNUSED_VAR(ref);
6642 PERL_UNUSED_VAR(ix);
6643 exception=AcquireExceptionInfo();
6644 perl_exception=newSVpv("",0);
6645 reference=SvRV(ST(0));
6646 av=(AV *) reference;
6647 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6649 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6650 if (image == (Image *) NULL)
6652 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6657 if (image->alpha_trait != UndefinedPixelTrait)
6659 if (image->colorspace == CMYKColorspace)
6662 if (image->alpha_trait != UndefinedPixelTrait)
6665 normalize=MagickFalse;
6668 region.width=image->columns;
6671 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6672 for (i=2; i < items; i+=2)
6674 attribute=(char *) SvPV(ST(i-1),na);
6680 if (LocaleCompare(attribute,"geometry") == 0)
6682 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6685 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6692 if (LocaleCompare(attribute,"height") == 0)
6694 region.height=SvIV(ST(i));
6697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6704 if (LocaleCompare(attribute,"map") == 0)
6709 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6716 if (LocaleCompare(attribute,"normalize") == 0)
6718 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6722 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6726 normalize=option != 0 ? MagickTrue : MagickFalse;
6729 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6736 if (LocaleCompare(attribute,"width") == 0)
6738 region.width=SvIV(ST(i));
6741 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6748 if (LocaleCompare(attribute,"x") == 0)
6750 region.x=SvIV(ST(i));
6753 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6760 if (LocaleCompare(attribute,"y") == 0)
6762 region.y=SvIV(ST(i));
6765 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6771 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6777 if (normalize != MagickFalse)
6782 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6783 region.height*sizeof(*pixels));
6784 if (pixels == (float *) NULL)
6786 ThrowPerlException(exception,ResourceLimitError,
6787 "MemoryAllocationFailed",PackageName);
6790 status=ExportImagePixels(image,region.x,region.y,region.width,
6791 region.height,map,FloatPixel,pixels,exception);
6792 if (status == MagickFalse)
6796 EXTEND(sp,strlen(map)*region.width*region.height);
6797 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6798 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6800 pixels=(float *) RelinquishMagickMemory(pixels);
6807 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6808 region.height*sizeof(*pixels));
6809 if (pixels == (Quantum *) NULL)
6811 ThrowPerlException(exception,ResourceLimitError,
6812 "MemoryAllocationFailed",PackageName);
6815 status=ExportImagePixels(image,region.x,region.y,region.width,
6816 region.height,map,QuantumPixel,pixels,exception);
6817 if (status == MagickFalse)
6821 EXTEND(sp,strlen(map)*region.width*region.height);
6822 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6823 PUSHs(sv_2mortal(newSViv(pixels[i])));
6825 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6829 InheritPerlException(exception,perl_exception);
6830 exception=DestroyExceptionInfo(exception);
6831 SvREFCNT_dec(perl_exception);
6835 ###############################################################################
6839 # I m a g e T o B l o b #
6843 ###############################################################################
6847 ImageToBlob(ref,...)
6848 Image::Magick ref=NO_INIT
6857 filename[MagickPathExtent];
6886 PERL_UNUSED_VAR(ref);
6887 PERL_UNUSED_VAR(ix);
6888 exception=AcquireExceptionInfo();
6889 perl_exception=newSVpv("",0);
6890 package_info=(struct PackageInfo *) NULL;
6891 if (sv_isobject(ST(0)) == 0)
6893 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6897 reference=SvRV(ST(0));
6898 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6899 if (image == (Image *) NULL)
6901 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6905 package_info=ClonePackageInfo(info,exception);
6906 for (i=2; i < items; i+=2)
6907 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6908 (void) CopyMagickString(filename,package_info->image_info->filename,
6911 for (next=image; next; next=next->next)
6913 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6914 next->scene=scene++;
6916 SetImageInfo(package_info->image_info,(unsigned int)
6917 GetImageListLength(image),exception);
6918 EXTEND(sp,(ssize_t) GetImageListLength(image));
6919 for ( ; image; image=image->next)
6922 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6923 if (blob != (char *) NULL)
6925 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6926 blob=(unsigned char *) RelinquishMagickMemory(blob);
6928 if (package_info->image_info->adjoin)
6933 if (package_info != (struct PackageInfo *) NULL)
6934 DestroyPackageInfo(package_info);
6935 InheritPerlException(exception,perl_exception);
6936 exception=DestroyExceptionInfo(exception);
6937 SvREFCNT_dec(perl_exception); /* throw away all errors */
6941 ###############################################################################
6949 ###############################################################################
6954 Image::Magick ref=NO_INIT
6958 OptimizeImageLayers = 3
6960 optimizeimagelayers = 5
7002 PERL_UNUSED_VAR(ref);
7003 PERL_UNUSED_VAR(ix);
7004 exception=AcquireExceptionInfo();
7005 perl_exception=newSVpv("",0);
7007 if (sv_isobject(ST(0)) == 0)
7009 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7013 reference=SvRV(ST(0));
7014 hv=SvSTASH(reference);
7016 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7018 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7019 if (image == (Image *) NULL)
7021 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7025 compose=image->compose;
7026 method=OptimizeLayer;
7027 for (i=2; i < items; i+=2)
7029 attribute=(char *) SvPV(ST(i-1),na);
7035 if (LocaleCompare(attribute,"compose") == 0)
7037 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7038 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7041 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7045 compose=(CompositeOperator) sp;
7048 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7055 if (LocaleCompare(attribute,"method") == 0)
7057 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7061 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7065 method=(LayerMethod) option;
7068 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7074 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7080 layers=(Image *) NULL;
7083 case CompareAnyLayer:
7084 case CompareClearLayer:
7085 case CompareOverlayLayer:
7088 layers=CompareImagesLayers(image,method,exception);
7095 layers=MergeImageLayers(image,method,exception);
7100 layers=DisposeImages(image,exception);
7103 case OptimizeImageLayer:
7105 layers=OptimizeImageLayers(image,exception);
7108 case OptimizePlusLayer:
7110 layers=OptimizePlusImageLayers(image,exception);
7113 case OptimizeTransLayer:
7115 OptimizeImageTransparency(image,exception);
7118 case RemoveDupsLayer:
7120 RemoveDuplicateLayers(&image,exception);
7123 case RemoveZeroLayer:
7125 RemoveZeroDelayLayers(&image,exception);
7134 General Purpose, GIF Animation Optimizer.
7136 layers=CoalesceImages(image,exception);
7137 if (layers == (Image *) NULL)
7140 layers=OptimizeImageLayers(image,exception);
7141 if (layers == (Image *) NULL)
7143 image=DestroyImageList(image);
7145 layers=(Image *) NULL;
7146 OptimizeImageTransparency(image,exception);
7147 quantize_info=AcquireQuantizeInfo(info->image_info);
7148 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7149 quantize_info=DestroyQuantizeInfo(quantize_info);
7152 case CompositeLayer:
7161 Split image sequence at the first 'NULL:' image.
7164 while (source != (Image *) NULL)
7166 source=GetNextImageInList(source);
7167 if ((source != (Image *) NULL) &&
7168 (LocaleCompare(source->magick,"NULL") == 0))
7171 if (source != (Image *) NULL)
7173 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7174 (GetNextImageInList(source) == (Image *) NULL))
7175 source=(Image *) NULL;
7179 Separate the two lists, junk the null: image.
7181 source=SplitImageList(source->previous);
7182 DeleteImageFromList(&source);
7185 if (source == (Image *) NULL)
7187 (void) ThrowMagickException(exception,GetMagickModule(),
7188 OptionError,"MissingNullSeparator","layers Composite");
7192 Adjust offset with gravity and virtual canvas.
7194 SetGeometry(image,&geometry);
7195 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7196 geometry.width=source->page.width != 0 ? source->page.width :
7198 geometry.height=source->page.height != 0 ? source->page.height :
7200 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7201 image->columns,image->page.height != 0 ? image->page.height :
7202 image->rows,image->gravity,&geometry);
7203 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7204 source=DestroyImageList(source);
7208 if (layers != (Image *) NULL)
7211 image=CloneImage(image,0,0,MagickTrue,exception);
7212 if (image == (Image *) NULL)
7214 for ( ; image; image=image->next)
7216 AddImageToRegistry(sv,image);
7218 av_push(av,sv_bless(rv,hv));
7221 exception=DestroyExceptionInfo(exception);
7223 SvREFCNT_dec(perl_exception);
7227 InheritPerlException(exception,perl_exception);
7228 exception=DestroyExceptionInfo(exception);
7229 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7230 SvPOK_on(perl_exception);
7231 ST(0)=sv_2mortal(perl_exception);
7236 ###############################################################################
7240 # M a g i c k T o M i m e #
7244 ###############################################################################
7248 MagickToMime(ref,name)
7249 Image::Magick ref=NO_INIT
7258 PERL_UNUSED_VAR(ref);
7259 PERL_UNUSED_VAR(ix);
7260 mime=MagickToMime(name);
7261 RETVAL=newSVpv(mime,0);
7262 mime=(char *) RelinquishMagickMemory(mime);
7268 ###############################################################################
7276 ###############################################################################
7281 Image::Magick ref=NO_INIT
7318 MedianConvolveImage = 36
7324 ReduceNoiseImage = 42
7350 ColorFloodfillImage= 68
7356 CycleColormapImage = 74
7366 MatteFloodfillImage= 84
7374 NumberColorsImage = 92
7384 SignatureImage = 102
7394 TransparentImage = 112
7396 ThresholdImage = 114
7410 DeconstructImage = 130
7412 GaussianBlurImage = 132
7418 UnsharpMaskImage = 138
7420 MotionBlurImage = 140
7422 OrderedDitherImage = 142
7429 AffineTransform = 149
7430 AffineTransformImage = 150
7432 DifferenceImage = 152
7433 AdaptiveThreshold = 153
7434 AdaptiveThresholdImage = 154
7439 BlackThreshold = 159
7440 BlackThresholdImage= 160
7441 WhiteThreshold = 161
7442 WhiteThresholdImage= 162
7443 RotationalBlur = 163
7444 RotationalBlurImage= 164
7446 ThumbnailImage = 166
7456 PosterizeImage = 176
7462 SepiaToneImage = 182
7463 SigmoidalContrast = 183
7464 SigmoidalContrastImage = 184
7469 ContrastStretch = 189
7470 ContrastStretchImage = 190
7475 AdaptiveSharpen = 195
7476 AdaptiveSharpenImage = 196
7478 TransposeImage = 198
7480 TransverseImage = 200
7482 AutoOrientImage = 202
7484 AdaptiveBlurImage = 204
7488 UniqueColorsImage = 208
7489 AdaptiveResize = 209
7490 AdaptiveResizeImage= 210
7494 LinearStretchImage = 214
7496 ColorMatrixImage = 216
7501 FloodfillPaint = 221
7502 FloodfillPaintImage= 222
7508 LiquidRescaleImage = 228
7518 SparseColorImage = 238
7522 SelectiveBlurImage = 242
7526 BlueShiftImage = 246
7527 ForwardFourierTransform = 247
7528 ForwardFourierTransformImage = 248
7529 InverseFourierTransform = 249
7530 InverseFourierTransformImage = 250
7531 ColorDecisionList = 251
7532 ColorDecisionListImage = 252
7534 AutoGammaImage = 254
7536 AutoLevelImage = 256
7538 LevelImageColors = 258
7541 BrightnessContrast = 261
7542 BrightnessContrastImage = 262
7544 MorphologyImage = 264
7548 StatisticImage = 268
7550 PerceptibleImage = 270
7554 GrayscaleImage = 274
7556 CannyEdgeImage = 276
7558 HoughLineImage = 278
7560 MeanShiftImage = 280
7563 ConnectedComponent = 283
7564 ConnectedComponentImage = 284
7566 CopyImagePixels = 286
7569 WaveletDenoise = 289
7570 WaveletDenoiseImage= 290
7572 ColorspaceImage = 292
7581 attribute_flag[MaxArguments],
7582 message[MagickPathExtent];
7643 argument_list[MaxArguments];
7645 PERL_UNUSED_VAR(ref);
7646 PERL_UNUSED_VAR(ix);
7647 exception=AcquireExceptionInfo();
7648 perl_exception=newSVpv("",0);
7649 reference_vector=NULL;
7653 if (sv_isobject(ST(0)) == 0)
7655 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7659 reference=SvRV(ST(0));
7660 region_info.width=0;
7661 region_info.height=0;
7664 region_image=(Image *) NULL;
7665 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7666 if (ix && (ix != 666))
7669 Called as Method(...)
7672 rp=(&Methods[ix-1]);
7678 Called as Mogrify("Method",...)
7680 attribute=(char *) SvPV(ST(1),na);
7683 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7684 attribute=(char *) SvPV(ST(2),na);
7687 for (rp=Methods; ; rp++)
7689 if (rp >= EndOf(Methods))
7691 ThrowPerlException(exception,OptionError,
7692 "UnrecognizedPerlMagickMethod",attribute);
7695 if (strEQcase(attribute,rp->name))
7701 if (image == (Image *) NULL)
7703 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7706 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7707 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7708 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7725 pp=(Arguments *) NULL;
7733 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7735 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7737 if (strEQcase(attribute,qq->method) > ssize_test)
7740 ssize_test=strEQcase(attribute,qq->method);
7743 if (pp == (Arguments *) NULL)
7745 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7747 goto continue_outer_loop;
7749 al=(&argument_list[pp-rp->arguments]);
7752 case ArrayReference:
7754 if (SvTYPE(sv) != SVt_RV)
7756 (void) FormatLocaleString(message,MagickPathExtent,
7757 "invalid %.60s value",pp->method);
7758 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7759 goto continue_outer_loop;
7761 al->array_reference=SvRV(sv);
7766 al->real_reference=SvNV(sv);
7771 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7774 case ImageReference:
7776 if (!sv_isobject(sv) ||
7777 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7778 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7780 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7786 case IntegerReference:
7788 al->integer_reference=SvIV(sv);
7791 case StringReference:
7793 al->string_reference=(char *) SvPV(sv,al->length);
7794 if (sv_isobject(sv))
7795 al->image_reference=SetupList(aTHX_ SvRV(sv),
7796 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7802 Is a string; look up name.
7804 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7806 al->string_reference=(char *) SvPV(sv,al->length);
7807 al->integer_reference=(-1);
7810 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7811 MagickFalse,SvPV(sv,na));
7812 if (pp->type == MagickChannelOptions)
7813 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7814 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7816 (void) FormatLocaleString(message,MagickPathExtent,
7817 "invalid %.60s value",pp->method);
7818 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7819 goto continue_outer_loop;
7824 attribute_flag[pp-rp->arguments]++;
7825 continue_outer_loop: ;
7827 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7828 pv=reference_vector;
7829 SetGeometryInfo(&geometry_info);
7830 channel=DefaultChannels;
7831 for (next=image; next; next=next->next)
7834 SetGeometry(image,&geometry);
7835 if ((region_info.width*region_info.height) != 0)
7838 image=CropImage(image,®ion_info,exception);
7844 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7845 ThrowPerlException(exception,OptionError,
7846 "UnrecognizedPerlMagickMethod",message);
7849 case 1: /* Comment */
7851 if (attribute_flag[0] == 0)
7852 argument_list[0].string_reference=(char *) NULL;
7853 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7854 info ? info->image_info : (ImageInfo *) NULL,image,
7855 argument_list[0].string_reference,exception),exception);
7860 if (attribute_flag[0] == 0)
7861 argument_list[0].string_reference=(char *) NULL;
7862 (void) SetImageProperty(image,"label",InterpretImageProperties(
7863 info ? info->image_info : (ImageInfo *) NULL,image,
7864 argument_list[0].string_reference,exception),exception);
7867 case 3: /* AddNoise */
7872 if (attribute_flag[0] == 0)
7873 argument_list[0].integer_reference=UniformNoise;
7875 if (attribute_flag[1] != 0)
7876 attenuate=argument_list[1].real_reference;
7877 if (attribute_flag[2] != 0)
7878 channel=(ChannelType) argument_list[2].integer_reference;
7879 channel_mask=SetImageChannelMask(image,channel);
7880 image=AddNoiseImage(image,(NoiseType)
7881 argument_list[0].integer_reference,attenuate,exception);
7882 if (image != (Image *) NULL)
7883 (void) SetImageChannelMask(image,channel_mask);
7886 case 4: /* Colorize */
7891 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7892 0,0,&target,exception);
7893 if (attribute_flag[0] != 0)
7894 (void) QueryColorCompliance(argument_list[0].string_reference,
7895 AllCompliance,&target,exception);
7896 if (attribute_flag[1] == 0)
7897 argument_list[1].string_reference="100%";
7898 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7902 case 5: /* Border */
7909 if (attribute_flag[0] != 0)
7910 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7911 &geometry,exception);
7912 if (attribute_flag[1] != 0)
7913 geometry.width=argument_list[1].integer_reference;
7914 if (attribute_flag[2] != 0)
7915 geometry.height=argument_list[2].integer_reference;
7916 if (attribute_flag[3] != 0)
7917 QueryColorCompliance(argument_list[3].string_reference,
7918 AllCompliance,&image->border_color,exception);
7919 if (attribute_flag[4] != 0)
7920 QueryColorCompliance(argument_list[4].string_reference,
7921 AllCompliance,&image->border_color,exception);
7922 if (attribute_flag[5] != 0)
7923 QueryColorCompliance(argument_list[5].string_reference,
7924 AllCompliance,&image->border_color,exception);
7925 compose=image->compose;
7926 if (attribute_flag[6] != 0)
7927 compose=(CompositeOperator) argument_list[6].integer_reference;
7928 image=BorderImage(image,&geometry,compose,exception);
7933 if (attribute_flag[0] != 0)
7935 flags=ParseGeometry(argument_list[0].string_reference,
7937 if ((flags & SigmaValue) == 0)
7938 geometry_info.sigma=1.0;
7940 if (attribute_flag[1] != 0)
7941 geometry_info.rho=argument_list[1].real_reference;
7942 if (attribute_flag[2] != 0)
7943 geometry_info.sigma=argument_list[2].real_reference;
7944 if (attribute_flag[3] != 0)
7945 channel=(ChannelType) argument_list[3].integer_reference;
7946 channel_mask=SetImageChannelMask(image,channel);
7947 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7949 if (image != (Image *) NULL)
7950 (void) SetImageChannelMask(image,channel_mask);
7955 if (attribute_flag[5] != 0)
7956 image->gravity=(GravityType) argument_list[5].integer_reference;
7957 if (attribute_flag[0] != 0)
7958 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7959 &geometry,exception);
7960 if (attribute_flag[1] != 0)
7961 geometry.width=argument_list[1].integer_reference;
7962 if (attribute_flag[2] != 0)
7963 geometry.height=argument_list[2].integer_reference;
7964 if (attribute_flag[3] != 0)
7965 geometry.x=argument_list[3].integer_reference;
7966 if (attribute_flag[4] != 0)
7967 geometry.y=argument_list[4].integer_reference;
7968 image=ChopImage(image,&geometry,exception);
7973 if (attribute_flag[6] != 0)
7974 image->gravity=(GravityType) argument_list[6].integer_reference;
7975 if (attribute_flag[0] != 0)
7976 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7977 &geometry,exception);
7978 if (attribute_flag[1] != 0)
7979 geometry.width=argument_list[1].integer_reference;
7980 if (attribute_flag[2] != 0)
7981 geometry.height=argument_list[2].integer_reference;
7982 if (attribute_flag[3] != 0)
7983 geometry.x=argument_list[3].integer_reference;
7984 if (attribute_flag[4] != 0)
7985 geometry.y=argument_list[4].integer_reference;
7986 if (attribute_flag[5] != 0)
7987 image->fuzz=StringToDoubleInterval(
7988 argument_list[5].string_reference,(double) QuantumRange+1.0);
7989 image=CropImage(image,&geometry,exception);
7992 case 9: /* Despeckle */
7994 image=DespeckleImage(image,exception);
7999 if (attribute_flag[0] != 0)
8000 geometry_info.rho=argument_list[0].real_reference;
8001 image=EdgeImage(image,geometry_info.rho,exception);
8004 case 11: /* Emboss */
8006 if (attribute_flag[0] != 0)
8008 flags=ParseGeometry(argument_list[0].string_reference,
8010 if ((flags & SigmaValue) == 0)
8011 geometry_info.sigma=1.0;
8013 if (attribute_flag[1] != 0)
8014 geometry_info.rho=argument_list[1].real_reference;
8015 if (attribute_flag[2] != 0)
8016 geometry_info.sigma=argument_list[2].real_reference;
8017 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8021 case 12: /* Enhance */
8023 image=EnhanceImage(image,exception);
8028 image=FlipImage(image,exception);
8033 image=FlopImage(image,exception);
8036 case 15: /* Frame */
8044 if (attribute_flag[0] != 0)
8046 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8047 &geometry,exception);
8048 frame_info.width=geometry.width;
8049 frame_info.height=geometry.height;
8050 frame_info.outer_bevel=geometry.x;
8051 frame_info.inner_bevel=geometry.y;
8053 if (attribute_flag[1] != 0)
8054 frame_info.width=argument_list[1].integer_reference;
8055 if (attribute_flag[2] != 0)
8056 frame_info.height=argument_list[2].integer_reference;
8057 if (attribute_flag[3] != 0)
8058 frame_info.inner_bevel=argument_list[3].integer_reference;
8059 if (attribute_flag[4] != 0)
8060 frame_info.outer_bevel=argument_list[4].integer_reference;
8061 if (attribute_flag[5] != 0)
8062 QueryColorCompliance(argument_list[5].string_reference,
8063 AllCompliance,&fill_color,exception);
8064 if (attribute_flag[6] != 0)
8065 QueryColorCompliance(argument_list[6].string_reference,
8066 AllCompliance,&fill_color,exception);
8067 frame_info.x=(ssize_t) frame_info.width;
8068 frame_info.y=(ssize_t) frame_info.height;
8069 frame_info.width=image->columns+2*frame_info.x;
8070 frame_info.height=image->rows+2*frame_info.y;
8071 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8072 image->alpha_color=fill_color;
8073 compose=image->compose;
8074 if (attribute_flag[7] != 0)
8075 compose=(CompositeOperator) argument_list[7].integer_reference;
8076 image=FrameImage(image,&frame_info,compose,exception);
8079 case 16: /* Implode */
8081 PixelInterpolateMethod
8084 if (attribute_flag[0] == 0)
8085 argument_list[0].real_reference=0.5;
8086 method=UndefinedInterpolatePixel;
8087 if (attribute_flag[1] != 0)
8088 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8089 image=ImplodeImage(image,argument_list[0].real_reference,
8093 case 17: /* Magnify */
8095 image=MagnifyImage(image,exception);
8098 case 18: /* MedianFilter */
8100 if (attribute_flag[0] != 0)
8102 flags=ParseGeometry(argument_list[0].string_reference,
8104 if ((flags & SigmaValue) == 0)
8105 geometry_info.sigma=geometry_info.rho;
8107 if (attribute_flag[1] != 0)
8108 geometry_info.rho=argument_list[1].real_reference;
8109 if (attribute_flag[2] != 0)
8110 geometry_info.sigma=argument_list[2].real_reference;
8111 if (attribute_flag[3] != 0)
8112 channel=(ChannelType) argument_list[3].integer_reference;
8113 channel_mask=SetImageChannelMask(image,channel);
8114 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8115 (size_t) geometry_info.sigma,exception);
8116 if (image != (Image *) NULL)
8117 (void) SetImageChannelMask(image,channel_mask);
8120 case 19: /* Minify */
8122 image=MinifyImage(image,exception);
8125 case 20: /* OilPaint */
8127 if (attribute_flag[0] == 0)
8128 argument_list[0].real_reference=0.0;
8129 if (attribute_flag[1] == 0)
8130 argument_list[1].real_reference=1.0;
8131 image=OilPaintImage(image,argument_list[0].real_reference,
8132 argument_list[1].real_reference,exception);
8135 case 21: /* ReduceNoise */
8137 if (attribute_flag[0] != 0)
8139 flags=ParseGeometry(argument_list[0].string_reference,
8141 if ((flags & SigmaValue) == 0)
8142 geometry_info.sigma=1.0;
8144 if (attribute_flag[1] != 0)
8145 geometry_info.rho=argument_list[1].real_reference;
8146 if (attribute_flag[2] != 0)
8147 geometry_info.sigma=argument_list[2].real_reference;
8148 if (attribute_flag[3] != 0)
8149 channel=(ChannelType) argument_list[3].integer_reference;
8150 channel_mask=SetImageChannelMask(image,channel);
8151 image=StatisticImage(image,NonpeakStatistic,(size_t)
8152 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8153 if (image != (Image *) NULL)
8154 (void) SetImageChannelMask(image,channel_mask);
8159 if (attribute_flag[0] != 0)
8160 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8161 &geometry,exception);
8162 if (attribute_flag[1] != 0)
8163 geometry.x=argument_list[1].integer_reference;
8164 if (attribute_flag[2] != 0)
8165 geometry.y=argument_list[2].integer_reference;
8166 image=RollImage(image,geometry.x,geometry.y,exception);
8169 case 23: /* Rotate */
8171 if (attribute_flag[0] == 0)
8172 argument_list[0].real_reference=90.0;
8173 if (attribute_flag[1] != 0)
8175 QueryColorCompliance(argument_list[1].string_reference,
8176 AllCompliance,&image->background_color,exception);
8177 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8178 (image->alpha_trait == UndefinedPixelTrait))
8179 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8181 image=RotateImage(image,argument_list[0].real_reference,exception);
8184 case 24: /* Sample */
8186 if (attribute_flag[0] != 0)
8187 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8188 &geometry,exception);
8189 if (attribute_flag[1] != 0)
8190 geometry.width=argument_list[1].integer_reference;
8191 if (attribute_flag[2] != 0)
8192 geometry.height=argument_list[2].integer_reference;
8193 image=SampleImage(image,geometry.width,geometry.height,exception);
8196 case 25: /* Scale */
8198 if (attribute_flag[0] != 0)
8199 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8200 &geometry,exception);
8201 if (attribute_flag[1] != 0)
8202 geometry.width=argument_list[1].integer_reference;
8203 if (attribute_flag[2] != 0)
8204 geometry.height=argument_list[2].integer_reference;
8205 image=ScaleImage(image,geometry.width,geometry.height,exception);
8208 case 26: /* Shade */
8210 if (attribute_flag[0] != 0)
8212 flags=ParseGeometry(argument_list[0].string_reference,
8214 if ((flags & SigmaValue) == 0)
8215 geometry_info.sigma=0.0;
8217 if (attribute_flag[1] != 0)
8218 geometry_info.rho=argument_list[1].real_reference;
8219 if (attribute_flag[2] != 0)
8220 geometry_info.sigma=argument_list[2].real_reference;
8221 image=ShadeImage(image,
8222 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8223 geometry_info.rho,geometry_info.sigma,exception);
8226 case 27: /* Sharpen */
8228 if (attribute_flag[0] != 0)
8230 flags=ParseGeometry(argument_list[0].string_reference,
8232 if ((flags & SigmaValue) == 0)
8233 geometry_info.sigma=1.0;
8235 if (attribute_flag[1] != 0)
8236 geometry_info.rho=argument_list[1].real_reference;
8237 if (attribute_flag[2] != 0)
8238 geometry_info.sigma=argument_list[2].real_reference;
8239 if (attribute_flag[3] != 0)
8240 channel=(ChannelType) argument_list[3].integer_reference;
8241 channel_mask=SetImageChannelMask(image,channel);
8242 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8244 if (image != (Image *) NULL)
8245 (void) SetImageChannelMask(image,channel_mask);
8248 case 28: /* Shear */
8250 if (attribute_flag[0] != 0)
8252 flags=ParseGeometry(argument_list[0].string_reference,
8254 if ((flags & SigmaValue) == 0)
8255 geometry_info.sigma=geometry_info.rho;
8257 if (attribute_flag[1] != 0)
8258 geometry_info.rho=argument_list[1].real_reference;
8259 if (attribute_flag[2] != 0)
8260 geometry_info.sigma=argument_list[2].real_reference;
8261 if (attribute_flag[3] != 0)
8262 QueryColorCompliance(argument_list[3].string_reference,
8263 AllCompliance,&image->background_color,exception);
8264 if (attribute_flag[4] != 0)
8265 QueryColorCompliance(argument_list[4].string_reference,
8266 AllCompliance,&image->background_color,exception);
8267 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8271 case 29: /* Spread */
8273 PixelInterpolateMethod
8276 if (attribute_flag[0] == 0)
8277 argument_list[0].real_reference=1.0;
8278 method=UndefinedInterpolatePixel;
8279 if (attribute_flag[1] != 0)
8280 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8281 image=SpreadImage(image,method,argument_list[0].real_reference,
8285 case 30: /* Swirl */
8287 PixelInterpolateMethod
8290 if (attribute_flag[0] == 0)
8291 argument_list[0].real_reference=50.0;
8292 method=UndefinedInterpolatePixel;
8293 if (attribute_flag[1] != 0)
8294 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8295 image=SwirlImage(image,argument_list[0].real_reference,
8299 case 31: /* Resize */
8302 if (attribute_flag[0] != 0)
8303 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8304 &geometry,exception);
8305 if (attribute_flag[1] != 0)
8306 geometry.width=argument_list[1].integer_reference;
8307 if (attribute_flag[2] != 0)
8308 geometry.height=argument_list[2].integer_reference;
8309 if (attribute_flag[3] == 0)
8310 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8311 if (attribute_flag[4] != 0)
8312 SetImageArtifact(image,"filter:support",
8313 argument_list[4].string_reference);
8314 image=ResizeImage(image,geometry.width,geometry.height,
8315 (FilterType) argument_list[3].integer_reference,
8319 case 33: /* Annotate */
8324 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8326 if (attribute_flag[0] != 0)
8331 text=InterpretImageProperties(info ? info->image_info :
8332 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8334 (void) CloneString(&draw_info->text,text);
8335 text=DestroyString(text);
8337 if (attribute_flag[1] != 0)
8338 (void) CloneString(&draw_info->font,
8339 argument_list[1].string_reference);
8340 if (attribute_flag[2] != 0)
8341 draw_info->pointsize=argument_list[2].real_reference;
8342 if (attribute_flag[3] != 0)
8343 (void) CloneString(&draw_info->density,
8344 argument_list[3].string_reference);
8345 if (attribute_flag[4] != 0)
8346 (void) QueryColorCompliance(argument_list[4].string_reference,
8347 AllCompliance,&draw_info->undercolor,exception);
8348 if (attribute_flag[5] != 0)
8350 (void) QueryColorCompliance(argument_list[5].string_reference,
8351 AllCompliance,&draw_info->stroke,exception);
8352 if (argument_list[5].image_reference != (Image *) NULL)
8353 draw_info->stroke_pattern=CloneImage(
8354 argument_list[5].image_reference,0,0,MagickTrue,exception);
8356 if (attribute_flag[6] != 0)
8358 (void) QueryColorCompliance(argument_list[6].string_reference,
8359 AllCompliance,&draw_info->fill,exception);
8360 if (argument_list[6].image_reference != (Image *) NULL)
8361 draw_info->fill_pattern=CloneImage(
8362 argument_list[6].image_reference,0,0,MagickTrue,exception);
8364 if (attribute_flag[7] != 0)
8366 (void) CloneString(&draw_info->geometry,
8367 argument_list[7].string_reference);
8368 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8369 &geometry,exception);
8370 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8371 geometry_info.sigma=geometry_info.xi;
8373 if (attribute_flag[8] != 0)
8374 (void) QueryColorCompliance(argument_list[8].string_reference,
8375 AllCompliance,&draw_info->fill,exception);
8376 if (attribute_flag[11] != 0)
8377 draw_info->gravity=(GravityType)
8378 argument_list[11].integer_reference;
8379 if (attribute_flag[25] != 0)
8384 av=(AV *) argument_list[25].array_reference;
8385 if ((av_len(av) != 3) && (av_len(av) != 5))
8387 ThrowPerlException(exception,OptionError,
8388 "affine matrix must have 4 or 6 elements",PackageName);
8391 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8392 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8393 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8394 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8395 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8396 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8398 ThrowPerlException(exception,OptionError,
8399 "affine matrix is singular",PackageName);
8402 if (av_len(av) == 5)
8404 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8405 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8408 for (j=12; j < 17; j++)
8410 if (attribute_flag[j] == 0)
8412 value=argument_list[j].string_reference;
8413 angle=argument_list[j].real_reference;
8414 current=draw_info->affine;
8415 GetAffineMatrix(&affine);
8423 flags=ParseGeometry(value,&geometry_info);
8424 affine.tx=geometry_info.xi;
8425 affine.ty=geometry_info.psi;
8426 if ((flags & PsiValue) == 0)
8427 affine.ty=affine.tx;
8435 flags=ParseGeometry(value,&geometry_info);
8436 affine.sx=geometry_info.rho;
8437 affine.sy=geometry_info.sigma;
8438 if ((flags & SigmaValue) == 0)
8439 affine.sy=affine.sx;
8449 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8450 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8451 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8452 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8460 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8468 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8472 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8473 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8474 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8475 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8476 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8478 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8481 if (attribute_flag[9] == 0)
8482 argument_list[9].real_reference=0.0;
8483 if (attribute_flag[10] == 0)
8484 argument_list[10].real_reference=0.0;
8485 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8488 geometry[MagickPathExtent];
8490 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8491 (double) argument_list[9].real_reference+draw_info->affine.tx,
8492 (double) argument_list[10].real_reference+draw_info->affine.ty);
8493 (void) CloneString(&draw_info->geometry,geometry);
8495 if (attribute_flag[17] != 0)
8496 draw_info->stroke_width=argument_list[17].real_reference;
8497 if (attribute_flag[18] != 0)
8499 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8500 MagickTrue : MagickFalse;
8501 draw_info->stroke_antialias=draw_info->text_antialias;
8503 if (attribute_flag[19] != 0)
8504 (void) CloneString(&draw_info->family,
8505 argument_list[19].string_reference);
8506 if (attribute_flag[20] != 0)
8507 draw_info->style=(StyleType) argument_list[20].integer_reference;
8508 if (attribute_flag[21] != 0)
8509 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8510 if (attribute_flag[22] != 0)
8511 draw_info->weight=argument_list[22].integer_reference;
8512 if (attribute_flag[23] != 0)
8513 draw_info->align=(AlignType) argument_list[23].integer_reference;
8514 if (attribute_flag[24] != 0)
8515 (void) CloneString(&draw_info->encoding,
8516 argument_list[24].string_reference);
8517 if (attribute_flag[25] != 0)
8518 draw_info->fill_pattern=CloneImage(
8519 argument_list[25].image_reference,0,0,MagickTrue,exception);
8520 if (attribute_flag[26] != 0)
8521 draw_info->fill_pattern=CloneImage(
8522 argument_list[26].image_reference,0,0,MagickTrue,exception);
8523 if (attribute_flag[27] != 0)
8524 draw_info->stroke_pattern=CloneImage(
8525 argument_list[27].image_reference,0,0,MagickTrue,exception);
8526 if (attribute_flag[29] != 0)
8527 draw_info->kerning=argument_list[29].real_reference;
8528 if (attribute_flag[30] != 0)
8529 draw_info->interline_spacing=argument_list[30].real_reference;
8530 if (attribute_flag[31] != 0)
8531 draw_info->interword_spacing=argument_list[31].real_reference;
8532 if (attribute_flag[32] != 0)
8533 draw_info->direction=(DirectionType)
8534 argument_list[32].integer_reference;
8535 (void) AnnotateImage(image,draw_info,exception);
8536 draw_info=DestroyDrawInfo(draw_info);
8539 case 34: /* ColorFloodfill */
8550 draw_info=CloneDrawInfo(info ? info->image_info :
8551 (ImageInfo *) NULL,(DrawInfo *) NULL);
8552 if (attribute_flag[0] != 0)
8553 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8554 &geometry,exception);
8555 if (attribute_flag[1] != 0)
8556 geometry.x=argument_list[1].integer_reference;
8557 if (attribute_flag[2] != 0)
8558 geometry.y=argument_list[2].integer_reference;
8559 if (attribute_flag[3] != 0)
8560 (void) QueryColorCompliance(argument_list[3].string_reference,
8561 AllCompliance,&draw_info->fill,exception);
8562 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8563 geometry.x,geometry.y,&target,exception);
8565 if (attribute_flag[4] != 0)
8567 QueryColorCompliance(argument_list[4].string_reference,
8568 AllCompliance,&target,exception);
8571 if (attribute_flag[5] != 0)
8572 image->fuzz=StringToDoubleInterval(
8573 argument_list[5].string_reference,(double) QuantumRange+1.0);
8574 if (attribute_flag[6] != 0)
8575 invert=(MagickBooleanType) argument_list[6].integer_reference;
8576 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8577 geometry.y,invert,exception);
8578 draw_info=DestroyDrawInfo(draw_info);
8581 case 35: /* Composite */
8584 composite_geometry[MagickPathExtent];
8593 compose=OverCompositeOp;
8594 if (attribute_flag[0] != 0)
8595 composite_image=argument_list[0].image_reference;
8598 ThrowPerlException(exception,OptionError,
8599 "CompositeImageRequired",PackageName);
8603 Parameter Handling used for BOTH normal and tiled composition.
8605 if (attribute_flag[1] != 0) /* compose */
8606 compose=(CompositeOperator) argument_list[1].integer_reference;
8607 if (attribute_flag[6] != 0) /* opacity */
8609 if (compose != DissolveCompositeOp)
8610 (void) SetImageAlpha(composite_image,(Quantum)
8611 StringToDoubleInterval(argument_list[6].string_reference,
8612 (double) QuantumRange+1.0),exception);
8634 Handle dissolve composite operator (patch by
8637 (void) CloneString(&image->geometry,
8638 argument_list[6].string_reference);
8639 opacity=(Quantum) StringToDoubleInterval(
8640 argument_list[6].string_reference,(double) QuantumRange+
8642 if (composite_image->alpha_trait != UndefinedPixelTrait)
8643 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8644 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8645 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8647 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8648 composite_image->columns,1,exception);
8649 for (x=0; x < (ssize_t) composite_image->columns; x++)
8651 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8652 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8654 q+=GetPixelChannels(composite_image);
8656 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8657 if (sync == MagickFalse)
8660 composite_view=DestroyCacheView(composite_view);
8663 if (attribute_flag[9] != 0) /* "color=>" */
8664 QueryColorCompliance(argument_list[9].string_reference,
8665 AllCompliance,&composite_image->background_color,exception);
8666 if (attribute_flag[12] != 0) /* "interpolate=>" */
8667 image->interpolate=(PixelInterpolateMethod)
8668 argument_list[12].integer_reference;
8669 if (attribute_flag[13] != 0) /* "args=>" */
8670 (void) SetImageArtifact(composite_image,"compose:args",
8671 argument_list[13].string_reference);
8672 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8673 (void) SetImageArtifact(composite_image,"compose:args",
8674 argument_list[14].string_reference);
8675 clip_to_self=MagickTrue;
8676 if (attribute_flag[15] != 0)
8677 clip_to_self=(MagickBooleanType)
8678 argument_list[15].integer_reference;
8680 Tiling Composition (with orthogonal rotate).
8682 rotate_image=(Image *) NULL;
8683 if (attribute_flag[8] != 0) /* "rotate=>" */
8688 rotate_image=RotateImage(composite_image,
8689 argument_list[8].real_reference,exception);
8690 if (rotate_image == (Image *) NULL)
8693 if ((attribute_flag[7] != 0) &&
8694 (argument_list[7].integer_reference != 0)) /* tile */
8701 Tile the composite image.
8703 if (attribute_flag[8] != 0) /* "tile=>" */
8704 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8707 (void) SetImageArtifact(composite_image,
8708 "compose:outside-overlay","false");
8709 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8710 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8712 if (attribute_flag[8] != 0) /* rotate */
8713 (void) CompositeImage(image,rotate_image,compose,
8714 MagickTrue,x,y,exception);
8716 (void) CompositeImage(image,composite_image,compose,
8717 MagickTrue,x,y,exception);
8719 if (attribute_flag[8] != 0) /* rotate */
8720 rotate_image=DestroyImage(rotate_image);
8724 Parameter Handling used used ONLY for normal composition.
8726 if (attribute_flag[5] != 0) /* gravity */
8727 image->gravity=(GravityType) argument_list[5].integer_reference;
8728 if (attribute_flag[2] != 0) /* geometry offset */
8730 SetGeometry(image,&geometry);
8731 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8733 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8736 if (attribute_flag[3] != 0) /* x offset */
8737 geometry.x=argument_list[3].integer_reference;
8738 if (attribute_flag[4] != 0) /* y offset */
8739 geometry.y=argument_list[4].integer_reference;
8740 if (attribute_flag[10] != 0) /* mask */
8742 if ((image->compose == DisplaceCompositeOp) ||
8743 (image->compose == DistortCompositeOp))
8746 Merge Y displacement into X displacement image.
8748 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8750 (void) CompositeImage(composite_image,
8751 argument_list[10].image_reference,CopyGreenCompositeOp,
8752 MagickTrue,0,0,exception);
8760 Set a blending mask for the composition.
8762 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8763 MagickTrue,exception);
8764 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8766 mask_image=DestroyImage(mask_image);
8769 if (attribute_flag[11] != 0) /* channel */
8770 channel=(ChannelType) argument_list[11].integer_reference;
8772 Composite two images (normal composition).
8774 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8775 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8776 (double) composite_image->rows,(double) geometry.x,(double)
8778 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8780 channel_mask=SetImageChannelMask(image,channel);
8781 if (attribute_flag[8] == 0) /* no rotate */
8782 CompositeImage(image,composite_image,compose,clip_to_self,
8783 geometry.x,geometry.y,exception);
8787 Position adjust rotated image then composite.
8789 geometry.x-=(ssize_t) (rotate_image->columns-
8790 composite_image->columns)/2;
8791 geometry.y-=(ssize_t) (rotate_image->rows-
8792 composite_image->rows)/2;
8793 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8794 geometry.y,exception);
8795 rotate_image=DestroyImage(rotate_image);
8797 if (attribute_flag[10] != 0) /* mask */
8799 if ((image->compose == DisplaceCompositeOp) ||
8800 (image->compose == DistortCompositeOp))
8801 composite_image=DestroyImage(composite_image);
8803 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8806 (void) SetImageChannelMask(image,channel_mask);
8809 case 36: /* Contrast */
8811 if (attribute_flag[0] == 0)
8812 argument_list[0].integer_reference=0;
8813 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8814 MagickTrue : MagickFalse,exception);
8817 case 37: /* CycleColormap */
8819 if (attribute_flag[0] == 0)
8820 argument_list[0].integer_reference=6;
8821 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8830 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8832 (void) CloneString(&draw_info->primitive,"point");
8833 if (attribute_flag[0] != 0)
8835 if (argument_list[0].integer_reference < 0)
8836 (void) CloneString(&draw_info->primitive,
8837 argument_list[0].string_reference);
8839 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8840 MagickPrimitiveOptions,argument_list[0].integer_reference));
8842 if (attribute_flag[1] != 0)
8844 if (LocaleCompare(draw_info->primitive,"path") == 0)
8846 (void) ConcatenateString(&draw_info->primitive," '");
8847 ConcatenateString(&draw_info->primitive,
8848 argument_list[1].string_reference);
8849 (void) ConcatenateString(&draw_info->primitive,"'");
8853 (void) ConcatenateString(&draw_info->primitive," ");
8854 ConcatenateString(&draw_info->primitive,
8855 argument_list[1].string_reference);
8858 if (attribute_flag[2] != 0)
8860 (void) ConcatenateString(&draw_info->primitive," ");
8861 (void) ConcatenateString(&draw_info->primitive,
8862 CommandOptionToMnemonic(MagickMethodOptions,
8863 argument_list[2].integer_reference));
8865 if (attribute_flag[3] != 0)
8867 (void) QueryColorCompliance(argument_list[3].string_reference,
8868 AllCompliance,&draw_info->stroke,exception);
8869 if (argument_list[3].image_reference != (Image *) NULL)
8870 draw_info->stroke_pattern=CloneImage(
8871 argument_list[3].image_reference,0,0,MagickTrue,exception);
8873 if (attribute_flag[4] != 0)
8875 (void) QueryColorCompliance(argument_list[4].string_reference,
8876 AllCompliance,&draw_info->fill,exception);
8877 if (argument_list[4].image_reference != (Image *) NULL)
8878 draw_info->fill_pattern=CloneImage(
8879 argument_list[4].image_reference,0,0,MagickTrue,exception);
8881 if (attribute_flag[5] != 0)
8882 draw_info->stroke_width=argument_list[5].real_reference;
8883 if (attribute_flag[6] != 0)
8884 (void) CloneString(&draw_info->font,
8885 argument_list[6].string_reference);
8886 if (attribute_flag[7] != 0)
8887 (void) QueryColorCompliance(argument_list[7].string_reference,
8888 AllCompliance,&draw_info->border_color,exception);
8889 if (attribute_flag[8] != 0)
8890 draw_info->affine.tx=argument_list[8].real_reference;
8891 if (attribute_flag[9] != 0)
8892 draw_info->affine.ty=argument_list[9].real_reference;
8893 if (attribute_flag[20] != 0)
8898 av=(AV *) argument_list[20].array_reference;
8899 if ((av_len(av) != 3) && (av_len(av) != 5))
8901 ThrowPerlException(exception,OptionError,
8902 "affine matrix must have 4 or 6 elements",PackageName);
8905 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8906 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8907 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8908 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8909 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8910 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8912 ThrowPerlException(exception,OptionError,
8913 "affine matrix is singular",PackageName);
8916 if (av_len(av) == 5)
8918 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8919 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8922 for (j=10; j < 15; j++)
8924 if (attribute_flag[j] == 0)
8926 value=argument_list[j].string_reference;
8927 angle=argument_list[j].real_reference;
8928 current=draw_info->affine;
8929 GetAffineMatrix(&affine);
8937 flags=ParseGeometry(value,&geometry_info);
8938 affine.tx=geometry_info.xi;
8939 affine.ty=geometry_info.psi;
8940 if ((flags & PsiValue) == 0)
8941 affine.ty=affine.tx;
8949 flags=ParseGeometry(value,&geometry_info);
8950 affine.sx=geometry_info.rho;
8951 affine.sy=geometry_info.sigma;
8952 if ((flags & SigmaValue) == 0)
8953 affine.sy=affine.sx;
8963 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8964 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8965 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8966 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8974 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8982 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8986 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8987 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8988 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8989 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8990 draw_info->affine.tx=
8991 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8992 draw_info->affine.ty=
8993 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8995 if (attribute_flag[15] != 0)
8996 draw_info->fill_pattern=CloneImage(
8997 argument_list[15].image_reference,0,0,MagickTrue,exception);
8998 if (attribute_flag[16] != 0)
8999 draw_info->pointsize=argument_list[16].real_reference;
9000 if (attribute_flag[17] != 0)
9002 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
9003 ? MagickTrue : MagickFalse;
9004 draw_info->text_antialias=draw_info->stroke_antialias;
9006 if (attribute_flag[18] != 0)
9007 (void) CloneString(&draw_info->density,
9008 argument_list[18].string_reference);
9009 if (attribute_flag[19] != 0)
9010 draw_info->stroke_width=argument_list[19].real_reference;
9011 if (attribute_flag[21] != 0)
9012 draw_info->dash_offset=argument_list[21].real_reference;
9013 if (attribute_flag[22] != 0)
9018 av=(AV *) argument_list[22].array_reference;
9019 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9020 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9021 if (draw_info->dash_pattern != (double *) NULL)
9023 for (i=0; i <= av_len(av); i++)
9024 draw_info->dash_pattern[i]=(double)
9025 SvNV(*(av_fetch(av,i,0)));
9026 draw_info->dash_pattern[i]=0.0;
9029 if (attribute_flag[23] != 0)
9030 image->interpolate=(PixelInterpolateMethod)
9031 argument_list[23].integer_reference;
9032 if ((attribute_flag[24] != 0) &&
9033 (draw_info->fill_pattern != (Image *) NULL))
9034 flags=ParsePageGeometry(draw_info->fill_pattern,
9035 argument_list[24].string_reference,
9036 &draw_info->fill_pattern->tile_offset,exception);
9037 if (attribute_flag[25] != 0)
9039 (void) ConcatenateString(&draw_info->primitive," '");
9040 (void) ConcatenateString(&draw_info->primitive,
9041 argument_list[25].string_reference);
9042 (void) ConcatenateString(&draw_info->primitive,"'");
9044 if (attribute_flag[26] != 0)
9045 draw_info->fill_pattern=CloneImage(
9046 argument_list[26].image_reference,0,0,MagickTrue,exception);
9047 if (attribute_flag[27] != 0)
9048 draw_info->stroke_pattern=CloneImage(
9049 argument_list[27].image_reference,0,0,MagickTrue,exception);
9050 if (attribute_flag[28] != 0)
9051 (void) CloneString(&draw_info->primitive,
9052 argument_list[28].string_reference);
9053 if (attribute_flag[29] != 0)
9054 draw_info->kerning=argument_list[29].real_reference;
9055 if (attribute_flag[30] != 0)
9056 draw_info->interline_spacing=argument_list[30].real_reference;
9057 if (attribute_flag[31] != 0)
9058 draw_info->interword_spacing=argument_list[31].real_reference;
9059 if (attribute_flag[32] != 0)
9060 draw_info->direction=(DirectionType)
9061 argument_list[32].integer_reference;
9062 DrawImage(image,draw_info,exception);
9063 draw_info=DestroyDrawInfo(draw_info);
9066 case 39: /* Equalize */
9068 if (attribute_flag[0] != 0)
9069 channel=(ChannelType) argument_list[0].integer_reference;
9070 channel_mask=SetImageChannelMask(image,channel);
9071 EqualizeImage(image,exception);
9072 (void) SetImageChannelMask(image,channel_mask);
9075 case 40: /* Gamma */
9077 if (attribute_flag[1] != 0)
9078 channel=(ChannelType) argument_list[1].integer_reference;
9079 if (attribute_flag[2] == 0)
9080 argument_list[2].real_reference=1.0;
9081 if (attribute_flag[3] == 0)
9082 argument_list[3].real_reference=1.0;
9083 if (attribute_flag[4] == 0)
9084 argument_list[4].real_reference=1.0;
9085 if (attribute_flag[0] == 0)
9087 (void) FormatLocaleString(message,MagickPathExtent,
9088 "%.20g,%.20g,%.20g",(double) argument_list[2].real_reference,
9089 (double) argument_list[3].real_reference,
9090 (double) argument_list[4].real_reference);
9091 argument_list[0].string_reference=message;
9093 (void) GammaImage(image,StringToDouble(
9094 argument_list[0].string_reference,(char **) NULL),exception);
9102 if (attribute_flag[0] == 0)
9104 ThrowPerlException(exception,OptionError,"MapImageRequired",
9108 quantize_info=AcquireQuantizeInfo(info->image_info);
9109 if (attribute_flag[1] != 0)
9110 quantize_info->dither_method=(DitherMethod)
9111 argument_list[1].integer_reference;
9112 (void) RemapImages(quantize_info,image,
9113 argument_list[0].image_reference,exception);
9114 quantize_info=DestroyQuantizeInfo(quantize_info);
9117 case 42: /* MatteFloodfill */
9128 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9130 if (attribute_flag[0] != 0)
9131 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9132 &geometry,exception);
9133 if (attribute_flag[1] != 0)
9134 geometry.x=argument_list[1].integer_reference;
9135 if (attribute_flag[2] != 0)
9136 geometry.y=argument_list[2].integer_reference;
9137 if (image->alpha_trait == UndefinedPixelTrait)
9138 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9139 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9140 geometry.x,geometry.y,&target,exception);
9141 if (attribute_flag[4] != 0)
9142 QueryColorCompliance(argument_list[4].string_reference,
9143 AllCompliance,&target,exception);
9144 if (attribute_flag[3] != 0)
9145 target.alpha=StringToDoubleInterval(
9146 argument_list[3].string_reference,(double) (double) QuantumRange+
9148 if (attribute_flag[5] != 0)
9149 image->fuzz=StringToDoubleInterval(
9150 argument_list[5].string_reference,(double) QuantumRange+1.0);
9152 if (attribute_flag[6] != 0)
9153 invert=(MagickBooleanType) argument_list[6].integer_reference;
9154 channel_mask=SetImageChannelMask(image,AlphaChannel);
9155 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9156 geometry.y,invert,exception);
9157 (void) SetImageChannelMask(image,channel_mask);
9158 draw_info=DestroyDrawInfo(draw_info);
9161 case 43: /* Modulate */
9164 modulate[MagickPathExtent];
9166 geometry_info.rho=100.0;
9167 geometry_info.sigma=100.0;
9168 geometry_info.xi=100.0;
9169 if (attribute_flag[0] != 0)
9170 (void)ParseGeometry(argument_list[0].string_reference,
9172 if (attribute_flag[1] != 0)
9173 geometry_info.xi=argument_list[1].real_reference;
9174 if (attribute_flag[2] != 0)
9175 geometry_info.sigma=argument_list[2].real_reference;
9176 if (attribute_flag[3] != 0)
9178 geometry_info.sigma=argument_list[3].real_reference;
9179 SetImageArtifact(image,"modulate:colorspace","HWB");
9181 if (attribute_flag[4] != 0)
9183 geometry_info.rho=argument_list[4].real_reference;
9184 SetImageArtifact(image,"modulate:colorspace","HSB");
9186 if (attribute_flag[5] != 0)
9188 geometry_info.sigma=argument_list[5].real_reference;
9189 SetImageArtifact(image,"modulate:colorspace","HSL");
9191 if (attribute_flag[6] != 0)
9193 geometry_info.rho=argument_list[6].real_reference;
9194 SetImageArtifact(image,"modulate:colorspace","HWB");
9196 (void) FormatLocaleString(modulate,MagickPathExtent,"%.20g,%.20g,%.20g",
9197 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9198 (void) ModulateImage(image,modulate,exception);
9201 case 44: /* Negate */
9203 if (attribute_flag[0] == 0)
9204 argument_list[0].integer_reference=0;
9205 if (attribute_flag[1] != 0)
9206 channel=(ChannelType) argument_list[1].integer_reference;
9207 channel_mask=SetImageChannelMask(image,channel);
9208 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9209 MagickTrue : MagickFalse,exception);
9210 (void) SetImageChannelMask(image,channel_mask);
9213 case 45: /* Normalize */
9215 if (attribute_flag[0] != 0)
9216 channel=(ChannelType) argument_list[0].integer_reference;
9217 channel_mask=SetImageChannelMask(image,channel);
9218 NormalizeImage(image,exception);
9219 (void) SetImageChannelMask(image,channel_mask);
9222 case 46: /* NumberColors */
9224 case 47: /* Opaque */
9233 (void) QueryColorCompliance("none",AllCompliance,&target,
9235 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9237 if (attribute_flag[0] != 0)
9238 (void) QueryColorCompliance(argument_list[0].string_reference,
9239 AllCompliance,&target,exception);
9240 if (attribute_flag[1] != 0)
9241 (void) QueryColorCompliance(argument_list[1].string_reference,
9242 AllCompliance,&fill_color,exception);
9243 if (attribute_flag[2] != 0)
9244 image->fuzz=StringToDoubleInterval(
9245 argument_list[2].string_reference,(double) QuantumRange+1.0);
9246 if (attribute_flag[3] != 0)
9247 channel=(ChannelType) argument_list[3].integer_reference;
9249 if (attribute_flag[4] != 0)
9250 invert=(MagickBooleanType) argument_list[4].integer_reference;
9251 channel_mask=SetImageChannelMask(image,channel);
9252 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9253 (void) SetImageChannelMask(image,channel_mask);
9256 case 48: /* Quantize */
9261 quantize_info=AcquireQuantizeInfo(info->image_info);
9262 if (attribute_flag[0] != 0)
9263 quantize_info->number_colors=(size_t)
9264 argument_list[0].integer_reference;
9265 if (attribute_flag[1] != 0)
9266 quantize_info->tree_depth=(size_t)
9267 argument_list[1].integer_reference;
9268 if (attribute_flag[2] != 0)
9269 quantize_info->colorspace=(ColorspaceType)
9270 argument_list[2].integer_reference;
9271 if (attribute_flag[3] != 0)
9272 quantize_info->dither_method=(DitherMethod)
9273 argument_list[3].integer_reference;
9274 if (attribute_flag[4] != 0)
9275 quantize_info->measure_error=
9276 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9277 if (attribute_flag[6] != 0)
9278 (void) QueryColorCompliance(argument_list[6].string_reference,
9279 AllCompliance,&image->transparent_color,exception);
9280 if (attribute_flag[7] != 0)
9281 quantize_info->dither_method=(DitherMethod)
9282 argument_list[7].integer_reference;
9283 if (attribute_flag[5] && argument_list[5].integer_reference)
9284 (void) QuantizeImages(quantize_info,image,exception);
9286 if ((image->storage_class == DirectClass) ||
9287 (image->colors > quantize_info->number_colors) ||
9288 (quantize_info->colorspace == GRAYColorspace))
9289 (void) QuantizeImage(quantize_info,image,exception);
9291 CompressImageColormap(image,exception);
9292 quantize_info=DestroyQuantizeInfo(quantize_info);
9295 case 49: /* Raise */
9297 if (attribute_flag[0] != 0)
9298 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9299 &geometry,exception);
9300 if (attribute_flag[1] != 0)
9301 geometry.width=argument_list[1].integer_reference;
9302 if (attribute_flag[2] != 0)
9303 geometry.height=argument_list[2].integer_reference;
9304 if (attribute_flag[3] == 0)
9305 argument_list[3].integer_reference=1;
9306 (void) RaiseImage(image,&geometry,
9307 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9311 case 50: /* Segment */
9318 smoothing_threshold;
9323 cluster_threshold=1.0;
9324 smoothing_threshold=1.5;
9325 colorspace=sRGBColorspace;
9326 verbose=MagickFalse;
9327 if (attribute_flag[0] != 0)
9329 flags=ParseGeometry(argument_list[0].string_reference,
9331 cluster_threshold=geometry_info.rho;
9332 if (flags & SigmaValue)
9333 smoothing_threshold=geometry_info.sigma;
9335 if (attribute_flag[1] != 0)
9336 cluster_threshold=argument_list[1].real_reference;
9337 if (attribute_flag[2] != 0)
9338 smoothing_threshold=argument_list[2].real_reference;
9339 if (attribute_flag[3] != 0)
9340 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9341 if (attribute_flag[4] != 0)
9342 verbose=argument_list[4].integer_reference != 0 ?
9343 MagickTrue : MagickFalse;
9344 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9345 smoothing_threshold,exception);
9348 case 51: /* Signature */
9350 (void) SignatureImage(image,exception);
9353 case 52: /* Solarize */
9355 geometry_info.rho=QuantumRange/2.0;
9356 if (attribute_flag[0] != 0)
9357 flags=ParseGeometry(argument_list[0].string_reference,
9359 if (attribute_flag[1] != 0)
9360 geometry_info.rho=StringToDoubleInterval(
9361 argument_list[1].string_reference,(double) QuantumRange+1.0);
9362 (void) SolarizeImage(image,geometry_info.rho,exception);
9367 (void) SyncImage(image,exception);
9370 case 54: /* Texture */
9372 if (attribute_flag[0] == 0)
9374 TextureImage(image,argument_list[0].image_reference,exception);
9377 case 55: /* Evalute */
9379 MagickEvaluateOperator
9382 op=SetEvaluateOperator;
9383 if (attribute_flag[0] == MagickFalse)
9384 argument_list[0].real_reference=0.0;
9385 if (attribute_flag[1] != MagickFalse)
9386 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9387 if (attribute_flag[2] != MagickFalse)
9388 channel=(ChannelType) argument_list[2].integer_reference;
9389 channel_mask=SetImageChannelMask(image,channel);
9390 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9392 (void) SetImageChannelMask(image,channel_mask);
9395 case 56: /* Transparent */
9406 (void) QueryColorCompliance("none",AllCompliance,&target,
9408 if (attribute_flag[0] != 0)
9409 (void) QueryColorCompliance(argument_list[0].string_reference,
9410 AllCompliance,&target,exception);
9411 opacity=TransparentAlpha;
9412 if (attribute_flag[1] != 0)
9413 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9414 (double) QuantumRange+1.0);
9415 if (attribute_flag[2] != 0)
9416 image->fuzz=StringToDoubleInterval(
9417 argument_list[2].string_reference,(double) QuantumRange+1.0);
9418 if (attribute_flag[3] == 0)
9419 argument_list[3].integer_reference=0;
9421 if (attribute_flag[3] != 0)
9422 invert=(MagickBooleanType) argument_list[3].integer_reference;
9423 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9427 case 57: /* Threshold */
9432 if (attribute_flag[0] == 0)
9433 argument_list[0].string_reference="50%";
9434 if (attribute_flag[1] != 0)
9435 channel=(ChannelType) argument_list[1].integer_reference;
9436 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9437 (double) QuantumRange+1.0);
9438 channel_mask=SetImageChannelMask(image,channel);
9439 (void) BilevelImage(image,threshold,exception);
9440 (void) SetImageChannelMask(image,channel_mask);
9443 case 58: /* Charcoal */
9445 if (attribute_flag[0] != 0)
9447 flags=ParseGeometry(argument_list[0].string_reference,
9449 if ((flags & SigmaValue) == 0)
9450 geometry_info.sigma=1.0;
9452 if (attribute_flag[1] != 0)
9453 geometry_info.rho=argument_list[1].real_reference;
9454 if (attribute_flag[2] != 0)
9455 geometry_info.sigma=argument_list[2].real_reference;
9456 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9462 if (attribute_flag[0] != 0)
9463 image->fuzz=StringToDoubleInterval(
9464 argument_list[0].string_reference,(double) QuantumRange+1.0);
9465 image=TrimImage(image,exception);
9470 PixelInterpolateMethod
9473 if (attribute_flag[0] != 0)
9475 flags=ParseGeometry(argument_list[0].string_reference,
9477 if ((flags & SigmaValue) == 0)
9478 geometry_info.sigma=1.0;
9480 if (attribute_flag[1] != 0)
9481 geometry_info.rho=argument_list[1].real_reference;
9482 if (attribute_flag[2] != 0)
9483 geometry_info.sigma=argument_list[2].real_reference;
9484 method=UndefinedInterpolatePixel;
9485 if (attribute_flag[3] != 0)
9486 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9487 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9491 case 61: /* Separate */
9493 if (attribute_flag[0] != 0)
9494 channel=(ChannelType) argument_list[0].integer_reference;
9495 image=SeparateImage(image,channel,exception);
9498 case 63: /* Stereo */
9500 if (attribute_flag[0] == 0)
9502 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9506 if (attribute_flag[1] != 0)
9507 geometry.x=argument_list[1].integer_reference;
9508 if (attribute_flag[2] != 0)
9509 geometry.y=argument_list[2].integer_reference;
9510 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9511 geometry.x,geometry.y,exception);
9514 case 64: /* Stegano */
9516 if (attribute_flag[0] == 0)
9518 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9522 if (attribute_flag[1] == 0)
9523 argument_list[1].integer_reference=0;
9524 image->offset=argument_list[1].integer_reference;
9525 image=SteganoImage(image,argument_list[0].image_reference,exception);
9528 case 65: /* Deconstruct */
9530 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9533 case 66: /* GaussianBlur */
9535 if (attribute_flag[0] != 0)
9537 flags=ParseGeometry(argument_list[0].string_reference,
9539 if ((flags & SigmaValue) == 0)
9540 geometry_info.sigma=1.0;
9542 if (attribute_flag[1] != 0)
9543 geometry_info.rho=argument_list[1].real_reference;
9544 if (attribute_flag[2] != 0)
9545 geometry_info.sigma=argument_list[2].real_reference;
9546 if (attribute_flag[3] != 0)
9547 channel=(ChannelType) argument_list[3].integer_reference;
9548 channel_mask=SetImageChannelMask(image,channel);
9549 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9551 if (image != (Image *) NULL)
9552 (void) SetImageChannelMask(image,channel_mask);
9555 case 67: /* Convolve */
9560 kernel=(KernelInfo *) NULL;
9561 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9563 if (attribute_flag[0] != 0)
9571 kernel=AcquireKernelInfo((const char *) NULL,exception);
9572 if (kernel == (KernelInfo *) NULL)
9574 av=(AV *) argument_list[0].array_reference;
9575 order=(size_t) sqrt(av_len(av)+1);
9576 kernel->width=order;
9577 kernel->height=order;
9578 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9579 order*sizeof(*kernel->values));
9580 if (kernel->values == (MagickRealType *) NULL)
9582 kernel=DestroyKernelInfo(kernel);
9583 ThrowPerlException(exception,ResourceLimitFatalError,
9584 "MemoryAllocationFailed",PackageName);
9587 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9588 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9589 for ( ; j < (ssize_t) (order*order); j++)
9590 kernel->values[j]=0.0;
9592 if (attribute_flag[1] != 0)
9593 channel=(ChannelType) argument_list[1].integer_reference;
9594 if (attribute_flag[2] != 0)
9595 SetImageArtifact(image,"filter:blur",
9596 argument_list[2].string_reference);
9597 if (attribute_flag[3] != 0)
9599 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9601 if (kernel == (KernelInfo *) NULL)
9604 channel_mask=SetImageChannelMask(image,channel);
9605 image=ConvolveImage(image,kernel,exception);
9606 if (image != (Image *) NULL)
9607 (void) SetImageChannelMask(image,channel_mask);
9608 kernel=DestroyKernelInfo(kernel);
9611 case 68: /* Profile */
9626 if (attribute_flag[0] != 0)
9627 name=argument_list[0].string_reference;
9628 if (attribute_flag[2] != 0)
9629 image->rendering_intent=(RenderingIntent)
9630 argument_list[2].integer_reference;
9631 if (attribute_flag[3] != 0)
9632 image->black_point_compensation=
9633 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9634 if (attribute_flag[1] != 0)
9636 if (argument_list[1].length == 0)
9639 Remove a profile from the image.
9641 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9646 Associate user supplied profile with the image.
9648 profile=AcquireStringInfo(argument_list[1].length);
9649 SetStringInfoDatum(profile,(const unsigned char *)
9650 argument_list[1].string_reference);
9651 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9652 (size_t) GetStringInfoLength(profile),exception);
9653 profile=DestroyStringInfo(profile);
9657 Associate a profile with the image.
9659 profile_info=CloneImageInfo(info ? info->image_info :
9660 (ImageInfo *) NULL);
9661 profile_image=ReadImages(profile_info,name,exception);
9662 if (profile_image == (Image *) NULL)
9664 ResetImageProfileIterator(profile_image);
9665 name=GetNextImageProfile(profile_image);
9666 while (name != (const char *) NULL)
9671 profile=GetImageProfile(profile_image,name);
9672 if (profile != (const StringInfo *) NULL)
9673 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9674 (size_t) GetStringInfoLength(profile),exception);
9675 name=GetNextImageProfile(profile_image);
9677 profile_image=DestroyImage(profile_image);
9678 profile_info=DestroyImageInfo(profile_info);
9681 case 69: /* UnsharpMask */
9683 if (attribute_flag[0] != 0)
9685 flags=ParseGeometry(argument_list[0].string_reference,
9687 if ((flags & SigmaValue) == 0)
9688 geometry_info.sigma=1.0;
9689 if ((flags & XiValue) == 0)
9690 geometry_info.xi=1.0;
9691 if ((flags & PsiValue) == 0)
9692 geometry_info.psi=0.5;
9694 if (attribute_flag[1] != 0)
9695 geometry_info.rho=argument_list[1].real_reference;
9696 if (attribute_flag[2] != 0)
9697 geometry_info.sigma=argument_list[2].real_reference;
9698 if (attribute_flag[3] != 0)
9699 geometry_info.xi=argument_list[3].real_reference;
9700 if (attribute_flag[4] != 0)
9701 geometry_info.psi=argument_list[4].real_reference;
9702 if (attribute_flag[5] != 0)
9703 channel=(ChannelType) argument_list[5].integer_reference;
9704 channel_mask=SetImageChannelMask(image,channel);
9705 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9706 geometry_info.xi,geometry_info.psi,exception);
9707 if (image != (Image *) NULL)
9708 (void) SetImageChannelMask(image,channel_mask);
9711 case 70: /* MotionBlur */
9713 if (attribute_flag[0] != 0)
9715 flags=ParseGeometry(argument_list[0].string_reference,
9717 if ((flags & SigmaValue) == 0)
9718 geometry_info.sigma=1.0;
9719 if ((flags & XiValue) == 0)
9720 geometry_info.xi=1.0;
9722 if (attribute_flag[1] != 0)
9723 geometry_info.rho=argument_list[1].real_reference;
9724 if (attribute_flag[2] != 0)
9725 geometry_info.sigma=argument_list[2].real_reference;
9726 if (attribute_flag[3] != 0)
9727 geometry_info.xi=argument_list[3].real_reference;
9728 if (attribute_flag[4] != 0)
9729 channel=(ChannelType) argument_list[4].integer_reference;
9730 channel_mask=SetImageChannelMask(image,channel);
9731 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9732 geometry_info.xi,exception);
9733 if (image != (Image *) NULL)
9734 (void) SetImageChannelMask(image,channel_mask);
9737 case 71: /* OrderedDither */
9739 if (attribute_flag[0] == 0)
9740 argument_list[0].string_reference="o8x8";
9741 if (attribute_flag[1] != 0)
9742 channel=(ChannelType) argument_list[1].integer_reference;
9743 channel_mask=SetImageChannelMask(image,channel);
9744 (void) OrderedDitherImage(image,argument_list[0].string_reference,
9746 (void) SetImageChannelMask(image,channel_mask);
9749 case 72: /* Shave */
9751 if (attribute_flag[0] != 0)
9752 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9753 &geometry,exception);
9754 if (attribute_flag[1] != 0)
9755 geometry.width=argument_list[1].integer_reference;
9756 if (attribute_flag[2] != 0)
9757 geometry.height=argument_list[2].integer_reference;
9758 image=ShaveImage(image,&geometry,exception);
9761 case 73: /* Level */
9769 white_point=(double) image->columns*image->rows;
9771 if (attribute_flag[0] != 0)
9773 flags=ParseGeometry(argument_list[0].string_reference,
9775 black_point=geometry_info.rho;
9776 if ((flags & SigmaValue) != 0)
9777 white_point=geometry_info.sigma;
9778 if ((flags & XiValue) != 0)
9779 gamma=geometry_info.xi;
9780 if ((flags & PercentValue) != 0)
9782 black_point*=(double) (QuantumRange/100.0);
9783 white_point*=(double) (QuantumRange/100.0);
9785 if ((flags & SigmaValue) == 0)
9786 white_point=(double) QuantumRange-black_point;
9788 if (attribute_flag[1] != 0)
9789 black_point=argument_list[1].real_reference;
9790 if (attribute_flag[2] != 0)
9791 white_point=argument_list[2].real_reference;
9792 if (attribute_flag[3] != 0)
9793 gamma=argument_list[3].real_reference;
9794 if (attribute_flag[4] != 0)
9795 channel=(ChannelType) argument_list[4].integer_reference;
9796 if (attribute_flag[5] != 0)
9798 argument_list[0].real_reference=argument_list[5].real_reference;
9799 attribute_flag[0]=attribute_flag[5];
9801 channel_mask=SetImageChannelMask(image,channel);
9802 (void) LevelImage(image,black_point,white_point,gamma,exception);
9803 (void) SetImageChannelMask(image,channel_mask);
9808 if (attribute_flag[0] == 0)
9809 argument_list[0].string_reference="#1";
9810 if (attribute_flag[1] == 0)
9811 argument_list[1].integer_reference=MagickTrue;
9812 (void) ClipImagePath(image,argument_list[0].string_reference,
9813 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9817 case 75: /* AffineTransform */
9822 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9824 if (attribute_flag[0] != 0)
9829 av=(AV *) argument_list[0].array_reference;
9830 if ((av_len(av) != 3) && (av_len(av) != 5))
9832 ThrowPerlException(exception,OptionError,
9833 "affine matrix must have 4 or 6 elements",PackageName);
9836 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9837 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9838 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9839 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9840 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9841 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9843 ThrowPerlException(exception,OptionError,
9844 "affine matrix is singular",PackageName);
9847 if (av_len(av) == 5)
9849 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9850 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9853 for (j=1; j < 6; j++)
9855 if (attribute_flag[j] == 0)
9857 value=argument_list[j].string_reference;
9858 angle=argument_list[j].real_reference;
9859 current=draw_info->affine;
9860 GetAffineMatrix(&affine);
9868 flags=ParseGeometry(value,&geometry_info);
9869 affine.tx=geometry_info.xi;
9870 affine.ty=geometry_info.psi;
9871 if ((flags & PsiValue) == 0)
9872 affine.ty=affine.tx;
9880 flags=ParseGeometry(value,&geometry_info);
9881 affine.sx=geometry_info.rho;
9882 affine.sy=geometry_info.sigma;
9883 if ((flags & SigmaValue) == 0)
9884 affine.sy=affine.sx;
9894 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9895 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9896 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9897 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9905 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9913 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9917 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9918 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9919 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9920 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9921 draw_info->affine.tx=
9922 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9923 draw_info->affine.ty=
9924 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9926 if (attribute_flag[6] != 0)
9927 image->interpolate=(PixelInterpolateMethod)
9928 argument_list[6].integer_reference;
9929 if (attribute_flag[7] != 0)
9930 QueryColorCompliance(argument_list[7].string_reference,
9931 AllCompliance,&image->background_color,exception);
9932 image=AffineTransformImage(image,&draw_info->affine,exception);
9933 draw_info=DestroyDrawInfo(draw_info);
9936 case 76: /* Difference */
9938 if (attribute_flag[0] == 0)
9940 ThrowPerlException(exception,OptionError,
9941 "ReferenceImageRequired",PackageName);
9944 if (attribute_flag[1] != 0)
9945 image->fuzz=StringToDoubleInterval(
9946 argument_list[1].string_reference,(double) QuantumRange+1.0);
9947 (void) SetImageColorMetric(image,argument_list[0].image_reference,
9951 case 77: /* AdaptiveThreshold */
9953 if (attribute_flag[0] != 0)
9955 flags=ParseGeometry(argument_list[0].string_reference,
9957 if ((flags & PercentValue) != 0)
9958 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9960 if (attribute_flag[1] != 0)
9961 geometry_info.rho=argument_list[1].integer_reference;
9962 if (attribute_flag[2] != 0)
9963 geometry_info.sigma=argument_list[2].integer_reference;
9964 if (attribute_flag[3] != 0)
9965 geometry_info.xi=argument_list[3].integer_reference;;
9966 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9967 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9970 case 78: /* Resample */
9976 if (attribute_flag[0] != 0)
9978 flags=ParseGeometry(argument_list[0].string_reference,
9980 if ((flags & SigmaValue) == 0)
9981 geometry_info.sigma=geometry_info.rho;
9983 if (attribute_flag[1] != 0)
9984 geometry_info.rho=argument_list[1].real_reference;
9985 if (attribute_flag[2] != 0)
9986 geometry_info.sigma=argument_list[2].real_reference;
9987 if (attribute_flag[3] == 0)
9988 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9989 if (attribute_flag[4] == 0)
9990 SetImageArtifact(image,"filter:support",
9991 argument_list[4].string_reference);
9992 width=(size_t) (geometry_info.rho*image->columns/
9993 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9994 height=(size_t) (geometry_info.sigma*image->rows/
9995 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9996 image=ResizeImage(image,width,height,(FilterType)
9997 argument_list[3].integer_reference,exception);
9998 if (image != (Image *) NULL)
10000 image->resolution.x=geometry_info.rho;
10001 image->resolution.y=geometry_info.sigma;
10005 case 79: /* Describe */
10007 if (attribute_flag[0] == 0)
10008 argument_list[0].file_reference=(FILE *) NULL;
10009 if (attribute_flag[1] != 0)
10010 (void) SetImageArtifact(image,"identify:features",
10011 argument_list[1].string_reference);
10012 (void) IdentifyImage(image,argument_list[0].file_reference,
10013 MagickTrue,exception);
10016 case 80: /* BlackThreshold */
10018 if (attribute_flag[0] == 0)
10019 argument_list[0].string_reference="50%";
10020 if (attribute_flag[2] != 0)
10021 channel=(ChannelType) argument_list[2].integer_reference;
10022 channel_mask=SetImageChannelMask(image,channel);
10023 BlackThresholdImage(image,argument_list[0].string_reference,
10025 (void) SetImageChannelMask(image,channel_mask);
10028 case 81: /* WhiteThreshold */
10030 if (attribute_flag[0] == 0)
10031 argument_list[0].string_reference="50%";
10032 if (attribute_flag[2] != 0)
10033 channel=(ChannelType) argument_list[2].integer_reference;
10034 channel_mask=SetImageChannelMask(image,channel);
10035 WhiteThresholdImage(image,argument_list[0].string_reference,
10037 (void) SetImageChannelMask(image,channel_mask);
10040 case 82: /* RotationalBlur */
10042 if (attribute_flag[0] != 0)
10044 flags=ParseGeometry(argument_list[0].string_reference,
10047 if (attribute_flag[1] != 0)
10048 geometry_info.rho=argument_list[1].real_reference;
10049 if (attribute_flag[2] != 0)
10050 channel=(ChannelType) argument_list[2].integer_reference;
10051 channel_mask=SetImageChannelMask(image,channel);
10052 image=RotationalBlurImage(image,geometry_info.rho,exception);
10053 if (image != (Image *) NULL)
10054 (void) SetImageChannelMask(image,channel_mask);
10057 case 83: /* Thumbnail */
10059 if (attribute_flag[0] != 0)
10060 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10061 &geometry,exception);
10062 if (attribute_flag[1] != 0)
10063 geometry.width=argument_list[1].integer_reference;
10064 if (attribute_flag[2] != 0)
10065 geometry.height=argument_list[2].integer_reference;
10066 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10069 case 84: /* Strip */
10071 (void) StripImage(image,exception);
10074 case 85: /* Tint */
10079 GetPixelInfo(image,&tint);
10080 if (attribute_flag[0] != 0)
10081 (void) QueryColorCompliance(argument_list[0].string_reference,
10082 AllCompliance,&tint,exception);
10083 if (attribute_flag[1] == 0)
10084 argument_list[1].string_reference="100";
10085 image=TintImage(image,argument_list[1].string_reference,&tint,
10089 case 86: /* Channel */
10091 if (attribute_flag[0] != 0)
10092 channel=(ChannelType) argument_list[0].integer_reference;
10093 image=SeparateImage(image,channel,exception);
10096 case 87: /* Splice */
10098 if (attribute_flag[7] != 0)
10099 image->gravity=(GravityType) argument_list[7].integer_reference;
10100 if (attribute_flag[0] != 0)
10101 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10102 &geometry,exception);
10103 if (attribute_flag[1] != 0)
10104 geometry.width=argument_list[1].integer_reference;
10105 if (attribute_flag[2] != 0)
10106 geometry.height=argument_list[2].integer_reference;
10107 if (attribute_flag[3] != 0)
10108 geometry.x=argument_list[3].integer_reference;
10109 if (attribute_flag[4] != 0)
10110 geometry.y=argument_list[4].integer_reference;
10111 if (attribute_flag[5] != 0)
10112 image->fuzz=StringToDoubleInterval(
10113 argument_list[5].string_reference,(double) QuantumRange+1.0);
10114 if (attribute_flag[6] != 0)
10115 (void) QueryColorCompliance(argument_list[6].string_reference,
10116 AllCompliance,&image->background_color,exception);
10117 image=SpliceImage(image,&geometry,exception);
10120 case 88: /* Posterize */
10122 if (attribute_flag[0] == 0)
10123 argument_list[0].integer_reference=3;
10124 if (attribute_flag[1] == 0)
10125 argument_list[1].integer_reference=0;
10126 (void) PosterizeImage(image,argument_list[0].integer_reference,
10127 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10128 NoDitherMethod,exception);
10131 case 89: /* Shadow */
10133 if (attribute_flag[0] != 0)
10135 flags=ParseGeometry(argument_list[0].string_reference,
10137 if ((flags & SigmaValue) == 0)
10138 geometry_info.sigma=1.0;
10139 if ((flags & XiValue) == 0)
10140 geometry_info.xi=4.0;
10141 if ((flags & PsiValue) == 0)
10142 geometry_info.psi=4.0;
10144 if (attribute_flag[1] != 0)
10145 geometry_info.rho=argument_list[1].real_reference;
10146 if (attribute_flag[2] != 0)
10147 geometry_info.sigma=argument_list[2].real_reference;
10148 if (attribute_flag[3] != 0)
10149 geometry_info.xi=argument_list[3].integer_reference;
10150 if (attribute_flag[4] != 0)
10151 geometry_info.psi=argument_list[4].integer_reference;
10152 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10153 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10154 ceil(geometry_info.psi-0.5),exception);
10157 case 90: /* Identify */
10159 if (attribute_flag[0] == 0)
10160 argument_list[0].file_reference=(FILE *) NULL;
10161 if (attribute_flag[1] != 0)
10162 (void) SetImageArtifact(image,"identify:features",
10163 argument_list[1].string_reference);
10164 if ((attribute_flag[2] != 0) &&
10165 (argument_list[2].integer_reference != 0))
10166 (void) SetImageArtifact(image,"identify:unique","true");
10167 (void) IdentifyImage(image,argument_list[0].file_reference,
10168 MagickTrue,exception);
10171 case 91: /* SepiaTone */
10173 if (attribute_flag[0] == 0)
10174 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10175 image=SepiaToneImage(image,argument_list[0].real_reference,
10179 case 92: /* SigmoidalContrast */
10184 if (attribute_flag[0] != 0)
10186 flags=ParseGeometry(argument_list[0].string_reference,
10188 if ((flags & SigmaValue) == 0)
10189 geometry_info.sigma=QuantumRange/2.0;
10190 if ((flags & PercentValue) != 0)
10191 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10193 if (attribute_flag[1] != 0)
10194 geometry_info.rho=argument_list[1].real_reference;
10195 if (attribute_flag[2] != 0)
10196 geometry_info.sigma=argument_list[2].real_reference;
10197 if (attribute_flag[3] != 0)
10198 channel=(ChannelType) argument_list[3].integer_reference;
10199 sharpen=MagickTrue;
10200 if (attribute_flag[4] != 0)
10201 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10203 channel_mask=SetImageChannelMask(image,channel);
10204 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10205 geometry_info.sigma,exception);
10206 (void) SetImageChannelMask(image,channel_mask);
10209 case 93: /* Extent */
10211 if (attribute_flag[7] != 0)
10212 image->gravity=(GravityType) argument_list[7].integer_reference;
10213 if (attribute_flag[0] != 0)
10218 flags=ParseGravityGeometry(image,
10219 argument_list[0].string_reference,&geometry,exception);
10221 if (geometry.width == 0)
10222 geometry.width=image->columns;
10223 if (geometry.height == 0)
10224 geometry.height=image->rows;
10226 if (attribute_flag[1] != 0)
10227 geometry.width=argument_list[1].integer_reference;
10228 if (attribute_flag[2] != 0)
10229 geometry.height=argument_list[2].integer_reference;
10230 if (attribute_flag[3] != 0)
10231 geometry.x=argument_list[3].integer_reference;
10232 if (attribute_flag[4] != 0)
10233 geometry.y=argument_list[4].integer_reference;
10234 if (attribute_flag[5] != 0)
10235 image->fuzz=StringToDoubleInterval(
10236 argument_list[5].string_reference,(double) QuantumRange+1.0);
10237 if (attribute_flag[6] != 0)
10238 (void) QueryColorCompliance(argument_list[6].string_reference,
10239 AllCompliance,&image->background_color,exception);
10240 image=ExtentImage(image,&geometry,exception);
10243 case 94: /* Vignette */
10245 if (attribute_flag[0] != 0)
10247 flags=ParseGeometry(argument_list[0].string_reference,
10249 if ((flags & SigmaValue) == 0)
10250 geometry_info.sigma=1.0;
10251 if ((flags & XiValue) == 0)
10252 geometry_info.xi=0.1*image->columns;
10253 if ((flags & PsiValue) == 0)
10254 geometry_info.psi=0.1*image->rows;
10256 if (attribute_flag[1] != 0)
10257 geometry_info.rho=argument_list[1].real_reference;
10258 if (attribute_flag[2] != 0)
10259 geometry_info.sigma=argument_list[2].real_reference;
10260 if (attribute_flag[3] != 0)
10261 geometry_info.xi=argument_list[3].integer_reference;
10262 if (attribute_flag[4] != 0)
10263 geometry_info.psi=argument_list[4].integer_reference;
10264 if (attribute_flag[5] != 0)
10265 (void) QueryColorCompliance(argument_list[5].string_reference,
10266 AllCompliance,&image->background_color,exception);
10267 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10268 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10269 ceil(geometry_info.psi-0.5),exception);
10272 case 95: /* ContrastStretch */
10279 white_point=(double) image->columns*image->rows;
10280 if (attribute_flag[0] != 0)
10282 flags=ParseGeometry(argument_list[0].string_reference,
10284 black_point=geometry_info.rho;
10285 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10287 if ((flags & PercentValue) != 0)
10289 black_point*=(double) image->columns*image->rows/100.0;
10290 white_point*=(double) image->columns*image->rows/100.0;
10292 white_point=(double) image->columns*image->rows-
10295 if (attribute_flag[1] != 0)
10296 black_point=argument_list[1].real_reference;
10297 if (attribute_flag[2] != 0)
10298 white_point=argument_list[2].real_reference;
10299 if (attribute_flag[4] != 0)
10300 channel=(ChannelType) argument_list[4].integer_reference;
10301 channel_mask=SetImageChannelMask(image,channel);
10302 (void) ContrastStretchImage(image,black_point,white_point,exception);
10303 (void) SetImageChannelMask(image,channel_mask);
10306 case 96: /* Sans0 */
10310 case 97: /* Sans1 */
10314 case 98: /* AdaptiveSharpen */
10316 if (attribute_flag[0] != 0)
10318 flags=ParseGeometry(argument_list[0].string_reference,
10320 if ((flags & SigmaValue) == 0)
10321 geometry_info.sigma=1.0;
10322 if ((flags & XiValue) == 0)
10323 geometry_info.xi=0.0;
10325 if (attribute_flag[1] != 0)
10326 geometry_info.rho=argument_list[1].real_reference;
10327 if (attribute_flag[2] != 0)
10328 geometry_info.sigma=argument_list[2].real_reference;
10329 if (attribute_flag[3] != 0)
10330 geometry_info.xi=argument_list[3].real_reference;
10331 if (attribute_flag[4] != 0)
10332 channel=(ChannelType) argument_list[4].integer_reference;
10333 channel_mask=SetImageChannelMask(image,channel);
10334 image=AdaptiveSharpenImage(image,geometry_info.rho,
10335 geometry_info.sigma,exception);
10336 if (image != (Image *) NULL)
10337 (void) SetImageChannelMask(image,channel_mask);
10340 case 99: /* Transpose */
10342 image=TransposeImage(image,exception);
10345 case 100: /* Tranverse */
10347 image=TransverseImage(image,exception);
10350 case 101: /* AutoOrient */
10352 image=AutoOrientImage(image,image->orientation,exception);
10355 case 102: /* AdaptiveBlur */
10357 if (attribute_flag[0] != 0)
10359 flags=ParseGeometry(argument_list[0].string_reference,
10361 if ((flags & SigmaValue) == 0)
10362 geometry_info.sigma=1.0;
10363 if ((flags & XiValue) == 0)
10364 geometry_info.xi=0.0;
10366 if (attribute_flag[1] != 0)
10367 geometry_info.rho=argument_list[1].real_reference;
10368 if (attribute_flag[2] != 0)
10369 geometry_info.sigma=argument_list[2].real_reference;
10370 if (attribute_flag[3] != 0)
10371 channel=(ChannelType) argument_list[3].integer_reference;
10372 channel_mask=SetImageChannelMask(image,channel);
10373 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10375 if (image != (Image *) NULL)
10376 (void) SetImageChannelMask(image,channel_mask);
10379 case 103: /* Sketch */
10381 if (attribute_flag[0] != 0)
10383 flags=ParseGeometry(argument_list[0].string_reference,
10385 if ((flags & SigmaValue) == 0)
10386 geometry_info.sigma=1.0;
10387 if ((flags & XiValue) == 0)
10388 geometry_info.xi=1.0;
10390 if (attribute_flag[1] != 0)
10391 geometry_info.rho=argument_list[1].real_reference;
10392 if (attribute_flag[2] != 0)
10393 geometry_info.sigma=argument_list[2].real_reference;
10394 if (attribute_flag[3] != 0)
10395 geometry_info.xi=argument_list[3].real_reference;
10396 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10397 geometry_info.xi,exception);
10400 case 104: /* UniqueColors */
10402 image=UniqueImageColors(image,exception);
10405 case 105: /* AdaptiveResize */
10407 if (attribute_flag[0] != 0)
10408 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10409 &geometry,exception);
10410 if (attribute_flag[1] != 0)
10411 geometry.width=argument_list[1].integer_reference;
10412 if (attribute_flag[2] != 0)
10413 geometry.height=argument_list[2].integer_reference;
10414 if (attribute_flag[3] != 0)
10415 image->filter=(FilterType) argument_list[4].integer_reference;
10416 if (attribute_flag[4] != 0)
10417 SetImageArtifact(image,"filter:support",
10418 argument_list[4].string_reference);
10419 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10423 case 106: /* ClipMask */
10428 if (attribute_flag[0] == 0)
10430 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10432 goto PerlException;
10434 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10436 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10437 mask_image=DestroyImage(mask_image);
10440 case 107: /* LinearStretch */
10447 white_point=(double) image->columns*image->rows;
10448 if (attribute_flag[0] != 0)
10450 flags=ParseGeometry(argument_list[0].string_reference,
10452 if ((flags & SigmaValue) != 0)
10453 white_point=geometry_info.sigma;
10454 if ((flags & PercentValue) != 0)
10456 black_point*=(double) image->columns*image->rows/100.0;
10457 white_point*=(double) image->columns*image->rows/100.0;
10459 if ((flags & SigmaValue) == 0)
10460 white_point=(double) image->columns*image->rows-black_point;
10462 if (attribute_flag[1] != 0)
10463 black_point=argument_list[1].real_reference;
10464 if (attribute_flag[2] != 0)
10465 white_point=argument_list[2].real_reference;
10466 (void) LinearStretchImage(image,black_point,white_point,exception);
10469 case 108: /* ColorMatrix */
10483 if (attribute_flag[0] == 0)
10485 av=(AV *) argument_list[0].array_reference;
10486 order=(size_t) sqrt(av_len(av)+1);
10487 color_matrix=(double *) AcquireQuantumMemory(order,order*
10488 sizeof(*color_matrix));
10489 if (color_matrix == (double *) NULL)
10491 ThrowPerlException(exception,ResourceLimitFatalError,
10492 "MemoryAllocationFailed",PackageName);
10493 goto PerlException;
10495 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10496 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10497 for ( ; j < (ssize_t) (order*order); j++)
10498 color_matrix[j]=0.0;
10499 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10500 if (kernel_info == (KernelInfo *) NULL)
10502 kernel_info->width=order;
10503 kernel_info->height=order;
10504 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10505 order*sizeof(*kernel_info->values));
10506 if (kernel_info->values != (MagickRealType *) NULL)
10508 for (i=0; i < (ssize_t) (order*order); i++)
10509 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10510 image=ColorMatrixImage(image,kernel_info,exception);
10512 kernel_info=DestroyKernelInfo(kernel_info);
10513 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10516 case 109: /* Mask */
10521 if (attribute_flag[0] == 0)
10523 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10525 goto PerlException;
10527 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10528 MagickTrue,exception);
10529 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10530 mask_image=DestroyImage(mask_image);
10533 case 110: /* Polaroid */
10544 PixelInterpolateMethod
10547 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10548 (DrawInfo *) NULL);
10549 caption=(char *) NULL;
10550 if (attribute_flag[0] != 0)
10551 caption=InterpretImageProperties(info ? info->image_info :
10552 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10555 if (attribute_flag[1] != 0)
10556 angle=argument_list[1].real_reference;
10557 if (attribute_flag[2] != 0)
10558 (void) CloneString(&draw_info->font,
10559 argument_list[2].string_reference);
10560 if (attribute_flag[3] != 0)
10561 (void) QueryColorCompliance(argument_list[3].string_reference,
10562 AllCompliance,&draw_info->stroke,exception);
10563 if (attribute_flag[4] != 0)
10564 (void) QueryColorCompliance(argument_list[4].string_reference,
10565 AllCompliance,&draw_info->fill,exception);
10566 if (attribute_flag[5] != 0)
10567 draw_info->stroke_width=argument_list[5].real_reference;
10568 if (attribute_flag[6] != 0)
10569 draw_info->pointsize=argument_list[6].real_reference;
10570 if (attribute_flag[7] != 0)
10571 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10572 if (attribute_flag[8] != 0)
10573 (void) QueryColorCompliance(argument_list[8].string_reference,
10574 AllCompliance,&image->background_color,exception);
10575 method=UndefinedInterpolatePixel;
10576 if (attribute_flag[9] != 0)
10577 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10578 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10579 draw_info=DestroyDrawInfo(draw_info);
10580 if (caption != (char *) NULL)
10581 caption=DestroyString(caption);
10584 case 111: /* FloodfillPaint */
10595 draw_info=CloneDrawInfo(info ? info->image_info :
10596 (ImageInfo *) NULL,(DrawInfo *) NULL);
10597 if (attribute_flag[0] != 0)
10598 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10599 &geometry,exception);
10600 if (attribute_flag[1] != 0)
10601 geometry.x=argument_list[1].integer_reference;
10602 if (attribute_flag[2] != 0)
10603 geometry.y=argument_list[2].integer_reference;
10604 if (attribute_flag[3] != 0)
10605 (void) QueryColorCompliance(argument_list[3].string_reference,
10606 AllCompliance,&draw_info->fill,exception);
10607 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10608 geometry.x,geometry.y,&target,exception);
10609 if (attribute_flag[4] != 0)
10610 QueryColorCompliance(argument_list[4].string_reference,
10611 AllCompliance,&target,exception);
10612 if (attribute_flag[5] != 0)
10613 image->fuzz=StringToDoubleInterval(
10614 argument_list[5].string_reference,(double) QuantumRange+1.0);
10615 if (attribute_flag[6] != 0)
10616 channel=(ChannelType) argument_list[6].integer_reference;
10617 invert=MagickFalse;
10618 if (attribute_flag[7] != 0)
10619 invert=(MagickBooleanType) argument_list[7].integer_reference;
10620 channel_mask=SetImageChannelMask(image,channel);
10621 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10622 geometry.y,invert,exception);
10623 (void) SetImageChannelMask(image,channel_mask);
10624 draw_info=DestroyDrawInfo(draw_info);
10627 case 112: /* Distort */
10639 number_coordinates;
10644 if (attribute_flag[0] == 0)
10646 method=UndefinedDistortion;
10647 if (attribute_flag[1] != 0)
10648 method=(DistortMethod) argument_list[1].integer_reference;
10649 av=(AV *) argument_list[0].array_reference;
10650 number_coordinates=(size_t) av_len(av)+1;
10651 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10652 sizeof(*coordinates));
10653 if (coordinates == (double *) NULL)
10655 ThrowPerlException(exception,ResourceLimitFatalError,
10656 "MemoryAllocationFailed",PackageName);
10657 goto PerlException;
10659 for (j=0; j < (ssize_t) number_coordinates; j++)
10660 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10661 virtual_pixel=UndefinedVirtualPixelMethod;
10662 if (attribute_flag[2] != 0)
10663 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10664 argument_list[2].integer_reference,exception);
10665 image=DistortImage(image,method,number_coordinates,coordinates,
10666 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10668 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10669 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10671 coordinates=(double *) RelinquishMagickMemory(coordinates);
10674 case 113: /* Clut */
10676 PixelInterpolateMethod
10679 if (attribute_flag[0] == 0)
10681 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10683 goto PerlException;
10685 method=UndefinedInterpolatePixel;
10686 if (attribute_flag[1] != 0)
10687 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10688 if (attribute_flag[2] != 0)
10689 channel=(ChannelType) argument_list[2].integer_reference;
10690 channel_mask=SetImageChannelMask(image,channel);
10691 (void) ClutImage(image,argument_list[0].image_reference,method,
10693 (void) SetImageChannelMask(image,channel_mask);
10696 case 114: /* LiquidRescale */
10698 if (attribute_flag[0] != 0)
10699 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10700 &geometry,exception);
10701 if (attribute_flag[1] != 0)
10702 geometry.width=argument_list[1].integer_reference;
10703 if (attribute_flag[2] != 0)
10704 geometry.height=argument_list[2].integer_reference;
10705 if (attribute_flag[3] == 0)
10706 argument_list[3].real_reference=1.0;
10707 if (attribute_flag[4] == 0)
10708 argument_list[4].real_reference=0.0;
10709 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10710 argument_list[3].real_reference,argument_list[4].real_reference,
10714 case 115: /* EncipherImage */
10716 (void) EncipherImage(image,argument_list[0].string_reference,
10720 case 116: /* DecipherImage */
10722 (void) DecipherImage(image,argument_list[0].string_reference,
10726 case 117: /* Deskew */
10728 geometry_info.rho=QuantumRange/2.0;
10729 if (attribute_flag[0] != 0)
10730 flags=ParseGeometry(argument_list[0].string_reference,
10732 if (attribute_flag[1] != 0)
10733 geometry_info.rho=StringToDoubleInterval(
10734 argument_list[1].string_reference,(double) QuantumRange+1.0);
10735 image=DeskewImage(image,geometry_info.rho,exception);
10738 case 118: /* Remap */
10743 if (attribute_flag[0] == 0)
10745 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10747 goto PerlException;
10749 quantize_info=AcquireQuantizeInfo(info->image_info);
10750 if (attribute_flag[1] != 0)
10751 quantize_info->dither_method=(DitherMethod)
10752 argument_list[1].integer_reference;
10753 (void) RemapImages(quantize_info,image,
10754 argument_list[0].image_reference,exception);
10755 quantize_info=DestroyQuantizeInfo(quantize_info);
10758 case 119: /* SparseColor */
10770 number_coordinates;
10775 if (attribute_flag[0] == 0)
10777 method=UndefinedColorInterpolate;
10778 if (attribute_flag[1] != 0)
10779 method=(SparseColorMethod) argument_list[1].integer_reference;
10780 av=(AV *) argument_list[0].array_reference;
10781 number_coordinates=(size_t) av_len(av)+1;
10782 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10783 sizeof(*coordinates));
10784 if (coordinates == (double *) NULL)
10786 ThrowPerlException(exception,ResourceLimitFatalError,
10787 "MemoryAllocationFailed",PackageName);
10788 goto PerlException;
10790 for (j=0; j < (ssize_t) number_coordinates; j++)
10791 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10792 virtual_pixel=UndefinedVirtualPixelMethod;
10793 if (attribute_flag[2] != 0)
10794 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10795 argument_list[2].integer_reference,exception);
10796 if (attribute_flag[3] != 0)
10797 channel=(ChannelType) argument_list[3].integer_reference;
10798 channel_mask=SetImageChannelMask(image,channel);
10799 image=SparseColorImage(image,method,number_coordinates,coordinates,
10801 if (image != (Image *) NULL)
10802 (void) SetImageChannelMask(image,channel_mask);
10803 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10804 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10806 coordinates=(double *) RelinquishMagickMemory(coordinates);
10809 case 120: /* Function */
10826 if (attribute_flag[0] == 0)
10828 function=UndefinedFunction;
10829 if (attribute_flag[1] != 0)
10830 function=(MagickFunction) argument_list[1].integer_reference;
10831 av=(AV *) argument_list[0].array_reference;
10832 number_parameters=(size_t) av_len(av)+1;
10833 parameters=(double *) AcquireQuantumMemory(number_parameters,
10834 sizeof(*parameters));
10835 if (parameters == (double *) NULL)
10837 ThrowPerlException(exception,ResourceLimitFatalError,
10838 "MemoryAllocationFailed",PackageName);
10839 goto PerlException;
10841 for (j=0; j < (ssize_t) number_parameters; j++)
10842 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10843 virtual_pixel=UndefinedVirtualPixelMethod;
10844 if (attribute_flag[2] != 0)
10845 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10846 argument_list[2].integer_reference,exception);
10847 (void) FunctionImage(image,function,number_parameters,parameters,
10849 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10850 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10852 parameters=(double *) RelinquishMagickMemory(parameters);
10855 case 121: /* SelectiveBlur */
10857 if (attribute_flag[0] != 0)
10859 flags=ParseGeometry(argument_list[0].string_reference,
10861 if ((flags & SigmaValue) == 0)
10862 geometry_info.sigma=1.0;
10863 if ((flags & PercentValue) != 0)
10864 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10866 if (attribute_flag[1] != 0)
10867 geometry_info.rho=argument_list[1].real_reference;
10868 if (attribute_flag[2] != 0)
10869 geometry_info.sigma=argument_list[2].real_reference;
10870 if (attribute_flag[3] != 0)
10871 geometry_info.xi=argument_list[3].integer_reference;;
10872 if (attribute_flag[5] != 0)
10873 channel=(ChannelType) argument_list[5].integer_reference;
10874 channel_mask=SetImageChannelMask(image,channel);
10875 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10876 geometry_info.xi,exception);
10877 if (image != (Image *) NULL)
10878 (void) SetImageChannelMask(image,channel_mask);
10881 case 122: /* HaldClut */
10883 if (attribute_flag[0] == 0)
10885 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10887 goto PerlException;
10889 if (attribute_flag[1] != 0)
10890 channel=(ChannelType) argument_list[1].integer_reference;
10891 channel_mask=SetImageChannelMask(image,channel);
10892 (void) HaldClutImage(image,argument_list[0].image_reference,
10894 (void) SetImageChannelMask(image,channel_mask);
10897 case 123: /* BlueShift */
10899 if (attribute_flag[0] != 0)
10900 (void) ParseGeometry(argument_list[0].string_reference,
10902 image=BlueShiftImage(image,geometry_info.rho,exception);
10905 case 124: /* ForwardFourierTransformImage */
10907 image=ForwardFourierTransformImage(image,
10908 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10912 case 125: /* InverseFourierTransformImage */
10914 image=InverseFourierTransformImage(image,image->next,
10915 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10919 case 126: /* ColorDecisionList */
10921 if (attribute_flag[0] == 0)
10922 argument_list[0].string_reference=(char *) NULL;
10923 (void) ColorDecisionListImage(image,
10924 argument_list[0].string_reference,exception);
10927 case 127: /* AutoGamma */
10929 if (attribute_flag[0] != 0)
10930 channel=(ChannelType) argument_list[0].integer_reference;
10931 channel_mask=SetImageChannelMask(image,channel);
10932 (void) AutoGammaImage(image,exception);
10933 (void) SetImageChannelMask(image,channel_mask);
10936 case 128: /* AutoLevel */
10938 if (attribute_flag[0] != 0)
10939 channel=(ChannelType) argument_list[0].integer_reference;
10940 channel_mask=SetImageChannelMask(image,channel);
10941 (void) AutoLevelImage(image,exception);
10942 (void) SetImageChannelMask(image,channel_mask);
10945 case 129: /* LevelColors */
10951 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10953 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10955 if (attribute_flag[1] != 0)
10956 (void) QueryColorCompliance(
10957 argument_list[1].string_reference,AllCompliance,&black_point,
10959 if (attribute_flag[2] != 0)
10960 (void) QueryColorCompliance(
10961 argument_list[2].string_reference,AllCompliance,&white_point,
10963 if (attribute_flag[3] != 0)
10964 channel=(ChannelType) argument_list[3].integer_reference;
10965 channel_mask=SetImageChannelMask(image,channel);
10966 (void) LevelImageColors(image,&black_point,&white_point,
10967 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10969 (void) SetImageChannelMask(image,channel_mask);
10972 case 130: /* Clamp */
10974 if (attribute_flag[0] != 0)
10975 channel=(ChannelType) argument_list[0].integer_reference;
10976 channel_mask=SetImageChannelMask(image,channel);
10977 (void) ClampImage(image,exception);
10978 (void) SetImageChannelMask(image,channel_mask);
10981 case 131: /* BrightnessContrast */
10989 if (attribute_flag[0] != 0)
10991 flags=ParseGeometry(argument_list[0].string_reference,
10993 brightness=geometry_info.rho;
10994 if ((flags & SigmaValue) == 0)
10995 contrast=geometry_info.sigma;
10997 if (attribute_flag[1] != 0)
10998 brightness=argument_list[1].real_reference;
10999 if (attribute_flag[2] != 0)
11000 contrast=argument_list[2].real_reference;
11001 if (attribute_flag[4] != 0)
11002 channel=(ChannelType) argument_list[4].integer_reference;
11003 channel_mask=SetImageChannelMask(image,channel);
11004 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11005 (void) SetImageChannelMask(image,channel_mask);
11008 case 132: /* Morphology */
11019 if (attribute_flag[0] == 0)
11021 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11022 if (kernel == (KernelInfo *) NULL)
11024 if (attribute_flag[1] != 0)
11025 channel=(ChannelType) argument_list[1].integer_reference;
11026 method=UndefinedMorphology;
11027 if (attribute_flag[2] != 0)
11028 method=argument_list[2].integer_reference;
11030 if (attribute_flag[3] != 0)
11031 iterations=argument_list[3].integer_reference;
11032 channel_mask=SetImageChannelMask(image,channel);
11033 image=MorphologyImage(image,method,iterations,kernel,exception);
11034 if (image != (Image *) NULL)
11035 (void) SetImageChannelMask(image,channel_mask);
11036 kernel=DestroyKernelInfo(kernel);
11039 case 133: /* Mode */
11041 if (attribute_flag[0] != 0)
11043 flags=ParseGeometry(argument_list[0].string_reference,
11045 if ((flags & SigmaValue) == 0)
11046 geometry_info.sigma=1.0;
11048 if (attribute_flag[1] != 0)
11049 geometry_info.rho=argument_list[1].real_reference;
11050 if (attribute_flag[2] != 0)
11051 geometry_info.sigma=argument_list[2].real_reference;
11052 if (attribute_flag[3] != 0)
11053 channel=(ChannelType) argument_list[3].integer_reference;
11054 channel_mask=SetImageChannelMask(image,channel);
11055 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11056 (size_t) geometry_info.sigma,exception);
11057 if (image != (Image *) NULL)
11058 (void) SetImageChannelMask(image,channel_mask);
11061 case 134: /* Statistic */
11066 statistic=UndefinedStatistic;
11067 if (attribute_flag[0] != 0)
11069 flags=ParseGeometry(argument_list[0].string_reference,
11071 if ((flags & SigmaValue) == 0)
11072 geometry_info.sigma=1.0;
11074 if (attribute_flag[1] != 0)
11075 geometry_info.rho=argument_list[1].real_reference;
11076 if (attribute_flag[2] != 0)
11077 geometry_info.sigma=argument_list[2].real_reference;
11078 if (attribute_flag[3] != 0)
11079 channel=(ChannelType) argument_list[3].integer_reference;
11080 if (attribute_flag[4] != 0)
11081 statistic=(StatisticType) argument_list[4].integer_reference;
11082 channel_mask=SetImageChannelMask(image,channel);
11083 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11084 (size_t) geometry_info.sigma,exception);
11085 if (image != (Image *) NULL)
11086 (void) SetImageChannelMask(image,channel_mask);
11089 case 135: /* Perceptible */
11094 epsilon=MagickEpsilon;
11095 if (attribute_flag[0] != 0)
11096 epsilon=argument_list[0].real_reference;
11097 if (attribute_flag[1] != 0)
11098 channel=(ChannelType) argument_list[1].integer_reference;
11099 channel_mask=SetImageChannelMask(image,channel);
11100 (void) PerceptibleImage(image,epsilon,exception);
11101 (void) SetImageChannelMask(image,channel_mask);
11104 case 136: /* Poly */
11115 if (attribute_flag[0] == 0)
11117 if (attribute_flag[1] != 0)
11118 channel=(ChannelType) argument_list[1].integer_reference;
11119 av=(AV *) argument_list[0].array_reference;
11120 number_terms=(size_t) av_len(av);
11121 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11122 if (terms == (double *) NULL)
11124 ThrowPerlException(exception,ResourceLimitFatalError,
11125 "MemoryAllocationFailed",PackageName);
11126 goto PerlException;
11128 for (j=0; j < av_len(av); j++)
11129 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11130 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11131 terms=(double *) RelinquishMagickMemory(terms);
11134 case 137: /* Grayscale */
11136 PixelIntensityMethod
11139 method=UndefinedPixelIntensityMethod;
11140 if (attribute_flag[0] != 0)
11141 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11142 (void) GrayscaleImage(image,method,exception);
11145 case 138: /* Canny */
11147 if (attribute_flag[0] != 0)
11149 flags=ParseGeometry(argument_list[0].string_reference,
11151 if ((flags & SigmaValue) == 0)
11152 geometry_info.sigma=1.0;
11153 if ((flags & XiValue) == 0)
11154 geometry_info.xi=0.10;
11155 if ((flags & PsiValue) == 0)
11156 geometry_info.psi=0.30;
11157 if ((flags & PercentValue) != 0)
11159 geometry_info.xi/=100.0;
11160 geometry_info.psi/=100.0;
11163 if (attribute_flag[1] != 0)
11164 geometry_info.rho=argument_list[1].real_reference;
11165 if (attribute_flag[2] != 0)
11166 geometry_info.sigma=argument_list[2].real_reference;
11167 if (attribute_flag[3] != 0)
11168 geometry_info.xi=argument_list[3].real_reference;
11169 if (attribute_flag[4] != 0)
11170 geometry_info.psi=argument_list[4].real_reference;
11171 if (attribute_flag[5] != 0)
11172 channel=(ChannelType) argument_list[5].integer_reference;
11173 channel_mask=SetImageChannelMask(image,channel);
11174 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11175 geometry_info.xi,geometry_info.psi,exception);
11176 if (image != (Image *) NULL)
11177 (void) SetImageChannelMask(image,channel_mask);
11180 case 139: /* HoughLine */
11182 if (attribute_flag[0] != 0)
11184 flags=ParseGeometry(argument_list[0].string_reference,
11186 if ((flags & SigmaValue) == 0)
11187 geometry_info.sigma=geometry_info.rho;
11188 if ((flags & XiValue) == 0)
11189 geometry_info.xi=40;
11191 if (attribute_flag[1] != 0)
11192 geometry_info.rho=(double) argument_list[1].integer_reference;
11193 if (attribute_flag[2] != 0)
11194 geometry_info.sigma=(double) argument_list[2].integer_reference;
11195 if (attribute_flag[3] != 0)
11196 geometry_info.xi=(double) argument_list[3].integer_reference;
11197 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11198 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11201 case 140: /* MeanShift */
11203 if (attribute_flag[0] != 0)
11205 flags=ParseGeometry(argument_list[0].string_reference,
11207 if ((flags & SigmaValue) == 0)
11208 geometry_info.sigma=geometry_info.rho;
11209 if ((flags & XiValue) == 0)
11210 geometry_info.xi=0.10*QuantumRange;
11211 if ((flags & PercentValue) != 0)
11212 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11214 if (attribute_flag[1] != 0)
11215 geometry_info.rho=(double) argument_list[1].integer_reference;
11216 if (attribute_flag[2] != 0)
11217 geometry_info.sigma=(double) argument_list[2].integer_reference;
11218 if (attribute_flag[3] != 0)
11219 geometry_info.xi=(double) argument_list[3].integer_reference;
11220 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11221 geometry_info.sigma,geometry_info.xi,exception);
11224 case 141: /* Kuwahara */
11226 if (attribute_flag[0] != 0)
11228 flags=ParseGeometry(argument_list[0].string_reference,
11230 if ((flags & SigmaValue) == 0)
11231 geometry_info.sigma=geometry_info.rho-0.5;
11233 if (attribute_flag[1] != 0)
11234 geometry_info.rho=argument_list[1].real_reference;
11235 if (attribute_flag[2] != 0)
11236 geometry_info.sigma=argument_list[2].real_reference;
11237 if (attribute_flag[3] != 0)
11238 channel=(ChannelType) argument_list[3].integer_reference;
11239 channel_mask=SetImageChannelMask(image,channel);
11240 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11242 if (image != (Image *) NULL)
11243 (void) SetImageChannelMask(image,channel_mask);
11246 case 142: /* ConnectedComponent */
11252 if (attribute_flag[0] != 0)
11253 connectivity=argument_list[0].integer_reference;
11254 image=ConnectedComponentsImage(image,connectivity,
11255 (CCObjectInfo **) NULL,exception);
11258 case 143: /* Copy */
11269 source_image=image;
11270 if (attribute_flag[0] != 0)
11271 source_image=argument_list[0].image_reference;
11272 SetGeometry(source_image,&geometry);
11273 if (attribute_flag[1] != 0)
11274 flags=ParseGravityGeometry(source_image,
11275 argument_list[1].string_reference,&geometry,exception);
11276 if (attribute_flag[2] != 0)
11277 geometry.width=argument_list[2].integer_reference;
11278 if (attribute_flag[3] != 0)
11279 geometry.height=argument_list[3].integer_reference;
11280 if (attribute_flag[4] != 0)
11281 geometry.x=argument_list[4].integer_reference;
11282 if (attribute_flag[5] != 0)
11283 geometry.y=argument_list[5].integer_reference;
11284 if (attribute_flag[6] != 0)
11285 image->gravity=(GravityType) argument_list[6].integer_reference;
11286 SetGeometry(image,&offset_geometry);
11287 if (attribute_flag[7] != 0)
11288 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11289 &offset_geometry,exception);
11290 offset.x=offset_geometry.x;
11291 offset.y=offset_geometry.y;
11292 if (attribute_flag[8] != 0)
11293 offset.x=argument_list[8].integer_reference;
11294 if (attribute_flag[9] != 0)
11295 offset.y=argument_list[9].integer_reference;
11296 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11300 case 144: /* Color */
11305 (void) QueryColorCompliance("none",AllCompliance,&color,exception);
11306 if (attribute_flag[0] != 0)
11307 (void) QueryColorCompliance(argument_list[0].string_reference,
11308 AllCompliance,&color,exception);
11309 (void) SetImageColor(image,&color,exception);
11312 case 145: /* WaveletDenoise */
11314 if (attribute_flag[0] != 0)
11316 flags=ParseGeometry(argument_list[0].string_reference,
11318 if ((flags & PercentValue) != 0)
11320 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
11321 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
11323 if ((flags & SigmaValue) == 0)
11324 geometry_info.sigma=0.0;
11326 if (attribute_flag[1] != 0)
11327 geometry_info.rho=argument_list[1].real_reference;
11328 if (attribute_flag[2] != 0)
11329 geometry_info.sigma=argument_list[2].real_reference;
11330 if (attribute_flag[3] != 0)
11331 channel=(ChannelType) argument_list[3].integer_reference;
11332 channel_mask=SetImageChannelMask(image,channel);
11333 image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma,
11335 if (image != (Image *) NULL)
11336 (void) SetImageChannelMask(image,channel_mask);
11339 case 146: /* Colorspace */
11344 colorspace=sRGBColorspace;
11345 if (attribute_flag[0] != 0)
11346 colorspace=(ColorspaceType) argument_list[0].integer_reference;
11347 (void) TransformImageColorspace(image,colorspace,exception);
11351 if (next != (Image *) NULL)
11352 (void) CatchImageException(next);
11353 if (region_image != (Image *) NULL)
11358 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11359 region_info.x,region_info.y,exception);
11361 (void) CatchImageException(region_image);
11362 image=DestroyImage(image);
11363 image=region_image;
11365 if (image != (Image *) NULL)
11368 if (next && (next != image))
11370 image->next=next->next;
11371 if (image->next != (Image *) NULL)
11372 image->next->previous=image;
11373 DeleteImageFromRegistry(*pv,next);
11375 sv_setiv(*pv,PTR2IV(image));
11383 if (reference_vector)
11384 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11385 InheritPerlException(exception,perl_exception);
11386 exception=DestroyExceptionInfo(exception);
11387 sv_setiv(perl_exception,(IV) number_images);
11388 SvPOK_on(perl_exception);
11389 ST(0)=sv_2mortal(perl_exception);
11394 ###############################################################################
11402 ###############################################################################
11407 Image::Magick ref=NO_INIT
11452 PERL_UNUSED_VAR(ref);
11453 PERL_UNUSED_VAR(ix);
11454 exception=AcquireExceptionInfo();
11455 perl_exception=newSVpv("",0);
11458 if (sv_isobject(ST(0)) == 0)
11460 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11462 goto PerlException;
11464 reference=SvRV(ST(0));
11465 hv=SvSTASH(reference);
11467 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11469 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11470 if (image == (Image *) NULL)
11472 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11474 goto PerlException;
11479 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11480 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11481 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11483 for (i=2; i < items; i+=2)
11485 attribute=(char *) SvPV(ST(i-1),na);
11486 switch (*attribute)
11491 if (LocaleCompare(attribute,"background") == 0)
11493 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11494 &montage_info->background_color,exception);
11495 for (next=image; next; next=next->next)
11496 next->background_color=montage_info->background_color;
11499 if (LocaleCompare(attribute,"border") == 0)
11501 montage_info->border_width=SvIV(ST(i));
11504 if (LocaleCompare(attribute,"bordercolor") == 0)
11506 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11507 &montage_info->border_color,exception);
11508 for (next=image; next; next=next->next)
11509 next->border_color=montage_info->border_color;
11512 if (LocaleCompare(attribute,"borderwidth") == 0)
11514 montage_info->border_width=SvIV(ST(i));
11517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11524 if (LocaleCompare(attribute,"compose") == 0)
11526 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11527 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11530 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11534 for (next=image; next; next=next->next)
11535 next->compose=(CompositeOperator) sp;
11538 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11545 if (LocaleCompare(attribute,"fill") == 0)
11547 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11548 &montage_info->fill,exception);
11551 if (LocaleCompare(attribute,"font") == 0)
11553 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11556 if (LocaleCompare(attribute,"frame") == 0)
11562 if (IsGeometry(p) == MagickFalse)
11564 ThrowPerlException(exception,OptionError,"MissingGeometry",
11568 (void) CloneString(&montage_info->frame,p);
11570 montage_info->frame=(char *) NULL;
11573 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11580 if (LocaleCompare(attribute,"geometry") == 0)
11586 if (IsGeometry(p) == MagickFalse)
11588 ThrowPerlException(exception,OptionError,"MissingGeometry",
11592 (void) CloneString(&montage_info->geometry,p);
11594 montage_info->geometry=(char *) NULL;
11597 if (LocaleCompare(attribute,"gravity") == 0)
11602 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11603 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11606 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11610 montage_info->gravity=(GravityType) in;
11611 for (next=image; next; next=next->next)
11612 next->gravity=(GravityType) in;
11615 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11622 if (LocaleCompare(attribute,"label") == 0)
11624 for (next=image; next; next=next->next)
11625 (void) SetImageProperty(next,"label",InterpretImageProperties(
11626 info ? info->image_info : (ImageInfo *) NULL,next,
11627 SvPV(ST(i),na),exception),exception);
11630 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11637 if (LocaleCompare(attribute,"mattecolor") == 0)
11639 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11640 &montage_info->alpha_color,exception);
11641 for (next=image; next; next=next->next)
11642 next->alpha_color=montage_info->alpha_color;
11645 if (LocaleCompare(attribute,"mode") == 0)
11650 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11651 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11656 ThrowPerlException(exception,OptionError,
11657 "UnrecognizedModeType",SvPV(ST(i),na));
11662 (void) CloneString(&montage_info->frame,"15x15+3+3");
11663 montage_info->shadow=MagickTrue;
11668 montage_info->frame=(char *) NULL;
11669 montage_info->shadow=MagickFalse;
11670 montage_info->border_width=0;
11673 case ConcatenateMode:
11675 montage_info->frame=(char *) NULL;
11676 montage_info->shadow=MagickFalse;
11677 (void) CloneString(&montage_info->geometry,"+0+0");
11678 montage_info->border_width=0;
11683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11690 if (LocaleCompare(attribute,"pointsize") == 0)
11692 montage_info->pointsize=SvIV(ST(i));
11695 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11702 if (LocaleCompare(attribute,"shadow") == 0)
11704 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11705 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11708 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11712 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11715 if (LocaleCompare(attribute,"stroke") == 0)
11717 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11718 &montage_info->stroke,exception);
11721 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11728 if (LocaleCompare(attribute,"texture") == 0)
11730 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11733 if (LocaleCompare(attribute,"tile") == 0)
11735 char *p=SvPV(ST(i),na);
11736 if (IsGeometry(p) == MagickFalse)
11738 ThrowPerlException(exception,OptionError,"MissingGeometry",
11742 (void) CloneString(&montage_info->tile,p);
11744 montage_info->tile=(char *) NULL;
11747 if (LocaleCompare(attribute,"title") == 0)
11749 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11752 if (LocaleCompare(attribute,"transparent") == 0)
11757 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11758 &transparent_color,exception);
11759 for (next=image; next; next=next->next)
11760 (void) TransparentPaintImage(next,&transparent_color,
11761 TransparentAlpha,MagickFalse,exception);
11764 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11776 image=MontageImageList(info->image_info,montage_info,image,exception);
11777 montage_info=DestroyMontageInfo(montage_info);
11778 if (image == (Image *) NULL)
11779 goto PerlException;
11780 if (transparent_color.alpha != TransparentAlpha)
11781 for (next=image; next; next=next->next)
11782 (void) TransparentPaintImage(next,&transparent_color,
11783 TransparentAlpha,MagickFalse,exception);
11784 for ( ; image; image=image->next)
11786 AddImageToRegistry(sv,image);
11788 av_push(av,sv_bless(rv,hv));
11791 exception=DestroyExceptionInfo(exception);
11792 ST(0)=av_reference;
11793 SvREFCNT_dec(perl_exception);
11797 InheritPerlException(exception,perl_exception);
11798 exception=DestroyExceptionInfo(exception);
11799 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11800 SvPOK_on(perl_exception);
11801 ST(0)=sv_2mortal(perl_exception);
11806 ###############################################################################
11814 ###############################################################################
11819 Image::Magick ref=NO_INIT
11857 PERL_UNUSED_VAR(ref);
11858 PERL_UNUSED_VAR(ix);
11859 exception=AcquireExceptionInfo();
11860 perl_exception=newSVpv("",0);
11864 if (sv_isobject(ST(0)) == 0)
11866 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11868 goto PerlException;
11870 reference=SvRV(ST(0));
11871 hv=SvSTASH(reference);
11873 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11875 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11876 if (image == (Image *) NULL)
11878 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11880 goto PerlException;
11882 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11887 for (i=2; i < items; i+=2)
11889 attribute=(char *) SvPV(ST(i-1),na);
11890 switch (*attribute)
11895 if (LocaleCompare(attribute,"frames") == 0)
11897 number_frames=SvIV(ST(i));
11900 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11906 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11912 image=MorphImages(image,number_frames,exception);
11913 if (image == (Image *) NULL)
11914 goto PerlException;
11915 for ( ; image; image=image->next)
11917 AddImageToRegistry(sv,image);
11919 av_push(av,sv_bless(rv,hv));
11922 exception=DestroyExceptionInfo(exception);
11923 ST(0)=av_reference;
11924 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11928 InheritPerlException(exception,perl_exception);
11929 exception=DestroyExceptionInfo(exception);
11930 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11931 SvPOK_on(perl_exception);
11932 ST(0)=sv_2mortal(perl_exception);
11937 ###############################################################################
11945 ###############################################################################
11950 Image::Magick ref=NO_INIT
11978 PERL_UNUSED_VAR(ref);
11979 PERL_UNUSED_VAR(ix);
11980 exception=AcquireExceptionInfo();
11981 perl_exception=newSVpv("",0);
11983 if (sv_isobject(ST(0)) == 0)
11985 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11987 goto PerlException;
11989 reference=SvRV(ST(0));
11990 hv=SvSTASH(reference);
11991 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11992 if (image == (Image *) NULL)
11994 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11996 goto PerlException;
11998 image=MergeImageLayers(image,MosaicLayer,exception);
12000 Create blessed Perl array for the returned image.
12003 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12005 AddImageToRegistry(sv,image);
12007 av_push(av,sv_bless(rv,hv));
12009 (void) CopyMagickString(info->image_info->filename,image->filename,
12011 SetImageInfo(info->image_info,0,exception);
12012 exception=DestroyExceptionInfo(exception);
12013 SvREFCNT_dec(perl_exception);
12017 InheritPerlException(exception,perl_exception);
12018 exception=DestroyExceptionInfo(exception);
12019 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12020 SvPOK_on(perl_exception); /* return messages in string context */
12021 ST(0)=sv_2mortal(perl_exception);
12026 ###############################################################################
12034 ###############################################################################
12039 Image::Magick ref=NO_INIT
12089 PERL_UNUSED_VAR(ref);
12090 PERL_UNUSED_VAR(ix);
12091 exception=AcquireExceptionInfo();
12092 perl_exception=newSVpv("",0);
12093 package_info=(struct PackageInfo *) NULL;
12094 ac=(items < 2) ? 1 : items-1;
12095 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12097 length=(STRLEN *) NULL;
12098 if (list == (char **) NULL)
12100 ThrowPerlException(exception,ResourceLimitError,
12101 "MemoryAllocationFailed",PackageName);
12102 goto PerlException;
12105 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12106 if (length == (STRLEN *) NULL)
12108 ThrowPerlException(exception,ResourceLimitError,
12109 "MemoryAllocationFailed",PackageName);
12110 goto PerlException;
12112 if (sv_isobject(ST(0)) == 0)
12114 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12116 goto PerlException;
12118 reference=SvRV(ST(0));
12119 if (SvTYPE(reference) != SVt_PVAV)
12121 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12123 goto PerlException;
12125 av=(AV *) reference;
12126 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12128 package_info=ClonePackageInfo(info,exception);
12131 *list=(char *) (*package_info->image_info->filename ?
12132 package_info->image_info->filename : "XC:black");
12134 for (n=0, i=0; i < ac; i++)
12136 list[n]=(char *) SvPV(ST(i+1),length[n]);
12137 if ((items >= 3) && strEQcase(list[n],"blob"))
12143 blob=(void *) (SvPV(ST(i+1),length[n]));
12144 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12146 if ((items >= 3) && strEQcase(list[n],"filename"))
12148 if ((items >= 3) && strEQcase(list[n],"file"))
12157 io_info=IoIFP(sv_2io(ST(i+1)));
12158 if (io_info == (PerlIO *) NULL)
12160 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12164 file=PerlIO_findFILE(io_info);
12165 if (file == (FILE *) NULL)
12167 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12171 SetImageInfoFile(package_info->image_info,file);
12173 if ((items >= 3) && strEQcase(list[n],"magick"))
12177 list[n]=(char *) NULL;
12179 status=ExpandFilenames(&n,&list);
12180 if (status == MagickFalse)
12182 ThrowPerlException(exception,ResourceLimitError,
12183 "MemoryAllocationFailed",PackageName);
12184 goto PerlException;
12187 for (i=0; i < n; i++)
12189 (void) CopyMagickString(package_info->image_info->filename,list[i],
12191 image=PingImage(package_info->image_info,exception);
12192 if (image == (Image *) NULL)
12194 if ((package_info->image_info->file != (FILE *) NULL) ||
12195 (package_info->image_info->blob != (void *) NULL))
12196 DisassociateImageStream(image);
12197 count+=GetImageListLength(image);
12198 EXTEND(sp,4*count);
12199 for (next=image; next; next=next->next)
12201 PUSHs(sv_2mortal(newSViv(next->columns)));
12202 PUSHs(sv_2mortal(newSViv(next->rows)));
12203 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12204 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12206 image=DestroyImageList(image);
12211 for (i=0; i < n; i++)
12212 if (list[i] != (char *) NULL)
12213 for (p=keep; list[i] != *p++; )
12216 list[i]=(char *) RelinquishMagickMemory(list[i]);
12221 if (package_info != (struct PackageInfo *) NULL)
12222 DestroyPackageInfo(package_info);
12223 if (list && (list != keep))
12224 list=(char **) RelinquishMagickMemory(list);
12226 keep=(char **) RelinquishMagickMemory(keep);
12228 length=(STRLEN *) RelinquishMagickMemory(length);
12229 InheritPerlException(exception,perl_exception);
12230 exception=DestroyExceptionInfo(exception);
12231 SvREFCNT_dec(perl_exception); /* throw away all errors */
12235 ###############################################################################
12243 ###############################################################################
12248 Image::Magick ref=NO_INIT
12281 PERL_UNUSED_VAR(ref);
12282 PERL_UNUSED_VAR(ix);
12283 exception=AcquireExceptionInfo();
12284 perl_exception=newSVpv("",0);
12287 if (sv_isobject(ST(0)) == 0)
12289 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12291 goto PerlException;
12293 reference=SvRV(ST(0));
12294 hv=SvSTASH(reference);
12296 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12298 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12299 if (image == (Image *) NULL)
12301 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12303 goto PerlException;
12305 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12306 preview_type=GammaPreview;
12308 preview_type=(PreviewType)
12309 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12310 for ( ; image; image=image->next)
12312 preview_image=PreviewImage(image,preview_type,exception);
12313 if (preview_image == (Image *) NULL)
12314 goto PerlException;
12315 AddImageToRegistry(sv,preview_image);
12317 av_push(av,sv_bless(rv,hv));
12320 exception=DestroyExceptionInfo(exception);
12321 ST(0)=av_reference;
12322 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12326 InheritPerlException(exception,perl_exception);
12327 exception=DestroyExceptionInfo(exception);
12328 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12329 SvPOK_on(perl_exception);
12330 ST(0)=sv_2mortal(perl_exception);
12335 ###############################################################################
12339 # Q u e r y C o l o r #
12343 ###############################################################################
12347 QueryColor(ref,...)
12348 Image::Magick ref=NO_INIT
12368 PERL_UNUSED_VAR(ref);
12369 PERL_UNUSED_VAR(ix);
12370 exception=AcquireExceptionInfo();
12371 perl_exception=newSVpv("",0);
12380 colorlist=GetColorInfoList("*",&colors,exception);
12382 for (i=0; i < (ssize_t) colors; i++)
12384 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12386 colorlist=(const ColorInfo **)
12387 RelinquishMagickMemory((ColorInfo **) colorlist);
12388 goto PerlException;
12390 EXTEND(sp,5*items);
12391 for (i=1; i < items; i++)
12393 name=(char *) SvPV(ST(i),na);
12394 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12399 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12400 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12401 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12402 if (color.colorspace == CMYKColorspace)
12403 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12404 if (color.alpha_trait != UndefinedPixelTrait)
12405 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12409 InheritPerlException(exception,perl_exception);
12410 exception=DestroyExceptionInfo(exception);
12411 SvREFCNT_dec(perl_exception);
12415 ###############################################################################
12419 # Q u e r y C o l o r N a m e #
12423 ###############################################################################
12427 QueryColorname(ref,...)
12428 Image::Magick ref=NO_INIT
12437 message[MagickPathExtent];
12456 *reference; /* reference is the SV* of ref=SvIV(reference) */
12458 PERL_UNUSED_VAR(ref);
12459 PERL_UNUSED_VAR(ix);
12460 exception=AcquireExceptionInfo();
12461 perl_exception=newSVpv("",0);
12462 reference=SvRV(ST(0));
12463 av=(AV *) reference;
12464 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12466 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12467 if (image == (Image *) NULL)
12469 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12471 goto PerlException;
12474 for (i=1; i < items; i++)
12476 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12478 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12480 PUSHs(sv_2mortal(newSVpv(message,0)));
12484 InheritPerlException(exception,perl_exception);
12485 exception=DestroyExceptionInfo(exception);
12486 SvREFCNT_dec(perl_exception);
12490 ###############################################################################
12494 # Q u e r y F o n t #
12498 ###############################################################################
12503 Image::Magick ref=NO_INIT
12510 message[MagickPathExtent];
12521 volatile const TypeInfo
12524 PERL_UNUSED_VAR(ref);
12525 PERL_UNUSED_VAR(ix);
12526 exception=AcquireExceptionInfo();
12527 perl_exception=newSVpv("",0);
12536 typelist=GetTypeInfoList("*",&types,exception);
12538 for (i=0; i < (ssize_t) types; i++)
12540 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12542 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12544 goto PerlException;
12546 EXTEND(sp,10*items);
12547 for (i=1; i < items; i++)
12549 name=(char *) SvPV(ST(i),na);
12550 type_info=GetTypeInfo(name,exception);
12551 if (type_info == (TypeInfo *) NULL)
12556 if (type_info->name == (char *) NULL)
12559 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12560 if (type_info->description == (char *) NULL)
12563 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12564 if (type_info->family == (char *) NULL)
12567 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12568 if (type_info->style == UndefinedStyle)
12571 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12572 type_info->style),0)));
12573 if (type_info->stretch == UndefinedStretch)
12576 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12577 type_info->stretch),0)));
12578 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12579 type_info->weight);
12580 PUSHs(sv_2mortal(newSVpv(message,0)));
12581 if (type_info->encoding == (char *) NULL)
12584 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12585 if (type_info->foundry == (char *) NULL)
12588 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12589 if (type_info->format == (char *) NULL)
12592 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12593 if (type_info->metrics == (char *) NULL)
12596 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12597 if (type_info->glyphs == (char *) NULL)
12600 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12604 InheritPerlException(exception,perl_exception);
12605 exception=DestroyExceptionInfo(exception);
12606 SvREFCNT_dec(perl_exception);
12610 ###############################################################################
12614 # Q u e r y F o n t M e t r i c s #
12618 ###############################################################################
12622 QueryFontMetrics(ref,...)
12623 Image::Magick ref=NO_INIT
12625 queryfontmetrics = 1
12672 *reference; /* reference is the SV* of ref=SvIV(reference) */
12677 PERL_UNUSED_VAR(ref);
12678 PERL_UNUSED_VAR(ix);
12679 exception=AcquireExceptionInfo();
12680 package_info=(struct PackageInfo *) NULL;
12681 perl_exception=newSVpv("",0);
12682 reference=SvRV(ST(0));
12683 av=(AV *) reference;
12684 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12686 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12687 if (image == (Image *) NULL)
12689 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12691 goto PerlException;
12693 package_info=ClonePackageInfo(info,exception);
12694 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12695 CloneString(&draw_info->text,"");
12696 current=draw_info->affine;
12697 GetAffineMatrix(&affine);
12700 EXTEND(sp,7*items);
12701 for (i=2; i < items; i+=2)
12703 attribute=(char *) SvPV(ST(i-1),na);
12704 switch (*attribute)
12709 if (LocaleCompare(attribute,"antialias") == 0)
12711 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12715 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12719 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12722 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12729 if (LocaleCompare(attribute,"density") == 0)
12731 CloneString(&draw_info->density,SvPV(ST(i),na));
12734 if (LocaleCompare(attribute,"direction") == 0)
12736 draw_info->direction=(DirectionType) ParseCommandOption(
12737 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12740 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12747 if (LocaleCompare(attribute,"encoding") == 0)
12749 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12752 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12759 if (LocaleCompare(attribute,"family") == 0)
12761 CloneString(&draw_info->family,SvPV(ST(i),na));
12764 if (LocaleCompare(attribute,"fill") == 0)
12767 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12768 &draw_info->fill,exception);
12771 if (LocaleCompare(attribute,"font") == 0)
12773 CloneString(&draw_info->font,SvPV(ST(i),na));
12776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12783 if (LocaleCompare(attribute,"geometry") == 0)
12785 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12788 if (LocaleCompare(attribute,"gravity") == 0)
12790 draw_info->gravity=(GravityType) ParseCommandOption(
12791 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12794 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12801 if (LocaleCompare(attribute,"interline-spacing") == 0)
12803 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12804 draw_info->interline_spacing=geometry_info.rho;
12807 if (LocaleCompare(attribute,"interword-spacing") == 0)
12809 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12810 draw_info->interword_spacing=geometry_info.rho;
12813 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12820 if (LocaleCompare(attribute,"kerning") == 0)
12822 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12823 draw_info->kerning=geometry_info.rho;
12826 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12833 if (LocaleCompare(attribute,"pointsize") == 0)
12835 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12836 draw_info->pointsize=geometry_info.rho;
12839 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12846 if (LocaleCompare(attribute,"rotate") == 0)
12848 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12849 affine.rx=geometry_info.rho;
12850 affine.ry=geometry_info.sigma;
12851 if ((flags & SigmaValue) == 0)
12852 affine.ry=affine.rx;
12855 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12862 if (LocaleCompare(attribute,"scale") == 0)
12864 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12865 affine.sx=geometry_info.rho;
12866 affine.sy=geometry_info.sigma;
12867 if ((flags & SigmaValue) == 0)
12868 affine.sy=affine.sx;
12871 if (LocaleCompare(attribute,"skew") == 0)
12877 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12878 x_angle=geometry_info.rho;
12879 y_angle=geometry_info.sigma;
12880 if ((flags & SigmaValue) == 0)
12882 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12883 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12886 if (LocaleCompare(attribute,"stroke") == 0)
12889 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12890 &draw_info->stroke,exception);
12893 if (LocaleCompare(attribute,"style") == 0)
12895 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12899 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12903 draw_info->style=(StyleType) type;
12906 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12913 if (LocaleCompare(attribute,"text") == 0)
12915 CloneString(&draw_info->text,SvPV(ST(i),na));
12918 if (LocaleCompare(attribute,"translate") == 0)
12920 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12921 affine.tx=geometry_info.rho;
12922 affine.ty=geometry_info.sigma;
12923 if ((flags & SigmaValue) == 0)
12924 affine.ty=affine.tx;
12927 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12934 if (LocaleCompare(attribute,"weight") == 0)
12936 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12937 draw_info->weight=(size_t) geometry_info.rho;
12940 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12947 if (LocaleCompare(attribute,"x") == 0)
12949 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12950 x=geometry_info.rho;
12953 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12960 if (LocaleCompare(attribute,"y") == 0)
12962 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12963 y=geometry_info.rho;
12966 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12978 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12979 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12980 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12981 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12982 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12983 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12984 if (draw_info->geometry == (char *) NULL)
12986 draw_info->geometry=AcquireString((char *) NULL);
12987 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12988 "%.20g,%.20g",x,y);
12990 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12991 (void) CatchImageException(image);
12992 if (status == MagickFalse)
12996 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12997 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12998 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12999 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13000 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13001 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13002 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13003 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13004 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13005 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13006 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13007 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13008 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13010 draw_info=DestroyDrawInfo(draw_info);
13013 if (package_info != (struct PackageInfo *) NULL)
13014 DestroyPackageInfo(package_info);
13015 InheritPerlException(exception,perl_exception);
13016 exception=DestroyExceptionInfo(exception);
13017 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13021 ###############################################################################
13025 # 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 #
13029 ###############################################################################
13033 QueryMultilineFontMetrics(ref,...)
13034 Image::Magick ref=NO_INIT
13036 querymultilinefontmetrics = 1
13083 *reference; /* reference is the SV* of ref=SvIV(reference) */
13088 PERL_UNUSED_VAR(ref);
13089 PERL_UNUSED_VAR(ix);
13090 exception=AcquireExceptionInfo();
13091 package_info=(struct PackageInfo *) NULL;
13092 perl_exception=newSVpv("",0);
13093 reference=SvRV(ST(0));
13094 av=(AV *) reference;
13095 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13097 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13098 if (image == (Image *) NULL)
13100 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13102 goto PerlException;
13104 package_info=ClonePackageInfo(info,exception);
13105 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13106 CloneString(&draw_info->text,"");
13107 current=draw_info->affine;
13108 GetAffineMatrix(&affine);
13111 EXTEND(sp,7*items);
13112 for (i=2; i < items; i+=2)
13114 attribute=(char *) SvPV(ST(i-1),na);
13115 switch (*attribute)
13120 if (LocaleCompare(attribute,"antialias") == 0)
13122 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13126 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13130 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13133 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13140 if (LocaleCompare(attribute,"density") == 0)
13142 CloneString(&draw_info->density,SvPV(ST(i),na));
13145 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13152 if (LocaleCompare(attribute,"encoding") == 0)
13154 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13157 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13164 if (LocaleCompare(attribute,"family") == 0)
13166 CloneString(&draw_info->family,SvPV(ST(i),na));
13169 if (LocaleCompare(attribute,"fill") == 0)
13172 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13173 &draw_info->fill,exception);
13176 if (LocaleCompare(attribute,"font") == 0)
13178 CloneString(&draw_info->font,SvPV(ST(i),na));
13181 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13188 if (LocaleCompare(attribute,"geometry") == 0)
13190 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13193 if (LocaleCompare(attribute,"gravity") == 0)
13195 draw_info->gravity=(GravityType) ParseCommandOption(
13196 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13199 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13206 if (LocaleCompare(attribute,"pointsize") == 0)
13208 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13209 draw_info->pointsize=geometry_info.rho;
13212 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13219 if (LocaleCompare(attribute,"rotate") == 0)
13221 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13222 affine.rx=geometry_info.rho;
13223 affine.ry=geometry_info.sigma;
13224 if ((flags & SigmaValue) == 0)
13225 affine.ry=affine.rx;
13228 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13235 if (LocaleCompare(attribute,"scale") == 0)
13237 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13238 affine.sx=geometry_info.rho;
13239 affine.sy=geometry_info.sigma;
13240 if ((flags & SigmaValue) == 0)
13241 affine.sy=affine.sx;
13244 if (LocaleCompare(attribute,"skew") == 0)
13250 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13251 x_angle=geometry_info.rho;
13252 y_angle=geometry_info.sigma;
13253 if ((flags & SigmaValue) == 0)
13255 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13256 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13259 if (LocaleCompare(attribute,"stroke") == 0)
13262 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13263 &draw_info->stroke,exception);
13266 if (LocaleCompare(attribute,"style") == 0)
13268 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13272 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13276 draw_info->style=(StyleType) type;
13279 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13286 if (LocaleCompare(attribute,"text") == 0)
13288 CloneString(&draw_info->text,SvPV(ST(i),na));
13291 if (LocaleCompare(attribute,"translate") == 0)
13293 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13294 affine.tx=geometry_info.rho;
13295 affine.ty=geometry_info.sigma;
13296 if ((flags & SigmaValue) == 0)
13297 affine.ty=affine.tx;
13300 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13307 if (LocaleCompare(attribute,"weight") == 0)
13309 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13310 draw_info->weight=(size_t) geometry_info.rho;
13313 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13320 if (LocaleCompare(attribute,"x") == 0)
13322 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13323 x=geometry_info.rho;
13326 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13333 if (LocaleCompare(attribute,"y") == 0)
13335 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13336 y=geometry_info.rho;
13339 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13345 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13351 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13352 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13353 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13354 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13355 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13356 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13357 if (draw_info->geometry == (char *) NULL)
13359 draw_info->geometry=AcquireString((char *) NULL);
13360 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13361 "%.20g,%.20g",x,y);
13363 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13364 (void) CatchException(exception);
13365 if (status == MagickFalse)
13369 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13370 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13371 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13372 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13373 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13374 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13375 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13376 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13377 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13378 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13379 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13380 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13381 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13383 draw_info=DestroyDrawInfo(draw_info);
13386 if (package_info != (struct PackageInfo *) NULL)
13387 DestroyPackageInfo(package_info);
13388 InheritPerlException(exception,perl_exception);
13389 exception=DestroyExceptionInfo(exception);
13390 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13394 ###############################################################################
13398 # Q u e r y F o r m a t #
13402 ###############################################################################
13406 QueryFormat(ref,...)
13407 Image::Magick ref=NO_INIT
13424 volatile const MagickInfo
13427 PERL_UNUSED_VAR(ref);
13428 PERL_UNUSED_VAR(ix);
13429 exception=AcquireExceptionInfo();
13430 perl_exception=newSVpv("",0);
13434 format[MagickPathExtent];
13442 format_list=GetMagickInfoList("*",&types,exception);
13444 for (i=0; i < (ssize_t) types; i++)
13446 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13447 LocaleLower(format);
13448 PUSHs(sv_2mortal(newSVpv(format,0)));
13450 format_list=(const MagickInfo **)
13451 RelinquishMagickMemory((MagickInfo *) format_list);
13452 goto PerlException;
13454 EXTEND(sp,8*items);
13455 for (i=1; i < items; i++)
13457 name=(char *) SvPV(ST(i),na);
13458 magick_info=GetMagickInfo(name,exception);
13459 if (magick_info == (const MagickInfo *) NULL)
13464 if (magick_info->description == (char *) NULL)
13467 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13468 if (magick_info->module == (char *) NULL)
13471 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13475 InheritPerlException(exception,perl_exception);
13476 exception=DestroyExceptionInfo(exception);
13477 SvREFCNT_dec(perl_exception);
13481 ###############################################################################
13485 # Q u e r y O p t i o n #
13489 ###############################################################################
13493 QueryOption(ref,...)
13494 Image::Magick ref=NO_INIT
13515 PERL_UNUSED_VAR(ref);
13516 PERL_UNUSED_VAR(ix);
13517 exception=AcquireExceptionInfo();
13518 perl_exception=newSVpv("",0);
13519 EXTEND(sp,8*items);
13520 for (i=1; i < items; i++)
13522 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13524 options=GetCommandOptions((CommandOption) option);
13525 if (options == (char **) NULL)
13529 for (j=0; options[j] != (char *) NULL; j++)
13530 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13531 options=DestroyStringList(options);
13535 InheritPerlException(exception,perl_exception);
13536 exception=DestroyExceptionInfo(exception);
13537 SvREFCNT_dec(perl_exception);
13541 ###############################################################################
13549 ###############################################################################
13554 Image::Magick ref=NO_INIT
13601 *perl_exception, /* Perl variable for storing messages */
13606 PERL_UNUSED_VAR(ref);
13607 PERL_UNUSED_VAR(ix);
13608 exception=AcquireExceptionInfo();
13609 perl_exception=newSVpv("",0);
13611 package_info=(struct PackageInfo *) NULL;
13613 ac=(items < 2) ? 1 : items-1;
13614 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13616 length=(STRLEN *) NULL;
13617 if (list == (char **) NULL)
13619 ThrowPerlException(exception,ResourceLimitError,
13620 "MemoryAllocationFailed",PackageName);
13621 goto PerlException;
13623 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13624 if (length == (STRLEN *) NULL)
13626 ThrowPerlException(exception,ResourceLimitError,
13627 "MemoryAllocationFailed",PackageName);
13628 goto PerlException;
13630 if (sv_isobject(ST(0)) == 0)
13632 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13634 goto PerlException;
13636 reference=SvRV(ST(0));
13637 hv=SvSTASH(reference);
13638 if (SvTYPE(reference) != SVt_PVAV)
13640 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13642 goto PerlException;
13644 av=(AV *) reference;
13645 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13647 package_info=ClonePackageInfo(info,exception);
13650 *list=(char *) (*package_info->image_info->filename ?
13651 package_info->image_info->filename : "XC:black");
13653 for (n=0, i=0; i < ac; i++)
13655 list[n]=(char *) SvPV(ST(i+1),length[n]);
13656 if ((items >= 3) && strEQcase(list[n],"blob"))
13662 blob=(void *) (SvPV(ST(i+1),length[n]));
13663 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13665 if ((items >= 3) && strEQcase(list[n],"filename"))
13667 if ((items >= 3) && strEQcase(list[n],"file"))
13676 io_info=IoIFP(sv_2io(ST(i+1)));
13677 if (io_info == (PerlIO *) NULL)
13679 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13683 file=PerlIO_findFILE(io_info);
13684 if (file == (FILE *) NULL)
13686 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13690 SetImageInfoFile(package_info->image_info,file);
13692 if ((items >= 3) && strEQcase(list[n],"magick"))
13696 list[n]=(char *) NULL;
13698 status=ExpandFilenames(&n,&list);
13699 if (status == MagickFalse)
13701 ThrowPerlException(exception,ResourceLimitError,
13702 "MemoryAllocationFailed",PackageName);
13703 goto PerlException;
13706 for (i=0; i < n; i++)
13708 if ((package_info->image_info->file == (FILE *) NULL) &&
13709 (package_info->image_info->blob == (void *) NULL))
13710 image=ReadImages(package_info->image_info,list[i],exception);
13713 image=ReadImages(package_info->image_info,
13714 package_info->image_info->filename,exception);
13715 if (image != (Image *) NULL)
13716 DisassociateImageStream(image);
13718 if (image == (Image *) NULL)
13720 for ( ; image; image=image->next)
13722 AddImageToRegistry(sv,image);
13724 av_push(av,sv_bless(rv,hv));
13732 for (i=0; i < n; i++)
13733 if (list[i] != (char *) NULL)
13734 for (p=keep; list[i] != *p++; )
13735 if (*p == (char *) NULL)
13737 list[i]=(char *) RelinquishMagickMemory(list[i]);
13742 if (package_info != (struct PackageInfo *) NULL)
13743 DestroyPackageInfo(package_info);
13744 if (list && (list != keep))
13745 list=(char **) RelinquishMagickMemory(list);
13747 keep=(char **) RelinquishMagickMemory(keep);
13749 length=(STRLEN *) RelinquishMagickMemory(length);
13750 InheritPerlException(exception,perl_exception);
13751 exception=DestroyExceptionInfo(exception);
13752 sv_setiv(perl_exception,(IV) number_images);
13753 SvPOK_on(perl_exception);
13754 ST(0)=sv_2mortal(perl_exception);
13759 ###############################################################################
13767 ###############################################################################
13772 Image::Magick ref=NO_INIT
13795 PERL_UNUSED_VAR(ref);
13796 PERL_UNUSED_VAR(ix);
13797 exception=AcquireExceptionInfo();
13798 perl_exception=newSVpv("",0);
13799 reference=SvRV(ST(0));
13800 av=(AV *) reference;
13801 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13803 for (i=1; i < items; i++)
13804 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13805 SvPV(ST(i),na),exception);
13806 InheritPerlException(exception,perl_exception);
13807 exception=DestroyExceptionInfo(exception);
13808 SvREFCNT_dec(perl_exception); /* throw away all errors */
13812 ###############################################################################
13820 ###############################################################################
13825 Image::Magick ref=NO_INIT
13848 *reference; /* reference is the SV* of ref=SvIV(reference) */
13850 PERL_UNUSED_VAR(ref);
13851 PERL_UNUSED_VAR(ix);
13852 exception=AcquireExceptionInfo();
13853 perl_exception=newSVpv("",0);
13854 if (sv_isobject(ST(0)) == 0)
13856 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13858 goto PerlException;
13860 reference=SvRV(ST(0));
13861 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13863 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13865 for (i=2; i < items; i+=2)
13866 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13869 InheritPerlException(exception,perl_exception);
13870 exception=DestroyExceptionInfo(exception);
13871 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13872 SvPOK_on(perl_exception);
13873 ST(0)=sv_2mortal(perl_exception);
13878 ###############################################################################
13882 # S e t P i x e l #
13886 ###############################################################################
13891 Image::Magick ref=NO_INIT
13933 *reference; /* reference is the SV* of ref=SvIV(reference) */
13935 PERL_UNUSED_VAR(ref);
13936 PERL_UNUSED_VAR(ix);
13937 exception=AcquireExceptionInfo();
13938 perl_exception=newSVpv("",0);
13939 reference=SvRV(ST(0));
13940 av=(AV *) reference;
13941 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13943 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13944 if (image == (Image *) NULL)
13946 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13948 goto PerlException;
13951 normalize=MagickTrue;
13954 region.width=image->columns;
13957 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13958 channel=DefaultChannels;
13959 for (i=2; i < items; i+=2)
13961 attribute=(char *) SvPV(ST(i-1),na);
13962 switch (*attribute)
13967 if (LocaleCompare(attribute,"channel") == 0)
13972 option=ParseChannelOption(SvPV(ST(i),na));
13975 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13979 channel=(ChannelType) option;
13982 if (LocaleCompare(attribute,"color") == 0)
13984 if (SvTYPE(ST(i)) != SVt_RV)
13987 message[MagickPathExtent];
13989 (void) FormatLocaleString(message,MagickPathExtent,
13990 "invalid %.60s value",attribute);
13991 ThrowPerlException(exception,OptionError,message,
13994 av=(AV *) SvRV(ST(i));
13997 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14004 if (LocaleCompare(attribute,"geometry") == 0)
14006 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
14009 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14016 if (LocaleCompare(attribute,"normalize") == 0)
14018 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14022 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14026 normalize=option != 0 ? MagickTrue : MagickFalse;
14029 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14036 if (LocaleCompare(attribute,"x") == 0)
14038 region.x=SvIV(ST(i));
14041 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14048 if (LocaleCompare(attribute,"y") == 0)
14050 region.y=SvIV(ST(i));
14053 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14065 (void) SetImageStorageClass(image,DirectClass,exception);
14066 channel_mask=SetImageChannelMask(image,channel);
14067 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14068 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14069 (SvTYPE(av) != SVt_PVAV))
14081 if (normalize != MagickFalse)
14082 scale=QuantumRange;
14083 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14086 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14087 av_fetch(av,i,0)))),q);
14090 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14093 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14094 av_fetch(av,i,0)))),q);
14097 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14100 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14101 av_fetch(av,i,0)))),q);
14104 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14105 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14107 SetPixelBlack(image,ClampToQuantum(scale*
14108 SvNV(*(av_fetch(av,i,0)))),q);
14111 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14114 SetPixelAlpha(image,ClampToQuantum(scale*
14115 SvNV(*(av_fetch(av,i,0)))),q);
14118 (void) SyncAuthenticPixels(image,exception);
14120 (void) SetImageChannelMask(image,channel_mask);
14123 InheritPerlException(exception,perl_exception);
14124 exception=DestroyExceptionInfo(exception);
14125 SvREFCNT_dec(perl_exception);
14129 ###############################################################################
14137 ###############################################################################
14142 Image::Magick ref=NO_INIT
14181 PERL_UNUSED_VAR(ref);
14182 PERL_UNUSED_VAR(ix);
14183 exception=AcquireExceptionInfo();
14184 perl_exception=newSVpv("",0);
14188 if (sv_isobject(ST(0)) == 0)
14190 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14192 goto PerlException;
14194 reference=SvRV(ST(0));
14195 hv=SvSTASH(reference);
14197 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14199 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14200 if (image == (Image *) NULL)
14202 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14204 goto PerlException;
14206 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14212 for (i=2; i < items; i+=2)
14214 attribute=(char *) SvPV(ST(i-1),na);
14215 switch (*attribute)
14220 if (LocaleCompare(attribute,"offset") == 0)
14222 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14225 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14232 if (LocaleCompare(attribute,"stack") == 0)
14234 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14238 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14244 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14250 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14256 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14258 if (image == (Image *) NULL)
14259 goto PerlException;
14260 for ( ; image; image=image->next)
14262 AddImageToRegistry(sv,image);
14264 av_push(av,sv_bless(rv,hv));
14267 exception=DestroyExceptionInfo(exception);
14268 ST(0)=av_reference;
14269 SvREFCNT_dec(perl_exception);
14273 InheritPerlException(exception,perl_exception);
14274 exception=DestroyExceptionInfo(exception);
14275 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14276 SvPOK_on(perl_exception);
14277 ST(0)=sv_2mortal(perl_exception);
14282 ###############################################################################
14286 # S t a t i s t i c s #
14290 ###############################################################################
14294 Statistics(ref,...)
14295 Image::Magick ref=NO_INIT
14297 StatisticsImage = 1
14299 statisticsimage = 3
14302 #define ChannelStatistics(channel) \
14304 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14305 (double) channel_statistics[channel].depth); \
14306 PUSHs(sv_2mortal(newSVpv(message,0))); \
14307 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14308 channel_statistics[channel].minima/QuantumRange); \
14309 PUSHs(sv_2mortal(newSVpv(message,0))); \
14310 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14311 channel_statistics[channel].maxima/QuantumRange); \
14312 PUSHs(sv_2mortal(newSVpv(message,0))); \
14313 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14314 channel_statistics[channel].mean/QuantumRange); \
14315 PUSHs(sv_2mortal(newSVpv(message,0))); \
14316 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14317 channel_statistics[channel].standard_deviation/QuantumRange); \
14318 PUSHs(sv_2mortal(newSVpv(message,0))); \
14319 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14320 channel_statistics[channel].kurtosis); \
14321 PUSHs(sv_2mortal(newSVpv(message,0))); \
14322 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14323 channel_statistics[channel].skewness); \
14324 PUSHs(sv_2mortal(newSVpv(message,0))); \
14325 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14326 channel_statistics[channel].entropy); \
14327 PUSHs(sv_2mortal(newSVpv(message,0))); \
14334 message[MagickPathExtent];
14337 *channel_statistics;
14355 PERL_UNUSED_VAR(ref);
14356 PERL_UNUSED_VAR(ix);
14357 exception=AcquireExceptionInfo();
14358 perl_exception=newSVpv("",0);
14360 if (sv_isobject(ST(0)) == 0)
14362 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14364 goto PerlException;
14366 reference=SvRV(ST(0));
14369 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14370 if (image == (Image *) NULL)
14372 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14374 goto PerlException;
14377 for ( ; image; image=image->next)
14382 channel_statistics=GetImageStatistics(image,exception);
14383 if (channel_statistics == (ChannelStatistics *) NULL)
14386 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
14388 PixelChannel channel=GetPixelChannelChannel(image,i);
14389 PixelTrait traits=GetPixelChannelTraits(image,channel);
14390 if (traits == UndefinedPixelTrait)
14392 EXTEND(sp,8*(i+1)*count);
14393 ChannelStatistics(channel);
14395 EXTEND(sp,8*(i+1)*count);
14396 ChannelStatistics(CompositePixelChannel);
14397 channel_statistics=(ChannelStatistics *)
14398 RelinquishMagickMemory(channel_statistics);
14402 InheritPerlException(exception,perl_exception);
14403 exception=DestroyExceptionInfo(exception);
14404 SvREFCNT_dec(perl_exception);
14408 ###############################################################################
14412 # S y n c A u t h e n t i c P i x e l s #
14416 ###############################################################################
14420 SyncAuthenticPixels(ref,...)
14421 Image::Magick ref = NO_INIT
14423 Syncauthenticpixels = 1
14424 SyncImagePixels = 2
14425 syncimagepixels = 3
14444 PERL_UNUSED_VAR(ref);
14445 PERL_UNUSED_VAR(ix);
14446 exception=AcquireExceptionInfo();
14447 perl_exception=newSVpv("",0);
14448 if (sv_isobject(ST(0)) == 0)
14450 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14452 goto PerlException;
14455 reference=SvRV(ST(0));
14456 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14457 if (image == (Image *) NULL)
14459 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14461 goto PerlException;
14464 status=SyncAuthenticPixels(image,exception);
14465 if (status != MagickFalse)
14469 InheritPerlException(exception,perl_exception);
14470 exception=DestroyExceptionInfo(exception);
14471 SvREFCNT_dec(perl_exception); /* throw away all errors */
14475 ###############################################################################
14483 ###############################################################################
14488 Image::Magick ref=NO_INIT
14496 filename[MagickPathExtent];
14520 PERL_UNUSED_VAR(ref);
14521 PERL_UNUSED_VAR(ix);
14522 exception=AcquireExceptionInfo();
14523 perl_exception=newSVpv("",0);
14525 package_info=(struct PackageInfo *) NULL;
14526 if (sv_isobject(ST(0)) == 0)
14528 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14530 goto PerlException;
14532 reference=SvRV(ST(0));
14533 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14534 if (image == (Image *) NULL)
14536 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14538 goto PerlException;
14540 package_info=ClonePackageInfo(info,exception);
14542 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14545 for (i=2; i < items; i+=2)
14546 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14548 (void) CopyMagickString(filename,package_info->image_info->filename,
14551 for (next=image; next; next=next->next)
14553 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14554 next->scene=scene++;
14556 *package_info->image_info->magick='\0';
14557 SetImageInfo(package_info->image_info,(unsigned int)
14558 GetImageListLength(image),exception);
14559 for (next=image; next; next=next->next)
14561 (void) WriteImage(package_info->image_info,next,exception);
14563 if (package_info->image_info->adjoin)
14568 if (package_info != (struct PackageInfo *) NULL)
14569 DestroyPackageInfo(package_info);
14570 InheritPerlException(exception,perl_exception);
14571 exception=DestroyExceptionInfo(exception);
14572 sv_setiv(perl_exception,(IV) number_images);
14573 SvPOK_on(perl_exception);
14574 ST(0)=sv_2mortal(perl_exception);