2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
56 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MagickPI 3.14159265358979323846264338327950288419716939937510
78 #define MaxArguments 33
82 #define NumberOf(array) (sizeof(array)/sizeof(*array))
83 #define PackageName "Image::Magick"
86 #define PerlIO_importFILE(f, fl) (f)
87 #define PerlIO_findFILE(f) NULL
90 #define sv_undef PL_sv_undef
93 #define AddImageToRegistry(sv,image) \
95 if (magick_registry != (SplayTreeInfo *) NULL) \
97 (void) AddValueToSplayTree(magick_registry,image,image); \
98 (sv)=newSViv(PTR2IV(image)); \
102 #define DeleteImageFromRegistry(reference,image) \
104 if (magick_registry != (SplayTreeInfo *) NULL) \
106 if (GetImageReferenceCount(image) == 1) \
107 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
108 image=DestroyImage(image); \
109 sv_setiv(reference,0); \
113 #define InheritPerlException(exception,perl_exception) \
116 message[MagickPathExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MagickPathExtent,"Exception %d: %s%s%s%s",\
121 (exception)->severity, (exception)->reason ? \
122 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
123 "Unknown", (exception)->description ? " (" : "", \
124 (exception)->description ? GetLocaleExceptionMessage( \
125 (exception)->severity,(exception)->description) : "", \
126 (exception)->description ? ")" : ""); \
127 if ((perl_exception) != (SV *) NULL) \
129 if (SvCUR(perl_exception)) \
130 sv_catpv(perl_exception,"\n"); \
131 sv_catpv(perl_exception,message); \
136 #define ThrowPerlException(exception,severity,tag,reason) \
137 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
138 tag,"`%s'",reason); \
141 Typedef and structure declarations.
145 ArrayReference = (~0),
146 RealReference = (~0)-1,
147 FileReference = (~0)-2,
148 ImageReference = (~0)-3,
149 IntegerReference = (~0)-4,
150 StringReference = (~0)-5
153 typedef struct _Arguments
193 *Image__Magick; /* data type for the Image::Magick package */
205 arguments[MaxArguments];
208 { "Comment", { {"comment", StringReference} } },
209 { "Label", { {"label", StringReference} } },
210 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
211 {"channel", MagickChannelOptions} } },
212 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
213 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
214 {"height", IntegerReference}, {"fill", StringReference},
215 {"bordercolor", StringReference}, {"color", StringReference},
216 {"compose", MagickComposeOptions} } },
217 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
218 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference}, {"gravity", MagickGravityOptions} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference},
251 {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
260 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
261 {"y", RealReference}, { "fill", StringReference},
262 {"color", StringReference} } },
263 { "Spread", { {"radius", RealReference},
264 {"interpolate", MagickInterpolateOptions} } },
265 { "Swirl", { {"degrees", RealReference},
266 {"interpolate", MagickInterpolateOptions} } },
267 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
268 {"height", IntegerReference}, {"filter", MagickFilterOptions},
269 {"support", StringReference } } },
270 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", RealReference } } },
273 { "Annotate", { {"text", StringReference}, {"font", StringReference},
274 {"pointsize", RealReference}, {"density", StringReference},
275 {"undercolor", StringReference}, {"stroke", StringReference},
276 {"fill", StringReference}, {"geometry", StringReference},
277 {"sans", StringReference}, {"x", RealReference},
278 {"y", RealReference}, {"gravity", MagickGravityOptions},
279 {"translate", StringReference}, {"scale", StringReference},
280 {"rotate", RealReference}, {"skewX", RealReference},
281 {"skewY", RealReference}, {"strokewidth", RealReference},
282 {"antialias", MagickBooleanOptions}, {"family", StringReference},
283 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
284 {"weight", IntegerReference}, {"align", MagickAlignOptions},
285 {"encoding", StringReference}, {"affine", ArrayReference},
286 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
287 {"tile", ImageReference}, {"kerning", RealReference},
288 {"interline-spacing", RealReference},
289 {"interword-spacing", RealReference},
290 {"direction", MagickDirectionOptions} } },
291 { "ColorFloodfill", { {"geometry", StringReference},
292 {"x", IntegerReference}, {"y", IntegerReference},
293 {"fill", StringReference}, {"bordercolor", StringReference},
294 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
295 { "Composite", { {"image", ImageReference},
296 {"compose", MagickComposeOptions}, {"geometry", StringReference},
297 {"x", IntegerReference}, {"y", IntegerReference},
298 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
299 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
300 {"color", StringReference}, {"mask", ImageReference},
301 {"channel", MagickChannelOptions},
302 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
303 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
304 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
305 { "CycleColormap", { {"display", IntegerReference} } },
306 { "Draw", { {"primitive", MagickPrimitiveOptions},
307 {"points", StringReference}, {"method", MagickMethodOptions},
308 {"stroke", StringReference}, {"fill", StringReference},
309 {"strokewidth", RealReference}, {"font", StringReference},
310 {"bordercolor", StringReference}, {"x", RealReference},
311 {"y", RealReference}, {"translate", StringReference},
312 {"scale", StringReference}, {"rotate", RealReference},
313 {"skewX", RealReference}, {"skewY", RealReference},
314 {"tile", ImageReference}, {"pointsize", RealReference},
315 {"antialias", MagickBooleanOptions}, {"density", StringReference},
316 {"linewidth", RealReference}, {"affine", ArrayReference},
317 {"stroke-dashoffset", RealReference},
318 {"stroke-dasharray", ArrayReference},
319 {"interpolate", MagickInterpolateOptions},
320 {"origin", StringReference}, {"text", StringReference},
321 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
322 {"vector-graphics", StringReference}, {"kerning", RealReference},
323 {"interline-spacing", RealReference},
324 {"interword-spacing", RealReference},
325 {"direction", MagickDirectionOptions} } },
326 { "Equalize", { {"channel", MagickChannelOptions} } },
327 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
328 {"red", RealReference}, {"green", RealReference},
329 {"blue", RealReference} } },
330 { "Map", { {"image", ImageReference},
331 {"dither-method", MagickDitherOptions} } },
332 { "MatteFloodfill", { {"geometry", StringReference},
333 {"x", IntegerReference}, {"y", IntegerReference},
334 {"opacity", StringReference}, {"bordercolor", StringReference},
335 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
336 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
337 {"saturation", RealReference}, {"whiteness", RealReference},
338 {"brightness", RealReference}, {"lightness", RealReference},
339 {"blackness", RealReference} } },
340 { "Negate", { {"gray", MagickBooleanOptions},
341 {"channel", MagickChannelOptions} } },
342 { "Normalize", { {"channel", MagickChannelOptions} } },
344 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
345 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
346 {"invert", MagickBooleanOptions} } },
347 { "Quantize", { {"colors", IntegerReference},
348 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
349 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
350 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
351 {"dither-method", MagickDitherOptions} } },
352 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
353 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
354 { "Segment", { {"geometry", StringReference},
355 {"cluster-threshold", RealReference},
356 {"smoothing-threshold", RealReference},
357 {"colorspace", MagickColorspaceOptions},
358 {"verbose", MagickBooleanOptions} } },
360 { "Solarize", { {"geometry", StringReference},
361 {"threshold", StringReference} } },
363 { "Texture", { {"texture", ImageReference} } },
364 { "Evaluate", { {"value", RealReference},
365 {"operator", MagickEvaluateOptions},
366 {"channel", MagickChannelOptions} } },
367 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
368 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
369 { "Threshold", { {"threshold", StringReference},
370 {"channel", MagickChannelOptions} } },
371 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
372 {"sigma", RealReference} } },
373 { "Trim", { {"fuzz", StringReference} } },
374 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
375 {"wavelength", RealReference},
376 {"interpolate", MagickInterpolateOptions} } },
377 { "Separate", { {"channel", MagickChannelOptions} } },
379 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
380 {"y", IntegerReference} } },
381 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
383 { "GaussianBlur", { {"geometry", StringReference},
384 {"radius", RealReference}, {"sigma", RealReference},
385 {"channel", MagickChannelOptions} } },
386 { "Convolve", { {"coefficients", ArrayReference},
387 {"channel", MagickChannelOptions}, {"bias", StringReference},
388 {"kernel", StringReference} } },
389 { "Profile", { {"name", StringReference}, {"profile", StringReference},
390 { "rendering-intent", MagickIntentOptions},
391 { "black-point-compensation", MagickBooleanOptions} } },
392 { "UnsharpMask", { {"geometry", StringReference},
393 {"radius", RealReference}, {"sigma", RealReference},
394 {"gain", RealReference}, {"threshold", RealReference},
395 {"channel", MagickChannelOptions} } },
396 { "MotionBlur", { {"geometry", StringReference},
397 {"radius", RealReference}, {"sigma", RealReference},
398 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
399 { "OrderedDither", { {"threshold", StringReference},
400 {"channel", MagickChannelOptions} } },
401 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
402 {"height", IntegerReference} } },
403 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
404 {"white-point", RealReference}, {"gamma", RealReference},
405 {"channel", MagickChannelOptions}, {"level", StringReference} } },
406 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
407 { "AffineTransform", { {"affine", ArrayReference},
408 {"translate", StringReference}, {"scale", StringReference},
409 {"rotate", RealReference}, {"skewX", RealReference},
410 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
411 {"background", StringReference} } },
412 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
413 { "AdaptiveThreshold", { {"geometry", StringReference},
414 {"width", IntegerReference}, {"height", IntegerReference} } },
415 { "Resample", { {"density", StringReference}, {"x", RealReference},
416 {"y", RealReference}, {"filter", MagickFilterOptions},
417 {"support", RealReference } } },
418 { "Describe", { {"file", FileReference} } },
419 { "BlackThreshold", { {"threshold", StringReference},
420 {"channel", MagickChannelOptions} } },
421 { "WhiteThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "RotationalBlur", { {"geometry", StringReference},
424 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
425 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
426 {"height", IntegerReference} } },
428 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
429 { "Channel", { {"channel", MagickChannelOptions} } },
430 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
431 {"height", IntegerReference}, {"x", IntegerReference},
432 {"y", IntegerReference}, {"fuzz", StringReference},
433 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
434 { "Posterize", { {"levels", IntegerReference},
435 {"dither", MagickBooleanOptions} } },
436 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
437 {"sigma", RealReference}, {"x", IntegerReference},
438 {"y", IntegerReference} } },
439 { "Identify", { {"file", FileReference}, {"features", StringReference},
440 {"unique", MagickBooleanOptions} } },
441 { "SepiaTone", { {"threshold", RealReference} } },
442 { "SigmoidalContrast", { {"geometry", StringReference},
443 {"contrast", RealReference}, {"mid-point", RealReference},
444 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
445 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
446 {"height", IntegerReference}, {"x", IntegerReference},
447 {"y", IntegerReference}, {"fuzz", StringReference},
448 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
449 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
450 {"sigma", RealReference}, {"x", IntegerReference},
451 {"y", IntegerReference}, {"background", StringReference} } },
452 { "ContrastStretch", { {"levels", StringReference},
453 {"black-point", RealReference},{"white-point", RealReference},
454 {"channel", MagickChannelOptions} } },
457 { "AdaptiveSharpen", { {"geometry", StringReference},
458 {"radius", RealReference}, {"sigma", RealReference},
459 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
463 { "AdaptiveBlur", { {"geometry", StringReference},
464 {"radius", RealReference}, {"sigma", RealReference},
465 {"channel", MagickChannelOptions} } },
466 { "Sketch", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"angle", RealReference} } },
470 { "AdaptiveResize", { {"geometry", StringReference},
471 {"width", IntegerReference}, {"height", IntegerReference},
472 {"filter", MagickFilterOptions}, {"support", StringReference },
473 {"blur", RealReference } } },
474 { "ClipMask", { {"mask", ImageReference} } },
475 { "LinearStretch", { {"levels", StringReference},
476 {"black-point", RealReference},{"white-point", RealReference} } },
477 { "ColorMatrix", { {"matrix", ArrayReference} } },
478 { "Mask", { {"mask", ImageReference} } },
479 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
480 {"font", StringReference}, {"stroke", StringReference},
481 {"fill", StringReference}, {"strokewidth", RealReference},
482 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
483 {"background", StringReference},
484 {"interpolate", MagickInterpolateOptions} } },
485 { "FloodfillPaint", { {"geometry", StringReference},
486 {"x", IntegerReference}, {"y", IntegerReference},
487 {"fill", StringReference}, {"bordercolor", StringReference},
488 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
489 {"invert", MagickBooleanOptions} } },
490 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
491 {"virtual-pixel", MagickVirtualPixelOptions},
492 {"best-fit", MagickBooleanOptions} } },
493 { "Clut", { {"image", ImageReference},
494 {"interpolate", MagickInterpolateOptions},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "BrightnessContrast", { {"levels", StringReference},
529 {"brightness", RealReference},{"contrast", RealReference},
530 {"channel", MagickChannelOptions} } },
531 { "Morphology", { {"kernel", StringReference},
532 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
533 {"iterations", IntegerReference} } },
534 { "Mode", { {"geometry", StringReference},
535 {"width", IntegerReference},{"height", IntegerReference},
536 {"channel", MagickChannelOptions} } },
537 { "Statistic", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
540 { "Perceptible", { {"epsilon", RealReference},
541 {"channel", MagickChannelOptions} } },
542 { "Poly", { {"terms", ArrayReference},
543 {"channel", MagickChannelOptions} } },
544 { "Grayscale", { {"method", MagickNoiseOptions} } },
545 { "CannyEdge", { {"geometry", StringReference},
546 {"radius", RealReference}, {"sigma", RealReference},
547 {"lower-percent", RealReference}, {"upper-percent", RealReference} } },
548 { "HoughLine", { {"geometry", StringReference},
549 {"width", IntegerReference}, {"height", IntegerReference},
550 {"threshold", IntegerReference} } },
551 { "MeanShift", { {"geometry", StringReference},
552 {"width", IntegerReference}, {"height", IntegerReference},
553 {"distance", RealReference} } },
554 { "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference},
555 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
556 { "ConnectedComponents", { {"connectivity", IntegerReference} } },
557 { "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference},
558 {"width", IntegerReference}, {"height", IntegerReference},
559 {"x", IntegerReference}, {"y", IntegerReference},
560 {"gravity", MagickGravityOptions}, {"offset", StringReference},
561 {"dx", IntegerReference}, {"dy", IntegerReference} } },
562 { "Color", { {"color", StringReference} } },
563 { "WaveletDenoise", { {"threshold", StringReference},
564 {"channel", MagickChannelOptions} } },
568 *magick_registry = (SplayTreeInfo *) NULL;
571 Forward declarations.
574 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
577 strEQcase(const char *,const char *);
580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
584 % C l o n e P a c k a g e I n f o %
588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
593 % The format of the ClonePackageInfo routine is:
595 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
598 % A description of each parameter follows:
600 % o info: a structure of type info.
602 % o exception: Return any errors or warnings in this structure.
605 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
606 ExceptionInfo *exception)
611 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
612 if (clone_info == (struct PackageInfo *) NULL)
614 ThrowPerlException(exception,ResourceLimitError,
615 "UnableToClonePackageInfo",PackageName);
616 return((struct PackageInfo *) NULL);
618 if (info == (struct PackageInfo *) NULL)
620 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
624 clone_info->image_info=CloneImageInfo(info->image_info);
629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
639 % constant() returns a double value for the specified name.
641 % The format of the constant routine is:
643 % double constant(char *name,ssize_t sans)
645 % A description of each parameter follows:
647 % o value: Method constant returns a double value for the specified name.
649 % o name: The name of the constant.
651 % o sans: This integer value is not used.
654 static double constant(char *name,ssize_t sans)
662 if (strEQ(name,"BlobError"))
664 if (strEQ(name,"BlobWarning"))
670 if (strEQ(name,"CacheError"))
672 if (strEQ(name,"CacheWarning"))
673 return(CacheWarning);
674 if (strEQ(name,"CoderError"))
676 if (strEQ(name,"CoderWarning"))
677 return(CoderWarning);
678 if (strEQ(name,"ConfigureError"))
679 return(ConfigureError);
680 if (strEQ(name,"ConfigureWarning"))
681 return(ConfigureWarning);
682 if (strEQ(name,"CorruptImageError"))
683 return(CorruptImageError);
684 if (strEQ(name,"CorruptImageWarning"))
685 return(CorruptImageWarning);
690 if (strEQ(name,"DelegateError"))
691 return(DelegateError);
692 if (strEQ(name,"DelegateWarning"))
693 return(DelegateWarning);
694 if (strEQ(name,"DrawError"))
696 if (strEQ(name,"DrawWarning"))
702 if (strEQ(name,"ErrorException"))
703 return(ErrorException);
704 if (strEQ(name,"ExceptionError"))
706 if (strEQ(name,"ExceptionWarning"))
707 return(CoderWarning);
712 if (strEQ(name,"FatalErrorException"))
713 return(FatalErrorException);
714 if (strEQ(name,"FileOpenError"))
715 return(FileOpenError);
716 if (strEQ(name,"FileOpenWarning"))
717 return(FileOpenWarning);
722 if (strEQ(name,"ImageError"))
724 if (strEQ(name,"ImageWarning"))
725 return(ImageWarning);
730 if (strEQ(name,"MaxRGB"))
731 return(QuantumRange);
732 if (strEQ(name,"MissingDelegateError"))
733 return(MissingDelegateError);
734 if (strEQ(name,"MissingDelegateWarning"))
735 return(MissingDelegateWarning);
736 if (strEQ(name,"ModuleError"))
738 if (strEQ(name,"ModuleWarning"))
739 return(ModuleWarning);
744 if (strEQ(name,"Opaque"))
746 if (strEQ(name,"OptionError"))
748 if (strEQ(name,"OptionWarning"))
749 return(OptionWarning);
754 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
755 return(MAGICKCORE_QUANTUM_DEPTH);
756 if (strEQ(name,"QuantumDepth"))
757 return(MAGICKCORE_QUANTUM_DEPTH);
758 if (strEQ(name,"QuantumRange"))
759 return(QuantumRange);
764 if (strEQ(name,"ResourceLimitError"))
765 return(ResourceLimitError);
766 if (strEQ(name,"ResourceLimitWarning"))
767 return(ResourceLimitWarning);
768 if (strEQ(name,"RegistryError"))
769 return(RegistryError);
770 if (strEQ(name,"RegistryWarning"))
771 return(RegistryWarning);
776 if (strEQ(name,"StreamError"))
778 if (strEQ(name,"StreamWarning"))
779 return(StreamWarning);
780 if (strEQ(name,"Success"))
786 if (strEQ(name,"Transparent"))
787 return(TransparentAlpha);
788 if (strEQ(name,"TypeError"))
790 if (strEQ(name,"TypeWarning"))
796 if (strEQ(name,"WarningException"))
797 return(WarningException);
802 if (strEQ(name,"XServerError"))
803 return(XServerError);
804 if (strEQ(name,"XServerWarning"))
805 return(XServerWarning);
814 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
818 % D e s t r o y P a c k a g e I n f o %
822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
824 % Method DestroyPackageInfo frees a previously created info structure.
826 % The format of the DestroyPackageInfo routine is:
828 % DestroyPackageInfo(struct PackageInfo *info)
830 % A description of each parameter follows:
832 % o info: a structure of type info.
835 static void DestroyPackageInfo(struct PackageInfo *info)
837 info->image_info=DestroyImageInfo(info->image_info);
838 info=(struct PackageInfo *) RelinquishMagickMemory(info);
842 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
850 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
852 % Method GetList is recursively called by SetupList to traverse the
853 % Image__Magick reference. If building an reference_vector (see SetupList),
854 % *current is the current position in *reference_vector and *last is the final
855 % entry in *reference_vector.
857 % The format of the GetList routine is:
861 % A description of each parameter follows:
863 % o info: a structure of type info.
866 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
867 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
872 if (reference == (SV *) NULL)
874 switch (SvTYPE(reference))
894 previous=(Image *) NULL;
898 for (i=0; i <= n; i++)
904 if (rv && *rv && sv_isobject(*rv))
906 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
908 if (image == (Image *) NULL)
910 if (image == previous)
912 image=CloneImage(image,0,0,MagickTrue,exception);
913 if (image == (Image *) NULL)
916 image->previous=previous;
917 *(previous ? &previous->next : &head)=image;
918 for (previous=image; previous->next; previous=previous->next) ;
926 Blessed scalar, one image.
928 image=INT2PTR(Image *,SvIV(reference));
929 if (image == (Image *) NULL)
931 image->previous=(Image *) NULL;
932 image->next=(Image *) NULL;
933 if (reference_vector)
935 if (*current == *last)
938 if (*reference_vector == (SV **) NULL)
939 *reference_vector=(SV **) AcquireQuantumMemory(*last,
940 sizeof(*reference_vector));
942 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
943 *last,sizeof(*reference_vector));
945 if (*reference_vector == (SV **) NULL)
947 ThrowPerlException(exception,ResourceLimitError,
948 "MemoryAllocationFailed",PackageName);
949 return((Image *) NULL);
951 (*reference_vector)[*current]=reference;
952 (*reference_vector)[++(*current)]=NULL;
959 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
960 (double) SvTYPE(reference));
961 return((Image *) NULL);
965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 % G e t P a c k a g e I n f o %
973 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
975 % Method GetPackageInfo looks up or creates an info structure for the given
976 % Image__Magick reference. If it does create a new one, the information in
977 % package_info is used to initialize it.
979 % The format of the GetPackageInfo routine is:
981 % struct PackageInfo *GetPackageInfo(void *reference,
982 % struct PackageInfo *package_info,ExceptionInfo *exception)
984 % A description of each parameter follows:
986 % o info: a structure of type info.
988 % o exception: Return any errors or warnings in this structure.
991 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
992 struct PackageInfo *package_info,ExceptionInfo *exception)
995 message[MagickPathExtent];
1003 (void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p",
1004 PackageName,XS_VERSION,reference);
1005 sv=perl_get_sv(message,(TRUE | 0x02));
1006 if (sv == (SV *) NULL)
1008 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1010 return(package_info);
1012 if (SvREFCNT(sv) == 0)
1013 (void) SvREFCNT_inc(sv);
1014 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1016 clone_info=ClonePackageInfo(package_info,exception);
1017 sv_setiv(sv,PTR2IV(clone_info));
1022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1026 % S e t A t t r i b u t e %
1030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1032 % SetAttribute() sets the attribute to the value in sval. This can change
1033 % either or both of image or info.
1035 % The format of the SetAttribute routine is:
1037 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1038 % SV *sval,ExceptionInfo *exception)
1040 % A description of each parameter follows:
1042 % o list: a list of strings.
1044 % o string: a character string.
1048 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1056 value=InterpretSiPrefixValue(string,&q);
1058 value*=interval/100.0;
1062 static inline double StringToDouble(const char *string,char **sentinal)
1064 return(InterpretLocaleValue(string,sentinal));
1067 static double StringToDoubleInterval(const char *string,const double interval)
1075 value=InterpretLocaleValue(string,&q);
1077 value*=interval/100.0;
1081 static inline ssize_t StringToLong(const char *value)
1083 return(strtol(value,(char **) NULL,10));
1086 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1087 const char *attribute,SV *sval,ExceptionInfo *exception)
1114 if (LocaleCompare(attribute,"adjoin") == 0)
1116 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1117 SvPV(sval,na)) : SvIV(sval);
1120 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1125 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1128 if (LocaleCompare(attribute,"alpha") == 0)
1130 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1131 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1134 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1138 for ( ; image; image=image->next)
1139 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1143 if (LocaleCompare(attribute,"antialias") == 0)
1145 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1146 SvPV(sval,na)) : SvIV(sval);
1149 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1154 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1157 if (LocaleCompare(attribute,"area-limit") == 0)
1162 limit=MagickResourceInfinity;
1163 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1164 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1166 (void) SetMagickResourceLimit(AreaResource,limit);
1169 if (LocaleCompare(attribute,"attenuate") == 0)
1172 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1175 if (LocaleCompare(attribute,"authenticate") == 0)
1178 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1182 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1183 for ( ; image; image=image->next)
1184 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1190 if (LocaleCompare(attribute,"background") == 0)
1192 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1195 info->image_info->background_color=target_color;
1196 for ( ; image; image=image->next)
1197 image->background_color=target_color;
1200 if (LocaleCompare(attribute,"blue-primary") == 0)
1202 for ( ; image; image=image->next)
1204 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1205 image->chromaticity.blue_primary.x=geometry_info.rho;
1206 image->chromaticity.blue_primary.y=geometry_info.sigma;
1207 if ((flags & SigmaValue) == 0)
1208 image->chromaticity.blue_primary.y=
1209 image->chromaticity.blue_primary.x;
1213 if (LocaleCompare(attribute,"bordercolor") == 0)
1215 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1218 info->image_info->border_color=target_color;
1219 for ( ; image; image=image->next)
1220 image->border_color=target_color;
1224 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1225 for ( ; image; image=image->next)
1226 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1232 if (LocaleCompare(attribute,"cache-threshold") == 0)
1234 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1235 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1236 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1237 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1240 if (LocaleCompare(attribute,"clip-mask") == 0)
1245 clip_mask=(Image *) NULL;
1247 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1248 for ( ; image; image=image->next)
1249 SetImageMask(image,ReadPixelMask,clip_mask,exception);
1252 if (LocaleNCompare(attribute,"colormap",8) == 0)
1254 for ( ; image; image=image->next)
1262 if (image->storage_class == DirectClass)
1265 items=sscanf(attribute,"%*[^[][%ld",&i);
1267 if (i > (ssize_t) image->colors)
1269 if ((strchr(SvPV(sval,na),',') == 0) ||
1270 (strchr(SvPV(sval,na),')') != 0))
1271 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1272 image->colormap+i,exception);
1275 color=image->colormap+i;
1276 pixel.red=color->red;
1277 pixel.green=color->green;
1278 pixel.blue=color->blue;
1279 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1280 pixel.red=geometry_info.rho;
1281 pixel.green=geometry_info.sigma;
1282 pixel.blue=geometry_info.xi;
1283 color->red=ClampToQuantum(pixel.red);
1284 color->green=ClampToQuantum(pixel.green);
1285 color->blue=ClampToQuantum(pixel.blue);
1290 if (LocaleCompare(attribute,"colorspace") == 0)
1292 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1293 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1296 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1300 for ( ; image; image=image->next)
1301 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1305 if (LocaleCompare(attribute,"comment") == 0)
1307 for ( ; image; image=image->next)
1308 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1309 info ? info->image_info : (ImageInfo *) NULL,image,
1310 SvPV(sval,na),exception),exception);
1313 if (LocaleCompare(attribute,"compression") == 0)
1315 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1316 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1319 ThrowPerlException(exception,OptionError,
1320 "UnrecognizedImageCompression",SvPV(sval,na));
1324 info->image_info->compression=(CompressionType) sp;
1325 for ( ; image; image=image->next)
1326 image->compression=(CompressionType) sp;
1330 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1331 for ( ; image; image=image->next)
1332 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1338 if (LocaleCompare(attribute,"debug") == 0)
1340 SetLogEventMask(SvPV(sval,na));
1343 if (LocaleCompare(attribute,"delay") == 0)
1345 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1346 for ( ; image; image=image->next)
1348 image->delay=(size_t) floor(geometry_info.rho+0.5);
1349 if ((flags & SigmaValue) != 0)
1350 image->ticks_per_second=(ssize_t)
1351 floor(geometry_info.sigma+0.5);
1355 if (LocaleCompare(attribute,"disk-limit") == 0)
1360 limit=MagickResourceInfinity;
1361 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1362 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1364 (void) SetMagickResourceLimit(DiskResource,limit);
1367 if (LocaleCompare(attribute,"density") == 0)
1369 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1371 ThrowPerlException(exception,OptionError,"MissingGeometry",
1376 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1377 for ( ; image; image=image->next)
1379 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1380 image->resolution.x=geometry_info.rho;
1381 image->resolution.y=geometry_info.sigma;
1382 if ((flags & SigmaValue) == 0)
1383 image->resolution.y=image->resolution.x;
1387 if (LocaleCompare(attribute,"depth") == 0)
1390 info->image_info->depth=SvIV(sval);
1391 for ( ; image; image=image->next)
1392 (void) SetImageDepth(image,SvIV(sval),exception);
1395 if (LocaleCompare(attribute,"dispose") == 0)
1397 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1398 SvPV(sval,na)) : SvIV(sval);
1401 ThrowPerlException(exception,OptionError,
1402 "UnrecognizedDisposeMethod",SvPV(sval,na));
1405 for ( ; image; image=image->next)
1406 image->dispose=(DisposeType) sp;
1409 if (LocaleCompare(attribute,"dither") == 0)
1413 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1414 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1417 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1421 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1425 if (LocaleCompare(attribute,"display") == 0)
1429 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1433 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1434 for ( ; image; image=image->next)
1435 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1441 if (LocaleCompare(attribute,"endian") == 0)
1443 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1444 SvPV(sval,na)) : SvIV(sval);
1447 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1452 info->image_info->endian=(EndianType) sp;
1453 for ( ; image; image=image->next)
1454 image->endian=(EndianType) sp;
1457 if (LocaleCompare(attribute,"extract") == 0)
1460 Set image extract geometry.
1462 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1466 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1467 for ( ; image; image=image->next)
1468 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1474 if (LocaleCompare(attribute,"filename") == 0)
1477 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1479 for ( ; image; image=image->next)
1480 (void) CopyMagickString(image->filename,SvPV(sval,na),
1484 if (LocaleCompare(attribute,"file") == 0)
1492 if (info == (struct PackageInfo *) NULL)
1494 io_info=IoIFP(sv_2io(sval));
1495 if (io_info == (PerlIO *) NULL)
1497 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1501 file=PerlIO_findFILE(io_info);
1502 if (file == (FILE *) NULL)
1504 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1508 SetImageInfoFile(info->image_info,file);
1511 if (LocaleCompare(attribute,"fill") == 0)
1514 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1517 if (LocaleCompare(attribute,"font") == 0)
1520 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1523 if (LocaleCompare(attribute,"foreground") == 0)
1525 if (LocaleCompare(attribute,"fuzz") == 0)
1528 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1530 for ( ; image; image=image->next)
1531 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1536 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1537 for ( ; image; image=image->next)
1538 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1544 if (LocaleCompare(attribute,"gamma") == 0)
1546 for ( ; image; image=image->next)
1547 image->gamma=SvNV(sval);
1550 if (LocaleCompare(attribute,"gravity") == 0)
1552 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1553 SvPV(sval,na)) : SvIV(sval);
1556 ThrowPerlException(exception,OptionError,
1557 "UnrecognizedGravityType",SvPV(sval,na));
1561 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1562 for ( ; image; image=image->next)
1563 image->gravity=(GravityType) sp;
1566 if (LocaleCompare(attribute,"green-primary") == 0)
1568 for ( ; image; image=image->next)
1570 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1571 image->chromaticity.green_primary.x=geometry_info.rho;
1572 image->chromaticity.green_primary.y=geometry_info.sigma;
1573 if ((flags & SigmaValue) == 0)
1574 image->chromaticity.green_primary.y=
1575 image->chromaticity.green_primary.x;
1580 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1581 for ( ; image; image=image->next)
1582 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1588 if (LocaleNCompare(attribute,"index",5) == 0)
1602 for ( ; image; image=image->next)
1604 if (image->storage_class != PseudoClass)
1608 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1610 image_view=AcquireAuthenticCacheView(image,exception);
1611 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1612 if (q != (Quantum *) NULL)
1614 items=sscanf(SvPV(sval,na),"%ld",&index);
1615 if ((index >= 0) && (index < (ssize_t) image->colors))
1616 SetPixelIndex(image,index,q);
1617 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1619 image_view=DestroyCacheView(image_view);
1623 if (LocaleCompare(attribute,"iterations") == 0)
1626 for ( ; image; image=image->next)
1627 image->iterations=SvIV(sval);
1630 if (LocaleCompare(attribute,"interlace") == 0)
1632 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1633 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1636 ThrowPerlException(exception,OptionError,
1637 "UnrecognizedInterlaceType",SvPV(sval,na));
1641 info->image_info->interlace=(InterlaceType) sp;
1642 for ( ; image; image=image->next)
1643 image->interlace=(InterlaceType) sp;
1647 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1648 for ( ; image; image=image->next)
1649 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1655 if (LocaleCompare(attribute,"label") == 0)
1657 for ( ; image; image=image->next)
1658 (void) SetImageProperty(image,"label",InterpretImageProperties(
1659 info ? info->image_info : (ImageInfo *) NULL,image,
1660 SvPV(sval,na),exception),exception);
1663 if (LocaleCompare(attribute,"loop") == 0)
1666 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1667 for ( ; image; image=image->next)
1668 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1674 if (LocaleCompare(attribute,"magick") == 0)
1677 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
1678 "%s:",SvPV(sval,na));
1679 for ( ; image; image=image->next)
1680 (void) CopyMagickString(image->magick,SvPV(sval,na),MagickPathExtent);
1683 if (LocaleCompare(attribute,"map-limit") == 0)
1688 limit=MagickResourceInfinity;
1689 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1690 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1692 (void) SetMagickResourceLimit(MapResource,limit);
1695 if (LocaleCompare(attribute,"mask") == 0)
1700 mask=(Image *) NULL;
1702 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1703 for ( ; image; image=image->next)
1704 SetImageMask(image,ReadPixelMask,mask,exception);
1707 if (LocaleCompare(attribute,"mattecolor") == 0)
1709 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1712 info->image_info->alpha_color=target_color;
1713 for ( ; image; image=image->next)
1714 image->alpha_color=target_color;
1717 if (LocaleCompare(attribute,"matte") == 0)
1719 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1720 SvPV(sval,na)) : SvIV(sval);
1723 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1727 for ( ; image; image=image->next)
1728 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1731 if (LocaleCompare(attribute,"memory-limit") == 0)
1736 limit=MagickResourceInfinity;
1737 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1738 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1740 (void) SetMagickResourceLimit(MemoryResource,limit);
1743 if (LocaleCompare(attribute,"monochrome") == 0)
1745 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1746 SvPV(sval,na)) : SvIV(sval);
1749 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1754 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1755 for ( ; image; image=image->next)
1756 (void) SetImageType(image,BilevelType,exception);
1760 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1761 for ( ; image; image=image->next)
1762 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1768 if (LocaleCompare(attribute,"option") == 0)
1771 DefineImageOption(info->image_info,SvPV(sval,na));
1774 if (LocaleCompare(attribute,"orientation") == 0)
1776 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1777 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1780 ThrowPerlException(exception,OptionError,
1781 "UnrecognizedOrientationType",SvPV(sval,na));
1785 info->image_info->orientation=(OrientationType) sp;
1786 for ( ; image; image=image->next)
1787 image->orientation=(OrientationType) sp;
1791 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1792 for ( ; image; image=image->next)
1793 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1799 if (LocaleCompare(attribute,"page") == 0)
1804 geometry=GetPageGeometry(SvPV(sval,na));
1806 (void) CloneString(&info->image_info->page,geometry);
1807 for ( ; image; image=image->next)
1808 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1809 geometry=(char *) RelinquishMagickMemory(geometry);
1812 if (LocaleNCompare(attribute,"pixel",5) == 0)
1826 for ( ; image; image=image->next)
1828 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1832 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1834 image_view=AcquireVirtualCacheView(image,exception);
1835 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1836 if (q != (Quantum *) NULL)
1838 if ((strchr(SvPV(sval,na),',') == 0) ||
1839 (strchr(SvPV(sval,na),')') != 0))
1840 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1844 GetPixelInfo(image,&pixel);
1845 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1846 pixel.red=geometry_info.rho;
1847 if ((flags & SigmaValue) != 0)
1848 pixel.green=geometry_info.sigma;
1849 if ((flags & XiValue) != 0)
1850 pixel.blue=geometry_info.xi;
1851 if ((flags & PsiValue) != 0)
1852 pixel.alpha=geometry_info.psi;
1853 if ((flags & ChiValue) != 0)
1854 pixel.black=geometry_info.chi;
1856 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1857 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1858 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1859 if (image->colorspace == CMYKColorspace)
1860 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1861 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1862 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1864 image_view=DestroyCacheView(image_view);
1868 if (LocaleCompare(attribute,"pointsize") == 0)
1872 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1873 info->image_info->pointsize=geometry_info.rho;
1877 if (LocaleCompare(attribute,"preview") == 0)
1879 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1880 SvPV(sval,na)) : SvIV(sval);
1883 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1888 info->image_info->preview_type=(PreviewType) sp;
1892 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1893 for ( ; image; image=image->next)
1894 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1900 if (LocaleCompare(attribute,"quality") == 0)
1903 info->image_info->quality=SvIV(sval);
1904 for ( ; image; image=image->next)
1905 image->quality=SvIV(sval);
1909 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1910 for ( ; image; image=image->next)
1911 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1917 if (LocaleCompare(attribute,"read-mask") == 0)
1922 mask=(Image *) NULL;
1924 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1925 for ( ; image; image=image->next)
1926 SetImageMask(image,ReadPixelMask,mask,exception);
1929 if (LocaleCompare(attribute,"red-primary") == 0)
1931 for ( ; image; image=image->next)
1933 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1934 image->chromaticity.red_primary.x=geometry_info.rho;
1935 image->chromaticity.red_primary.y=geometry_info.sigma;
1936 if ((flags & SigmaValue) == 0)
1937 image->chromaticity.red_primary.y=
1938 image->chromaticity.red_primary.x;
1942 if (LocaleCompare(attribute,"render") == 0)
1944 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1945 SvPV(sval,na)) : SvIV(sval);
1948 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1952 for ( ; image; image=image->next)
1953 image->rendering_intent=(RenderingIntent) sp;
1956 if (LocaleCompare(attribute,"repage") == 0)
1961 for ( ; image; image=image->next)
1963 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1964 if ((flags & WidthValue) != 0)
1966 if ((flags & HeightValue) == 0)
1967 geometry.height=geometry.width;
1968 image->page.width=geometry.width;
1969 image->page.height=geometry.height;
1971 if ((flags & AspectValue) != 0)
1973 if ((flags & XValue) != 0)
1974 image->page.x+=geometry.x;
1975 if ((flags & YValue) != 0)
1976 image->page.y+=geometry.y;
1980 if ((flags & XValue) != 0)
1982 image->page.x=geometry.x;
1983 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1984 image->page.width=image->columns+geometry.x;
1986 if ((flags & YValue) != 0)
1988 image->page.y=geometry.y;
1989 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1990 image->page.height=image->rows+geometry.y;
1997 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1998 for ( ; image; image=image->next)
1999 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2005 if (LocaleCompare(attribute,"sampling-factor") == 0)
2007 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2009 ThrowPerlException(exception,OptionError,"MissingGeometry",
2014 (void) CloneString(&info->image_info->sampling_factor,
2018 if (LocaleCompare(attribute,"scene") == 0)
2020 for ( ; image; image=image->next)
2021 image->scene=SvIV(sval);
2024 if (LocaleCompare(attribute,"server") == 0)
2026 if (LocaleCompare(attribute,"size") == 0)
2030 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2032 ThrowPerlException(exception,OptionError,"MissingGeometry",
2036 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2040 if (LocaleCompare(attribute,"stroke") == 0)
2043 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2047 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2048 for ( ; image; image=image->next)
2049 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2055 if (LocaleCompare(attribute,"texture") == 0)
2058 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2061 if (LocaleCompare(attribute,"thread-limit") == 0)
2066 limit=MagickResourceInfinity;
2067 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2068 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2070 (void) SetMagickResourceLimit(ThreadResource,limit);
2073 if (LocaleCompare(attribute,"tile-offset") == 0)
2078 geometry=GetPageGeometry(SvPV(sval,na));
2080 (void) CloneString(&info->image_info->page,geometry);
2081 for ( ; image; image=image->next)
2082 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2084 geometry=(char *) RelinquishMagickMemory(geometry);
2087 if (LocaleCompare(attribute,"time-limit") == 0)
2092 limit=MagickResourceInfinity;
2093 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2094 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2096 (void) SetMagickResourceLimit(TimeResource,limit);
2099 if (LocaleCompare(attribute,"transparent-color") == 0)
2101 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2104 info->image_info->transparent_color=target_color;
2105 for ( ; image; image=image->next)
2106 image->transparent_color=target_color;
2109 if (LocaleCompare(attribute,"type") == 0)
2111 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2112 SvPV(sval,na)) : SvIV(sval);
2115 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2120 info->image_info->type=(ImageType) sp;
2121 for ( ; image; image=image->next)
2122 SetImageType(image,(ImageType) sp,exception);
2126 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2127 for ( ; image; image=image->next)
2128 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2134 if (LocaleCompare(attribute,"units") == 0)
2136 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2137 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2140 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2145 info->image_info->units=(ResolutionType) sp;
2146 for ( ; image; image=image->next)
2151 units=(ResolutionType) sp;
2152 if (image->units != units)
2153 switch (image->units)
2155 case UndefinedResolution:
2156 case PixelsPerInchResolution:
2158 if (units == PixelsPerCentimeterResolution)
2160 image->resolution.x*=2.54;
2161 image->resolution.y*=2.54;
2165 case PixelsPerCentimeterResolution:
2167 if (units == PixelsPerInchResolution)
2169 image->resolution.x/=2.54;
2170 image->resolution.y/=2.54;
2180 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2181 for ( ; image; image=image->next)
2182 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2188 if (LocaleCompare(attribute,"verbose") == 0)
2190 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2191 SvPV(sval,na)) : SvIV(sval);
2194 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2199 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2202 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2204 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2205 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2208 ThrowPerlException(exception,OptionError,
2209 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2212 for ( ; image; image=image->next)
2213 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2217 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2218 for ( ; image; image=image->next)
2219 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2225 if (LocaleCompare(attribute,"white-point") == 0)
2227 for ( ; image; image=image->next)
2229 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2230 image->chromaticity.white_point.x=geometry_info.rho;
2231 image->chromaticity.white_point.y=geometry_info.sigma;
2232 if ((flags & SigmaValue) == 0)
2233 image->chromaticity.white_point.y=
2234 image->chromaticity.white_point.x;
2238 if (LocaleCompare(attribute,"write-mask") == 0)
2243 mask=(Image *) NULL;
2245 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2246 for ( ; image; image=image->next)
2247 SetImageMask(image,WritePixelMask,mask,exception);
2251 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2252 for ( ; image; image=image->next)
2253 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2259 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2260 for ( ; image; image=image->next)
2261 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2272 % S e t u p L i s t %
2276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2278 % Method SetupList returns the list of all the images linked by their
2279 % image->next and image->previous link lists for use with ImageMagick. If
2280 % info is non-NULL, an info structure is returned in *info. If
2281 % reference_vector is non-NULL,an array of SV* are returned in
2282 % *reference_vector. Reference_vector is used when the images are going to be
2283 % replaced with new Image*'s.
2285 % The format of the SetupList routine is:
2287 % Image *SetupList(SV *reference,struct PackageInfo **info,
2288 % SV ***reference_vector,ExceptionInfo *exception)
2290 % A description of each parameter follows:
2292 % o list: a list of strings.
2294 % o string: a character string.
2296 % o exception: Return any errors or warnings in this structure.
2299 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2300 SV ***reference_vector,ExceptionInfo *exception)
2309 if (reference_vector)
2310 *reference_vector=NULL;
2315 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2316 if (info && (SvTYPE(reference) == SVt_PVAV))
2317 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2327 % s t r E Q c a s e %
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2333 % strEQcase() compares two strings and returns 0 if they are the
2334 % same or if the second string runs out first. The comparison is case
2337 % The format of the strEQcase routine is:
2339 % ssize_t strEQcase(const char *p,const char *q)
2341 % A description of each parameter follows:
2343 % o p: a character string.
2345 % o q: a character string.
2349 static ssize_t strEQcase(const char *p,const char *q)
2357 for (i=0 ; (c=(*q)) != 0; i++)
2359 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2360 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2365 return(((*q == 0) && (*p == 0)) ? i : 0);
2369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2373 % I m a g e : : M a g i c k %
2377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2381 MODULE = Image::Magick PACKAGE = Image::Magick
2386 MagickCoreGenesis("PerlMagick",MagickFalse);
2387 SetWarningHandler(NULL);
2388 SetErrorHandler(NULL);
2389 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2390 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2396 if (magick_registry != (SplayTreeInfo *) NULL)
2397 magick_registry=DestroySplayTree(magick_registry);
2398 MagickCoreTerminus();
2402 constant(name,argument)
2407 ###############################################################################
2415 ###############################################################################
2420 Image::Magick ref=NO_INIT
2444 PERL_UNUSED_VAR(ref);
2445 PERL_UNUSED_VAR(ix);
2446 exception=AcquireExceptionInfo();
2447 perl_exception=newSVpv("",0);
2448 package_info=(struct PackageInfo *) NULL;
2449 if (sv_isobject(ST(0)) == 0)
2451 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2455 reference=SvRV(ST(0));
2456 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2457 if (image == (Image *) NULL)
2459 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2463 package_info=ClonePackageInfo(info,exception);
2465 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2468 for (i=2; i < items; i+=2)
2469 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2471 (void) AnimateImages(package_info->image_info,image,exception);
2472 (void) CatchImageException(image);
2475 if (package_info != (struct PackageInfo *) NULL)
2476 DestroyPackageInfo(package_info);
2477 InheritPerlException(exception,perl_exception);
2478 exception=DestroyExceptionInfo(exception);
2479 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2480 SvPOK_on(perl_exception);
2481 ST(0)=sv_2mortal(perl_exception);
2486 ###############################################################################
2494 ###############################################################################
2499 Image::Magick ref=NO_INIT
2537 PERL_UNUSED_VAR(ref);
2538 PERL_UNUSED_VAR(ix);
2539 exception=AcquireExceptionInfo();
2540 perl_exception=newSVpv("",0);
2544 if (sv_isobject(ST(0)) == 0)
2546 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2550 reference=SvRV(ST(0));
2551 hv=SvSTASH(reference);
2553 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2555 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2556 if (image == (Image *) NULL)
2558 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2562 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2567 for (i=2; i < items; i+=2)
2569 attribute=(char *) SvPV(ST(i-1),na);
2575 if (LocaleCompare(attribute,"stack") == 0)
2577 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2581 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2587 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2593 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2599 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2600 if (image == (Image *) NULL)
2602 for ( ; image; image=image->next)
2604 AddImageToRegistry(sv,image);
2606 av_push(av,sv_bless(rv,hv));
2609 exception=DestroyExceptionInfo(exception);
2611 SvREFCNT_dec(perl_exception);
2615 InheritPerlException(exception,perl_exception);
2616 exception=DestroyExceptionInfo(exception);
2617 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2618 SvPOK_on(perl_exception);
2619 ST(0)=sv_2mortal(perl_exception);
2624 ###############################################################################
2632 ###############################################################################
2637 Image::Magick ref=NO_INIT
2668 PERL_UNUSED_VAR(ref);
2669 PERL_UNUSED_VAR(ix);
2670 exception=AcquireExceptionInfo();
2671 perl_exception=newSVpv("",0);
2673 if (sv_isobject(ST(0)) == 0)
2675 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2679 reference=SvRV(ST(0));
2680 hv=SvSTASH(reference);
2681 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2682 if (image == (Image *) NULL)
2684 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2688 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2689 if (image == (Image *) NULL)
2692 Create blessed Perl array for the returned image.
2695 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2697 AddImageToRegistry(sv,image);
2699 av_push(av,sv_bless(rv,hv));
2701 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2702 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2703 "average-%.*s",(int) (MagickPathExtent-9),
2704 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2705 (void) CopyMagickString(image->filename,info->image_info->filename,
2707 SetImageInfo(info->image_info,0,exception);
2708 exception=DestroyExceptionInfo(exception);
2709 SvREFCNT_dec(perl_exception);
2713 InheritPerlException(exception,perl_exception);
2714 exception=DestroyExceptionInfo(exception);
2715 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2716 SvPOK_on(perl_exception);
2717 ST(0)=sv_2mortal(perl_exception);
2722 ###############################################################################
2726 # B l o b T o I m a g e #
2730 ###############################################################################
2734 BlobToImage(ref,...)
2735 Image::Magick ref=NO_INIT
2781 PERL_UNUSED_VAR(ref);
2782 PERL_UNUSED_VAR(ix);
2783 exception=AcquireExceptionInfo();
2784 perl_exception=newSVpv("",0);
2787 ac=(items < 2) ? 1 : items-1;
2788 length=(STRLEN *) NULL;
2789 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2790 if (list == (char **) NULL)
2792 ThrowPerlException(exception,ResourceLimitError,
2793 "MemoryAllocationFailed",PackageName);
2796 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2797 if (length == (STRLEN *) NULL)
2799 ThrowPerlException(exception,ResourceLimitError,
2800 "MemoryAllocationFailed",PackageName);
2803 if (sv_isobject(ST(0)) == 0)
2805 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2809 reference=SvRV(ST(0));
2810 hv=SvSTASH(reference);
2811 if (SvTYPE(reference) != SVt_PVAV)
2813 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2817 av=(AV *) reference;
2818 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2823 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2826 for (n=0, i=0; i < ac; i++)
2828 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2829 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2831 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2836 list[n]=(char *) NULL;
2838 for (i=number_images=0; i < n; i++)
2840 image=BlobToImage(info->image_info,list[i],length[i],exception);
2841 if (image == (Image *) NULL)
2843 for ( ; image; image=image->next)
2845 AddImageToRegistry(sv,image);
2847 av_push(av,sv_bless(rv,hv));
2855 for (i=0; i < n; i++)
2856 if (list[i] != (char *) NULL)
2857 for (p=keep; list[i] != *p++; )
2858 if (*p == (char *) NULL)
2860 list[i]=(char *) RelinquishMagickMemory(list[i]);
2866 list=(char **) RelinquishMagickMemory(list);
2868 length=(STRLEN *) RelinquishMagickMemory(length);
2869 InheritPerlException(exception,perl_exception);
2870 exception=DestroyExceptionInfo(exception);
2871 sv_setiv(perl_exception,(IV) number_images);
2872 SvPOK_on(perl_exception);
2873 ST(0)=sv_2mortal(perl_exception);
2878 ###############################################################################
2882 # C h a n n e l F x #
2886 ###############################################################################
2891 Image::Magick ref=NO_INIT
2903 expression[MagickPathExtent];
2931 PERL_UNUSED_VAR(ref);
2932 PERL_UNUSED_VAR(ix);
2933 exception=AcquireExceptionInfo();
2934 perl_exception=newSVpv("",0);
2938 if (sv_isobject(ST(0)) == 0)
2940 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2944 reference=SvRV(ST(0));
2945 hv=SvSTASH(reference);
2947 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2949 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2950 if (image == (Image *) NULL)
2952 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2956 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2960 channel=DefaultChannels;
2961 (void) CopyMagickString(expression,"u",MagickPathExtent);
2963 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2965 for (i=2; i < items; i+=2)
2967 attribute=(char *) SvPV(ST(i-1),na);
2973 if (LocaleCompare(attribute,"channel") == 0)
2978 option=ParseChannelOption(SvPV(ST(i),na));
2981 ThrowPerlException(exception,OptionError,
2982 "UnrecognizedType",SvPV(ST(i),na));
2985 channel=(ChannelType) option;
2988 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2995 if (LocaleCompare(attribute,"expression") == 0)
2997 (void) CopyMagickString(expression,SvPV(ST(i),na),
3001 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3007 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3013 channel_mask=SetImageChannelMask(image,channel);
3014 image=ChannelFxImage(image,expression,exception);
3015 if (image != (Image *) NULL)
3016 (void) SetImageChannelMask(image,channel_mask);
3017 if (image == (Image *) NULL)
3019 for ( ; image; image=image->next)
3021 AddImageToRegistry(sv,image);
3023 av_push(av,sv_bless(rv,hv));
3026 exception=DestroyExceptionInfo(exception);
3028 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3032 InheritPerlException(exception,perl_exception);
3033 exception=DestroyExceptionInfo(exception);
3034 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3035 SvPOK_on(perl_exception);
3036 ST(0)=sv_2mortal(perl_exception);
3041 ###############################################################################
3049 ###############################################################################
3054 Image::Magick ref=NO_INIT
3087 PERL_UNUSED_VAR(ref);
3088 PERL_UNUSED_VAR(ix);
3089 exception=AcquireExceptionInfo();
3090 perl_exception=newSVpv("",0);
3092 if (sv_isobject(ST(0)) == 0)
3094 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3098 reference=SvRV(ST(0));
3099 hv=SvSTASH(reference);
3100 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3101 if (image == (Image *) NULL)
3103 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3108 Create blessed Perl array for the returned image.
3111 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3113 for ( ; image; image=image->next)
3115 clone=CloneImage(image,0,0,MagickTrue,exception);
3116 if (clone == (Image *) NULL)
3118 AddImageToRegistry(sv,clone);
3120 av_push(av,sv_bless(rv,hv));
3123 exception=DestroyExceptionInfo(exception);
3124 SvREFCNT_dec(perl_exception);
3128 InheritPerlException(exception,perl_exception);
3129 exception=DestroyExceptionInfo(exception);
3130 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3131 SvPOK_on(perl_exception);
3132 ST(0)=sv_2mortal(perl_exception);
3137 ###############################################################################
3145 ###############################################################################
3153 PERL_UNUSED_VAR(ref);
3154 if (magick_registry != (SplayTreeInfo *) NULL)
3159 ResetSplayTreeIterator(magick_registry);
3160 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3161 while (p != (Image *) NULL)
3164 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3170 ###############################################################################
3178 ###############################################################################
3183 Image::Magick ref=NO_INIT
3212 PERL_UNUSED_VAR(ref);
3213 PERL_UNUSED_VAR(ix);
3214 exception=AcquireExceptionInfo();
3215 perl_exception=newSVpv("",0);
3217 if (sv_isobject(ST(0)) == 0)
3219 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3223 reference=SvRV(ST(0));
3224 hv=SvSTASH(reference);
3226 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3228 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3229 if (image == (Image *) NULL)
3231 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3235 image=CoalesceImages(image,exception);
3236 if (image == (Image *) NULL)
3238 for ( ; image; image=image->next)
3240 AddImageToRegistry(sv,image);
3242 av_push(av,sv_bless(rv,hv));
3245 exception=DestroyExceptionInfo(exception);
3247 SvREFCNT_dec(perl_exception);
3251 InheritPerlException(exception,perl_exception);
3252 exception=DestroyExceptionInfo(exception);
3253 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3254 SvPOK_on(perl_exception);
3255 ST(0)=sv_2mortal(perl_exception);
3260 ###############################################################################
3268 ###############################################################################
3273 Image::Magick ref=NO_INIT
3319 PERL_UNUSED_VAR(ref);
3320 PERL_UNUSED_VAR(ix);
3321 exception=AcquireExceptionInfo();
3322 perl_exception=newSVpv("",0);
3326 if (sv_isobject(ST(0)) == 0)
3328 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3332 reference=SvRV(ST(0));
3333 hv=SvSTASH(reference);
3335 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3337 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3338 if (image == (Image *) NULL)
3340 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3344 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3348 reconstruct_image=image;
3349 metric=RootMeanSquaredErrorMetric;
3350 for (i=2; i < items; i+=2)
3352 attribute=(char *) SvPV(ST(i-1),na);
3358 if (LocaleCompare(attribute,"channel") == 0)
3363 option=ParseChannelOption(SvPV(ST(i),na));
3366 ThrowPerlException(exception,OptionError,
3367 "UnrecognizedType",SvPV(ST(i),na));
3370 (void) SetPixelChannelMask(image,(ChannelType) option);
3373 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3380 if (LocaleCompare(attribute,"fuzz") == 0)
3382 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3392 if (LocaleCompare(attribute,"image") == 0)
3394 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3395 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3398 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3405 if (LocaleCompare(attribute,"metric") == 0)
3407 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3411 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3415 metric=(MetricType) option;
3418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3424 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3430 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3432 if (difference_image != (Image *) NULL)
3434 difference_image->error.mean_error_per_pixel=distortion;
3435 AddImageToRegistry(sv,difference_image);
3437 av_push(av,sv_bless(rv,hv));
3440 exception=DestroyExceptionInfo(exception);
3442 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3446 InheritPerlException(exception,perl_exception);
3447 exception=DestroyExceptionInfo(exception);
3448 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3449 SvPOK_on(perl_exception);
3450 ST(0)=sv_2mortal(perl_exception);
3455 ###############################################################################
3459 # C o m p l e x I m a g e s #
3463 ###############################################################################
3468 Image::Magick ref=NO_INIT
3505 PERL_UNUSED_VAR(ref);
3506 PERL_UNUSED_VAR(ix);
3507 exception=AcquireExceptionInfo();
3508 perl_exception=newSVpv("",0);
3510 if (sv_isobject(ST(0)) == 0)
3512 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3516 reference=SvRV(ST(0));
3517 hv=SvSTASH(reference);
3518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3519 if (image == (Image *) NULL)
3521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3525 op=UndefinedComplexOperator;
3531 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3535 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3539 op=(ComplexOperator) in;
3542 for (i=2; i < items; i+=2)
3544 attribute=(char *) SvPV(ST(i-1),na);
3550 if (LocaleCompare(attribute,"operator") == 0)
3555 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3556 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3559 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3563 op=(ComplexOperator) in;
3566 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3572 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3578 image=ComplexImages(image,op,exception);
3579 if (image == (Image *) NULL)
3582 Create blessed Perl array for the returned image.
3585 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3587 AddImageToRegistry(sv,image);
3589 av_push(av,sv_bless(rv,hv));
3591 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3592 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3593 "complex-%.*s",(int) (MagickPathExtent-9),
3594 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3595 (void) CopyMagickString(image->filename,info->image_info->filename,
3597 SetImageInfo(info->image_info,0,exception);
3598 exception=DestroyExceptionInfo(exception);
3599 SvREFCNT_dec(perl_exception);
3603 InheritPerlException(exception,perl_exception);
3604 exception=DestroyExceptionInfo(exception);
3605 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3606 SvPOK_on(perl_exception);
3607 ST(0)=sv_2mortal(perl_exception);
3612 ###############################################################################
3616 # C o m p a r e L a y e r s #
3620 ###############################################################################
3625 Image::Magick ref=NO_INIT
3627 CompareImagesLayers = 1
3629 compareimagelayers = 3
3666 PERL_UNUSED_VAR(ref);
3667 PERL_UNUSED_VAR(ix);
3668 exception=AcquireExceptionInfo();
3669 perl_exception=newSVpv("",0);
3671 if (sv_isobject(ST(0)) == 0)
3673 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3677 reference=SvRV(ST(0));
3678 hv=SvSTASH(reference);
3680 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3682 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3683 if (image == (Image *) NULL)
3685 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3689 method=CompareAnyLayer;
3690 for (i=2; i < items; i+=2)
3692 attribute=(char *) SvPV(ST(i-1),na);
3698 if (LocaleCompare(attribute,"method") == 0)
3700 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3704 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3708 method=(LayerMethod) option;
3711 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3717 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3723 image=CompareImagesLayers(image,method,exception);
3724 if (image == (Image *) NULL)
3726 for ( ; image; image=image->next)
3728 AddImageToRegistry(sv,image);
3730 av_push(av,sv_bless(rv,hv));
3733 exception=DestroyExceptionInfo(exception);
3735 SvREFCNT_dec(perl_exception);
3739 InheritPerlException(exception,perl_exception);
3740 exception=DestroyExceptionInfo(exception);
3741 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3742 SvPOK_on(perl_exception);
3743 ST(0)=sv_2mortal(perl_exception);
3748 ###############################################################################
3756 ###############################################################################
3761 Image::Magick ref=NO_INIT
3767 PERL_UNUSED_VAR(ref);
3768 if (sv_isobject(ST(0)) == 0)
3769 croak("ReferenceIsNotMyType");
3770 reference=SvRV(ST(0));
3771 switch (SvTYPE(reference))
3776 message[MagickPathExtent];
3794 Array (AV *) reference
3796 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3797 XS_VERSION,reference);
3798 hv=gv_stashpv(PackageName, FALSE);
3801 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3805 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3807 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3808 DestroyPackageInfo(info);
3810 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3820 Blessed scalar = (Image *) SvIV(reference)
3822 image=INT2PTR(Image *,SvIV(reference));
3823 if (image != (Image *) NULL)
3824 DeleteImageFromRegistry(reference,image);
3833 ###############################################################################
3841 ###############################################################################
3846 Image::Magick ref=NO_INIT
3870 PERL_UNUSED_VAR(ref);
3871 PERL_UNUSED_VAR(ix);
3872 exception=AcquireExceptionInfo();
3873 perl_exception=newSVpv("",0);
3874 package_info=(struct PackageInfo *) NULL;
3875 if (sv_isobject(ST(0)) == 0)
3877 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3881 reference=SvRV(ST(0));
3882 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3883 if (image == (Image *) NULL)
3885 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3889 package_info=ClonePackageInfo(info,exception);
3891 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3894 for (i=2; i < items; i+=2)
3895 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3897 (void) DisplayImages(package_info->image_info,image,exception);
3898 (void) CatchImageException(image);
3901 if (package_info != (struct PackageInfo *) NULL)
3902 DestroyPackageInfo(package_info);
3903 InheritPerlException(exception,perl_exception);
3904 exception=DestroyExceptionInfo(exception);
3905 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3906 SvPOK_on(perl_exception);
3907 ST(0)=sv_2mortal(perl_exception);
3912 ###############################################################################
3916 # E v a l u a t e I m a g e s #
3920 ###############################################################################
3925 Image::Magick ref=NO_INIT
3947 MagickEvaluateOperator
3962 PERL_UNUSED_VAR(ref);
3963 PERL_UNUSED_VAR(ix);
3964 exception=AcquireExceptionInfo();
3965 perl_exception=newSVpv("",0);
3967 if (sv_isobject(ST(0)) == 0)
3969 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3973 reference=SvRV(ST(0));
3974 hv=SvSTASH(reference);
3975 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3976 if (image == (Image *) NULL)
3978 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3982 op=MeanEvaluateOperator;
3988 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3992 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3996 op=(MagickEvaluateOperator) in;
3999 for (i=2; i < items; i+=2)
4001 attribute=(char *) SvPV(ST(i-1),na);
4007 if (LocaleCompare(attribute,"operator") == 0)
4012 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4013 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4016 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4020 op=(MagickEvaluateOperator) in;
4023 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4029 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4035 image=EvaluateImages(image,op,exception);
4036 if (image == (Image *) NULL)
4039 Create blessed Perl array for the returned image.
4042 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4044 AddImageToRegistry(sv,image);
4046 av_push(av,sv_bless(rv,hv));
4048 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4049 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4050 "evaluate-%.*s",(int) (MagickPathExtent-9),
4051 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4052 (void) CopyMagickString(image->filename,info->image_info->filename,
4054 SetImageInfo(info->image_info,0,exception);
4055 exception=DestroyExceptionInfo(exception);
4056 SvREFCNT_dec(perl_exception);
4060 InheritPerlException(exception,perl_exception);
4061 exception=DestroyExceptionInfo(exception);
4062 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4063 SvPOK_on(perl_exception);
4064 ST(0)=sv_2mortal(perl_exception);
4069 ###############################################################################
4077 ###############################################################################
4082 Image::Magick ref=NO_INIT
4089 #define ChannelFeatures(channel,direction) \
4091 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4092 channel_features[channel].angular_second_moment[direction]); \
4093 PUSHs(sv_2mortal(newSVpv(message,0))); \
4094 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4095 channel_features[channel].contrast[direction]); \
4096 PUSHs(sv_2mortal(newSVpv(message,0))); \
4097 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4098 channel_features[channel].contrast[direction]); \
4099 PUSHs(sv_2mortal(newSVpv(message,0))); \
4100 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4101 channel_features[channel].variance_sum_of_squares[direction]); \
4102 PUSHs(sv_2mortal(newSVpv(message,0))); \
4103 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4104 channel_features[channel].inverse_difference_moment[direction]); \
4105 PUSHs(sv_2mortal(newSVpv(message,0))); \
4106 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4107 channel_features[channel].sum_average[direction]); \
4108 PUSHs(sv_2mortal(newSVpv(message,0))); \
4109 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4110 channel_features[channel].sum_variance[direction]); \
4111 PUSHs(sv_2mortal(newSVpv(message,0))); \
4112 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4113 channel_features[channel].sum_entropy[direction]); \
4114 PUSHs(sv_2mortal(newSVpv(message,0))); \
4115 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4116 channel_features[channel].entropy[direction]); \
4117 PUSHs(sv_2mortal(newSVpv(message,0))); \
4118 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4119 channel_features[channel].difference_variance[direction]); \
4120 PUSHs(sv_2mortal(newSVpv(message,0))); \
4121 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4122 channel_features[channel].difference_entropy[direction]); \
4123 PUSHs(sv_2mortal(newSVpv(message,0))); \
4124 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4125 channel_features[channel].measure_of_correlation_1[direction]); \
4126 PUSHs(sv_2mortal(newSVpv(message,0))); \
4127 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4128 channel_features[channel].measure_of_correlation_2[direction]); \
4129 PUSHs(sv_2mortal(newSVpv(message,0))); \
4130 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4131 channel_features[channel].maximum_correlation_coefficient[direction]); \
4132 PUSHs(sv_2mortal(newSVpv(message,0))); \
4140 message[MagickPathExtent];
4167 PERL_UNUSED_VAR(ref);
4168 PERL_UNUSED_VAR(ix);
4169 exception=AcquireExceptionInfo();
4170 perl_exception=newSVpv("",0);
4172 if (sv_isobject(ST(0)) == 0)
4174 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4178 reference=SvRV(ST(0));
4181 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4182 if (image == (Image *) NULL)
4184 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4189 for (i=2; i < items; i+=2)
4191 attribute=(char *) SvPV(ST(i-1),na);
4197 if (LocaleCompare(attribute,"distance") == 0)
4199 distance=StringToLong((char *) SvPV(ST(1),na));
4202 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4208 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4215 for ( ; image; image=image->next)
4217 channel_features=GetImageFeatures(image,distance,exception);
4218 if (channel_features == (ChannelFeatures *) NULL)
4221 EXTEND(sp,280*count);
4222 for (i=0; i < 4; i++)
4224 ChannelFeatures(RedChannel,i);
4225 ChannelFeatures(GreenChannel,i);
4226 ChannelFeatures(BlueChannel,i);
4227 if (image->colorspace == CMYKColorspace)
4228 ChannelFeatures(BlackChannel,i);
4229 if (image->alpha_trait != UndefinedPixelTrait)
4230 ChannelFeatures(AlphaChannel,i);
4232 channel_features=(ChannelFeatures *)
4233 RelinquishMagickMemory(channel_features);
4237 InheritPerlException(exception,perl_exception);
4238 exception=DestroyExceptionInfo(exception);
4239 SvREFCNT_dec(perl_exception);
4243 ###############################################################################
4251 ###############################################################################
4256 Image::Magick ref=NO_INIT
4294 PERL_UNUSED_VAR(ref);
4295 PERL_UNUSED_VAR(ix);
4296 exception=AcquireExceptionInfo();
4297 perl_exception=newSVpv("",0);
4299 if (sv_isobject(ST(0)) == 0)
4301 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4305 reference=SvRV(ST(0));
4306 hv=SvSTASH(reference);
4307 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4308 if (image == (Image *) NULL)
4310 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4314 background_color=image->background_color;
4316 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4317 &background_color,exception);
4319 for (i=2; i < items; i+=2)
4321 attribute=(char *) SvPV(ST(i-1),na);
4327 if (LocaleCompare(attribute,"background") == 0)
4329 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4330 AllCompliance,&background_color,exception);
4333 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4339 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4345 image->background_color=background_color;
4346 image=MergeImageLayers(image,FlattenLayer,exception);
4347 if (image == (Image *) NULL)
4350 Create blessed Perl array for the returned image.
4353 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4355 AddImageToRegistry(sv,image);
4357 av_push(av,sv_bless(rv,hv));
4359 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4360 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4361 "flatten-%.*s",(int) (MagickPathExtent-9),
4362 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4363 (void) CopyMagickString(image->filename,info->image_info->filename,
4365 SetImageInfo(info->image_info,0,exception);
4366 exception=DestroyExceptionInfo(exception);
4367 SvREFCNT_dec(perl_exception);
4371 InheritPerlException(exception,perl_exception);
4372 exception=DestroyExceptionInfo(exception);
4373 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4374 SvPOK_on(perl_exception); /* return messages in string context */
4375 ST(0)=sv_2mortal(perl_exception);
4380 ###############################################################################
4388 ###############################################################################
4393 Image::Magick ref=NO_INIT
4405 expression[MagickPathExtent];
4433 PERL_UNUSED_VAR(ref);
4434 PERL_UNUSED_VAR(ix);
4435 exception=AcquireExceptionInfo();
4436 perl_exception=newSVpv("",0);
4440 if (sv_isobject(ST(0)) == 0)
4442 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4446 reference=SvRV(ST(0));
4447 hv=SvSTASH(reference);
4449 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4451 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4452 if (image == (Image *) NULL)
4454 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4458 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4462 channel=DefaultChannels;
4463 (void) CopyMagickString(expression,"u",MagickPathExtent);
4465 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4467 for (i=2; i < items; i+=2)
4469 attribute=(char *) SvPV(ST(i-1),na);
4475 if (LocaleCompare(attribute,"channel") == 0)
4480 option=ParseChannelOption(SvPV(ST(i),na));
4483 ThrowPerlException(exception,OptionError,
4484 "UnrecognizedType",SvPV(ST(i),na));
4487 channel=(ChannelType) option;
4490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4497 if (LocaleCompare(attribute,"expression") == 0)
4499 (void) CopyMagickString(expression,SvPV(ST(i),na),
4503 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4509 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4515 channel_mask=SetImageChannelMask(image,channel);
4516 image=FxImage(image,expression,exception);
4517 if (image != (Image *) NULL)
4518 (void) SetImageChannelMask(image,channel_mask);
4519 if (image == (Image *) NULL)
4521 for ( ; image; image=image->next)
4523 AddImageToRegistry(sv,image);
4525 av_push(av,sv_bless(rv,hv));
4528 exception=DestroyExceptionInfo(exception);
4530 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4534 InheritPerlException(exception,perl_exception);
4535 exception=DestroyExceptionInfo(exception);
4536 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4537 SvPOK_on(perl_exception);
4538 ST(0)=sv_2mortal(perl_exception);
4543 ###############################################################################
4551 ###############################################################################
4556 Image::Magick ref=NO_INIT
4567 color[MagickPathExtent];
4592 PERL_UNUSED_VAR(ref);
4593 PERL_UNUSED_VAR(ix);
4594 exception=AcquireExceptionInfo();
4595 perl_exception=newSVpv("",0);
4596 if (sv_isobject(ST(0)) == 0)
4598 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4602 reference=SvRV(ST(0));
4603 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4604 if (image == (Image *) NULL && !info)
4607 for (i=1; i < items; i++)
4609 attribute=(char *) SvPV(ST(i),na);
4616 if (LocaleCompare(attribute,"adjoin") == 0)
4619 s=newSViv((ssize_t) info->image_info->adjoin);
4620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4623 if (LocaleCompare(attribute,"antialias") == 0)
4626 s=newSViv((ssize_t) info->image_info->antialias);
4627 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4630 if (LocaleCompare(attribute,"area") == 0)
4632 s=newSViv(GetMagickResource(AreaResource));
4633 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4636 if (LocaleCompare(attribute,"attenuate") == 0)
4641 value=GetImageProperty(image,attribute,exception);
4642 if (value != (const char *) NULL)
4644 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4647 if (LocaleCompare(attribute,"authenticate") == 0)
4654 option=GetImageOption(info->image_info,attribute);
4655 if (option != (const char *) NULL)
4656 s=newSVpv(option,0);
4658 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4661 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4668 if (LocaleCompare(attribute,"background") == 0)
4670 if (image == (Image *) NULL)
4672 (void) FormatLocaleString(color,MagickPathExtent,
4673 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4674 (double) image->background_color.green,
4675 (double) image->background_color.blue,
4676 (double) image->background_color.alpha);
4678 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4681 if (LocaleCompare(attribute,"base-columns") == 0)
4683 if (image != (Image *) NULL)
4684 s=newSViv((ssize_t) image->magick_columns);
4685 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4688 if (LocaleCompare(attribute,"base-filename") == 0)
4690 if (image != (Image *) NULL)
4691 s=newSVpv(image->magick_filename,0);
4692 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4695 if (LocaleCompare(attribute,"base-height") == 0)
4697 if (image != (Image *) NULL)
4698 s=newSViv((ssize_t) image->magick_rows);
4699 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4702 if (LocaleCompare(attribute,"base-rows") == 0)
4704 if (image != (Image *) NULL)
4705 s=newSViv((ssize_t) image->magick_rows);
4706 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4709 if (LocaleCompare(attribute,"base-width") == 0)
4711 if (image != (Image *) NULL)
4712 s=newSViv((ssize_t) image->magick_columns);
4713 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4716 if (LocaleCompare(attribute,"blue-primary") == 0)
4718 if (image == (Image *) NULL)
4720 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4721 image->chromaticity.blue_primary.x,
4722 image->chromaticity.blue_primary.y);
4724 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4727 if (LocaleCompare(attribute,"bordercolor") == 0)
4729 if (image == (Image *) NULL)
4731 (void) FormatLocaleString(color,MagickPathExtent,
4732 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4733 (double) image->border_color.green,
4734 (double) image->border_color.blue,
4735 (double) image->border_color.alpha);
4737 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4740 if (LocaleCompare(attribute,"bounding-box") == 0)
4743 geometry[MagickPathExtent];
4748 if (image == (Image *) NULL)
4750 page=GetImageBoundingBox(image,exception);
4751 (void) FormatLocaleString(geometry,MagickPathExtent,
4752 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4753 page.height,(double) page.x,(double) page.y);
4754 s=newSVpv(geometry,0);
4755 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4758 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4765 if (LocaleCompare(attribute,"class") == 0)
4767 if (image == (Image *) NULL)
4769 s=newSViv(image->storage_class);
4770 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4771 image->storage_class));
4773 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4776 if (LocaleCompare(attribute,"clip-mask") == 0)
4778 if (image != (Image *) NULL)
4787 if (image->read_mask == MagickFalse)
4788 ClipImage(image,exception);
4789 mask_image=GetImageMask(image,ReadPixelMask,exception);
4790 if (mask_image != (Image *) NULL)
4792 AddImageToRegistry(sv,mask_image);
4793 s=sv_bless(newRV(sv),SvSTASH(reference));
4796 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4799 if (LocaleCompare(attribute,"clip-path") == 0)
4801 if (image != (Image *) NULL)
4810 if (image->read_mask != MagickFalse)
4811 ClipImage(image,exception);
4812 mask_image=GetImageMask(image,ReadPixelMask,exception);
4813 if (mask_image != (Image *) NULL)
4815 AddImageToRegistry(sv,mask_image);
4816 s=sv_bless(newRV(sv),SvSTASH(reference));
4819 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4822 if (LocaleCompare(attribute,"compression") == 0)
4824 j=info ? info->image_info->compression : image ?
4825 image->compression : UndefinedCompression;
4827 if (info->image_info->compression == UndefinedCompression)
4828 j=image->compression;
4830 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4833 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4836 if (LocaleCompare(attribute,"colorspace") == 0)
4838 j=image ? image->colorspace : RGBColorspace;
4840 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4843 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4846 if (LocaleCompare(attribute,"colors") == 0)
4848 if (image != (Image *) NULL)
4849 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4851 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4854 if (LocaleNCompare(attribute,"colormap",8) == 0)
4859 if (image == (Image *) NULL || !image->colormap)
4862 items=sscanf(attribute,"%*[^[][%ld",&j);
4864 if (j > (ssize_t) image->colors)
4866 (void) FormatLocaleString(color,MagickPathExtent,
4867 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4868 (double) image->colormap[j].green,
4869 (double) image->colormap[j].blue,
4870 (double) image->colormap[j].alpha);
4872 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4875 if (LocaleCompare(attribute,"columns") == 0)
4877 if (image != (Image *) NULL)
4878 s=newSViv((ssize_t) image->columns);
4879 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4882 if (LocaleCompare(attribute,"comment") == 0)
4887 value=GetImageProperty(image,attribute,exception);
4888 if (value != (const char *) NULL)
4890 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4893 if (LocaleCompare(attribute,"copyright") == 0)
4895 s=newSVpv(GetMagickCopyright(),0);
4896 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4906 if (LocaleCompare(attribute,"density") == 0)
4909 geometry[MagickPathExtent];
4911 if (image == (Image *) NULL)
4913 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4914 image->resolution.x,image->resolution.y);
4915 s=newSVpv(geometry,0);
4916 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4919 if (LocaleCompare(attribute,"delay") == 0)
4921 if (image != (Image *) NULL)
4922 s=newSViv((ssize_t) image->delay);
4923 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4926 if (LocaleCompare(attribute,"depth") == 0)
4928 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4929 if (image != (Image *) NULL)
4930 s=newSViv((ssize_t) GetImageDepth(image,exception));
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 if (LocaleCompare(attribute,"directory") == 0)
4936 if (image && image->directory)
4937 s=newSVpv(image->directory,0);
4938 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4941 if (LocaleCompare(attribute,"dispose") == 0)
4943 if (image == (Image *) NULL)
4946 s=newSViv(image->dispose);
4948 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4950 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4953 if (LocaleCompare(attribute,"disk") == 0)
4955 s=newSViv(GetMagickResource(DiskResource));
4956 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4959 if (LocaleCompare(attribute,"dither") == 0)
4962 s=newSViv((ssize_t) info->image_info->dither);
4963 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4966 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4968 if (info && info->image_info->server_name)
4969 s=newSVpv(info->image_info->server_name,0);
4970 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4973 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4980 if (LocaleCompare(attribute,"elapsed-time") == 0)
4982 if (image != (Image *) NULL)
4983 s=newSVnv(GetElapsedTime(&image->timer));
4984 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4987 if (LocaleCompare(attribute,"endian") == 0)
4989 j=info ? info->image_info->endian : image ? image->endian :
4992 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4994 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4997 if (LocaleCompare(attribute,"error") == 0)
4999 if (image != (Image *) NULL)
5000 s=newSVnv(image->error.mean_error_per_pixel);
5001 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5004 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5011 if (LocaleCompare(attribute,"filesize") == 0)
5013 if (image != (Image *) NULL)
5014 s=newSViv((ssize_t) GetBlobSize(image));
5015 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5018 if (LocaleCompare(attribute,"filename") == 0)
5020 if (info && info->image_info->filename &&
5021 *info->image_info->filename)
5022 s=newSVpv(info->image_info->filename,0);
5023 if (image != (Image *) NULL)
5024 s=newSVpv(image->filename,0);
5025 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5028 if (LocaleCompare(attribute,"filter") == 0)
5030 s=image ? newSViv(image->filter) : newSViv(0);
5031 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5034 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5037 if (LocaleCompare(attribute,"font") == 0)
5039 if (info && info->image_info->font)
5040 s=newSVpv(info->image_info->font,0);
5041 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5044 if (LocaleCompare(attribute,"foreground") == 0)
5046 if (LocaleCompare(attribute,"format") == 0)
5051 magick_info=(const MagickInfo *) NULL;
5052 if (info && (*info->image_info->magick != '\0'))
5053 magick_info=GetMagickInfo(info->image_info->magick,exception);
5054 if (image != (Image *) NULL)
5055 magick_info=GetMagickInfo(image->magick,exception);
5056 if ((magick_info != (const MagickInfo *) NULL) &&
5057 (*magick_info->description != '\0'))
5058 s=newSVpv((char *) magick_info->description,0);
5059 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5062 if (LocaleCompare(attribute,"fuzz") == 0)
5065 s=newSVnv(info->image_info->fuzz);
5066 if (image != (Image *) NULL)
5067 s=newSVnv(image->fuzz);
5068 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5071 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5078 if (LocaleCompare(attribute,"gamma") == 0)
5080 if (image != (Image *) NULL)
5081 s=newSVnv(image->gamma);
5082 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5085 if (LocaleCompare(attribute,"geometry") == 0)
5087 if (image && image->geometry)
5088 s=newSVpv(image->geometry,0);
5089 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5092 if (LocaleCompare(attribute,"gravity") == 0)
5094 s=image ? newSViv(image->gravity) : newSViv(0);
5095 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5098 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5101 if (LocaleCompare(attribute,"green-primary") == 0)
5103 if (image == (Image *) NULL)
5105 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5106 image->chromaticity.green_primary.x,
5107 image->chromaticity.green_primary.y);
5109 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5112 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5119 if (LocaleCompare(attribute,"height") == 0)
5121 if (image != (Image *) NULL)
5122 s=newSViv((ssize_t) image->rows);
5123 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5126 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5133 if (LocaleCompare(attribute,"icc") == 0)
5135 if (image != (Image *) NULL)
5140 profile=GetImageProfile(image,"icc");
5141 if (profile != (StringInfo *) NULL)
5142 s=newSVpv((const char *) GetStringInfoDatum(profile),
5143 GetStringInfoLength(profile));
5145 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5148 if (LocaleCompare(attribute,"icm") == 0)
5150 if (image != (Image *) NULL)
5155 profile=GetImageProfile(image,"icm");
5156 if (profile != (const StringInfo *) NULL)
5157 s=newSVpv((const char *) GetStringInfoDatum(profile),
5158 GetStringInfoLength(profile));
5160 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5163 if (LocaleCompare(attribute,"id") == 0)
5165 if (image != (Image *) NULL)
5168 key[MagickPathExtent];
5176 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5178 status=SetImageRegistry(ImageRegistryType,key,image,
5183 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5186 if (LocaleNCompare(attribute,"index",5) == 0)
5189 name[MagickPathExtent];
5198 register const Quantum
5204 if (image == (Image *) NULL)
5206 if (image->storage_class != PseudoClass)
5210 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5212 image_view=AcquireVirtualCacheView(image,exception);
5213 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5214 if (p != (const Quantum *) NULL)
5216 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5217 GetPixelIndex(image,p));
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5221 image_view=DestroyCacheView(image_view);
5224 if (LocaleCompare(attribute,"iptc") == 0)
5226 if (image != (Image *) NULL)
5231 profile=GetImageProfile(image,"iptc");
5232 if (profile != (const StringInfo *) NULL)
5233 s=newSVpv((const char *) GetStringInfoDatum(profile),
5234 GetStringInfoLength(profile));
5236 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5239 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5241 if (image != (Image *) NULL)
5242 s=newSViv((ssize_t) image->iterations);
5243 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5246 if (LocaleCompare(attribute,"interlace") == 0)
5248 j=info ? info->image_info->interlace : image ? image->interlace :
5251 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5254 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5257 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5264 if (LocaleCompare(attribute,"label") == 0)
5269 if (image == (Image *) NULL)
5271 value=GetImageProperty(image,"Label",exception);
5272 if (value != (const char *) NULL)
5274 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5277 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5279 if (image != (Image *) NULL)
5280 s=newSViv((ssize_t) image->iterations);
5281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5284 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5291 if (LocaleCompare(attribute,"magick") == 0)
5293 if (info && *info->image_info->magick)
5294 s=newSVpv(info->image_info->magick,0);
5295 if (image != (Image *) NULL)
5296 s=newSVpv(image->magick,0);
5297 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5300 if (LocaleCompare(attribute,"map") == 0)
5302 s=newSViv(GetMagickResource(MapResource));
5303 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5306 if (LocaleCompare(attribute,"maximum-error") == 0)
5308 if (image != (Image *) NULL)
5309 s=newSVnv(image->error.normalized_maximum_error);
5310 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5313 if (LocaleCompare(attribute,"memory") == 0)
5315 s=newSViv(GetMagickResource(MemoryResource));
5316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5319 if (LocaleCompare(attribute,"mean-error") == 0)
5321 if (image != (Image *) NULL)
5322 s=newSVnv(image->error.normalized_mean_error);
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 if (LocaleCompare(attribute,"mime") == 0)
5328 if (info && *info->image_info->magick)
5329 s=newSVpv(MagickToMime(info->image_info->magick),0);
5330 if (image != (Image *) NULL)
5331 s=newSVpv(MagickToMime(image->magick),0);
5332 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5335 if (LocaleCompare(attribute,"mattecolor") == 0)
5337 if (image == (Image *) NULL)
5339 (void) FormatLocaleString(color,MagickPathExtent,
5340 "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red,
5341 (double) image->alpha_color.green,
5342 (double) image->alpha_color.blue,
5343 (double) image->alpha_color.alpha);
5345 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5348 if (LocaleCompare(attribute,"matte") == 0)
5350 if (image != (Image *) NULL)
5351 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5353 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5356 if (LocaleCompare(attribute,"mime") == 0)
5362 if (info && *info->image_info->magick)
5363 magick=info->image_info->magick;
5364 if (image != (Image *) NULL)
5365 magick=image->magick;
5371 mime=MagickToMime(magick);
5373 mime=(char *) RelinquishMagickMemory(mime);
5375 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5378 if (LocaleCompare(attribute,"monochrome") == 0)
5380 if (image == (Image *) NULL)
5382 j=info ? info->image_info->monochrome :
5383 SetImageMonochrome(image,exception);
5385 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5388 if (LocaleCompare(attribute,"montage") == 0)
5390 if (image && image->montage)
5391 s=newSVpv(image->montage,0);
5392 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5395 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5402 if (LocaleCompare(attribute,"orientation") == 0)
5404 j=info ? info->image_info->orientation : image ?
5405 image->orientation : UndefinedOrientation;
5407 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5410 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5413 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5420 if (LocaleCompare(attribute,"page") == 0)
5422 if (info && info->image_info->page)
5423 s=newSVpv(info->image_info->page,0);
5424 if (image != (Image *) NULL)
5427 geometry[MagickPathExtent];
5429 (void) FormatLocaleString(geometry,MagickPathExtent,
5430 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5431 (double) image->page.height,(double) image->page.x,(double)
5433 s=newSVpv(geometry,0);
5435 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5438 if (LocaleCompare(attribute,"page.x") == 0)
5440 if (image != (Image *) NULL)
5441 s=newSViv((ssize_t) image->page.x);
5442 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5445 if (LocaleCompare(attribute,"page.y") == 0)
5447 if (image != (Image *) NULL)
5448 s=newSViv((ssize_t) image->page.y);
5449 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5452 if (LocaleNCompare(attribute,"pixel",5) == 0)
5455 tuple[MagickPathExtent];
5464 register const Quantum
5467 if (image == (Image *) NULL)
5471 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5473 p=GetVirtualPixels(image,x,y,1,1,exception);
5474 if (image->colorspace != CMYKColorspace)
5475 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5476 QuantumFormat "," QuantumFormat "," QuantumFormat,
5477 GetPixelRed(image,p),GetPixelGreen(image,p),
5478 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5480 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5481 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5482 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5483 GetPixelBlue(image,p),GetPixelBlack(image,p),
5484 GetPixelAlpha(image,p));
5486 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5489 if (LocaleCompare(attribute,"pointsize") == 0)
5492 s=newSViv((ssize_t) info->image_info->pointsize);
5493 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5496 if (LocaleCompare(attribute,"preview") == 0)
5498 s=newSViv(info->image_info->preview_type);
5499 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5500 info->image_info->preview_type));
5502 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5512 if (LocaleCompare(attribute,"quality") == 0)
5515 s=newSViv((ssize_t) info->image_info->quality);
5516 if (image != (Image *) NULL)
5517 s=newSViv((ssize_t) image->quality);
5518 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5521 if (LocaleCompare(attribute,"quantum") == 0)
5524 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5525 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5528 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5535 if (LocaleCompare(attribute,"rendering-intent") == 0)
5537 s=newSViv(image->rendering_intent);
5538 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5539 image->rendering_intent));
5541 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5544 if (LocaleCompare(attribute,"red-primary") == 0)
5546 if (image == (Image *) NULL)
5548 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5549 image->chromaticity.red_primary.x,
5550 image->chromaticity.red_primary.y);
5552 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5555 if (LocaleCompare(attribute,"rows") == 0)
5557 if (image != (Image *) NULL)
5558 s=newSViv((ssize_t) image->rows);
5559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5569 if (LocaleCompare(attribute,"sampling-factor") == 0)
5571 if (info && info->image_info->sampling_factor)
5572 s=newSVpv(info->image_info->sampling_factor,0);
5573 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5576 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5578 if (info && info->image_info->server_name)
5579 s=newSVpv(info->image_info->server_name,0);
5580 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5583 if (LocaleCompare(attribute,"size") == 0)
5585 if (info && info->image_info->size)
5586 s=newSVpv(info->image_info->size,0);
5587 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5590 if (LocaleCompare(attribute,"scene") == 0)
5592 if (image != (Image *) NULL)
5593 s=newSViv((ssize_t) image->scene);
5594 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5597 if (LocaleCompare(attribute,"scenes") == 0)
5599 if (image != (Image *) NULL)
5600 s=newSViv((ssize_t) info->image_info->number_scenes);
5601 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5604 if (LocaleCompare(attribute,"signature") == 0)
5609 if (image == (Image *) NULL)
5611 (void) SignatureImage(image,exception);
5612 value=GetImageProperty(image,"Signature",exception);
5613 if (value != (const char *) NULL)
5615 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5618 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5625 if (LocaleCompare(attribute,"taint") == 0)
5627 if (image != (Image *) NULL)
5628 s=newSViv((ssize_t) IsTaintImage(image));
5629 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5632 if (LocaleCompare(attribute,"texture") == 0)
5634 if (info && info->image_info->texture)
5635 s=newSVpv(info->image_info->texture,0);
5636 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5639 if (LocaleCompare(attribute,"total-ink-density") == 0)
5641 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5642 if (image != (Image *) NULL)
5643 s=newSVnv(GetImageTotalInkDensity(image,exception));
5644 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5647 if (LocaleCompare(attribute,"transparent-color") == 0)
5649 if (image == (Image *) NULL)
5651 (void) FormatLocaleString(color,MagickPathExtent,
5652 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5653 (double) image->transparent_color.green,
5654 (double) image->transparent_color.blue,
5655 (double) image->transparent_color.alpha);
5657 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5660 if (LocaleCompare(attribute,"type") == 0)
5662 if (image == (Image *) NULL)
5664 j=(ssize_t) GetImageType(image);
5666 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5671 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5678 if (LocaleCompare(attribute,"units") == 0)
5680 j=info ? info->image_info->units : image ? image->units :
5681 UndefinedResolution;
5682 if (info && (info->image_info->units == UndefinedResolution))
5685 if (j == UndefinedResolution)
5686 s=newSVpv("undefined units",0);
5688 if (j == PixelsPerInchResolution)
5689 s=newSVpv("pixels / inch",0);
5691 s=newSVpv("pixels / centimeter",0);
5692 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5695 if (LocaleCompare(attribute,"user-time") == 0)
5697 if (image != (Image *) NULL)
5698 s=newSVnv(GetUserTime(&image->timer));
5699 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5709 if (LocaleCompare(attribute,"verbose") == 0)
5712 s=newSViv((ssize_t) info->image_info->verbose);
5713 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5716 if (LocaleCompare(attribute,"version") == 0)
5718 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5719 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5722 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5724 if (image == (Image *) NULL)
5726 j=(ssize_t) GetImageVirtualPixelMethod(image);
5728 (void) sv_setpv(s,CommandOptionToMnemonic(
5729 MagickVirtualPixelOptions,j));
5731 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5734 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5741 if (LocaleCompare(attribute,"white-point") == 0)
5743 if (image == (Image *) NULL)
5745 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5746 image->chromaticity.white_point.x,
5747 image->chromaticity.white_point.y);
5749 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5752 if (LocaleCompare(attribute,"width") == 0)
5754 if (image != (Image *) NULL)
5755 s=newSViv((ssize_t) image->columns);
5756 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5759 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5766 if (LocaleCompare(attribute,"xmp") == 0)
5768 if (image != (Image *) NULL)
5773 profile=GetImageProfile(image,"xmp");
5774 if (profile != (StringInfo *) NULL)
5775 s=newSVpv((const char *) GetStringInfoDatum(profile),
5776 GetStringInfoLength(profile));
5778 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5781 if (LocaleCompare(attribute,"x-resolution") == 0)
5783 if (image != (Image *) NULL)
5784 s=newSVnv(image->resolution.x);
5785 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5788 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5795 if (LocaleCompare(attribute,"y-resolution") == 0)
5797 if (image != (Image *) NULL)
5798 s=newSVnv(image->resolution.y);
5799 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5802 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5809 if (image == (Image *) NULL)
5810 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5814 value=GetImageProperty(image,attribute,exception);
5815 if (value != (const char *) NULL)
5818 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5821 if (*attribute != '%')
5822 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5829 meta=InterpretImageProperties(info ? info->image_info :
5830 (ImageInfo *) NULL,image,attribute,exception);
5832 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5833 meta=(char *) RelinquishMagickMemory(meta);
5837 exception=DestroyExceptionInfo(exception);
5838 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5842 ###############################################################################
5846 # G e t A u t h e n t i c P i x e l s #
5850 ###############################################################################
5854 GetAuthenticPixels(ref,...)
5855 Image::Magick ref = NO_INIT
5857 getauthenticpixels = 1
5887 PERL_UNUSED_VAR(ref);
5888 PERL_UNUSED_VAR(ix);
5889 exception=AcquireExceptionInfo();
5890 perl_exception=newSVpv("",0);
5891 if (sv_isobject(ST(0)) == 0)
5893 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5897 reference=SvRV(ST(0));
5899 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5900 if (image == (Image *) NULL)
5902 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5909 region.width=image->columns;
5912 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5913 for (i=2; i < items; i+=2)
5915 attribute=(char *) SvPV(ST(i-1),na);
5921 if (LocaleCompare(attribute,"geometry") == 0)
5923 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5926 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5933 if (LocaleCompare(attribute,"height") == 0)
5935 region.height=SvIV(ST(i));
5938 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5945 if (LocaleCompare(attribute,"x") == 0)
5947 region.x=SvIV(ST(i));
5950 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5957 if (LocaleCompare(attribute,"y") == 0)
5959 region.y=SvIV(ST(i));
5962 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5969 if (LocaleCompare(attribute,"width") == 0)
5971 region.width=SvIV(ST(i));
5974 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5980 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5981 region.height,exception);
5982 if (blob != (void *) NULL)
5986 InheritPerlException(exception,perl_exception);
5987 exception=DestroyExceptionInfo(exception);
5988 SvREFCNT_dec(perl_exception); /* throw away all errors */
5997 ###############################################################################
6001 # G e t V i r t u a l P i x e l s #
6005 ###############################################################################
6009 GetVirtualPixels(ref,...)
6010 Image::Magick ref = NO_INIT
6012 getvirtualpixels = 1
6013 AcquireImagePixels = 2
6014 acquireimagepixels = 3
6042 PERL_UNUSED_VAR(ref);
6043 PERL_UNUSED_VAR(ix);
6044 exception=AcquireExceptionInfo();
6045 perl_exception=newSVpv("",0);
6046 if (sv_isobject(ST(0)) == 0)
6048 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6052 reference=SvRV(ST(0));
6054 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6055 if (image == (Image *) NULL)
6057 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6064 region.width=image->columns;
6067 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6068 for (i=2; i < items; i+=2)
6070 attribute=(char *) SvPV(ST(i-1),na);
6076 if (LocaleCompare(attribute,"geometry") == 0)
6078 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6081 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6088 if (LocaleCompare(attribute,"height") == 0)
6090 region.height=SvIV(ST(i));
6093 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6100 if (LocaleCompare(attribute,"x") == 0)
6102 region.x=SvIV(ST(i));
6105 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6112 if (LocaleCompare(attribute,"y") == 0)
6114 region.y=SvIV(ST(i));
6117 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6124 if (LocaleCompare(attribute,"width") == 0)
6126 region.width=SvIV(ST(i));
6129 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6135 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6136 region.height,exception);
6137 if (blob != (void *) NULL)
6141 InheritPerlException(exception,perl_exception);
6142 exception=DestroyExceptionInfo(exception);
6143 SvREFCNT_dec(perl_exception); /* throw away all errors */
6146 RETVAL = (void *) blob;
6152 ###############################################################################
6156 # G e t A u t h e n t i c M e t a c o n t e n t #
6160 ###############################################################################
6164 GetAuthenticMetacontent(ref,...)
6165 Image::Magick ref = NO_INIT
6167 getauthenticmetacontent = 1
6188 PERL_UNUSED_VAR(ref);
6189 PERL_UNUSED_VAR(ix);
6190 exception=AcquireExceptionInfo();
6191 perl_exception=newSVpv("",0);
6192 if (sv_isobject(ST(0)) == 0)
6194 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6198 reference=SvRV(ST(0));
6200 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6201 if (image == (Image *) NULL)
6203 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6208 blob=(void *) GetAuthenticMetacontent(image);
6209 if (blob != (void *) NULL)
6213 InheritPerlException(exception,perl_exception);
6214 exception=DestroyExceptionInfo(exception);
6215 SvREFCNT_dec(perl_exception); /* throw away all errors */
6224 ###############################################################################
6228 # G e t V i r t u a l M e t a c o n t e n t #
6232 ###############################################################################
6236 GetVirtualMetacontent(ref,...)
6237 Image::Magick ref = NO_INIT
6239 getvirtualmetacontent = 1
6258 PERL_UNUSED_VAR(ref);
6259 PERL_UNUSED_VAR(ix);
6260 exception=AcquireExceptionInfo();
6261 perl_exception=newSVpv("",0);
6262 if (sv_isobject(ST(0)) == 0)
6264 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6268 reference=SvRV(ST(0));
6270 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6271 if (image == (Image *) NULL)
6273 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6278 blob=(void *) GetVirtualMetacontent(image);
6279 if (blob != (void *) NULL)
6283 InheritPerlException(exception,perl_exception);
6284 exception=DestroyExceptionInfo(exception);
6285 SvREFCNT_dec(perl_exception); /* throw away all errors */
6294 ###############################################################################
6298 # H i s t o g r a m #
6302 ###############################################################################
6307 Image::Magick ref=NO_INIT
6318 message[MagickPathExtent];
6345 PERL_UNUSED_VAR(ref);
6346 PERL_UNUSED_VAR(ix);
6347 exception=AcquireExceptionInfo();
6348 perl_exception=newSVpv("",0);
6350 if (sv_isobject(ST(0)) == 0)
6352 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6356 reference=SvRV(ST(0));
6359 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6360 if (image == (Image *) NULL)
6362 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6367 for ( ; image; image=image->next)
6369 histogram=GetImageHistogram(image,&number_colors,exception);
6370 if (histogram == (PixelInfo *) NULL)
6372 count+=(ssize_t) number_colors;
6374 for (i=0; i < (ssize_t) number_colors; i++)
6376 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6378 PUSHs(sv_2mortal(newSVpv(message,0)));
6379 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6380 histogram[i].green);
6381 PUSHs(sv_2mortal(newSVpv(message,0)));
6382 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6384 PUSHs(sv_2mortal(newSVpv(message,0)));
6385 if (image->colorspace == CMYKColorspace)
6387 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6388 histogram[i].black);
6389 PUSHs(sv_2mortal(newSVpv(message,0)));
6391 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6392 histogram[i].alpha);
6393 PUSHs(sv_2mortal(newSVpv(message,0)));
6394 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6395 histogram[i].count);
6396 PUSHs(sv_2mortal(newSVpv(message,0)));
6398 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6402 InheritPerlException(exception,perl_exception);
6403 exception=DestroyExceptionInfo(exception);
6404 SvREFCNT_dec(perl_exception);
6408 ###############################################################################
6416 ###############################################################################
6421 Image::Magick ref=NO_INIT
6445 register const Quantum
6459 *reference; /* reference is the SV* of ref=SvIV(reference) */
6461 PERL_UNUSED_VAR(ref);
6462 PERL_UNUSED_VAR(ix);
6463 exception=AcquireExceptionInfo();
6464 perl_exception=newSVpv("",0);
6465 reference=SvRV(ST(0));
6466 av=(AV *) reference;
6467 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6469 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6470 if (image == (Image *) NULL)
6472 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6476 normalize=MagickTrue;
6479 region.width=image->columns;
6482 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6483 for (i=2; i < items; i+=2)
6485 attribute=(char *) SvPV(ST(i-1),na);
6491 if (LocaleCompare(attribute,"channel") == 0)
6496 option=ParseChannelOption(SvPV(ST(i),na));
6499 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6503 (void) SetPixelChannelMask(image,(ChannelType) option);
6506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6513 if (LocaleCompare(attribute,"geometry") == 0)
6515 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6518 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6525 if (LocaleCompare(attribute,"normalize") == 0)
6527 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6531 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6535 normalize=option != 0 ? MagickTrue : MagickFalse;
6538 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6545 if (LocaleCompare(attribute,"x") == 0)
6547 region.x=SvIV(ST(i));
6550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6557 if (LocaleCompare(attribute,"y") == 0)
6559 region.y=SvIV(ST(i));
6562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6568 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6574 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6575 if (p == (const Quantum *) NULL)
6583 if (normalize != MagickFalse)
6584 scale=1.0/QuantumRange;
6585 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6586 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6587 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6588 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6589 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6590 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6591 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6592 (image->colorspace == CMYKColorspace))
6593 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6594 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6595 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6599 InheritPerlException(exception,perl_exception);
6600 exception=DestroyExceptionInfo(exception);
6601 SvREFCNT_dec(perl_exception);
6605 ###############################################################################
6609 # G e t P i x e l s #
6613 ###############################################################################
6618 Image::Magick ref=NO_INIT
6657 *reference; /* reference is the SV* of ref=SvIV(reference) */
6659 PERL_UNUSED_VAR(ref);
6660 PERL_UNUSED_VAR(ix);
6661 exception=AcquireExceptionInfo();
6662 perl_exception=newSVpv("",0);
6663 reference=SvRV(ST(0));
6664 av=(AV *) reference;
6665 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6667 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6668 if (image == (Image *) NULL)
6670 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6675 if (image->alpha_trait != UndefinedPixelTrait)
6677 if (image->colorspace == CMYKColorspace)
6680 if (image->alpha_trait != UndefinedPixelTrait)
6683 normalize=MagickFalse;
6686 region.width=image->columns;
6689 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6690 for (i=2; i < items; i+=2)
6692 attribute=(char *) SvPV(ST(i-1),na);
6698 if (LocaleCompare(attribute,"geometry") == 0)
6700 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6703 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6710 if (LocaleCompare(attribute,"height") == 0)
6712 region.height=SvIV(ST(i));
6715 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6722 if (LocaleCompare(attribute,"map") == 0)
6727 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6734 if (LocaleCompare(attribute,"normalize") == 0)
6736 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6740 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6744 normalize=option != 0 ? MagickTrue : MagickFalse;
6747 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6754 if (LocaleCompare(attribute,"width") == 0)
6756 region.width=SvIV(ST(i));
6759 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6766 if (LocaleCompare(attribute,"x") == 0)
6768 region.x=SvIV(ST(i));
6771 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6778 if (LocaleCompare(attribute,"y") == 0)
6780 region.y=SvIV(ST(i));
6783 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6795 if (normalize != MagickFalse)
6800 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6801 region.height*sizeof(*pixels));
6802 if (pixels == (float *) NULL)
6804 ThrowPerlException(exception,ResourceLimitError,
6805 "MemoryAllocationFailed",PackageName);
6808 status=ExportImagePixels(image,region.x,region.y,region.width,
6809 region.height,map,FloatPixel,pixels,exception);
6810 if (status == MagickFalse)
6814 EXTEND(sp,strlen(map)*region.width*region.height);
6815 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6816 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6818 pixels=(float *) RelinquishMagickMemory(pixels);
6825 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6826 region.height*sizeof(*pixels));
6827 if (pixels == (Quantum *) NULL)
6829 ThrowPerlException(exception,ResourceLimitError,
6830 "MemoryAllocationFailed",PackageName);
6833 status=ExportImagePixels(image,region.x,region.y,region.width,
6834 region.height,map,QuantumPixel,pixels,exception);
6835 if (status == MagickFalse)
6839 EXTEND(sp,strlen(map)*region.width*region.height);
6840 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6841 PUSHs(sv_2mortal(newSViv(pixels[i])));
6843 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6847 InheritPerlException(exception,perl_exception);
6848 exception=DestroyExceptionInfo(exception);
6849 SvREFCNT_dec(perl_exception);
6853 ###############################################################################
6857 # I m a g e T o B l o b #
6861 ###############################################################################
6865 ImageToBlob(ref,...)
6866 Image::Magick ref=NO_INIT
6875 filename[MagickPathExtent];
6904 PERL_UNUSED_VAR(ref);
6905 PERL_UNUSED_VAR(ix);
6906 exception=AcquireExceptionInfo();
6907 perl_exception=newSVpv("",0);
6908 package_info=(struct PackageInfo *) NULL;
6909 if (sv_isobject(ST(0)) == 0)
6911 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6915 reference=SvRV(ST(0));
6916 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6917 if (image == (Image *) NULL)
6919 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6923 package_info=ClonePackageInfo(info,exception);
6924 for (i=2; i < items; i+=2)
6925 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6926 (void) CopyMagickString(filename,package_info->image_info->filename,
6929 for (next=image; next; next=next->next)
6931 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6932 next->scene=scene++;
6934 SetImageInfo(package_info->image_info,(unsigned int)
6935 GetImageListLength(image),exception);
6936 EXTEND(sp,(ssize_t) GetImageListLength(image));
6937 for ( ; image; image=image->next)
6940 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6941 if (blob != (char *) NULL)
6943 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6944 blob=(unsigned char *) RelinquishMagickMemory(blob);
6946 if (package_info->image_info->adjoin)
6951 if (package_info != (struct PackageInfo *) NULL)
6952 DestroyPackageInfo(package_info);
6953 InheritPerlException(exception,perl_exception);
6954 exception=DestroyExceptionInfo(exception);
6955 SvREFCNT_dec(perl_exception); /* throw away all errors */
6959 ###############################################################################
6967 ###############################################################################
6972 Image::Magick ref=NO_INIT
6976 OptimizeImageLayers = 3
6978 optimizeimagelayers = 5
7020 PERL_UNUSED_VAR(ref);
7021 PERL_UNUSED_VAR(ix);
7022 exception=AcquireExceptionInfo();
7023 perl_exception=newSVpv("",0);
7025 if (sv_isobject(ST(0)) == 0)
7027 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7031 reference=SvRV(ST(0));
7032 hv=SvSTASH(reference);
7034 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7036 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7037 if (image == (Image *) NULL)
7039 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7043 compose=image->compose;
7044 method=OptimizeLayer;
7045 for (i=2; i < items; i+=2)
7047 attribute=(char *) SvPV(ST(i-1),na);
7053 if (LocaleCompare(attribute,"compose") == 0)
7055 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7056 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7059 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7063 compose=(CompositeOperator) sp;
7066 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7073 if (LocaleCompare(attribute,"method") == 0)
7075 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7079 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7083 method=(LayerMethod) option;
7086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7092 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7098 layers=(Image *) NULL;
7101 case CompareAnyLayer:
7102 case CompareClearLayer:
7103 case CompareOverlayLayer:
7106 layers=CompareImagesLayers(image,method,exception);
7113 layers=MergeImageLayers(image,method,exception);
7118 layers=DisposeImages(image,exception);
7121 case OptimizeImageLayer:
7123 layers=OptimizeImageLayers(image,exception);
7126 case OptimizePlusLayer:
7128 layers=OptimizePlusImageLayers(image,exception);
7131 case OptimizeTransLayer:
7133 OptimizeImageTransparency(image,exception);
7136 case RemoveDupsLayer:
7138 RemoveDuplicateLayers(&image,exception);
7141 case RemoveZeroLayer:
7143 RemoveZeroDelayLayers(&image,exception);
7152 General Purpose, GIF Animation Optimizer.
7154 layers=CoalesceImages(image,exception);
7155 if (layers == (Image *) NULL)
7158 layers=OptimizeImageLayers(image,exception);
7159 if (layers == (Image *) NULL)
7161 image=DestroyImageList(image);
7163 layers=(Image *) NULL;
7164 OptimizeImageTransparency(image,exception);
7165 quantize_info=AcquireQuantizeInfo(info->image_info);
7166 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7167 quantize_info=DestroyQuantizeInfo(quantize_info);
7170 case CompositeLayer:
7179 Split image sequence at the first 'NULL:' image.
7182 while (source != (Image *) NULL)
7184 source=GetNextImageInList(source);
7185 if ((source != (Image *) NULL) &&
7186 (LocaleCompare(source->magick,"NULL") == 0))
7189 if (source != (Image *) NULL)
7191 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7192 (GetNextImageInList(source) == (Image *) NULL))
7193 source=(Image *) NULL;
7197 Separate the two lists, junk the null: image.
7199 source=SplitImageList(source->previous);
7200 DeleteImageFromList(&source);
7203 if (source == (Image *) NULL)
7205 (void) ThrowMagickException(exception,GetMagickModule(),
7206 OptionError,"MissingNullSeparator","layers Composite");
7210 Adjust offset with gravity and virtual canvas.
7212 SetGeometry(image,&geometry);
7213 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7214 geometry.width=source->page.width != 0 ? source->page.width :
7216 geometry.height=source->page.height != 0 ? source->page.height :
7218 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7219 image->columns,image->page.height != 0 ? image->page.height :
7220 image->rows,image->gravity,&geometry);
7221 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7222 source=DestroyImageList(source);
7226 if (layers != (Image *) NULL)
7229 image=CloneImage(image,0,0,MagickTrue,exception);
7230 if (image == (Image *) NULL)
7232 for ( ; image; image=image->next)
7234 AddImageToRegistry(sv,image);
7236 av_push(av,sv_bless(rv,hv));
7239 exception=DestroyExceptionInfo(exception);
7241 SvREFCNT_dec(perl_exception);
7245 InheritPerlException(exception,perl_exception);
7246 exception=DestroyExceptionInfo(exception);
7247 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7248 SvPOK_on(perl_exception);
7249 ST(0)=sv_2mortal(perl_exception);
7254 ###############################################################################
7258 # M a g i c k T o M i m e #
7262 ###############################################################################
7266 MagickToMime(ref,name)
7267 Image::Magick ref=NO_INIT
7276 PERL_UNUSED_VAR(ref);
7277 PERL_UNUSED_VAR(ix);
7278 mime=MagickToMime(name);
7279 RETVAL=newSVpv(mime,0);
7280 mime=(char *) RelinquishMagickMemory(mime);
7286 ###############################################################################
7294 ###############################################################################
7299 Image::Magick ref=NO_INIT
7336 MedianConvolveImage = 36
7342 ReduceNoiseImage = 42
7368 ColorFloodfillImage= 68
7374 CycleColormapImage = 74
7384 MatteFloodfillImage= 84
7392 NumberColorsImage = 92
7402 SignatureImage = 102
7412 TransparentImage = 112
7414 ThresholdImage = 114
7428 DeconstructImage = 130
7430 GaussianBlurImage = 132
7436 UnsharpMaskImage = 138
7438 MotionBlurImage = 140
7440 OrderedDitherImage = 142
7447 AffineTransform = 149
7448 AffineTransformImage = 150
7450 DifferenceImage = 152
7451 AdaptiveThreshold = 153
7452 AdaptiveThresholdImage = 154
7457 BlackThreshold = 159
7458 BlackThresholdImage= 160
7459 WhiteThreshold = 161
7460 WhiteThresholdImage= 162
7461 RotationalBlur = 163
7462 RotationalBlurImage= 164
7464 ThumbnailImage = 166
7474 PosterizeImage = 176
7480 SepiaToneImage = 182
7481 SigmoidalContrast = 183
7482 SigmoidalContrastImage = 184
7487 ContrastStretch = 189
7488 ContrastStretchImage = 190
7493 AdaptiveSharpen = 195
7494 AdaptiveSharpenImage = 196
7496 TransposeImage = 198
7498 TransverseImage = 200
7500 AutoOrientImage = 202
7502 AdaptiveBlurImage = 204
7506 UniqueColorsImage = 208
7507 AdaptiveResize = 209
7508 AdaptiveResizeImage= 210
7512 LinearStretchImage = 214
7514 ColorMatrixImage = 216
7519 FloodfillPaint = 221
7520 FloodfillPaintImage= 222
7526 LiquidRescaleImage = 228
7536 SparseColorImage = 238
7540 SelectiveBlurImage = 242
7544 BlueShiftImage = 246
7545 ForwardFourierTransform = 247
7546 ForwardFourierTransformImage = 248
7547 InverseFourierTransform = 249
7548 InverseFourierTransformImage = 250
7549 ColorDecisionList = 251
7550 ColorDecisionListImage = 252
7552 AutoGammaImage = 254
7554 AutoLevelImage = 256
7556 LevelImageColors = 258
7559 BrightnessContrast = 261
7560 BrightnessContrastImage = 262
7562 MorphologyImage = 264
7566 StatisticImage = 268
7568 PerceptibleImage = 270
7572 GrayscaleImage = 274
7574 CannyEdgeImage = 276
7576 HoughLineImage = 278
7578 MeanShiftImage = 280
7581 ConnectedComponent = 283
7582 ConnectedComponentImage = 284
7584 CopyImagePixels = 286
7587 WaveletDenoise = 289
7588 WaveletDenoiseImage= 290
7597 attribute_flag[MaxArguments],
7598 message[MagickPathExtent];
7659 argument_list[MaxArguments];
7661 PERL_UNUSED_VAR(ref);
7662 PERL_UNUSED_VAR(ix);
7663 exception=AcquireExceptionInfo();
7664 perl_exception=newSVpv("",0);
7665 reference_vector=NULL;
7669 if (sv_isobject(ST(0)) == 0)
7671 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7675 reference=SvRV(ST(0));
7676 region_info.width=0;
7677 region_info.height=0;
7680 region_image=(Image *) NULL;
7681 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7682 if (ix && (ix != 666))
7685 Called as Method(...)
7688 rp=(&Methods[ix-1]);
7694 Called as Mogrify("Method",...)
7696 attribute=(char *) SvPV(ST(1),na);
7699 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7700 attribute=(char *) SvPV(ST(2),na);
7703 for (rp=Methods; ; rp++)
7705 if (rp >= EndOf(Methods))
7707 ThrowPerlException(exception,OptionError,
7708 "UnrecognizedPerlMagickMethod",attribute);
7711 if (strEQcase(attribute,rp->name))
7717 if (image == (Image *) NULL)
7719 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7722 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7723 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7724 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7741 pp=(Arguments *) NULL;
7749 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7751 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7753 if (strEQcase(attribute,qq->method) > ssize_test)
7756 ssize_test=strEQcase(attribute,qq->method);
7759 if (pp == (Arguments *) NULL)
7761 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7763 goto continue_outer_loop;
7765 al=(&argument_list[pp-rp->arguments]);
7768 case ArrayReference:
7770 if (SvTYPE(sv) != SVt_RV)
7772 (void) FormatLocaleString(message,MagickPathExtent,
7773 "invalid %.60s value",pp->method);
7774 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7775 goto continue_outer_loop;
7777 al->array_reference=SvRV(sv);
7782 al->real_reference=SvNV(sv);
7787 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7790 case ImageReference:
7792 if (!sv_isobject(sv) ||
7793 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7794 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7796 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7802 case IntegerReference:
7804 al->integer_reference=SvIV(sv);
7807 case StringReference:
7809 al->string_reference=(char *) SvPV(sv,al->length);
7810 if (sv_isobject(sv))
7811 al->image_reference=SetupList(aTHX_ SvRV(sv),
7812 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7818 Is a string; look up name.
7820 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7822 al->string_reference=(char *) SvPV(sv,al->length);
7823 al->integer_reference=(-1);
7826 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7827 MagickFalse,SvPV(sv,na));
7828 if (pp->type == MagickChannelOptions)
7829 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7830 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7832 (void) FormatLocaleString(message,MagickPathExtent,
7833 "invalid %.60s value",pp->method);
7834 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7835 goto continue_outer_loop;
7840 attribute_flag[pp-rp->arguments]++;
7841 continue_outer_loop: ;
7843 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7844 pv=reference_vector;
7845 SetGeometryInfo(&geometry_info);
7846 channel=DefaultChannels;
7847 for (next=image; next; next=next->next)
7850 SetGeometry(image,&geometry);
7851 if ((region_info.width*region_info.height) != 0)
7854 image=CropImage(image,®ion_info,exception);
7860 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7861 ThrowPerlException(exception,OptionError,
7862 "UnrecognizedPerlMagickMethod",message);
7865 case 1: /* Comment */
7867 if (attribute_flag[0] == 0)
7868 argument_list[0].string_reference=(char *) NULL;
7869 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7870 info ? info->image_info : (ImageInfo *) NULL,image,
7871 argument_list[0].string_reference,exception),exception);
7876 if (attribute_flag[0] == 0)
7877 argument_list[0].string_reference=(char *) NULL;
7878 (void) SetImageProperty(image,"label",InterpretImageProperties(
7879 info ? info->image_info : (ImageInfo *) NULL,image,
7880 argument_list[0].string_reference,exception),exception);
7883 case 3: /* AddNoise */
7888 if (attribute_flag[0] == 0)
7889 argument_list[0].integer_reference=UniformNoise;
7891 if (attribute_flag[1] != 0)
7892 attenuate=argument_list[1].real_reference;
7893 if (attribute_flag[2] != 0)
7894 channel=(ChannelType) argument_list[2].integer_reference;
7895 channel_mask=SetImageChannelMask(image,channel);
7896 image=AddNoiseImage(image,(NoiseType)
7897 argument_list[0].integer_reference,attenuate,exception);
7898 if (image != (Image *) NULL)
7899 (void) SetImageChannelMask(image,channel_mask);
7902 case 4: /* Colorize */
7907 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7908 0,0,&target,exception);
7909 if (attribute_flag[0] != 0)
7910 (void) QueryColorCompliance(argument_list[0].string_reference,
7911 AllCompliance,&target,exception);
7912 if (attribute_flag[1] == 0)
7913 argument_list[1].string_reference="100%";
7914 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7918 case 5: /* Border */
7925 if (attribute_flag[0] != 0)
7926 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7927 &geometry,exception);
7928 if (attribute_flag[1] != 0)
7929 geometry.width=argument_list[1].integer_reference;
7930 if (attribute_flag[2] != 0)
7931 geometry.height=argument_list[2].integer_reference;
7932 if (attribute_flag[3] != 0)
7933 QueryColorCompliance(argument_list[3].string_reference,
7934 AllCompliance,&image->border_color,exception);
7935 if (attribute_flag[4] != 0)
7936 QueryColorCompliance(argument_list[4].string_reference,
7937 AllCompliance,&image->border_color,exception);
7938 if (attribute_flag[5] != 0)
7939 QueryColorCompliance(argument_list[5].string_reference,
7940 AllCompliance,&image->border_color,exception);
7941 compose=image->compose;
7942 if (attribute_flag[6] != 0)
7943 compose=(CompositeOperator) argument_list[6].integer_reference;
7944 image=BorderImage(image,&geometry,compose,exception);
7949 if (attribute_flag[0] != 0)
7951 flags=ParseGeometry(argument_list[0].string_reference,
7953 if ((flags & SigmaValue) == 0)
7954 geometry_info.sigma=1.0;
7956 if (attribute_flag[1] != 0)
7957 geometry_info.rho=argument_list[1].real_reference;
7958 if (attribute_flag[2] != 0)
7959 geometry_info.sigma=argument_list[2].real_reference;
7960 if (attribute_flag[3] != 0)
7961 channel=(ChannelType) argument_list[3].integer_reference;
7962 channel_mask=SetImageChannelMask(image,channel);
7963 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7965 if (image != (Image *) NULL)
7966 (void) SetImageChannelMask(image,channel_mask);
7971 if (attribute_flag[5] != 0)
7972 image->gravity=(GravityType) argument_list[5].integer_reference;
7973 if (attribute_flag[0] != 0)
7974 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7975 &geometry,exception);
7976 if (attribute_flag[1] != 0)
7977 geometry.width=argument_list[1].integer_reference;
7978 if (attribute_flag[2] != 0)
7979 geometry.height=argument_list[2].integer_reference;
7980 if (attribute_flag[3] != 0)
7981 geometry.x=argument_list[3].integer_reference;
7982 if (attribute_flag[4] != 0)
7983 geometry.y=argument_list[4].integer_reference;
7984 image=ChopImage(image,&geometry,exception);
7989 if (attribute_flag[6] != 0)
7990 image->gravity=(GravityType) argument_list[6].integer_reference;
7991 if (attribute_flag[0] != 0)
7992 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7993 &geometry,exception);
7994 if (attribute_flag[1] != 0)
7995 geometry.width=argument_list[1].integer_reference;
7996 if (attribute_flag[2] != 0)
7997 geometry.height=argument_list[2].integer_reference;
7998 if (attribute_flag[3] != 0)
7999 geometry.x=argument_list[3].integer_reference;
8000 if (attribute_flag[4] != 0)
8001 geometry.y=argument_list[4].integer_reference;
8002 if (attribute_flag[5] != 0)
8003 image->fuzz=StringToDoubleInterval(
8004 argument_list[5].string_reference,(double) QuantumRange+1.0);
8005 image=CropImage(image,&geometry,exception);
8008 case 9: /* Despeckle */
8010 image=DespeckleImage(image,exception);
8015 if (attribute_flag[0] != 0)
8016 geometry_info.rho=argument_list[0].real_reference;
8017 image=EdgeImage(image,geometry_info.rho,exception);
8020 case 11: /* Emboss */
8022 if (attribute_flag[0] != 0)
8024 flags=ParseGeometry(argument_list[0].string_reference,
8026 if ((flags & SigmaValue) == 0)
8027 geometry_info.sigma=1.0;
8029 if (attribute_flag[1] != 0)
8030 geometry_info.rho=argument_list[1].real_reference;
8031 if (attribute_flag[2] != 0)
8032 geometry_info.sigma=argument_list[2].real_reference;
8033 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8037 case 12: /* Enhance */
8039 image=EnhanceImage(image,exception);
8044 image=FlipImage(image,exception);
8049 image=FlopImage(image,exception);
8052 case 15: /* Frame */
8060 if (attribute_flag[0] != 0)
8062 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8063 &geometry,exception);
8064 frame_info.width=geometry.width;
8065 frame_info.height=geometry.height;
8066 frame_info.outer_bevel=geometry.x;
8067 frame_info.inner_bevel=geometry.y;
8069 if (attribute_flag[1] != 0)
8070 frame_info.width=argument_list[1].integer_reference;
8071 if (attribute_flag[2] != 0)
8072 frame_info.height=argument_list[2].integer_reference;
8073 if (attribute_flag[3] != 0)
8074 frame_info.inner_bevel=argument_list[3].integer_reference;
8075 if (attribute_flag[4] != 0)
8076 frame_info.outer_bevel=argument_list[4].integer_reference;
8077 if (attribute_flag[5] != 0)
8078 QueryColorCompliance(argument_list[5].string_reference,
8079 AllCompliance,&fill_color,exception);
8080 if (attribute_flag[6] != 0)
8081 QueryColorCompliance(argument_list[6].string_reference,
8082 AllCompliance,&fill_color,exception);
8083 frame_info.x=(ssize_t) frame_info.width;
8084 frame_info.y=(ssize_t) frame_info.height;
8085 frame_info.width=image->columns+2*frame_info.x;
8086 frame_info.height=image->rows+2*frame_info.y;
8087 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8088 image->alpha_color=fill_color;
8089 compose=image->compose;
8090 if (attribute_flag[7] != 0)
8091 compose=(CompositeOperator) argument_list[7].integer_reference;
8092 image=FrameImage(image,&frame_info,compose,exception);
8095 case 16: /* Implode */
8097 PixelInterpolateMethod
8100 if (attribute_flag[0] == 0)
8101 argument_list[0].real_reference=0.5;
8102 method=UndefinedInterpolatePixel;
8103 if (attribute_flag[1] != 0)
8104 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8105 image=ImplodeImage(image,argument_list[0].real_reference,
8109 case 17: /* Magnify */
8111 image=MagnifyImage(image,exception);
8114 case 18: /* MedianFilter */
8116 if (attribute_flag[0] != 0)
8118 flags=ParseGeometry(argument_list[0].string_reference,
8120 if ((flags & SigmaValue) == 0)
8121 geometry_info.sigma=geometry_info.rho;
8123 if (attribute_flag[1] != 0)
8124 geometry_info.rho=argument_list[1].real_reference;
8125 if (attribute_flag[2] != 0)
8126 geometry_info.sigma=argument_list[2].real_reference;
8127 if (attribute_flag[3] != 0)
8128 channel=(ChannelType) argument_list[3].integer_reference;
8129 channel_mask=SetImageChannelMask(image,channel);
8130 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8131 (size_t) geometry_info.sigma,exception);
8132 if (image != (Image *) NULL)
8133 (void) SetImageChannelMask(image,channel_mask);
8136 case 19: /* Minify */
8138 image=MinifyImage(image,exception);
8141 case 20: /* OilPaint */
8143 if (attribute_flag[0] == 0)
8144 argument_list[0].real_reference=0.0;
8145 if (attribute_flag[1] == 0)
8146 argument_list[1].real_reference=1.0;
8147 image=OilPaintImage(image,argument_list[0].real_reference,
8148 argument_list[1].real_reference,exception);
8151 case 21: /* ReduceNoise */
8153 if (attribute_flag[0] != 0)
8155 flags=ParseGeometry(argument_list[0].string_reference,
8157 if ((flags & SigmaValue) == 0)
8158 geometry_info.sigma=1.0;
8160 if (attribute_flag[1] != 0)
8161 geometry_info.rho=argument_list[1].real_reference;
8162 if (attribute_flag[2] != 0)
8163 geometry_info.sigma=argument_list[2].real_reference;
8164 if (attribute_flag[3] != 0)
8165 channel=(ChannelType) argument_list[3].integer_reference;
8166 channel_mask=SetImageChannelMask(image,channel);
8167 image=StatisticImage(image,NonpeakStatistic,(size_t)
8168 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8169 if (image != (Image *) NULL)
8170 (void) SetImageChannelMask(image,channel_mask);
8175 if (attribute_flag[0] != 0)
8176 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8177 &geometry,exception);
8178 if (attribute_flag[1] != 0)
8179 geometry.x=argument_list[1].integer_reference;
8180 if (attribute_flag[2] != 0)
8181 geometry.y=argument_list[2].integer_reference;
8182 image=RollImage(image,geometry.x,geometry.y,exception);
8185 case 23: /* Rotate */
8187 if (attribute_flag[0] == 0)
8188 argument_list[0].real_reference=90.0;
8189 if (attribute_flag[1] != 0)
8191 QueryColorCompliance(argument_list[1].string_reference,
8192 AllCompliance,&image->background_color,exception);
8193 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8194 (image->alpha_trait == UndefinedPixelTrait))
8195 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8197 image=RotateImage(image,argument_list[0].real_reference,exception);
8200 case 24: /* Sample */
8202 if (attribute_flag[0] != 0)
8203 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8204 &geometry,exception);
8205 if (attribute_flag[1] != 0)
8206 geometry.width=argument_list[1].integer_reference;
8207 if (attribute_flag[2] != 0)
8208 geometry.height=argument_list[2].integer_reference;
8209 image=SampleImage(image,geometry.width,geometry.height,exception);
8212 case 25: /* Scale */
8214 if (attribute_flag[0] != 0)
8215 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8216 &geometry,exception);
8217 if (attribute_flag[1] != 0)
8218 geometry.width=argument_list[1].integer_reference;
8219 if (attribute_flag[2] != 0)
8220 geometry.height=argument_list[2].integer_reference;
8221 image=ScaleImage(image,geometry.width,geometry.height,exception);
8224 case 26: /* Shade */
8226 if (attribute_flag[0] != 0)
8228 flags=ParseGeometry(argument_list[0].string_reference,
8230 if ((flags & SigmaValue) == 0)
8231 geometry_info.sigma=0.0;
8233 if (attribute_flag[1] != 0)
8234 geometry_info.rho=argument_list[1].real_reference;
8235 if (attribute_flag[2] != 0)
8236 geometry_info.sigma=argument_list[2].real_reference;
8237 image=ShadeImage(image,
8238 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8239 geometry_info.rho,geometry_info.sigma,exception);
8242 case 27: /* Sharpen */
8244 if (attribute_flag[0] != 0)
8246 flags=ParseGeometry(argument_list[0].string_reference,
8248 if ((flags & SigmaValue) == 0)
8249 geometry_info.sigma=1.0;
8251 if (attribute_flag[1] != 0)
8252 geometry_info.rho=argument_list[1].real_reference;
8253 if (attribute_flag[2] != 0)
8254 geometry_info.sigma=argument_list[2].real_reference;
8255 if (attribute_flag[3] != 0)
8256 channel=(ChannelType) argument_list[3].integer_reference;
8257 channel_mask=SetImageChannelMask(image,channel);
8258 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8260 if (image != (Image *) NULL)
8261 (void) SetImageChannelMask(image,channel_mask);
8264 case 28: /* Shear */
8266 if (attribute_flag[0] != 0)
8268 flags=ParseGeometry(argument_list[0].string_reference,
8270 if ((flags & SigmaValue) == 0)
8271 geometry_info.sigma=geometry_info.rho;
8273 if (attribute_flag[1] != 0)
8274 geometry_info.rho=argument_list[1].real_reference;
8275 if (attribute_flag[2] != 0)
8276 geometry_info.sigma=argument_list[2].real_reference;
8277 if (attribute_flag[3] != 0)
8278 QueryColorCompliance(argument_list[3].string_reference,
8279 AllCompliance,&image->background_color,exception);
8280 if (attribute_flag[4] != 0)
8281 QueryColorCompliance(argument_list[4].string_reference,
8282 AllCompliance,&image->background_color,exception);
8283 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8287 case 29: /* Spread */
8289 PixelInterpolateMethod
8292 if (attribute_flag[0] == 0)
8293 argument_list[0].real_reference=1.0;
8294 method=UndefinedInterpolatePixel;
8295 if (attribute_flag[1] != 0)
8296 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8297 image=SpreadImage(image,method,argument_list[0].real_reference,
8301 case 30: /* Swirl */
8303 PixelInterpolateMethod
8306 if (attribute_flag[0] == 0)
8307 argument_list[0].real_reference=50.0;
8308 method=UndefinedInterpolatePixel;
8309 if (attribute_flag[1] != 0)
8310 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8311 image=SwirlImage(image,argument_list[0].real_reference,
8315 case 31: /* Resize */
8318 if (attribute_flag[0] != 0)
8319 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8320 &geometry,exception);
8321 if (attribute_flag[1] != 0)
8322 geometry.width=argument_list[1].integer_reference;
8323 if (attribute_flag[2] != 0)
8324 geometry.height=argument_list[2].integer_reference;
8325 if (attribute_flag[3] == 0)
8326 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8327 if (attribute_flag[4] != 0)
8328 SetImageArtifact(image,"filter:support",
8329 argument_list[4].string_reference);
8330 image=ResizeImage(image,geometry.width,geometry.height,
8331 (FilterType) argument_list[3].integer_reference,
8335 case 33: /* Annotate */
8340 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8342 if (attribute_flag[0] != 0)
8347 text=InterpretImageProperties(info ? info->image_info :
8348 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8350 (void) CloneString(&draw_info->text,text);
8351 text=DestroyString(text);
8353 if (attribute_flag[1] != 0)
8354 (void) CloneString(&draw_info->font,
8355 argument_list[1].string_reference);
8356 if (attribute_flag[2] != 0)
8357 draw_info->pointsize=argument_list[2].real_reference;
8358 if (attribute_flag[3] != 0)
8359 (void) CloneString(&draw_info->density,
8360 argument_list[3].string_reference);
8361 if (attribute_flag[4] != 0)
8362 (void) QueryColorCompliance(argument_list[4].string_reference,
8363 AllCompliance,&draw_info->undercolor,exception);
8364 if (attribute_flag[5] != 0)
8366 (void) QueryColorCompliance(argument_list[5].string_reference,
8367 AllCompliance,&draw_info->stroke,exception);
8368 if (argument_list[5].image_reference != (Image *) NULL)
8369 draw_info->stroke_pattern=CloneImage(
8370 argument_list[5].image_reference,0,0,MagickTrue,exception);
8372 if (attribute_flag[6] != 0)
8374 (void) QueryColorCompliance(argument_list[6].string_reference,
8375 AllCompliance,&draw_info->fill,exception);
8376 if (argument_list[6].image_reference != (Image *) NULL)
8377 draw_info->fill_pattern=CloneImage(
8378 argument_list[6].image_reference,0,0,MagickTrue,exception);
8380 if (attribute_flag[7] != 0)
8382 (void) CloneString(&draw_info->geometry,
8383 argument_list[7].string_reference);
8384 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8385 &geometry,exception);
8386 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8387 geometry_info.sigma=geometry_info.xi;
8389 if (attribute_flag[8] != 0)
8390 (void) QueryColorCompliance(argument_list[8].string_reference,
8391 AllCompliance,&draw_info->fill,exception);
8392 if (attribute_flag[11] != 0)
8393 draw_info->gravity=(GravityType)
8394 argument_list[11].integer_reference;
8395 if (attribute_flag[25] != 0)
8400 av=(AV *) argument_list[25].array_reference;
8401 if ((av_len(av) != 3) && (av_len(av) != 5))
8403 ThrowPerlException(exception,OptionError,
8404 "affine matrix must have 4 or 6 elements",PackageName);
8407 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8408 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8409 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8410 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8411 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8412 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8414 ThrowPerlException(exception,OptionError,
8415 "affine matrix is singular",PackageName);
8418 if (av_len(av) == 5)
8420 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8421 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8424 for (j=12; j < 17; j++)
8426 if (attribute_flag[j] == 0)
8428 value=argument_list[j].string_reference;
8429 angle=argument_list[j].real_reference;
8430 current=draw_info->affine;
8431 GetAffineMatrix(&affine);
8439 flags=ParseGeometry(value,&geometry_info);
8440 affine.tx=geometry_info.xi;
8441 affine.ty=geometry_info.psi;
8442 if ((flags & PsiValue) == 0)
8443 affine.ty=affine.tx;
8451 flags=ParseGeometry(value,&geometry_info);
8452 affine.sx=geometry_info.rho;
8453 affine.sy=geometry_info.sigma;
8454 if ((flags & SigmaValue) == 0)
8455 affine.sy=affine.sx;
8465 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8466 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8467 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8468 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8476 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8484 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8488 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8489 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8490 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8491 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8492 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8494 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8497 if (attribute_flag[9] == 0)
8498 argument_list[9].real_reference=0.0;
8499 if (attribute_flag[10] == 0)
8500 argument_list[10].real_reference=0.0;
8501 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8504 geometry[MagickPathExtent];
8506 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8507 (double) argument_list[9].real_reference+draw_info->affine.tx,
8508 (double) argument_list[10].real_reference+draw_info->affine.ty);
8509 (void) CloneString(&draw_info->geometry,geometry);
8511 if (attribute_flag[17] != 0)
8512 draw_info->stroke_width=argument_list[17].real_reference;
8513 if (attribute_flag[18] != 0)
8515 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8516 MagickTrue : MagickFalse;
8517 draw_info->stroke_antialias=draw_info->text_antialias;
8519 if (attribute_flag[19] != 0)
8520 (void) CloneString(&draw_info->family,
8521 argument_list[19].string_reference);
8522 if (attribute_flag[20] != 0)
8523 draw_info->style=(StyleType) argument_list[20].integer_reference;
8524 if (attribute_flag[21] != 0)
8525 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8526 if (attribute_flag[22] != 0)
8527 draw_info->weight=argument_list[22].integer_reference;
8528 if (attribute_flag[23] != 0)
8529 draw_info->align=(AlignType) argument_list[23].integer_reference;
8530 if (attribute_flag[24] != 0)
8531 (void) CloneString(&draw_info->encoding,
8532 argument_list[24].string_reference);
8533 if (attribute_flag[25] != 0)
8534 draw_info->fill_pattern=CloneImage(
8535 argument_list[25].image_reference,0,0,MagickTrue,exception);
8536 if (attribute_flag[26] != 0)
8537 draw_info->fill_pattern=CloneImage(
8538 argument_list[26].image_reference,0,0,MagickTrue,exception);
8539 if (attribute_flag[27] != 0)
8540 draw_info->stroke_pattern=CloneImage(
8541 argument_list[27].image_reference,0,0,MagickTrue,exception);
8542 if (attribute_flag[29] != 0)
8543 draw_info->kerning=argument_list[29].real_reference;
8544 if (attribute_flag[30] != 0)
8545 draw_info->interline_spacing=argument_list[30].real_reference;
8546 if (attribute_flag[31] != 0)
8547 draw_info->interword_spacing=argument_list[31].real_reference;
8548 if (attribute_flag[32] != 0)
8549 draw_info->direction=(DirectionType)
8550 argument_list[32].integer_reference;
8551 (void) AnnotateImage(image,draw_info,exception);
8552 draw_info=DestroyDrawInfo(draw_info);
8555 case 34: /* ColorFloodfill */
8566 draw_info=CloneDrawInfo(info ? info->image_info :
8567 (ImageInfo *) NULL,(DrawInfo *) NULL);
8568 if (attribute_flag[0] != 0)
8569 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8570 &geometry,exception);
8571 if (attribute_flag[1] != 0)
8572 geometry.x=argument_list[1].integer_reference;
8573 if (attribute_flag[2] != 0)
8574 geometry.y=argument_list[2].integer_reference;
8575 if (attribute_flag[3] != 0)
8576 (void) QueryColorCompliance(argument_list[3].string_reference,
8577 AllCompliance,&draw_info->fill,exception);
8578 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8579 geometry.x,geometry.y,&target,exception);
8581 if (attribute_flag[4] != 0)
8583 QueryColorCompliance(argument_list[4].string_reference,
8584 AllCompliance,&target,exception);
8587 if (attribute_flag[5] != 0)
8588 image->fuzz=StringToDoubleInterval(
8589 argument_list[5].string_reference,(double) QuantumRange+1.0);
8590 if (attribute_flag[6] != 0)
8591 invert=(MagickBooleanType) argument_list[6].integer_reference;
8592 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8593 geometry.y,invert,exception);
8594 draw_info=DestroyDrawInfo(draw_info);
8597 case 35: /* Composite */
8600 composite_geometry[MagickPathExtent];
8609 compose=OverCompositeOp;
8610 if (attribute_flag[0] != 0)
8611 composite_image=argument_list[0].image_reference;
8614 ThrowPerlException(exception,OptionError,
8615 "CompositeImageRequired",PackageName);
8619 Parameter Handling used for BOTH normal and tiled composition.
8621 if (attribute_flag[1] != 0) /* compose */
8622 compose=(CompositeOperator) argument_list[1].integer_reference;
8623 if (attribute_flag[6] != 0) /* opacity */
8625 if (compose != DissolveCompositeOp)
8626 (void) SetImageAlpha(composite_image,(Quantum)
8627 StringToDoubleInterval(argument_list[6].string_reference,
8628 (double) QuantumRange+1.0),exception);
8650 Handle dissolve composite operator (patch by
8653 (void) CloneString(&image->geometry,
8654 argument_list[6].string_reference);
8655 opacity=(Quantum) StringToDoubleInterval(
8656 argument_list[6].string_reference,(double) QuantumRange+
8658 if (composite_image->alpha_trait != UndefinedPixelTrait)
8659 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8660 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8661 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8663 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8664 composite_image->columns,1,exception);
8665 for (x=0; x < (ssize_t) composite_image->columns; x++)
8667 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8668 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8670 q+=GetPixelChannels(composite_image);
8672 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8673 if (sync == MagickFalse)
8676 composite_view=DestroyCacheView(composite_view);
8679 if (attribute_flag[9] != 0) /* "color=>" */
8680 QueryColorCompliance(argument_list[9].string_reference,
8681 AllCompliance,&composite_image->background_color,exception);
8682 if (attribute_flag[12] != 0) /* "interpolate=>" */
8683 image->interpolate=(PixelInterpolateMethod)
8684 argument_list[12].integer_reference;
8685 if (attribute_flag[13] != 0) /* "args=>" */
8686 (void) SetImageArtifact(composite_image,"compose:args",
8687 argument_list[13].string_reference);
8688 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8689 (void) SetImageArtifact(composite_image,"compose:args",
8690 argument_list[14].string_reference);
8691 clip_to_self=MagickTrue;
8692 if (attribute_flag[15] != 0)
8693 clip_to_self=(MagickBooleanType)
8694 argument_list[15].integer_reference;
8696 Tiling Composition (with orthogonal rotate).
8698 rotate_image=(Image *) NULL;
8699 if (attribute_flag[8] != 0) /* "rotate=>" */
8704 rotate_image=RotateImage(composite_image,
8705 argument_list[8].real_reference,exception);
8706 if (rotate_image == (Image *) NULL)
8709 if ((attribute_flag[7] != 0) &&
8710 (argument_list[7].integer_reference != 0)) /* tile */
8717 Tile the composite image.
8719 if (attribute_flag[8] != 0) /* "tile=>" */
8720 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8723 (void) SetImageArtifact(composite_image,
8724 "compose:outside-overlay","false");
8725 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8726 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8728 if (attribute_flag[8] != 0) /* rotate */
8729 (void) CompositeImage(image,rotate_image,compose,
8730 MagickTrue,x,y,exception);
8732 (void) CompositeImage(image,composite_image,compose,
8733 MagickTrue,x,y,exception);
8735 if (attribute_flag[8] != 0) /* rotate */
8736 rotate_image=DestroyImage(rotate_image);
8740 Parameter Handling used used ONLY for normal composition.
8742 if (attribute_flag[5] != 0) /* gravity */
8743 image->gravity=(GravityType) argument_list[5].integer_reference;
8744 if (attribute_flag[2] != 0) /* geometry offset */
8746 SetGeometry(image,&geometry);
8747 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8749 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8752 if (attribute_flag[3] != 0) /* x offset */
8753 geometry.x=argument_list[3].integer_reference;
8754 if (attribute_flag[4] != 0) /* y offset */
8755 geometry.y=argument_list[4].integer_reference;
8756 if (attribute_flag[10] != 0) /* mask */
8758 if ((image->compose == DisplaceCompositeOp) ||
8759 (image->compose == DistortCompositeOp))
8762 Merge Y displacement into X displacement image.
8764 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8766 (void) CompositeImage(composite_image,
8767 argument_list[10].image_reference,CopyGreenCompositeOp,
8768 MagickTrue,0,0,exception);
8776 Set a blending mask for the composition.
8778 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8779 MagickTrue,exception);
8780 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8782 mask_image=DestroyImage(mask_image);
8785 if (attribute_flag[11] != 0) /* channel */
8786 channel=(ChannelType) argument_list[11].integer_reference;
8788 Composite two images (normal composition).
8790 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8791 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8792 (double) composite_image->rows,(double) geometry.x,(double)
8794 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8796 channel_mask=SetImageChannelMask(image,channel);
8797 if (attribute_flag[8] == 0) /* no rotate */
8798 CompositeImage(image,composite_image,compose,clip_to_self,
8799 geometry.x,geometry.y,exception);
8803 Position adjust rotated image then composite.
8805 geometry.x-=(ssize_t) (rotate_image->columns-
8806 composite_image->columns)/2;
8807 geometry.y-=(ssize_t) (rotate_image->rows-
8808 composite_image->rows)/2;
8809 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8810 geometry.y,exception);
8811 rotate_image=DestroyImage(rotate_image);
8813 if (attribute_flag[10] != 0) /* mask */
8815 if ((image->compose == DisplaceCompositeOp) ||
8816 (image->compose == DistortCompositeOp))
8817 composite_image=DestroyImage(composite_image);
8819 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8822 (void) SetImageChannelMask(image,channel_mask);
8825 case 36: /* Contrast */
8827 if (attribute_flag[0] == 0)
8828 argument_list[0].integer_reference=0;
8829 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8830 MagickTrue : MagickFalse,exception);
8833 case 37: /* CycleColormap */
8835 if (attribute_flag[0] == 0)
8836 argument_list[0].integer_reference=6;
8837 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8846 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8848 (void) CloneString(&draw_info->primitive,"point");
8849 if (attribute_flag[0] != 0)
8851 if (argument_list[0].integer_reference < 0)
8852 (void) CloneString(&draw_info->primitive,
8853 argument_list[0].string_reference);
8855 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8856 MagickPrimitiveOptions,argument_list[0].integer_reference));
8858 if (attribute_flag[1] != 0)
8860 if (LocaleCompare(draw_info->primitive,"path") == 0)
8862 (void) ConcatenateString(&draw_info->primitive," '");
8863 ConcatenateString(&draw_info->primitive,
8864 argument_list[1].string_reference);
8865 (void) ConcatenateString(&draw_info->primitive,"'");
8869 (void) ConcatenateString(&draw_info->primitive," ");
8870 ConcatenateString(&draw_info->primitive,
8871 argument_list[1].string_reference);
8874 if (attribute_flag[2] != 0)
8876 (void) ConcatenateString(&draw_info->primitive," ");
8877 (void) ConcatenateString(&draw_info->primitive,
8878 CommandOptionToMnemonic(MagickMethodOptions,
8879 argument_list[2].integer_reference));
8881 if (attribute_flag[3] != 0)
8883 (void) QueryColorCompliance(argument_list[3].string_reference,
8884 AllCompliance,&draw_info->stroke,exception);
8885 if (argument_list[3].image_reference != (Image *) NULL)
8886 draw_info->stroke_pattern=CloneImage(
8887 argument_list[3].image_reference,0,0,MagickTrue,exception);
8889 if (attribute_flag[4] != 0)
8891 (void) QueryColorCompliance(argument_list[4].string_reference,
8892 AllCompliance,&draw_info->fill,exception);
8893 if (argument_list[4].image_reference != (Image *) NULL)
8894 draw_info->fill_pattern=CloneImage(
8895 argument_list[4].image_reference,0,0,MagickTrue,exception);
8897 if (attribute_flag[5] != 0)
8898 draw_info->stroke_width=argument_list[5].real_reference;
8899 if (attribute_flag[6] != 0)
8900 (void) CloneString(&draw_info->font,
8901 argument_list[6].string_reference);
8902 if (attribute_flag[7] != 0)
8903 (void) QueryColorCompliance(argument_list[7].string_reference,
8904 AllCompliance,&draw_info->border_color,exception);
8905 if (attribute_flag[8] != 0)
8906 draw_info->affine.tx=argument_list[8].real_reference;
8907 if (attribute_flag[9] != 0)
8908 draw_info->affine.ty=argument_list[9].real_reference;
8909 if (attribute_flag[20] != 0)
8914 av=(AV *) argument_list[20].array_reference;
8915 if ((av_len(av) != 3) && (av_len(av) != 5))
8917 ThrowPerlException(exception,OptionError,
8918 "affine matrix must have 4 or 6 elements",PackageName);
8921 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8922 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8923 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8924 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8925 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8926 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8928 ThrowPerlException(exception,OptionError,
8929 "affine matrix is singular",PackageName);
8932 if (av_len(av) == 5)
8934 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8935 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8938 for (j=10; j < 15; j++)
8940 if (attribute_flag[j] == 0)
8942 value=argument_list[j].string_reference;
8943 angle=argument_list[j].real_reference;
8944 current=draw_info->affine;
8945 GetAffineMatrix(&affine);
8953 flags=ParseGeometry(value,&geometry_info);
8954 affine.tx=geometry_info.xi;
8955 affine.ty=geometry_info.psi;
8956 if ((flags & PsiValue) == 0)
8957 affine.ty=affine.tx;
8965 flags=ParseGeometry(value,&geometry_info);
8966 affine.sx=geometry_info.rho;
8967 affine.sy=geometry_info.sigma;
8968 if ((flags & SigmaValue) == 0)
8969 affine.sy=affine.sx;
8979 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8980 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8981 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8982 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8990 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8998 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9002 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9003 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9004 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9005 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9006 draw_info->affine.tx=
9007 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9008 draw_info->affine.ty=
9009 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9011 if (attribute_flag[15] != 0)
9012 draw_info->fill_pattern=CloneImage(
9013 argument_list[15].image_reference,0,0,MagickTrue,exception);
9014 if (attribute_flag[16] != 0)
9015 draw_info->pointsize=argument_list[16].real_reference;
9016 if (attribute_flag[17] != 0)
9018 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
9019 ? MagickTrue : MagickFalse;
9020 draw_info->text_antialias=draw_info->stroke_antialias;
9022 if (attribute_flag[18] != 0)
9023 (void) CloneString(&draw_info->density,
9024 argument_list[18].string_reference);
9025 if (attribute_flag[19] != 0)
9026 draw_info->stroke_width=argument_list[19].real_reference;
9027 if (attribute_flag[21] != 0)
9028 draw_info->dash_offset=argument_list[21].real_reference;
9029 if (attribute_flag[22] != 0)
9034 av=(AV *) argument_list[22].array_reference;
9035 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9036 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9037 if (draw_info->dash_pattern != (double *) NULL)
9039 for (i=0; i <= av_len(av); i++)
9040 draw_info->dash_pattern[i]=(double)
9041 SvNV(*(av_fetch(av,i,0)));
9042 draw_info->dash_pattern[i]=0.0;
9045 if (attribute_flag[23] != 0)
9046 image->interpolate=(PixelInterpolateMethod)
9047 argument_list[23].integer_reference;
9048 if ((attribute_flag[24] != 0) &&
9049 (draw_info->fill_pattern != (Image *) NULL))
9050 flags=ParsePageGeometry(draw_info->fill_pattern,
9051 argument_list[24].string_reference,
9052 &draw_info->fill_pattern->tile_offset,exception);
9053 if (attribute_flag[25] != 0)
9055 (void) ConcatenateString(&draw_info->primitive," '");
9056 (void) ConcatenateString(&draw_info->primitive,
9057 argument_list[25].string_reference);
9058 (void) ConcatenateString(&draw_info->primitive,"'");
9060 if (attribute_flag[26] != 0)
9061 draw_info->fill_pattern=CloneImage(
9062 argument_list[26].image_reference,0,0,MagickTrue,exception);
9063 if (attribute_flag[27] != 0)
9064 draw_info->stroke_pattern=CloneImage(
9065 argument_list[27].image_reference,0,0,MagickTrue,exception);
9066 if (attribute_flag[28] != 0)
9067 (void) CloneString(&draw_info->primitive,
9068 argument_list[28].string_reference);
9069 if (attribute_flag[29] != 0)
9070 draw_info->kerning=argument_list[29].real_reference;
9071 if (attribute_flag[30] != 0)
9072 draw_info->interline_spacing=argument_list[30].real_reference;
9073 if (attribute_flag[31] != 0)
9074 draw_info->interword_spacing=argument_list[31].real_reference;
9075 if (attribute_flag[32] != 0)
9076 draw_info->direction=(DirectionType)
9077 argument_list[32].integer_reference;
9078 DrawImage(image,draw_info,exception);
9079 draw_info=DestroyDrawInfo(draw_info);
9082 case 39: /* Equalize */
9084 if (attribute_flag[0] != 0)
9085 channel=(ChannelType) argument_list[0].integer_reference;
9086 channel_mask=SetImageChannelMask(image,channel);
9087 EqualizeImage(image,exception);
9088 (void) SetImageChannelMask(image,channel_mask);
9091 case 40: /* Gamma */
9093 if (attribute_flag[1] != 0)
9094 channel=(ChannelType) argument_list[1].integer_reference;
9095 if (attribute_flag[2] == 0)
9096 argument_list[2].real_reference=1.0;
9097 if (attribute_flag[3] == 0)
9098 argument_list[3].real_reference=1.0;
9099 if (attribute_flag[4] == 0)
9100 argument_list[4].real_reference=1.0;
9101 if (attribute_flag[0] == 0)
9103 (void) FormatLocaleString(message,MagickPathExtent,
9104 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9105 (double) argument_list[3].real_reference,
9106 (double) argument_list[4].real_reference);
9107 argument_list[0].string_reference=message;
9109 (void) GammaImage(image,StringToDouble(
9110 argument_list[0].string_reference,(char **) NULL),exception);
9118 if (attribute_flag[0] == 0)
9120 ThrowPerlException(exception,OptionError,"MapImageRequired",
9124 quantize_info=AcquireQuantizeInfo(info->image_info);
9125 if (attribute_flag[1] != 0)
9126 quantize_info->dither_method=(DitherMethod)
9127 argument_list[1].integer_reference;
9128 (void) RemapImages(quantize_info,image,
9129 argument_list[0].image_reference,exception);
9130 quantize_info=DestroyQuantizeInfo(quantize_info);
9133 case 42: /* MatteFloodfill */
9144 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9146 if (attribute_flag[0] != 0)
9147 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9148 &geometry,exception);
9149 if (attribute_flag[1] != 0)
9150 geometry.x=argument_list[1].integer_reference;
9151 if (attribute_flag[2] != 0)
9152 geometry.y=argument_list[2].integer_reference;
9153 if (image->alpha_trait == UndefinedPixelTrait)
9154 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9155 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9156 geometry.x,geometry.y,&target,exception);
9157 if (attribute_flag[4] != 0)
9158 QueryColorCompliance(argument_list[4].string_reference,
9159 AllCompliance,&target,exception);
9160 if (attribute_flag[3] != 0)
9161 target.alpha=StringToDoubleInterval(
9162 argument_list[3].string_reference,(double) (double) QuantumRange+
9164 if (attribute_flag[5] != 0)
9165 image->fuzz=StringToDoubleInterval(
9166 argument_list[5].string_reference,(double) QuantumRange+1.0);
9168 if (attribute_flag[6] != 0)
9169 invert=(MagickBooleanType) argument_list[6].integer_reference;
9170 channel_mask=SetImageChannelMask(image,AlphaChannel);
9171 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9172 geometry.y,invert,exception);
9173 (void) SetImageChannelMask(image,channel_mask);
9174 draw_info=DestroyDrawInfo(draw_info);
9177 case 43: /* Modulate */
9180 modulate[MagickPathExtent];
9182 geometry_info.rho=100.0;
9183 geometry_info.sigma=100.0;
9184 geometry_info.xi=100.0;
9185 if (attribute_flag[0] != 0)
9186 (void)ParseGeometry(argument_list[0].string_reference,
9188 if (attribute_flag[1] != 0)
9189 geometry_info.xi=argument_list[1].real_reference;
9190 if (attribute_flag[2] != 0)
9191 geometry_info.sigma=argument_list[2].real_reference;
9192 if (attribute_flag[3] != 0)
9194 geometry_info.sigma=argument_list[3].real_reference;
9195 SetImageArtifact(image,"modulate:colorspace","HWB");
9197 if (attribute_flag[4] != 0)
9199 geometry_info.rho=argument_list[4].real_reference;
9200 SetImageArtifact(image,"modulate:colorspace","HSB");
9202 if (attribute_flag[5] != 0)
9204 geometry_info.sigma=argument_list[5].real_reference;
9205 SetImageArtifact(image,"modulate:colorspace","HSL");
9207 if (attribute_flag[6] != 0)
9209 geometry_info.rho=argument_list[6].real_reference;
9210 SetImageArtifact(image,"modulate:colorspace","HWB");
9212 (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g",
9213 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9214 (void) ModulateImage(image,modulate,exception);
9217 case 44: /* Negate */
9219 if (attribute_flag[0] == 0)
9220 argument_list[0].integer_reference=0;
9221 if (attribute_flag[1] != 0)
9222 channel=(ChannelType) argument_list[1].integer_reference;
9223 channel_mask=SetImageChannelMask(image,channel);
9224 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9225 MagickTrue : MagickFalse,exception);
9226 (void) SetImageChannelMask(image,channel_mask);
9229 case 45: /* Normalize */
9231 if (attribute_flag[0] != 0)
9232 channel=(ChannelType) argument_list[0].integer_reference;
9233 channel_mask=SetImageChannelMask(image,channel);
9234 NormalizeImage(image,exception);
9235 (void) SetImageChannelMask(image,channel_mask);
9238 case 46: /* NumberColors */
9240 case 47: /* Opaque */
9249 (void) QueryColorCompliance("none",AllCompliance,&target,
9251 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9253 if (attribute_flag[0] != 0)
9254 (void) QueryColorCompliance(argument_list[0].string_reference,
9255 AllCompliance,&target,exception);
9256 if (attribute_flag[1] != 0)
9257 (void) QueryColorCompliance(argument_list[1].string_reference,
9258 AllCompliance,&fill_color,exception);
9259 if (attribute_flag[2] != 0)
9260 image->fuzz=StringToDoubleInterval(
9261 argument_list[2].string_reference,(double) QuantumRange+1.0);
9262 if (attribute_flag[3] != 0)
9263 channel=(ChannelType) argument_list[3].integer_reference;
9265 if (attribute_flag[4] != 0)
9266 invert=(MagickBooleanType) argument_list[4].integer_reference;
9267 channel_mask=SetImageChannelMask(image,channel);
9268 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9269 (void) SetImageChannelMask(image,channel_mask);
9272 case 48: /* Quantize */
9277 quantize_info=AcquireQuantizeInfo(info->image_info);
9278 if (attribute_flag[0] != 0)
9279 quantize_info->number_colors=(size_t)
9280 argument_list[0].integer_reference;
9281 if (attribute_flag[1] != 0)
9282 quantize_info->tree_depth=(size_t)
9283 argument_list[1].integer_reference;
9284 if (attribute_flag[2] != 0)
9285 quantize_info->colorspace=(ColorspaceType)
9286 argument_list[2].integer_reference;
9287 if (attribute_flag[3] != 0)
9288 quantize_info->dither_method=(DitherMethod)
9289 argument_list[3].integer_reference;
9290 if (attribute_flag[4] != 0)
9291 quantize_info->measure_error=
9292 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9293 if (attribute_flag[6] != 0)
9294 (void) QueryColorCompliance(argument_list[6].string_reference,
9295 AllCompliance,&image->transparent_color,exception);
9296 if (attribute_flag[7] != 0)
9297 quantize_info->dither_method=(DitherMethod)
9298 argument_list[7].integer_reference;
9299 if (attribute_flag[5] && argument_list[5].integer_reference)
9300 (void) QuantizeImages(quantize_info,image,exception);
9302 if ((image->storage_class == DirectClass) ||
9303 (image->colors > quantize_info->number_colors) ||
9304 (quantize_info->colorspace == GRAYColorspace))
9305 (void) QuantizeImage(quantize_info,image,exception);
9307 CompressImageColormap(image,exception);
9308 quantize_info=DestroyQuantizeInfo(quantize_info);
9311 case 49: /* Raise */
9313 if (attribute_flag[0] != 0)
9314 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9315 &geometry,exception);
9316 if (attribute_flag[1] != 0)
9317 geometry.width=argument_list[1].integer_reference;
9318 if (attribute_flag[2] != 0)
9319 geometry.height=argument_list[2].integer_reference;
9320 if (attribute_flag[3] == 0)
9321 argument_list[3].integer_reference=1;
9322 (void) RaiseImage(image,&geometry,
9323 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9327 case 50: /* Segment */
9334 smoothing_threshold;
9339 cluster_threshold=1.0;
9340 smoothing_threshold=1.5;
9341 colorspace=sRGBColorspace;
9342 verbose=MagickFalse;
9343 if (attribute_flag[0] != 0)
9345 flags=ParseGeometry(argument_list[0].string_reference,
9347 cluster_threshold=geometry_info.rho;
9348 if (flags & SigmaValue)
9349 smoothing_threshold=geometry_info.sigma;
9351 if (attribute_flag[1] != 0)
9352 cluster_threshold=argument_list[1].real_reference;
9353 if (attribute_flag[2] != 0)
9354 smoothing_threshold=argument_list[2].real_reference;
9355 if (attribute_flag[3] != 0)
9356 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9357 if (attribute_flag[4] != 0)
9358 verbose=argument_list[4].integer_reference != 0 ?
9359 MagickTrue : MagickFalse;
9360 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9361 smoothing_threshold,exception);
9364 case 51: /* Signature */
9366 (void) SignatureImage(image,exception);
9369 case 52: /* Solarize */
9371 geometry_info.rho=QuantumRange/2.0;
9372 if (attribute_flag[0] != 0)
9373 flags=ParseGeometry(argument_list[0].string_reference,
9375 if (attribute_flag[1] != 0)
9376 geometry_info.rho=StringToDoubleInterval(
9377 argument_list[1].string_reference,(double) QuantumRange+1.0);
9378 (void) SolarizeImage(image,geometry_info.rho,exception);
9383 (void) SyncImage(image,exception);
9386 case 54: /* Texture */
9388 if (attribute_flag[0] == 0)
9390 TextureImage(image,argument_list[0].image_reference,exception);
9393 case 55: /* Evalute */
9395 MagickEvaluateOperator
9398 op=SetEvaluateOperator;
9399 if (attribute_flag[0] == MagickFalse)
9400 argument_list[0].real_reference=0.0;
9401 if (attribute_flag[1] != MagickFalse)
9402 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9403 if (attribute_flag[2] != MagickFalse)
9404 channel=(ChannelType) argument_list[2].integer_reference;
9405 channel_mask=SetImageChannelMask(image,channel);
9406 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9408 (void) SetImageChannelMask(image,channel_mask);
9411 case 56: /* Transparent */
9422 (void) QueryColorCompliance("none",AllCompliance,&target,
9424 if (attribute_flag[0] != 0)
9425 (void) QueryColorCompliance(argument_list[0].string_reference,
9426 AllCompliance,&target,exception);
9427 opacity=TransparentAlpha;
9428 if (attribute_flag[1] != 0)
9429 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9430 (double) QuantumRange+1.0);
9431 if (attribute_flag[2] != 0)
9432 image->fuzz=StringToDoubleInterval(
9433 argument_list[2].string_reference,(double) QuantumRange+1.0);
9434 if (attribute_flag[3] == 0)
9435 argument_list[3].integer_reference=0;
9437 if (attribute_flag[3] != 0)
9438 invert=(MagickBooleanType) argument_list[3].integer_reference;
9439 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9443 case 57: /* Threshold */
9448 if (attribute_flag[0] == 0)
9449 argument_list[0].string_reference="50%";
9450 if (attribute_flag[1] != 0)
9451 channel=(ChannelType) argument_list[1].integer_reference;
9452 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9453 (double) QuantumRange+1.0);
9454 channel_mask=SetImageChannelMask(image,channel);
9455 (void) BilevelImage(image,threshold,exception);
9456 (void) SetImageChannelMask(image,channel_mask);
9459 case 58: /* Charcoal */
9461 if (attribute_flag[0] != 0)
9463 flags=ParseGeometry(argument_list[0].string_reference,
9465 if ((flags & SigmaValue) == 0)
9466 geometry_info.sigma=1.0;
9468 if (attribute_flag[1] != 0)
9469 geometry_info.rho=argument_list[1].real_reference;
9470 if (attribute_flag[2] != 0)
9471 geometry_info.sigma=argument_list[2].real_reference;
9472 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9478 if (attribute_flag[0] != 0)
9479 image->fuzz=StringToDoubleInterval(
9480 argument_list[0].string_reference,(double) QuantumRange+1.0);
9481 image=TrimImage(image,exception);
9486 PixelInterpolateMethod
9489 if (attribute_flag[0] != 0)
9491 flags=ParseGeometry(argument_list[0].string_reference,
9493 if ((flags & SigmaValue) == 0)
9494 geometry_info.sigma=1.0;
9496 if (attribute_flag[1] != 0)
9497 geometry_info.rho=argument_list[1].real_reference;
9498 if (attribute_flag[2] != 0)
9499 geometry_info.sigma=argument_list[2].real_reference;
9500 method=UndefinedInterpolatePixel;
9501 if (attribute_flag[3] != 0)
9502 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9503 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9507 case 61: /* Separate */
9509 if (attribute_flag[0] != 0)
9510 channel=(ChannelType) argument_list[0].integer_reference;
9511 image=SeparateImage(image,channel,exception);
9514 case 63: /* Stereo */
9516 if (attribute_flag[0] == 0)
9518 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9522 if (attribute_flag[1] != 0)
9523 geometry.x=argument_list[1].integer_reference;
9524 if (attribute_flag[2] != 0)
9525 geometry.y=argument_list[2].integer_reference;
9526 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9527 geometry.x,geometry.y,exception);
9530 case 64: /* Stegano */
9532 if (attribute_flag[0] == 0)
9534 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9538 if (attribute_flag[1] == 0)
9539 argument_list[1].integer_reference=0;
9540 image->offset=argument_list[1].integer_reference;
9541 image=SteganoImage(image,argument_list[0].image_reference,exception);
9544 case 65: /* Deconstruct */
9546 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9549 case 66: /* GaussianBlur */
9551 if (attribute_flag[0] != 0)
9553 flags=ParseGeometry(argument_list[0].string_reference,
9555 if ((flags & SigmaValue) == 0)
9556 geometry_info.sigma=1.0;
9558 if (attribute_flag[1] != 0)
9559 geometry_info.rho=argument_list[1].real_reference;
9560 if (attribute_flag[2] != 0)
9561 geometry_info.sigma=argument_list[2].real_reference;
9562 if (attribute_flag[3] != 0)
9563 channel=(ChannelType) argument_list[3].integer_reference;
9564 channel_mask=SetImageChannelMask(image,channel);
9565 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9567 if (image != (Image *) NULL)
9568 (void) SetImageChannelMask(image,channel_mask);
9571 case 67: /* Convolve */
9576 kernel=(KernelInfo *) NULL;
9577 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9579 if (attribute_flag[0] != 0)
9587 kernel=AcquireKernelInfo((const char *) NULL,exception);
9588 if (kernel == (KernelInfo *) NULL)
9590 av=(AV *) argument_list[0].array_reference;
9591 order=(size_t) sqrt(av_len(av)+1);
9592 kernel->width=order;
9593 kernel->height=order;
9594 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9595 order*sizeof(*kernel->values));
9596 if (kernel->values == (MagickRealType *) NULL)
9598 kernel=DestroyKernelInfo(kernel);
9599 ThrowPerlException(exception,ResourceLimitFatalError,
9600 "MemoryAllocationFailed",PackageName);
9603 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9604 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9605 for ( ; j < (ssize_t) (order*order); j++)
9606 kernel->values[j]=0.0;
9608 if (attribute_flag[1] != 0)
9609 channel=(ChannelType) argument_list[1].integer_reference;
9610 if (attribute_flag[2] != 0)
9611 SetImageArtifact(image,"filter:blur",
9612 argument_list[2].string_reference);
9613 if (attribute_flag[3] != 0)
9615 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9617 if (kernel == (KernelInfo *) NULL)
9620 channel_mask=SetImageChannelMask(image,channel);
9621 image=ConvolveImage(image,kernel,exception);
9622 if (image != (Image *) NULL)
9623 (void) SetImageChannelMask(image,channel_mask);
9624 kernel=DestroyKernelInfo(kernel);
9627 case 68: /* Profile */
9642 if (attribute_flag[0] != 0)
9643 name=argument_list[0].string_reference;
9644 if (attribute_flag[2] != 0)
9645 image->rendering_intent=(RenderingIntent)
9646 argument_list[2].integer_reference;
9647 if (attribute_flag[3] != 0)
9648 image->black_point_compensation=
9649 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9650 if (attribute_flag[1] != 0)
9652 if (argument_list[1].length == 0)
9655 Remove a profile from the image.
9657 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9662 Associate user supplied profile with the image.
9664 profile=AcquireStringInfo(argument_list[1].length);
9665 SetStringInfoDatum(profile,(const unsigned char *)
9666 argument_list[1].string_reference);
9667 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9668 (size_t) GetStringInfoLength(profile),exception);
9669 profile=DestroyStringInfo(profile);
9673 Associate a profile with the image.
9675 profile_info=CloneImageInfo(info ? info->image_info :
9676 (ImageInfo *) NULL);
9677 profile_image=ReadImages(profile_info,name,exception);
9678 if (profile_image == (Image *) NULL)
9680 ResetImageProfileIterator(profile_image);
9681 name=GetNextImageProfile(profile_image);
9682 while (name != (const char *) NULL)
9687 profile=GetImageProfile(profile_image,name);
9688 if (profile != (const StringInfo *) NULL)
9689 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9690 (size_t) GetStringInfoLength(profile),exception);
9691 name=GetNextImageProfile(profile_image);
9693 profile_image=DestroyImage(profile_image);
9694 profile_info=DestroyImageInfo(profile_info);
9697 case 69: /* UnsharpMask */
9699 if (attribute_flag[0] != 0)
9701 flags=ParseGeometry(argument_list[0].string_reference,
9703 if ((flags & SigmaValue) == 0)
9704 geometry_info.sigma=1.0;
9705 if ((flags & XiValue) == 0)
9706 geometry_info.xi=1.0;
9707 if ((flags & PsiValue) == 0)
9708 geometry_info.psi=0.5;
9710 if (attribute_flag[1] != 0)
9711 geometry_info.rho=argument_list[1].real_reference;
9712 if (attribute_flag[2] != 0)
9713 geometry_info.sigma=argument_list[2].real_reference;
9714 if (attribute_flag[3] != 0)
9715 geometry_info.xi=argument_list[3].real_reference;
9716 if (attribute_flag[4] != 0)
9717 geometry_info.psi=argument_list[4].real_reference;
9718 if (attribute_flag[5] != 0)
9719 channel=(ChannelType) argument_list[5].integer_reference;
9720 channel_mask=SetImageChannelMask(image,channel);
9721 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9722 geometry_info.xi,geometry_info.psi,exception);
9723 if (image != (Image *) NULL)
9724 (void) SetImageChannelMask(image,channel_mask);
9727 case 70: /* MotionBlur */
9729 if (attribute_flag[0] != 0)
9731 flags=ParseGeometry(argument_list[0].string_reference,
9733 if ((flags & SigmaValue) == 0)
9734 geometry_info.sigma=1.0;
9735 if ((flags & XiValue) == 0)
9736 geometry_info.xi=1.0;
9738 if (attribute_flag[1] != 0)
9739 geometry_info.rho=argument_list[1].real_reference;
9740 if (attribute_flag[2] != 0)
9741 geometry_info.sigma=argument_list[2].real_reference;
9742 if (attribute_flag[3] != 0)
9743 geometry_info.xi=argument_list[3].real_reference;
9744 if (attribute_flag[4] != 0)
9745 channel=(ChannelType) argument_list[4].integer_reference;
9746 channel_mask=SetImageChannelMask(image,channel);
9747 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9748 geometry_info.xi,exception);
9749 if (image != (Image *) NULL)
9750 (void) SetImageChannelMask(image,channel_mask);
9753 case 71: /* OrderedDither */
9755 if (attribute_flag[0] == 0)
9756 argument_list[0].string_reference="o8x8";
9757 if (attribute_flag[1] != 0)
9758 channel=(ChannelType) argument_list[1].integer_reference;
9759 channel_mask=SetImageChannelMask(image,channel);
9760 (void) OrderedDitherImage(image,argument_list[0].string_reference,
9762 (void) SetImageChannelMask(image,channel_mask);
9765 case 72: /* Shave */
9767 if (attribute_flag[0] != 0)
9768 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9769 &geometry,exception);
9770 if (attribute_flag[1] != 0)
9771 geometry.width=argument_list[1].integer_reference;
9772 if (attribute_flag[2] != 0)
9773 geometry.height=argument_list[2].integer_reference;
9774 image=ShaveImage(image,&geometry,exception);
9777 case 73: /* Level */
9785 white_point=(double) image->columns*image->rows;
9787 if (attribute_flag[0] != 0)
9789 flags=ParseGeometry(argument_list[0].string_reference,
9791 black_point=geometry_info.rho;
9792 if ((flags & SigmaValue) != 0)
9793 white_point=geometry_info.sigma;
9794 if ((flags & XiValue) != 0)
9795 gamma=geometry_info.xi;
9796 if ((flags & PercentValue) != 0)
9798 black_point*=(double) (QuantumRange/100.0);
9799 white_point*=(double) (QuantumRange/100.0);
9801 if ((flags & SigmaValue) == 0)
9802 white_point=(double) QuantumRange-black_point;
9804 if (attribute_flag[1] != 0)
9805 black_point=argument_list[1].real_reference;
9806 if (attribute_flag[2] != 0)
9807 white_point=argument_list[2].real_reference;
9808 if (attribute_flag[3] != 0)
9809 gamma=argument_list[3].real_reference;
9810 if (attribute_flag[4] != 0)
9811 channel=(ChannelType) argument_list[4].integer_reference;
9812 if (attribute_flag[5] != 0)
9814 argument_list[0].real_reference=argument_list[5].real_reference;
9815 attribute_flag[0]=attribute_flag[5];
9817 channel_mask=SetImageChannelMask(image,channel);
9818 (void) LevelImage(image,black_point,white_point,gamma,exception);
9819 (void) SetImageChannelMask(image,channel_mask);
9824 if (attribute_flag[0] == 0)
9825 argument_list[0].string_reference="#1";
9826 if (attribute_flag[1] == 0)
9827 argument_list[1].integer_reference=MagickTrue;
9828 (void) ClipImagePath(image,argument_list[0].string_reference,
9829 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9833 case 75: /* AffineTransform */
9838 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9840 if (attribute_flag[0] != 0)
9845 av=(AV *) argument_list[0].array_reference;
9846 if ((av_len(av) != 3) && (av_len(av) != 5))
9848 ThrowPerlException(exception,OptionError,
9849 "affine matrix must have 4 or 6 elements",PackageName);
9852 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9853 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9854 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9855 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9856 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9857 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9859 ThrowPerlException(exception,OptionError,
9860 "affine matrix is singular",PackageName);
9863 if (av_len(av) == 5)
9865 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9866 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9869 for (j=1; j < 6; j++)
9871 if (attribute_flag[j] == 0)
9873 value=argument_list[j].string_reference;
9874 angle=argument_list[j].real_reference;
9875 current=draw_info->affine;
9876 GetAffineMatrix(&affine);
9884 flags=ParseGeometry(value,&geometry_info);
9885 affine.tx=geometry_info.xi;
9886 affine.ty=geometry_info.psi;
9887 if ((flags & PsiValue) == 0)
9888 affine.ty=affine.tx;
9896 flags=ParseGeometry(value,&geometry_info);
9897 affine.sx=geometry_info.rho;
9898 affine.sy=geometry_info.sigma;
9899 if ((flags & SigmaValue) == 0)
9900 affine.sy=affine.sx;
9910 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9911 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9912 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9913 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9921 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9929 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9933 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9934 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9935 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9936 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9937 draw_info->affine.tx=
9938 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9939 draw_info->affine.ty=
9940 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9942 if (attribute_flag[6] != 0)
9943 image->interpolate=(PixelInterpolateMethod)
9944 argument_list[6].integer_reference;
9945 if (attribute_flag[7] != 0)
9946 QueryColorCompliance(argument_list[7].string_reference,
9947 AllCompliance,&image->background_color,exception);
9948 image=AffineTransformImage(image,&draw_info->affine,exception);
9949 draw_info=DestroyDrawInfo(draw_info);
9952 case 76: /* Difference */
9954 if (attribute_flag[0] == 0)
9956 ThrowPerlException(exception,OptionError,
9957 "ReferenceImageRequired",PackageName);
9960 if (attribute_flag[1] != 0)
9961 image->fuzz=StringToDoubleInterval(
9962 argument_list[1].string_reference,(double) QuantumRange+1.0);
9963 (void) SetImageColorMetric(image,argument_list[0].image_reference,
9967 case 77: /* AdaptiveThreshold */
9969 if (attribute_flag[0] != 0)
9971 flags=ParseGeometry(argument_list[0].string_reference,
9973 if ((flags & PercentValue) != 0)
9974 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9976 if (attribute_flag[1] != 0)
9977 geometry_info.rho=argument_list[1].integer_reference;
9978 if (attribute_flag[2] != 0)
9979 geometry_info.sigma=argument_list[2].integer_reference;
9980 if (attribute_flag[3] != 0)
9981 geometry_info.xi=argument_list[3].integer_reference;;
9982 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9983 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9986 case 78: /* Resample */
9992 if (attribute_flag[0] != 0)
9994 flags=ParseGeometry(argument_list[0].string_reference,
9996 if ((flags & SigmaValue) == 0)
9997 geometry_info.sigma=geometry_info.rho;
9999 if (attribute_flag[1] != 0)
10000 geometry_info.rho=argument_list[1].real_reference;
10001 if (attribute_flag[2] != 0)
10002 geometry_info.sigma=argument_list[2].real_reference;
10003 if (attribute_flag[3] == 0)
10004 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
10005 if (attribute_flag[4] == 0)
10006 SetImageArtifact(image,"filter:support",
10007 argument_list[4].string_reference);
10008 width=(size_t) (geometry_info.rho*image->columns/
10009 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
10010 height=(size_t) (geometry_info.sigma*image->rows/
10011 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
10012 image=ResizeImage(image,width,height,(FilterType)
10013 argument_list[3].integer_reference,exception);
10014 if (image != (Image *) NULL)
10016 image->resolution.x=geometry_info.rho;
10017 image->resolution.y=geometry_info.sigma;
10021 case 79: /* Describe */
10023 if (attribute_flag[0] == 0)
10024 argument_list[0].file_reference=(FILE *) NULL;
10025 if (attribute_flag[1] != 0)
10026 (void) SetImageArtifact(image,"identify:features",
10027 argument_list[1].string_reference);
10028 (void) IdentifyImage(image,argument_list[0].file_reference,
10029 MagickTrue,exception);
10032 case 80: /* BlackThreshold */
10034 if (attribute_flag[0] == 0)
10035 argument_list[0].string_reference="50%";
10036 if (attribute_flag[2] != 0)
10037 channel=(ChannelType) argument_list[2].integer_reference;
10038 channel_mask=SetImageChannelMask(image,channel);
10039 BlackThresholdImage(image,argument_list[0].string_reference,
10041 (void) SetImageChannelMask(image,channel_mask);
10044 case 81: /* WhiteThreshold */
10046 if (attribute_flag[0] == 0)
10047 argument_list[0].string_reference="50%";
10048 if (attribute_flag[2] != 0)
10049 channel=(ChannelType) argument_list[2].integer_reference;
10050 channel_mask=SetImageChannelMask(image,channel);
10051 WhiteThresholdImage(image,argument_list[0].string_reference,
10053 (void) SetImageChannelMask(image,channel_mask);
10056 case 82: /* RotationalBlur */
10058 if (attribute_flag[0] != 0)
10060 flags=ParseGeometry(argument_list[0].string_reference,
10063 if (attribute_flag[1] != 0)
10064 geometry_info.rho=argument_list[1].real_reference;
10065 if (attribute_flag[2] != 0)
10066 channel=(ChannelType) argument_list[2].integer_reference;
10067 channel_mask=SetImageChannelMask(image,channel);
10068 image=RotationalBlurImage(image,geometry_info.rho,exception);
10069 if (image != (Image *) NULL)
10070 (void) SetImageChannelMask(image,channel_mask);
10073 case 83: /* Thumbnail */
10075 if (attribute_flag[0] != 0)
10076 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10077 &geometry,exception);
10078 if (attribute_flag[1] != 0)
10079 geometry.width=argument_list[1].integer_reference;
10080 if (attribute_flag[2] != 0)
10081 geometry.height=argument_list[2].integer_reference;
10082 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10085 case 84: /* Strip */
10087 (void) StripImage(image,exception);
10090 case 85: /* Tint */
10095 GetPixelInfo(image,&tint);
10096 if (attribute_flag[0] != 0)
10097 (void) QueryColorCompliance(argument_list[0].string_reference,
10098 AllCompliance,&tint,exception);
10099 if (attribute_flag[1] == 0)
10100 argument_list[1].string_reference="100";
10101 image=TintImage(image,argument_list[1].string_reference,&tint,
10105 case 86: /* Channel */
10107 if (attribute_flag[0] != 0)
10108 channel=(ChannelType) argument_list[0].integer_reference;
10109 image=SeparateImage(image,channel,exception);
10112 case 87: /* Splice */
10114 if (attribute_flag[7] != 0)
10115 image->gravity=(GravityType) argument_list[7].integer_reference;
10116 if (attribute_flag[0] != 0)
10117 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10118 &geometry,exception);
10119 if (attribute_flag[1] != 0)
10120 geometry.width=argument_list[1].integer_reference;
10121 if (attribute_flag[2] != 0)
10122 geometry.height=argument_list[2].integer_reference;
10123 if (attribute_flag[3] != 0)
10124 geometry.x=argument_list[3].integer_reference;
10125 if (attribute_flag[4] != 0)
10126 geometry.y=argument_list[4].integer_reference;
10127 if (attribute_flag[5] != 0)
10128 image->fuzz=StringToDoubleInterval(
10129 argument_list[5].string_reference,(double) QuantumRange+1.0);
10130 if (attribute_flag[6] != 0)
10131 (void) QueryColorCompliance(argument_list[6].string_reference,
10132 AllCompliance,&image->background_color,exception);
10133 image=SpliceImage(image,&geometry,exception);
10136 case 88: /* Posterize */
10138 if (attribute_flag[0] == 0)
10139 argument_list[0].integer_reference=3;
10140 if (attribute_flag[1] == 0)
10141 argument_list[1].integer_reference=0;
10142 (void) PosterizeImage(image,argument_list[0].integer_reference,
10143 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10144 NoDitherMethod,exception);
10147 case 89: /* Shadow */
10149 if (attribute_flag[0] != 0)
10151 flags=ParseGeometry(argument_list[0].string_reference,
10153 if ((flags & SigmaValue) == 0)
10154 geometry_info.sigma=1.0;
10155 if ((flags & XiValue) == 0)
10156 geometry_info.xi=4.0;
10157 if ((flags & PsiValue) == 0)
10158 geometry_info.psi=4.0;
10160 if (attribute_flag[1] != 0)
10161 geometry_info.rho=argument_list[1].real_reference;
10162 if (attribute_flag[2] != 0)
10163 geometry_info.sigma=argument_list[2].real_reference;
10164 if (attribute_flag[3] != 0)
10165 geometry_info.xi=argument_list[3].integer_reference;
10166 if (attribute_flag[4] != 0)
10167 geometry_info.psi=argument_list[4].integer_reference;
10168 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10169 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10170 ceil(geometry_info.psi-0.5),exception);
10173 case 90: /* Identify */
10175 if (attribute_flag[0] == 0)
10176 argument_list[0].file_reference=(FILE *) NULL;
10177 if (attribute_flag[1] != 0)
10178 (void) SetImageArtifact(image,"identify:features",
10179 argument_list[1].string_reference);
10180 if ((attribute_flag[2] != 0) &&
10181 (argument_list[2].integer_reference != 0))
10182 (void) SetImageArtifact(image,"identify:unique","true");
10183 (void) IdentifyImage(image,argument_list[0].file_reference,
10184 MagickTrue,exception);
10187 case 91: /* SepiaTone */
10189 if (attribute_flag[0] == 0)
10190 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10191 image=SepiaToneImage(image,argument_list[0].real_reference,
10195 case 92: /* SigmoidalContrast */
10200 if (attribute_flag[0] != 0)
10202 flags=ParseGeometry(argument_list[0].string_reference,
10204 if ((flags & SigmaValue) == 0)
10205 geometry_info.sigma=QuantumRange/2.0;
10206 if ((flags & PercentValue) != 0)
10207 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10209 if (attribute_flag[1] != 0)
10210 geometry_info.rho=argument_list[1].real_reference;
10211 if (attribute_flag[2] != 0)
10212 geometry_info.sigma=argument_list[2].real_reference;
10213 if (attribute_flag[3] != 0)
10214 channel=(ChannelType) argument_list[3].integer_reference;
10215 sharpen=MagickTrue;
10216 if (attribute_flag[4] != 0)
10217 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10219 channel_mask=SetImageChannelMask(image,channel);
10220 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10221 geometry_info.sigma,exception);
10222 (void) SetImageChannelMask(image,channel_mask);
10225 case 93: /* Extent */
10227 if (attribute_flag[7] != 0)
10228 image->gravity=(GravityType) argument_list[7].integer_reference;
10229 if (attribute_flag[0] != 0)
10234 flags=ParseGravityGeometry(image,
10235 argument_list[0].string_reference,&geometry,exception);
10237 if (geometry.width == 0)
10238 geometry.width=image->columns;
10239 if (geometry.height == 0)
10240 geometry.height=image->rows;
10242 if (attribute_flag[1] != 0)
10243 geometry.width=argument_list[1].integer_reference;
10244 if (attribute_flag[2] != 0)
10245 geometry.height=argument_list[2].integer_reference;
10246 if (attribute_flag[3] != 0)
10247 geometry.x=argument_list[3].integer_reference;
10248 if (attribute_flag[4] != 0)
10249 geometry.y=argument_list[4].integer_reference;
10250 if (attribute_flag[5] != 0)
10251 image->fuzz=StringToDoubleInterval(
10252 argument_list[5].string_reference,(double) QuantumRange+1.0);
10253 if (attribute_flag[6] != 0)
10254 (void) QueryColorCompliance(argument_list[6].string_reference,
10255 AllCompliance,&image->background_color,exception);
10256 image=ExtentImage(image,&geometry,exception);
10259 case 94: /* Vignette */
10261 if (attribute_flag[0] != 0)
10263 flags=ParseGeometry(argument_list[0].string_reference,
10265 if ((flags & SigmaValue) == 0)
10266 geometry_info.sigma=1.0;
10267 if ((flags & XiValue) == 0)
10268 geometry_info.xi=0.1*image->columns;
10269 if ((flags & PsiValue) == 0)
10270 geometry_info.psi=0.1*image->rows;
10272 if (attribute_flag[1] != 0)
10273 geometry_info.rho=argument_list[1].real_reference;
10274 if (attribute_flag[2] != 0)
10275 geometry_info.sigma=argument_list[2].real_reference;
10276 if (attribute_flag[3] != 0)
10277 geometry_info.xi=argument_list[3].integer_reference;
10278 if (attribute_flag[4] != 0)
10279 geometry_info.psi=argument_list[4].integer_reference;
10280 if (attribute_flag[5] != 0)
10281 (void) QueryColorCompliance(argument_list[5].string_reference,
10282 AllCompliance,&image->background_color,exception);
10283 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10284 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10285 ceil(geometry_info.psi-0.5),exception);
10288 case 95: /* ContrastStretch */
10295 white_point=(double) image->columns*image->rows;
10296 if (attribute_flag[0] != 0)
10298 flags=ParseGeometry(argument_list[0].string_reference,
10300 black_point=geometry_info.rho;
10301 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10303 if ((flags & PercentValue) != 0)
10305 black_point*=(double) image->columns*image->rows/100.0;
10306 white_point*=(double) image->columns*image->rows/100.0;
10308 white_point=(double) image->columns*image->rows-
10311 if (attribute_flag[1] != 0)
10312 black_point=argument_list[1].real_reference;
10313 if (attribute_flag[2] != 0)
10314 white_point=argument_list[2].real_reference;
10315 if (attribute_flag[4] != 0)
10316 channel=(ChannelType) argument_list[4].integer_reference;
10317 channel_mask=SetImageChannelMask(image,channel);
10318 (void) ContrastStretchImage(image,black_point,white_point,exception);
10319 (void) SetImageChannelMask(image,channel_mask);
10322 case 96: /* Sans0 */
10326 case 97: /* Sans1 */
10330 case 98: /* AdaptiveSharpen */
10332 if (attribute_flag[0] != 0)
10334 flags=ParseGeometry(argument_list[0].string_reference,
10336 if ((flags & SigmaValue) == 0)
10337 geometry_info.sigma=1.0;
10338 if ((flags & XiValue) == 0)
10339 geometry_info.xi=0.0;
10341 if (attribute_flag[1] != 0)
10342 geometry_info.rho=argument_list[1].real_reference;
10343 if (attribute_flag[2] != 0)
10344 geometry_info.sigma=argument_list[2].real_reference;
10345 if (attribute_flag[3] != 0)
10346 geometry_info.xi=argument_list[3].real_reference;
10347 if (attribute_flag[4] != 0)
10348 channel=(ChannelType) argument_list[4].integer_reference;
10349 channel_mask=SetImageChannelMask(image,channel);
10350 image=AdaptiveSharpenImage(image,geometry_info.rho,
10351 geometry_info.sigma,exception);
10352 if (image != (Image *) NULL)
10353 (void) SetImageChannelMask(image,channel_mask);
10356 case 99: /* Transpose */
10358 image=TransposeImage(image,exception);
10361 case 100: /* Tranverse */
10363 image=TransverseImage(image,exception);
10366 case 101: /* AutoOrient */
10368 image=AutoOrientImage(image,image->orientation,exception);
10371 case 102: /* AdaptiveBlur */
10373 if (attribute_flag[0] != 0)
10375 flags=ParseGeometry(argument_list[0].string_reference,
10377 if ((flags & SigmaValue) == 0)
10378 geometry_info.sigma=1.0;
10379 if ((flags & XiValue) == 0)
10380 geometry_info.xi=0.0;
10382 if (attribute_flag[1] != 0)
10383 geometry_info.rho=argument_list[1].real_reference;
10384 if (attribute_flag[2] != 0)
10385 geometry_info.sigma=argument_list[2].real_reference;
10386 if (attribute_flag[3] != 0)
10387 channel=(ChannelType) argument_list[3].integer_reference;
10388 channel_mask=SetImageChannelMask(image,channel);
10389 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10391 if (image != (Image *) NULL)
10392 (void) SetImageChannelMask(image,channel_mask);
10395 case 103: /* Sketch */
10397 if (attribute_flag[0] != 0)
10399 flags=ParseGeometry(argument_list[0].string_reference,
10401 if ((flags & SigmaValue) == 0)
10402 geometry_info.sigma=1.0;
10403 if ((flags & XiValue) == 0)
10404 geometry_info.xi=1.0;
10406 if (attribute_flag[1] != 0)
10407 geometry_info.rho=argument_list[1].real_reference;
10408 if (attribute_flag[2] != 0)
10409 geometry_info.sigma=argument_list[2].real_reference;
10410 if (attribute_flag[3] != 0)
10411 geometry_info.xi=argument_list[3].real_reference;
10412 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10413 geometry_info.xi,exception);
10416 case 104: /* UniqueColors */
10418 image=UniqueImageColors(image,exception);
10421 case 105: /* AdaptiveResize */
10423 if (attribute_flag[0] != 0)
10424 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10425 &geometry,exception);
10426 if (attribute_flag[1] != 0)
10427 geometry.width=argument_list[1].integer_reference;
10428 if (attribute_flag[2] != 0)
10429 geometry.height=argument_list[2].integer_reference;
10430 if (attribute_flag[3] != 0)
10431 image->filter=(FilterType) argument_list[4].integer_reference;
10432 if (attribute_flag[4] != 0)
10433 SetImageArtifact(image,"filter:support",
10434 argument_list[4].string_reference);
10435 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10439 case 106: /* ClipMask */
10444 if (attribute_flag[0] == 0)
10446 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10448 goto PerlException;
10450 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10452 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10453 mask_image=DestroyImage(mask_image);
10456 case 107: /* LinearStretch */
10463 white_point=(double) image->columns*image->rows;
10464 if (attribute_flag[0] != 0)
10466 flags=ParseGeometry(argument_list[0].string_reference,
10468 if ((flags & SigmaValue) != 0)
10469 white_point=geometry_info.sigma;
10470 if ((flags & PercentValue) != 0)
10472 black_point*=(double) image->columns*image->rows/100.0;
10473 white_point*=(double) image->columns*image->rows/100.0;
10475 if ((flags & SigmaValue) == 0)
10476 white_point=(double) image->columns*image->rows-black_point;
10478 if (attribute_flag[1] != 0)
10479 black_point=argument_list[1].real_reference;
10480 if (attribute_flag[2] != 0)
10481 white_point=argument_list[2].real_reference;
10482 (void) LinearStretchImage(image,black_point,white_point,exception);
10485 case 108: /* ColorMatrix */
10499 if (attribute_flag[0] == 0)
10501 av=(AV *) argument_list[0].array_reference;
10502 order=(size_t) sqrt(av_len(av)+1);
10503 color_matrix=(double *) AcquireQuantumMemory(order,order*
10504 sizeof(*color_matrix));
10505 if (color_matrix == (double *) NULL)
10507 ThrowPerlException(exception,ResourceLimitFatalError,
10508 "MemoryAllocationFailed",PackageName);
10509 goto PerlException;
10511 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10512 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10513 for ( ; j < (ssize_t) (order*order); j++)
10514 color_matrix[j]=0.0;
10515 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10516 if (kernel_info == (KernelInfo *) NULL)
10518 kernel_info->width=order;
10519 kernel_info->height=order;
10520 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10521 order*sizeof(*kernel_info->values));
10522 if (kernel_info->values != (MagickRealType *) NULL)
10524 for (i=0; i < (ssize_t) (order*order); i++)
10525 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10526 image=ColorMatrixImage(image,kernel_info,exception);
10528 kernel_info=DestroyKernelInfo(kernel_info);
10529 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10532 case 109: /* Mask */
10537 if (attribute_flag[0] == 0)
10539 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10541 goto PerlException;
10543 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10544 MagickTrue,exception);
10545 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10546 mask_image=DestroyImage(mask_image);
10549 case 110: /* Polaroid */
10560 PixelInterpolateMethod
10563 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10564 (DrawInfo *) NULL);
10565 caption=(char *) NULL;
10566 if (attribute_flag[0] != 0)
10567 caption=InterpretImageProperties(info ? info->image_info :
10568 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10571 if (attribute_flag[1] != 0)
10572 angle=argument_list[1].real_reference;
10573 if (attribute_flag[2] != 0)
10574 (void) CloneString(&draw_info->font,
10575 argument_list[2].string_reference);
10576 if (attribute_flag[3] != 0)
10577 (void) QueryColorCompliance(argument_list[3].string_reference,
10578 AllCompliance,&draw_info->stroke,exception);
10579 if (attribute_flag[4] != 0)
10580 (void) QueryColorCompliance(argument_list[4].string_reference,
10581 AllCompliance,&draw_info->fill,exception);
10582 if (attribute_flag[5] != 0)
10583 draw_info->stroke_width=argument_list[5].real_reference;
10584 if (attribute_flag[6] != 0)
10585 draw_info->pointsize=argument_list[6].real_reference;
10586 if (attribute_flag[7] != 0)
10587 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10588 if (attribute_flag[8] != 0)
10589 (void) QueryColorCompliance(argument_list[8].string_reference,
10590 AllCompliance,&image->background_color,exception);
10591 method=UndefinedInterpolatePixel;
10592 if (attribute_flag[9] != 0)
10593 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10594 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10595 draw_info=DestroyDrawInfo(draw_info);
10596 if (caption != (char *) NULL)
10597 caption=DestroyString(caption);
10600 case 111: /* FloodfillPaint */
10611 draw_info=CloneDrawInfo(info ? info->image_info :
10612 (ImageInfo *) NULL,(DrawInfo *) NULL);
10613 if (attribute_flag[0] != 0)
10614 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10615 &geometry,exception);
10616 if (attribute_flag[1] != 0)
10617 geometry.x=argument_list[1].integer_reference;
10618 if (attribute_flag[2] != 0)
10619 geometry.y=argument_list[2].integer_reference;
10620 if (attribute_flag[3] != 0)
10621 (void) QueryColorCompliance(argument_list[3].string_reference,
10622 AllCompliance,&draw_info->fill,exception);
10623 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10624 geometry.x,geometry.y,&target,exception);
10625 if (attribute_flag[4] != 0)
10626 QueryColorCompliance(argument_list[4].string_reference,
10627 AllCompliance,&target,exception);
10628 if (attribute_flag[5] != 0)
10629 image->fuzz=StringToDoubleInterval(
10630 argument_list[5].string_reference,(double) QuantumRange+1.0);
10631 if (attribute_flag[6] != 0)
10632 channel=(ChannelType) argument_list[6].integer_reference;
10633 invert=MagickFalse;
10634 if (attribute_flag[7] != 0)
10635 invert=(MagickBooleanType) argument_list[7].integer_reference;
10636 channel_mask=SetImageChannelMask(image,channel);
10637 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10638 geometry.y,invert,exception);
10639 (void) SetImageChannelMask(image,channel_mask);
10640 draw_info=DestroyDrawInfo(draw_info);
10643 case 112: /* Distort */
10655 number_coordinates;
10660 if (attribute_flag[0] == 0)
10662 method=UndefinedDistortion;
10663 if (attribute_flag[1] != 0)
10664 method=(DistortMethod) argument_list[1].integer_reference;
10665 av=(AV *) argument_list[0].array_reference;
10666 number_coordinates=(size_t) av_len(av)+1;
10667 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10668 sizeof(*coordinates));
10669 if (coordinates == (double *) NULL)
10671 ThrowPerlException(exception,ResourceLimitFatalError,
10672 "MemoryAllocationFailed",PackageName);
10673 goto PerlException;
10675 for (j=0; j < (ssize_t) number_coordinates; j++)
10676 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10677 virtual_pixel=UndefinedVirtualPixelMethod;
10678 if (attribute_flag[2] != 0)
10679 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10680 argument_list[2].integer_reference,exception);
10681 image=DistortImage(image,method,number_coordinates,coordinates,
10682 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10684 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10685 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10687 coordinates=(double *) RelinquishMagickMemory(coordinates);
10690 case 113: /* Clut */
10692 PixelInterpolateMethod
10695 if (attribute_flag[0] == 0)
10697 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10699 goto PerlException;
10701 method=UndefinedInterpolatePixel;
10702 if (attribute_flag[1] != 0)
10703 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10704 if (attribute_flag[2] != 0)
10705 channel=(ChannelType) argument_list[2].integer_reference;
10706 channel_mask=SetImageChannelMask(image,channel);
10707 (void) ClutImage(image,argument_list[0].image_reference,method,
10709 (void) SetImageChannelMask(image,channel_mask);
10712 case 114: /* LiquidRescale */
10714 if (attribute_flag[0] != 0)
10715 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10716 &geometry,exception);
10717 if (attribute_flag[1] != 0)
10718 geometry.width=argument_list[1].integer_reference;
10719 if (attribute_flag[2] != 0)
10720 geometry.height=argument_list[2].integer_reference;
10721 if (attribute_flag[3] == 0)
10722 argument_list[3].real_reference=1.0;
10723 if (attribute_flag[4] == 0)
10724 argument_list[4].real_reference=0.0;
10725 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10726 argument_list[3].real_reference,argument_list[4].real_reference,
10730 case 115: /* EncipherImage */
10732 (void) EncipherImage(image,argument_list[0].string_reference,
10736 case 116: /* DecipherImage */
10738 (void) DecipherImage(image,argument_list[0].string_reference,
10742 case 117: /* Deskew */
10744 geometry_info.rho=QuantumRange/2.0;
10745 if (attribute_flag[0] != 0)
10746 flags=ParseGeometry(argument_list[0].string_reference,
10748 if (attribute_flag[1] != 0)
10749 geometry_info.rho=StringToDoubleInterval(
10750 argument_list[1].string_reference,(double) QuantumRange+1.0);
10751 image=DeskewImage(image,geometry_info.rho,exception);
10754 case 118: /* Remap */
10759 if (attribute_flag[0] == 0)
10761 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10763 goto PerlException;
10765 quantize_info=AcquireQuantizeInfo(info->image_info);
10766 if (attribute_flag[1] != 0)
10767 quantize_info->dither_method=(DitherMethod)
10768 argument_list[1].integer_reference;
10769 (void) RemapImages(quantize_info,image,
10770 argument_list[0].image_reference,exception);
10771 quantize_info=DestroyQuantizeInfo(quantize_info);
10774 case 119: /* SparseColor */
10786 number_coordinates;
10791 if (attribute_flag[0] == 0)
10793 method=UndefinedColorInterpolate;
10794 if (attribute_flag[1] != 0)
10795 method=(SparseColorMethod) argument_list[1].integer_reference;
10796 av=(AV *) argument_list[0].array_reference;
10797 number_coordinates=(size_t) av_len(av)+1;
10798 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10799 sizeof(*coordinates));
10800 if (coordinates == (double *) NULL)
10802 ThrowPerlException(exception,ResourceLimitFatalError,
10803 "MemoryAllocationFailed",PackageName);
10804 goto PerlException;
10806 for (j=0; j < (ssize_t) number_coordinates; j++)
10807 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10808 virtual_pixel=UndefinedVirtualPixelMethod;
10809 if (attribute_flag[2] != 0)
10810 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10811 argument_list[2].integer_reference,exception);
10812 if (attribute_flag[3] != 0)
10813 channel=(ChannelType) argument_list[3].integer_reference;
10814 channel_mask=SetImageChannelMask(image,channel);
10815 image=SparseColorImage(image,method,number_coordinates,coordinates,
10817 if (image != (Image *) NULL)
10818 (void) SetImageChannelMask(image,channel_mask);
10819 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10820 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10822 coordinates=(double *) RelinquishMagickMemory(coordinates);
10825 case 120: /* Function */
10842 if (attribute_flag[0] == 0)
10844 function=UndefinedFunction;
10845 if (attribute_flag[1] != 0)
10846 function=(MagickFunction) argument_list[1].integer_reference;
10847 av=(AV *) argument_list[0].array_reference;
10848 number_parameters=(size_t) av_len(av)+1;
10849 parameters=(double *) AcquireQuantumMemory(number_parameters,
10850 sizeof(*parameters));
10851 if (parameters == (double *) NULL)
10853 ThrowPerlException(exception,ResourceLimitFatalError,
10854 "MemoryAllocationFailed",PackageName);
10855 goto PerlException;
10857 for (j=0; j < (ssize_t) number_parameters; j++)
10858 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10859 virtual_pixel=UndefinedVirtualPixelMethod;
10860 if (attribute_flag[2] != 0)
10861 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10862 argument_list[2].integer_reference,exception);
10863 (void) FunctionImage(image,function,number_parameters,parameters,
10865 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10866 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10868 parameters=(double *) RelinquishMagickMemory(parameters);
10871 case 121: /* SelectiveBlur */
10873 if (attribute_flag[0] != 0)
10875 flags=ParseGeometry(argument_list[0].string_reference,
10877 if ((flags & SigmaValue) == 0)
10878 geometry_info.sigma=1.0;
10879 if ((flags & PercentValue) != 0)
10880 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10882 if (attribute_flag[1] != 0)
10883 geometry_info.rho=argument_list[1].real_reference;
10884 if (attribute_flag[2] != 0)
10885 geometry_info.sigma=argument_list[2].real_reference;
10886 if (attribute_flag[3] != 0)
10887 geometry_info.xi=argument_list[3].integer_reference;;
10888 if (attribute_flag[5] != 0)
10889 channel=(ChannelType) argument_list[5].integer_reference;
10890 channel_mask=SetImageChannelMask(image,channel);
10891 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10892 geometry_info.xi,exception);
10893 if (image != (Image *) NULL)
10894 (void) SetImageChannelMask(image,channel_mask);
10897 case 122: /* HaldClut */
10899 if (attribute_flag[0] == 0)
10901 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10903 goto PerlException;
10905 if (attribute_flag[1] != 0)
10906 channel=(ChannelType) argument_list[1].integer_reference;
10907 channel_mask=SetImageChannelMask(image,channel);
10908 (void) HaldClutImage(image,argument_list[0].image_reference,
10910 (void) SetImageChannelMask(image,channel_mask);
10913 case 123: /* BlueShift */
10915 if (attribute_flag[0] != 0)
10916 (void) ParseGeometry(argument_list[0].string_reference,
10918 image=BlueShiftImage(image,geometry_info.rho,exception);
10921 case 124: /* ForwardFourierTransformImage */
10923 image=ForwardFourierTransformImage(image,
10924 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10928 case 125: /* InverseFourierTransformImage */
10930 image=InverseFourierTransformImage(image,image->next,
10931 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10935 case 126: /* ColorDecisionList */
10937 if (attribute_flag[0] == 0)
10938 argument_list[0].string_reference=(char *) NULL;
10939 (void) ColorDecisionListImage(image,
10940 argument_list[0].string_reference,exception);
10943 case 127: /* AutoGamma */
10945 if (attribute_flag[0] != 0)
10946 channel=(ChannelType) argument_list[0].integer_reference;
10947 channel_mask=SetImageChannelMask(image,channel);
10948 (void) AutoGammaImage(image,exception);
10949 (void) SetImageChannelMask(image,channel_mask);
10952 case 128: /* AutoLevel */
10954 if (attribute_flag[0] != 0)
10955 channel=(ChannelType) argument_list[0].integer_reference;
10956 channel_mask=SetImageChannelMask(image,channel);
10957 (void) AutoLevelImage(image,exception);
10958 (void) SetImageChannelMask(image,channel_mask);
10961 case 129: /* LevelColors */
10967 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10969 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10971 if (attribute_flag[1] != 0)
10972 (void) QueryColorCompliance(
10973 argument_list[1].string_reference,AllCompliance,&black_point,
10975 if (attribute_flag[2] != 0)
10976 (void) QueryColorCompliance(
10977 argument_list[2].string_reference,AllCompliance,&white_point,
10979 if (attribute_flag[3] != 0)
10980 channel=(ChannelType) argument_list[3].integer_reference;
10981 channel_mask=SetImageChannelMask(image,channel);
10982 (void) LevelImageColors(image,&black_point,&white_point,
10983 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10985 (void) SetImageChannelMask(image,channel_mask);
10988 case 130: /* Clamp */
10990 if (attribute_flag[0] != 0)
10991 channel=(ChannelType) argument_list[0].integer_reference;
10992 channel_mask=SetImageChannelMask(image,channel);
10993 (void) ClampImage(image,exception);
10994 (void) SetImageChannelMask(image,channel_mask);
10997 case 131: /* BrightnessContrast */
11005 if (attribute_flag[0] != 0)
11007 flags=ParseGeometry(argument_list[0].string_reference,
11009 brightness=geometry_info.rho;
11010 if ((flags & SigmaValue) == 0)
11011 contrast=geometry_info.sigma;
11013 if (attribute_flag[1] != 0)
11014 brightness=argument_list[1].real_reference;
11015 if (attribute_flag[2] != 0)
11016 contrast=argument_list[2].real_reference;
11017 if (attribute_flag[4] != 0)
11018 channel=(ChannelType) argument_list[4].integer_reference;
11019 channel_mask=SetImageChannelMask(image,channel);
11020 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11021 (void) SetImageChannelMask(image,channel_mask);
11024 case 132: /* Morphology */
11035 if (attribute_flag[0] == 0)
11037 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11038 if (kernel == (KernelInfo *) NULL)
11040 if (attribute_flag[1] != 0)
11041 channel=(ChannelType) argument_list[1].integer_reference;
11042 method=UndefinedMorphology;
11043 if (attribute_flag[2] != 0)
11044 method=argument_list[2].integer_reference;
11046 if (attribute_flag[3] != 0)
11047 iterations=argument_list[3].integer_reference;
11048 channel_mask=SetImageChannelMask(image,channel);
11049 image=MorphologyImage(image,method,iterations,kernel,exception);
11050 if (image != (Image *) NULL)
11051 (void) SetImageChannelMask(image,channel_mask);
11052 kernel=DestroyKernelInfo(kernel);
11055 case 133: /* Mode */
11057 if (attribute_flag[0] != 0)
11059 flags=ParseGeometry(argument_list[0].string_reference,
11061 if ((flags & SigmaValue) == 0)
11062 geometry_info.sigma=1.0;
11064 if (attribute_flag[1] != 0)
11065 geometry_info.rho=argument_list[1].real_reference;
11066 if (attribute_flag[2] != 0)
11067 geometry_info.sigma=argument_list[2].real_reference;
11068 if (attribute_flag[3] != 0)
11069 channel=(ChannelType) argument_list[3].integer_reference;
11070 channel_mask=SetImageChannelMask(image,channel);
11071 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11072 (size_t) geometry_info.sigma,exception);
11073 if (image != (Image *) NULL)
11074 (void) SetImageChannelMask(image,channel_mask);
11077 case 134: /* Statistic */
11082 statistic=UndefinedStatistic;
11083 if (attribute_flag[0] != 0)
11085 flags=ParseGeometry(argument_list[0].string_reference,
11087 if ((flags & SigmaValue) == 0)
11088 geometry_info.sigma=1.0;
11090 if (attribute_flag[1] != 0)
11091 geometry_info.rho=argument_list[1].real_reference;
11092 if (attribute_flag[2] != 0)
11093 geometry_info.sigma=argument_list[2].real_reference;
11094 if (attribute_flag[3] != 0)
11095 channel=(ChannelType) argument_list[3].integer_reference;
11096 if (attribute_flag[4] != 0)
11097 statistic=(StatisticType) argument_list[4].integer_reference;
11098 channel_mask=SetImageChannelMask(image,channel);
11099 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11100 (size_t) geometry_info.sigma,exception);
11101 if (image != (Image *) NULL)
11102 (void) SetImageChannelMask(image,channel_mask);
11105 case 135: /* Perceptible */
11110 epsilon=MagickEpsilon;
11111 if (attribute_flag[0] != 0)
11112 epsilon=argument_list[0].real_reference;
11113 if (attribute_flag[1] != 0)
11114 channel=(ChannelType) argument_list[1].integer_reference;
11115 channel_mask=SetImageChannelMask(image,channel);
11116 (void) PerceptibleImage(image,epsilon,exception);
11117 (void) SetImageChannelMask(image,channel_mask);
11120 case 136: /* Poly */
11131 if (attribute_flag[0] == 0)
11133 if (attribute_flag[1] != 0)
11134 channel=(ChannelType) argument_list[1].integer_reference;
11135 av=(AV *) argument_list[0].array_reference;
11136 number_terms=(size_t) av_len(av);
11137 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11138 if (terms == (double *) NULL)
11140 ThrowPerlException(exception,ResourceLimitFatalError,
11141 "MemoryAllocationFailed",PackageName);
11142 goto PerlException;
11144 for (j=0; j < av_len(av); j++)
11145 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11146 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11147 terms=(double *) RelinquishMagickMemory(terms);
11150 case 137: /* Grayscale */
11152 PixelIntensityMethod
11155 method=UndefinedPixelIntensityMethod;
11156 if (attribute_flag[0] != 0)
11157 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11158 (void) GrayscaleImage(image,method,exception);
11161 case 138: /* Canny */
11163 if (attribute_flag[0] != 0)
11165 flags=ParseGeometry(argument_list[0].string_reference,
11167 if ((flags & SigmaValue) == 0)
11168 geometry_info.sigma=1.0;
11169 if ((flags & XiValue) == 0)
11170 geometry_info.xi=0.10;
11171 if ((flags & PsiValue) == 0)
11172 geometry_info.psi=0.30;
11173 if ((flags & PercentValue) != 0)
11175 geometry_info.xi/=100.0;
11176 geometry_info.psi/=100.0;
11179 if (attribute_flag[1] != 0)
11180 geometry_info.rho=argument_list[1].real_reference;
11181 if (attribute_flag[2] != 0)
11182 geometry_info.sigma=argument_list[2].real_reference;
11183 if (attribute_flag[3] != 0)
11184 geometry_info.xi=argument_list[3].real_reference;
11185 if (attribute_flag[4] != 0)
11186 geometry_info.psi=argument_list[4].real_reference;
11187 if (attribute_flag[5] != 0)
11188 channel=(ChannelType) argument_list[5].integer_reference;
11189 channel_mask=SetImageChannelMask(image,channel);
11190 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11191 geometry_info.xi,geometry_info.psi,exception);
11192 if (image != (Image *) NULL)
11193 (void) SetImageChannelMask(image,channel_mask);
11196 case 139: /* HoughLine */
11198 if (attribute_flag[0] != 0)
11200 flags=ParseGeometry(argument_list[0].string_reference,
11202 if ((flags & SigmaValue) == 0)
11203 geometry_info.sigma=geometry_info.rho;
11204 if ((flags & XiValue) == 0)
11205 geometry_info.xi=40;
11207 if (attribute_flag[1] != 0)
11208 geometry_info.rho=(double) argument_list[1].integer_reference;
11209 if (attribute_flag[2] != 0)
11210 geometry_info.sigma=(double) argument_list[2].integer_reference;
11211 if (attribute_flag[3] != 0)
11212 geometry_info.xi=(double) argument_list[3].integer_reference;
11213 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11214 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11217 case 140: /* MeanShift */
11219 if (attribute_flag[0] != 0)
11221 flags=ParseGeometry(argument_list[0].string_reference,
11223 if ((flags & SigmaValue) == 0)
11224 geometry_info.sigma=geometry_info.rho;
11225 if ((flags & XiValue) == 0)
11226 geometry_info.xi=0.10*QuantumRange;
11227 if ((flags & PercentValue) != 0)
11228 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11230 if (attribute_flag[1] != 0)
11231 geometry_info.rho=(double) argument_list[1].integer_reference;
11232 if (attribute_flag[2] != 0)
11233 geometry_info.sigma=(double) argument_list[2].integer_reference;
11234 if (attribute_flag[3] != 0)
11235 geometry_info.xi=(double) argument_list[3].integer_reference;
11236 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11237 geometry_info.sigma,geometry_info.xi,exception);
11240 case 141: /* Kuwahara */
11242 if (attribute_flag[0] != 0)
11244 flags=ParseGeometry(argument_list[0].string_reference,
11246 if ((flags & SigmaValue) == 0)
11247 geometry_info.sigma=geometry_info.rho-0.5;
11249 if (attribute_flag[1] != 0)
11250 geometry_info.rho=argument_list[1].real_reference;
11251 if (attribute_flag[2] != 0)
11252 geometry_info.sigma=argument_list[2].real_reference;
11253 if (attribute_flag[3] != 0)
11254 channel=(ChannelType) argument_list[3].integer_reference;
11255 channel_mask=SetImageChannelMask(image,channel);
11256 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11258 if (image != (Image *) NULL)
11259 (void) SetImageChannelMask(image,channel_mask);
11262 case 142: /* ConnectedComponent */
11268 if (attribute_flag[0] != 0)
11269 connectivity=argument_list[0].integer_reference;
11270 image=ConnectedComponentsImage(image,connectivity,
11271 (CCObjectInfo **) NULL,exception);
11274 case 143: /* Copy */
11285 source_image=image;
11286 if (attribute_flag[0] != 0)
11287 source_image=argument_list[0].image_reference;
11288 SetGeometry(source_image,&geometry);
11289 if (attribute_flag[1] != 0)
11290 flags=ParseGravityGeometry(source_image,
11291 argument_list[1].string_reference,&geometry,exception);
11292 if (attribute_flag[2] != 0)
11293 geometry.width=argument_list[2].integer_reference;
11294 if (attribute_flag[3] != 0)
11295 geometry.height=argument_list[3].integer_reference;
11296 if (attribute_flag[4] != 0)
11297 geometry.x=argument_list[4].integer_reference;
11298 if (attribute_flag[5] != 0)
11299 geometry.y=argument_list[5].integer_reference;
11300 if (attribute_flag[6] != 0)
11301 image->gravity=(GravityType) argument_list[6].integer_reference;
11302 SetGeometry(image,&offset_geometry);
11303 if (attribute_flag[7] != 0)
11304 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11305 &offset_geometry,exception);
11306 offset.x=offset_geometry.x;
11307 offset.y=offset_geometry.y;
11308 if (attribute_flag[8] != 0)
11309 offset.x=argument_list[8].integer_reference;
11310 if (attribute_flag[9] != 0)
11311 offset.y=argument_list[9].integer_reference;
11312 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11316 case 144: /* Color */
11321 (void) QueryColorCompliance("none",AllCompliance,&color,exception);
11322 if (attribute_flag[0] != 0)
11323 (void) QueryColorCompliance(argument_list[0].string_reference,
11324 AllCompliance,&color,exception);
11325 (void) SetImageColor(image,&color,exception);
11328 case 145: /* WaveletDenoise */
11330 if (attribute_flag[0] == 0)
11331 argument_list[0].string_reference="5%";
11332 if (attribute_flag[2] != 0)
11333 channel=(ChannelType) argument_list[2].integer_reference;
11334 flags=ParseGeometry(argument_list[0].string_reference,&geometry_info);
11335 if ((flags & PercentValue) != 0)
11336 geometry_info.rho*=(double) (QuantumRange/100.0);
11337 channel_mask=SetImageChannelMask(image,channel);
11338 image=WaveletDenoiseImage(image,geometry_info.rho,exception);
11339 if (image != (Image *) NULL)
11340 (void) SetImageChannelMask(image,channel_mask);
11344 if (next != (Image *) NULL)
11345 (void) CatchImageException(next);
11346 if (region_image != (Image *) NULL)
11351 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11352 region_info.x,region_info.y,exception);
11354 (void) CatchImageException(region_image);
11355 image=DestroyImage(image);
11356 image=region_image;
11358 if (image != (Image *) NULL)
11361 if (next && (next != image))
11363 image->next=next->next;
11364 if (image->next != (Image *) NULL)
11365 image->next->previous=image;
11366 DeleteImageFromRegistry(*pv,next);
11368 sv_setiv(*pv,PTR2IV(image));
11376 if (reference_vector)
11377 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11378 InheritPerlException(exception,perl_exception);
11379 exception=DestroyExceptionInfo(exception);
11380 sv_setiv(perl_exception,(IV) number_images);
11381 SvPOK_on(perl_exception);
11382 ST(0)=sv_2mortal(perl_exception);
11387 ###############################################################################
11395 ###############################################################################
11400 Image::Magick ref=NO_INIT
11445 PERL_UNUSED_VAR(ref);
11446 PERL_UNUSED_VAR(ix);
11447 exception=AcquireExceptionInfo();
11448 perl_exception=newSVpv("",0);
11451 if (sv_isobject(ST(0)) == 0)
11453 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11455 goto PerlException;
11457 reference=SvRV(ST(0));
11458 hv=SvSTASH(reference);
11460 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11462 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11463 if (image == (Image *) NULL)
11465 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11467 goto PerlException;
11472 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11473 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11474 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11476 for (i=2; i < items; i+=2)
11478 attribute=(char *) SvPV(ST(i-1),na);
11479 switch (*attribute)
11484 if (LocaleCompare(attribute,"background") == 0)
11486 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11487 &montage_info->background_color,exception);
11488 for (next=image; next; next=next->next)
11489 next->background_color=montage_info->background_color;
11492 if (LocaleCompare(attribute,"border") == 0)
11494 montage_info->border_width=SvIV(ST(i));
11497 if (LocaleCompare(attribute,"bordercolor") == 0)
11499 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11500 &montage_info->border_color,exception);
11501 for (next=image; next; next=next->next)
11502 next->border_color=montage_info->border_color;
11505 if (LocaleCompare(attribute,"borderwidth") == 0)
11507 montage_info->border_width=SvIV(ST(i));
11510 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11517 if (LocaleCompare(attribute,"compose") == 0)
11519 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11520 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11523 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11527 for (next=image; next; next=next->next)
11528 next->compose=(CompositeOperator) sp;
11531 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11538 if (LocaleCompare(attribute,"fill") == 0)
11540 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11541 &montage_info->fill,exception);
11544 if (LocaleCompare(attribute,"font") == 0)
11546 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11549 if (LocaleCompare(attribute,"frame") == 0)
11555 if (IsGeometry(p) == MagickFalse)
11557 ThrowPerlException(exception,OptionError,"MissingGeometry",
11561 (void) CloneString(&montage_info->frame,p);
11563 montage_info->frame=(char *) NULL;
11566 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11573 if (LocaleCompare(attribute,"geometry") == 0)
11579 if (IsGeometry(p) == MagickFalse)
11581 ThrowPerlException(exception,OptionError,"MissingGeometry",
11585 (void) CloneString(&montage_info->geometry,p);
11587 montage_info->geometry=(char *) NULL;
11590 if (LocaleCompare(attribute,"gravity") == 0)
11595 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11596 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11599 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11603 montage_info->gravity=(GravityType) in;
11604 for (next=image; next; next=next->next)
11605 next->gravity=(GravityType) in;
11608 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11615 if (LocaleCompare(attribute,"label") == 0)
11617 for (next=image; next; next=next->next)
11618 (void) SetImageProperty(next,"label",InterpretImageProperties(
11619 info ? info->image_info : (ImageInfo *) NULL,next,
11620 SvPV(ST(i),na),exception),exception);
11623 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11630 if (LocaleCompare(attribute,"mattecolor") == 0)
11632 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11633 &montage_info->alpha_color,exception);
11634 for (next=image; next; next=next->next)
11635 next->alpha_color=montage_info->alpha_color;
11638 if (LocaleCompare(attribute,"mode") == 0)
11643 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11644 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11649 ThrowPerlException(exception,OptionError,
11650 "UnrecognizedModeType",SvPV(ST(i),na));
11655 (void) CloneString(&montage_info->frame,"15x15+3+3");
11656 montage_info->shadow=MagickTrue;
11661 montage_info->frame=(char *) NULL;
11662 montage_info->shadow=MagickFalse;
11663 montage_info->border_width=0;
11666 case ConcatenateMode:
11668 montage_info->frame=(char *) NULL;
11669 montage_info->shadow=MagickFalse;
11670 (void) CloneString(&montage_info->geometry,"+0+0");
11671 montage_info->border_width=0;
11676 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11683 if (LocaleCompare(attribute,"pointsize") == 0)
11685 montage_info->pointsize=SvIV(ST(i));
11688 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11695 if (LocaleCompare(attribute,"shadow") == 0)
11697 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11698 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11701 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11705 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11708 if (LocaleCompare(attribute,"stroke") == 0)
11710 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11711 &montage_info->stroke,exception);
11714 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11721 if (LocaleCompare(attribute,"texture") == 0)
11723 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11726 if (LocaleCompare(attribute,"tile") == 0)
11728 char *p=SvPV(ST(i),na);
11729 if (IsGeometry(p) == MagickFalse)
11731 ThrowPerlException(exception,OptionError,"MissingGeometry",
11735 (void) CloneString(&montage_info->tile,p);
11737 montage_info->tile=(char *) NULL;
11740 if (LocaleCompare(attribute,"title") == 0)
11742 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11745 if (LocaleCompare(attribute,"transparent") == 0)
11750 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11751 &transparent_color,exception);
11752 for (next=image; next; next=next->next)
11753 (void) TransparentPaintImage(next,&transparent_color,
11754 TransparentAlpha,MagickFalse,exception);
11757 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11763 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11769 image=MontageImageList(info->image_info,montage_info,image,exception);
11770 montage_info=DestroyMontageInfo(montage_info);
11771 if (image == (Image *) NULL)
11772 goto PerlException;
11773 if (transparent_color.alpha != TransparentAlpha)
11774 for (next=image; next; next=next->next)
11775 (void) TransparentPaintImage(next,&transparent_color,
11776 TransparentAlpha,MagickFalse,exception);
11777 for ( ; image; image=image->next)
11779 AddImageToRegistry(sv,image);
11781 av_push(av,sv_bless(rv,hv));
11784 exception=DestroyExceptionInfo(exception);
11785 ST(0)=av_reference;
11786 SvREFCNT_dec(perl_exception);
11790 InheritPerlException(exception,perl_exception);
11791 exception=DestroyExceptionInfo(exception);
11792 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11793 SvPOK_on(perl_exception);
11794 ST(0)=sv_2mortal(perl_exception);
11799 ###############################################################################
11807 ###############################################################################
11812 Image::Magick ref=NO_INIT
11850 PERL_UNUSED_VAR(ref);
11851 PERL_UNUSED_VAR(ix);
11852 exception=AcquireExceptionInfo();
11853 perl_exception=newSVpv("",0);
11857 if (sv_isobject(ST(0)) == 0)
11859 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11861 goto PerlException;
11863 reference=SvRV(ST(0));
11864 hv=SvSTASH(reference);
11866 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11868 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11869 if (image == (Image *) NULL)
11871 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11873 goto PerlException;
11875 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11880 for (i=2; i < items; i+=2)
11882 attribute=(char *) SvPV(ST(i-1),na);
11883 switch (*attribute)
11888 if (LocaleCompare(attribute,"frames") == 0)
11890 number_frames=SvIV(ST(i));
11893 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11905 image=MorphImages(image,number_frames,exception);
11906 if (image == (Image *) NULL)
11907 goto PerlException;
11908 for ( ; image; image=image->next)
11910 AddImageToRegistry(sv,image);
11912 av_push(av,sv_bless(rv,hv));
11915 exception=DestroyExceptionInfo(exception);
11916 ST(0)=av_reference;
11917 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11921 InheritPerlException(exception,perl_exception);
11922 exception=DestroyExceptionInfo(exception);
11923 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11924 SvPOK_on(perl_exception);
11925 ST(0)=sv_2mortal(perl_exception);
11930 ###############################################################################
11938 ###############################################################################
11943 Image::Magick ref=NO_INIT
11971 PERL_UNUSED_VAR(ref);
11972 PERL_UNUSED_VAR(ix);
11973 exception=AcquireExceptionInfo();
11974 perl_exception=newSVpv("",0);
11976 if (sv_isobject(ST(0)) == 0)
11978 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11980 goto PerlException;
11982 reference=SvRV(ST(0));
11983 hv=SvSTASH(reference);
11984 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11985 if (image == (Image *) NULL)
11987 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11989 goto PerlException;
11991 image=MergeImageLayers(image,MosaicLayer,exception);
11993 Create blessed Perl array for the returned image.
11996 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11998 AddImageToRegistry(sv,image);
12000 av_push(av,sv_bless(rv,hv));
12002 (void) CopyMagickString(info->image_info->filename,image->filename,
12004 SetImageInfo(info->image_info,0,exception);
12005 exception=DestroyExceptionInfo(exception);
12006 SvREFCNT_dec(perl_exception);
12010 InheritPerlException(exception,perl_exception);
12011 exception=DestroyExceptionInfo(exception);
12012 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12013 SvPOK_on(perl_exception); /* return messages in string context */
12014 ST(0)=sv_2mortal(perl_exception);
12019 ###############################################################################
12027 ###############################################################################
12032 Image::Magick ref=NO_INIT
12082 PERL_UNUSED_VAR(ref);
12083 PERL_UNUSED_VAR(ix);
12084 exception=AcquireExceptionInfo();
12085 perl_exception=newSVpv("",0);
12086 package_info=(struct PackageInfo *) NULL;
12087 ac=(items < 2) ? 1 : items-1;
12088 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12090 length=(STRLEN *) NULL;
12091 if (list == (char **) NULL)
12093 ThrowPerlException(exception,ResourceLimitError,
12094 "MemoryAllocationFailed",PackageName);
12095 goto PerlException;
12098 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12099 if (length == (STRLEN *) NULL)
12101 ThrowPerlException(exception,ResourceLimitError,
12102 "MemoryAllocationFailed",PackageName);
12103 goto PerlException;
12105 if (sv_isobject(ST(0)) == 0)
12107 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12109 goto PerlException;
12111 reference=SvRV(ST(0));
12112 if (SvTYPE(reference) != SVt_PVAV)
12114 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12116 goto PerlException;
12118 av=(AV *) reference;
12119 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12121 package_info=ClonePackageInfo(info,exception);
12124 *list=(char *) (*package_info->image_info->filename ?
12125 package_info->image_info->filename : "XC:black");
12127 for (n=0, i=0; i < ac; i++)
12129 list[n]=(char *) SvPV(ST(i+1),length[n]);
12130 if ((items >= 3) && strEQcase(list[n],"blob"))
12136 blob=(void *) (SvPV(ST(i+1),length[n]));
12137 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12139 if ((items >= 3) && strEQcase(list[n],"filename"))
12141 if ((items >= 3) && strEQcase(list[n],"file"))
12150 io_info=IoIFP(sv_2io(ST(i+1)));
12151 if (io_info == (PerlIO *) NULL)
12153 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12157 file=PerlIO_findFILE(io_info);
12158 if (file == (FILE *) NULL)
12160 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12164 SetImageInfoFile(package_info->image_info,file);
12166 if ((items >= 3) && strEQcase(list[n],"magick"))
12170 list[n]=(char *) NULL;
12172 status=ExpandFilenames(&n,&list);
12173 if (status == MagickFalse)
12175 ThrowPerlException(exception,ResourceLimitError,
12176 "MemoryAllocationFailed",PackageName);
12177 goto PerlException;
12180 for (i=0; i < n; i++)
12182 (void) CopyMagickString(package_info->image_info->filename,list[i],
12184 image=PingImage(package_info->image_info,exception);
12185 if (image == (Image *) NULL)
12187 if ((package_info->image_info->file != (FILE *) NULL) ||
12188 (package_info->image_info->blob != (void *) NULL))
12189 DisassociateImageStream(image);
12190 count+=GetImageListLength(image);
12191 EXTEND(sp,4*count);
12192 for (next=image; next; next=next->next)
12194 PUSHs(sv_2mortal(newSViv(next->columns)));
12195 PUSHs(sv_2mortal(newSViv(next->rows)));
12196 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12197 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12199 image=DestroyImageList(image);
12204 for (i=0; i < n; i++)
12205 if (list[i] != (char *) NULL)
12206 for (p=keep; list[i] != *p++; )
12209 list[i]=(char *) RelinquishMagickMemory(list[i]);
12214 if (package_info != (struct PackageInfo *) NULL)
12215 DestroyPackageInfo(package_info);
12216 if (list && (list != keep))
12217 list=(char **) RelinquishMagickMemory(list);
12219 keep=(char **) RelinquishMagickMemory(keep);
12221 length=(STRLEN *) RelinquishMagickMemory(length);
12222 InheritPerlException(exception,perl_exception);
12223 exception=DestroyExceptionInfo(exception);
12224 SvREFCNT_dec(perl_exception); /* throw away all errors */
12228 ###############################################################################
12236 ###############################################################################
12241 Image::Magick ref=NO_INIT
12274 PERL_UNUSED_VAR(ref);
12275 PERL_UNUSED_VAR(ix);
12276 exception=AcquireExceptionInfo();
12277 perl_exception=newSVpv("",0);
12280 if (sv_isobject(ST(0)) == 0)
12282 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12284 goto PerlException;
12286 reference=SvRV(ST(0));
12287 hv=SvSTASH(reference);
12289 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12291 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12292 if (image == (Image *) NULL)
12294 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12296 goto PerlException;
12298 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12299 preview_type=GammaPreview;
12301 preview_type=(PreviewType)
12302 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12303 for ( ; image; image=image->next)
12305 preview_image=PreviewImage(image,preview_type,exception);
12306 if (preview_image == (Image *) NULL)
12307 goto PerlException;
12308 AddImageToRegistry(sv,preview_image);
12310 av_push(av,sv_bless(rv,hv));
12313 exception=DestroyExceptionInfo(exception);
12314 ST(0)=av_reference;
12315 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12319 InheritPerlException(exception,perl_exception);
12320 exception=DestroyExceptionInfo(exception);
12321 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12322 SvPOK_on(perl_exception);
12323 ST(0)=sv_2mortal(perl_exception);
12328 ###############################################################################
12332 # Q u e r y C o l o r #
12336 ###############################################################################
12340 QueryColor(ref,...)
12341 Image::Magick ref=NO_INIT
12361 PERL_UNUSED_VAR(ref);
12362 PERL_UNUSED_VAR(ix);
12363 exception=AcquireExceptionInfo();
12364 perl_exception=newSVpv("",0);
12373 colorlist=GetColorInfoList("*",&colors,exception);
12375 for (i=0; i < (ssize_t) colors; i++)
12377 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12379 colorlist=(const ColorInfo **)
12380 RelinquishMagickMemory((ColorInfo **) colorlist);
12381 goto PerlException;
12383 EXTEND(sp,5*items);
12384 for (i=1; i < items; i++)
12386 name=(char *) SvPV(ST(i),na);
12387 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12392 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12393 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12394 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12395 if (color.colorspace == CMYKColorspace)
12396 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12397 if (color.alpha_trait != UndefinedPixelTrait)
12398 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12402 InheritPerlException(exception,perl_exception);
12403 exception=DestroyExceptionInfo(exception);
12404 SvREFCNT_dec(perl_exception);
12408 ###############################################################################
12412 # Q u e r y C o l o r N a m e #
12416 ###############################################################################
12420 QueryColorname(ref,...)
12421 Image::Magick ref=NO_INIT
12430 message[MagickPathExtent];
12449 *reference; /* reference is the SV* of ref=SvIV(reference) */
12451 PERL_UNUSED_VAR(ref);
12452 PERL_UNUSED_VAR(ix);
12453 exception=AcquireExceptionInfo();
12454 perl_exception=newSVpv("",0);
12455 reference=SvRV(ST(0));
12456 av=(AV *) reference;
12457 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12459 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12460 if (image == (Image *) NULL)
12462 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12464 goto PerlException;
12467 for (i=1; i < items; i++)
12469 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12471 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12473 PUSHs(sv_2mortal(newSVpv(message,0)));
12477 InheritPerlException(exception,perl_exception);
12478 exception=DestroyExceptionInfo(exception);
12479 SvREFCNT_dec(perl_exception);
12483 ###############################################################################
12487 # Q u e r y F o n t #
12491 ###############################################################################
12496 Image::Magick ref=NO_INIT
12503 message[MagickPathExtent];
12514 volatile const TypeInfo
12517 PERL_UNUSED_VAR(ref);
12518 PERL_UNUSED_VAR(ix);
12519 exception=AcquireExceptionInfo();
12520 perl_exception=newSVpv("",0);
12529 typelist=GetTypeInfoList("*",&types,exception);
12531 for (i=0; i < (ssize_t) types; i++)
12533 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12535 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12537 goto PerlException;
12539 EXTEND(sp,10*items);
12540 for (i=1; i < items; i++)
12542 name=(char *) SvPV(ST(i),na);
12543 type_info=GetTypeInfo(name,exception);
12544 if (type_info == (TypeInfo *) NULL)
12549 if (type_info->name == (char *) NULL)
12552 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12553 if (type_info->description == (char *) NULL)
12556 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12557 if (type_info->family == (char *) NULL)
12560 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12561 if (type_info->style == UndefinedStyle)
12564 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12565 type_info->style),0)));
12566 if (type_info->stretch == UndefinedStretch)
12569 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12570 type_info->stretch),0)));
12571 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12572 type_info->weight);
12573 PUSHs(sv_2mortal(newSVpv(message,0)));
12574 if (type_info->encoding == (char *) NULL)
12577 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12578 if (type_info->foundry == (char *) NULL)
12581 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12582 if (type_info->format == (char *) NULL)
12585 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12586 if (type_info->metrics == (char *) NULL)
12589 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12590 if (type_info->glyphs == (char *) NULL)
12593 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12597 InheritPerlException(exception,perl_exception);
12598 exception=DestroyExceptionInfo(exception);
12599 SvREFCNT_dec(perl_exception);
12603 ###############################################################################
12607 # Q u e r y F o n t M e t r i c s #
12611 ###############################################################################
12615 QueryFontMetrics(ref,...)
12616 Image::Magick ref=NO_INIT
12618 queryfontmetrics = 1
12665 *reference; /* reference is the SV* of ref=SvIV(reference) */
12670 PERL_UNUSED_VAR(ref);
12671 PERL_UNUSED_VAR(ix);
12672 exception=AcquireExceptionInfo();
12673 package_info=(struct PackageInfo *) NULL;
12674 perl_exception=newSVpv("",0);
12675 reference=SvRV(ST(0));
12676 av=(AV *) reference;
12677 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12679 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12680 if (image == (Image *) NULL)
12682 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12684 goto PerlException;
12686 package_info=ClonePackageInfo(info,exception);
12687 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12688 CloneString(&draw_info->text,"");
12689 current=draw_info->affine;
12690 GetAffineMatrix(&affine);
12693 EXTEND(sp,7*items);
12694 for (i=2; i < items; i+=2)
12696 attribute=(char *) SvPV(ST(i-1),na);
12697 switch (*attribute)
12702 if (LocaleCompare(attribute,"antialias") == 0)
12704 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12708 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12712 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12715 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12722 if (LocaleCompare(attribute,"density") == 0)
12724 CloneString(&draw_info->density,SvPV(ST(i),na));
12727 if (LocaleCompare(attribute,"direction") == 0)
12729 draw_info->direction=(DirectionType) ParseCommandOption(
12730 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12733 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12740 if (LocaleCompare(attribute,"encoding") == 0)
12742 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12745 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12752 if (LocaleCompare(attribute,"family") == 0)
12754 CloneString(&draw_info->family,SvPV(ST(i),na));
12757 if (LocaleCompare(attribute,"fill") == 0)
12760 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12761 &draw_info->fill,exception);
12764 if (LocaleCompare(attribute,"font") == 0)
12766 CloneString(&draw_info->font,SvPV(ST(i),na));
12769 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12776 if (LocaleCompare(attribute,"geometry") == 0)
12778 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12781 if (LocaleCompare(attribute,"gravity") == 0)
12783 draw_info->gravity=(GravityType) ParseCommandOption(
12784 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12787 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12794 if (LocaleCompare(attribute,"interline-spacing") == 0)
12796 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12797 draw_info->interline_spacing=geometry_info.rho;
12800 if (LocaleCompare(attribute,"interword-spacing") == 0)
12802 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12803 draw_info->interword_spacing=geometry_info.rho;
12806 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12813 if (LocaleCompare(attribute,"kerning") == 0)
12815 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12816 draw_info->kerning=geometry_info.rho;
12819 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12826 if (LocaleCompare(attribute,"pointsize") == 0)
12828 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12829 draw_info->pointsize=geometry_info.rho;
12832 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12839 if (LocaleCompare(attribute,"rotate") == 0)
12841 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12842 affine.rx=geometry_info.rho;
12843 affine.ry=geometry_info.sigma;
12844 if ((flags & SigmaValue) == 0)
12845 affine.ry=affine.rx;
12848 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12855 if (LocaleCompare(attribute,"scale") == 0)
12857 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12858 affine.sx=geometry_info.rho;
12859 affine.sy=geometry_info.sigma;
12860 if ((flags & SigmaValue) == 0)
12861 affine.sy=affine.sx;
12864 if (LocaleCompare(attribute,"skew") == 0)
12870 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12871 x_angle=geometry_info.rho;
12872 y_angle=geometry_info.sigma;
12873 if ((flags & SigmaValue) == 0)
12875 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12876 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12879 if (LocaleCompare(attribute,"stroke") == 0)
12882 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12883 &draw_info->stroke,exception);
12886 if (LocaleCompare(attribute,"style") == 0)
12888 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12892 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12896 draw_info->style=(StyleType) type;
12899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12906 if (LocaleCompare(attribute,"text") == 0)
12908 CloneString(&draw_info->text,SvPV(ST(i),na));
12911 if (LocaleCompare(attribute,"translate") == 0)
12913 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12914 affine.tx=geometry_info.rho;
12915 affine.ty=geometry_info.sigma;
12916 if ((flags & SigmaValue) == 0)
12917 affine.ty=affine.tx;
12920 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12927 if (LocaleCompare(attribute,"weight") == 0)
12929 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12930 draw_info->weight=(size_t) geometry_info.rho;
12933 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12940 if (LocaleCompare(attribute,"x") == 0)
12942 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12943 x=geometry_info.rho;
12946 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12953 if (LocaleCompare(attribute,"y") == 0)
12955 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12956 y=geometry_info.rho;
12959 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12965 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12971 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12972 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12973 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12974 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12975 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12976 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12977 if (draw_info->geometry == (char *) NULL)
12979 draw_info->geometry=AcquireString((char *) NULL);
12980 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12981 "%.15g,%.15g",x,y);
12983 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12984 (void) CatchImageException(image);
12985 if (status == MagickFalse)
12989 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12990 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12991 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12992 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12993 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12994 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12995 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12996 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12997 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12998 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12999 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13000 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13001 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13003 draw_info=DestroyDrawInfo(draw_info);
13006 if (package_info != (struct PackageInfo *) NULL)
13007 DestroyPackageInfo(package_info);
13008 InheritPerlException(exception,perl_exception);
13009 exception=DestroyExceptionInfo(exception);
13010 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13014 ###############################################################################
13018 # 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 #
13022 ###############################################################################
13026 QueryMultilineFontMetrics(ref,...)
13027 Image::Magick ref=NO_INIT
13029 querymultilinefontmetrics = 1
13076 *reference; /* reference is the SV* of ref=SvIV(reference) */
13081 PERL_UNUSED_VAR(ref);
13082 PERL_UNUSED_VAR(ix);
13083 exception=AcquireExceptionInfo();
13084 package_info=(struct PackageInfo *) NULL;
13085 perl_exception=newSVpv("",0);
13086 reference=SvRV(ST(0));
13087 av=(AV *) reference;
13088 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13090 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13091 if (image == (Image *) NULL)
13093 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13095 goto PerlException;
13097 package_info=ClonePackageInfo(info,exception);
13098 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13099 CloneString(&draw_info->text,"");
13100 current=draw_info->affine;
13101 GetAffineMatrix(&affine);
13104 EXTEND(sp,7*items);
13105 for (i=2; i < items; i+=2)
13107 attribute=(char *) SvPV(ST(i-1),na);
13108 switch (*attribute)
13113 if (LocaleCompare(attribute,"antialias") == 0)
13115 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13119 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13123 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13126 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13133 if (LocaleCompare(attribute,"density") == 0)
13135 CloneString(&draw_info->density,SvPV(ST(i),na));
13138 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13145 if (LocaleCompare(attribute,"encoding") == 0)
13147 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13150 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13157 if (LocaleCompare(attribute,"family") == 0)
13159 CloneString(&draw_info->family,SvPV(ST(i),na));
13162 if (LocaleCompare(attribute,"fill") == 0)
13165 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13166 &draw_info->fill,exception);
13169 if (LocaleCompare(attribute,"font") == 0)
13171 CloneString(&draw_info->font,SvPV(ST(i),na));
13174 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13181 if (LocaleCompare(attribute,"geometry") == 0)
13183 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13186 if (LocaleCompare(attribute,"gravity") == 0)
13188 draw_info->gravity=(GravityType) ParseCommandOption(
13189 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13192 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13199 if (LocaleCompare(attribute,"pointsize") == 0)
13201 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13202 draw_info->pointsize=geometry_info.rho;
13205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13212 if (LocaleCompare(attribute,"rotate") == 0)
13214 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13215 affine.rx=geometry_info.rho;
13216 affine.ry=geometry_info.sigma;
13217 if ((flags & SigmaValue) == 0)
13218 affine.ry=affine.rx;
13221 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13228 if (LocaleCompare(attribute,"scale") == 0)
13230 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13231 affine.sx=geometry_info.rho;
13232 affine.sy=geometry_info.sigma;
13233 if ((flags & SigmaValue) == 0)
13234 affine.sy=affine.sx;
13237 if (LocaleCompare(attribute,"skew") == 0)
13243 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13244 x_angle=geometry_info.rho;
13245 y_angle=geometry_info.sigma;
13246 if ((flags & SigmaValue) == 0)
13248 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13249 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13252 if (LocaleCompare(attribute,"stroke") == 0)
13255 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13256 &draw_info->stroke,exception);
13259 if (LocaleCompare(attribute,"style") == 0)
13261 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13265 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13269 draw_info->style=(StyleType) type;
13272 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13279 if (LocaleCompare(attribute,"text") == 0)
13281 CloneString(&draw_info->text,SvPV(ST(i),na));
13284 if (LocaleCompare(attribute,"translate") == 0)
13286 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13287 affine.tx=geometry_info.rho;
13288 affine.ty=geometry_info.sigma;
13289 if ((flags & SigmaValue) == 0)
13290 affine.ty=affine.tx;
13293 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13300 if (LocaleCompare(attribute,"weight") == 0)
13302 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13303 draw_info->weight=(size_t) geometry_info.rho;
13306 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13313 if (LocaleCompare(attribute,"x") == 0)
13315 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13316 x=geometry_info.rho;
13319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13326 if (LocaleCompare(attribute,"y") == 0)
13328 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13329 y=geometry_info.rho;
13332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13344 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13345 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13346 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13347 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13348 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13349 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13350 if (draw_info->geometry == (char *) NULL)
13352 draw_info->geometry=AcquireString((char *) NULL);
13353 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13354 "%.15g,%.15g",x,y);
13356 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13357 (void) CatchException(exception);
13358 if (status == MagickFalse)
13362 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13363 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13364 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13365 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13366 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13367 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13368 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13369 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13370 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13371 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13372 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13373 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13374 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13376 draw_info=DestroyDrawInfo(draw_info);
13379 if (package_info != (struct PackageInfo *) NULL)
13380 DestroyPackageInfo(package_info);
13381 InheritPerlException(exception,perl_exception);
13382 exception=DestroyExceptionInfo(exception);
13383 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13387 ###############################################################################
13391 # Q u e r y F o r m a t #
13395 ###############################################################################
13399 QueryFormat(ref,...)
13400 Image::Magick ref=NO_INIT
13417 volatile const MagickInfo
13420 PERL_UNUSED_VAR(ref);
13421 PERL_UNUSED_VAR(ix);
13422 exception=AcquireExceptionInfo();
13423 perl_exception=newSVpv("",0);
13427 format[MagickPathExtent];
13435 format_list=GetMagickInfoList("*",&types,exception);
13437 for (i=0; i < (ssize_t) types; i++)
13439 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13440 LocaleLower(format);
13441 PUSHs(sv_2mortal(newSVpv(format,0)));
13443 format_list=(const MagickInfo **)
13444 RelinquishMagickMemory((MagickInfo *) format_list);
13445 goto PerlException;
13447 EXTEND(sp,8*items);
13448 for (i=1; i < items; i++)
13450 name=(char *) SvPV(ST(i),na);
13451 magick_info=GetMagickInfo(name,exception);
13452 if (magick_info == (const MagickInfo *) NULL)
13457 if (magick_info->description == (char *) NULL)
13460 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13461 if (magick_info->module == (char *) NULL)
13464 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13468 InheritPerlException(exception,perl_exception);
13469 exception=DestroyExceptionInfo(exception);
13470 SvREFCNT_dec(perl_exception);
13474 ###############################################################################
13478 # Q u e r y O p t i o n #
13482 ###############################################################################
13486 QueryOption(ref,...)
13487 Image::Magick ref=NO_INIT
13508 PERL_UNUSED_VAR(ref);
13509 PERL_UNUSED_VAR(ix);
13510 exception=AcquireExceptionInfo();
13511 perl_exception=newSVpv("",0);
13512 EXTEND(sp,8*items);
13513 for (i=1; i < items; i++)
13515 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13517 options=GetCommandOptions((CommandOption) option);
13518 if (options == (char **) NULL)
13522 for (j=0; options[j] != (char *) NULL; j++)
13523 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13524 options=DestroyStringList(options);
13528 InheritPerlException(exception,perl_exception);
13529 exception=DestroyExceptionInfo(exception);
13530 SvREFCNT_dec(perl_exception);
13534 ###############################################################################
13542 ###############################################################################
13547 Image::Magick ref=NO_INIT
13594 *perl_exception, /* Perl variable for storing messages */
13599 PERL_UNUSED_VAR(ref);
13600 PERL_UNUSED_VAR(ix);
13601 exception=AcquireExceptionInfo();
13602 perl_exception=newSVpv("",0);
13604 package_info=(struct PackageInfo *) NULL;
13606 ac=(items < 2) ? 1 : items-1;
13607 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13609 length=(STRLEN *) NULL;
13610 if (list == (char **) NULL)
13612 ThrowPerlException(exception,ResourceLimitError,
13613 "MemoryAllocationFailed",PackageName);
13614 goto PerlException;
13616 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13617 if (length == (STRLEN *) NULL)
13619 ThrowPerlException(exception,ResourceLimitError,
13620 "MemoryAllocationFailed",PackageName);
13621 goto PerlException;
13623 if (sv_isobject(ST(0)) == 0)
13625 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13627 goto PerlException;
13629 reference=SvRV(ST(0));
13630 hv=SvSTASH(reference);
13631 if (SvTYPE(reference) != SVt_PVAV)
13633 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13635 goto PerlException;
13637 av=(AV *) reference;
13638 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13640 package_info=ClonePackageInfo(info,exception);
13643 *list=(char *) (*package_info->image_info->filename ?
13644 package_info->image_info->filename : "XC:black");
13646 for (n=0, i=0; i < ac; i++)
13648 list[n]=(char *) SvPV(ST(i+1),length[n]);
13649 if ((items >= 3) && strEQcase(list[n],"blob"))
13655 blob=(void *) (SvPV(ST(i+1),length[n]));
13656 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13658 if ((items >= 3) && strEQcase(list[n],"filename"))
13660 if ((items >= 3) && strEQcase(list[n],"file"))
13669 io_info=IoIFP(sv_2io(ST(i+1)));
13670 if (io_info == (PerlIO *) NULL)
13672 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13676 file=PerlIO_findFILE(io_info);
13677 if (file == (FILE *) NULL)
13679 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13683 SetImageInfoFile(package_info->image_info,file);
13685 if ((items >= 3) && strEQcase(list[n],"magick"))
13689 list[n]=(char *) NULL;
13691 status=ExpandFilenames(&n,&list);
13692 if (status == MagickFalse)
13694 ThrowPerlException(exception,ResourceLimitError,
13695 "MemoryAllocationFailed",PackageName);
13696 goto PerlException;
13699 for (i=0; i < n; i++)
13701 if ((package_info->image_info->file == (FILE *) NULL) &&
13702 (package_info->image_info->blob == (void *) NULL))
13703 image=ReadImages(package_info->image_info,list[i],exception);
13706 image=ReadImages(package_info->image_info,
13707 package_info->image_info->filename,exception);
13708 if (image != (Image *) NULL)
13709 DisassociateImageStream(image);
13711 if (image == (Image *) NULL)
13713 for ( ; image; image=image->next)
13715 AddImageToRegistry(sv,image);
13717 av_push(av,sv_bless(rv,hv));
13725 for (i=0; i < n; i++)
13726 if (list[i] != (char *) NULL)
13727 for (p=keep; list[i] != *p++; )
13728 if (*p == (char *) NULL)
13730 list[i]=(char *) RelinquishMagickMemory(list[i]);
13735 if (package_info != (struct PackageInfo *) NULL)
13736 DestroyPackageInfo(package_info);
13737 if (list && (list != keep))
13738 list=(char **) RelinquishMagickMemory(list);
13740 keep=(char **) RelinquishMagickMemory(keep);
13742 length=(STRLEN *) RelinquishMagickMemory(length);
13743 InheritPerlException(exception,perl_exception);
13744 exception=DestroyExceptionInfo(exception);
13745 sv_setiv(perl_exception,(IV) number_images);
13746 SvPOK_on(perl_exception);
13747 ST(0)=sv_2mortal(perl_exception);
13752 ###############################################################################
13760 ###############################################################################
13765 Image::Magick ref=NO_INIT
13788 PERL_UNUSED_VAR(ref);
13789 PERL_UNUSED_VAR(ix);
13790 exception=AcquireExceptionInfo();
13791 perl_exception=newSVpv("",0);
13792 reference=SvRV(ST(0));
13793 av=(AV *) reference;
13794 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13796 for (i=1; i < items; i++)
13797 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13798 SvPV(ST(i),na),exception);
13799 InheritPerlException(exception,perl_exception);
13800 exception=DestroyExceptionInfo(exception);
13801 SvREFCNT_dec(perl_exception); /* throw away all errors */
13805 ###############################################################################
13813 ###############################################################################
13818 Image::Magick ref=NO_INIT
13841 *reference; /* reference is the SV* of ref=SvIV(reference) */
13843 PERL_UNUSED_VAR(ref);
13844 PERL_UNUSED_VAR(ix);
13845 exception=AcquireExceptionInfo();
13846 perl_exception=newSVpv("",0);
13847 if (sv_isobject(ST(0)) == 0)
13849 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13851 goto PerlException;
13853 reference=SvRV(ST(0));
13854 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13856 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13858 for (i=2; i < items; i+=2)
13859 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13862 InheritPerlException(exception,perl_exception);
13863 exception=DestroyExceptionInfo(exception);
13864 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13865 SvPOK_on(perl_exception);
13866 ST(0)=sv_2mortal(perl_exception);
13871 ###############################################################################
13875 # S e t P i x e l #
13879 ###############################################################################
13884 Image::Magick ref=NO_INIT
13926 *reference; /* reference is the SV* of ref=SvIV(reference) */
13928 PERL_UNUSED_VAR(ref);
13929 PERL_UNUSED_VAR(ix);
13930 exception=AcquireExceptionInfo();
13931 perl_exception=newSVpv("",0);
13932 reference=SvRV(ST(0));
13933 av=(AV *) reference;
13934 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13936 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13937 if (image == (Image *) NULL)
13939 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13941 goto PerlException;
13944 normalize=MagickTrue;
13947 region.width=image->columns;
13950 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13951 channel=DefaultChannels;
13952 for (i=2; i < items; i+=2)
13954 attribute=(char *) SvPV(ST(i-1),na);
13955 switch (*attribute)
13960 if (LocaleCompare(attribute,"channel") == 0)
13965 option=ParseChannelOption(SvPV(ST(i),na));
13968 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13972 channel=(ChannelType) option;
13975 if (LocaleCompare(attribute,"color") == 0)
13977 if (SvTYPE(ST(i)) != SVt_RV)
13980 message[MagickPathExtent];
13982 (void) FormatLocaleString(message,MagickPathExtent,
13983 "invalid %.60s value",attribute);
13984 ThrowPerlException(exception,OptionError,message,
13987 av=(AV *) SvRV(ST(i));
13990 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13997 if (LocaleCompare(attribute,"geometry") == 0)
13999 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
14002 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14009 if (LocaleCompare(attribute,"normalize") == 0)
14011 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14015 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14019 normalize=option != 0 ? MagickTrue : MagickFalse;
14022 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14029 if (LocaleCompare(attribute,"x") == 0)
14031 region.x=SvIV(ST(i));
14034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14041 if (LocaleCompare(attribute,"y") == 0)
14043 region.y=SvIV(ST(i));
14046 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14052 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14058 (void) SetImageStorageClass(image,DirectClass,exception);
14059 channel_mask=SetImageChannelMask(image,channel);
14060 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14061 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14062 (SvTYPE(av) != SVt_PVAV))
14074 if (normalize != MagickFalse)
14075 scale=QuantumRange;
14076 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14079 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14080 av_fetch(av,i,0)))),q);
14083 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14086 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14087 av_fetch(av,i,0)))),q);
14090 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14093 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14094 av_fetch(av,i,0)))),q);
14097 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14098 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14100 SetPixelBlack(image,ClampToQuantum(scale*
14101 SvNV(*(av_fetch(av,i,0)))),q);
14104 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14107 SetPixelAlpha(image,ClampToQuantum(scale*
14108 SvNV(*(av_fetch(av,i,0)))),q);
14111 (void) SyncAuthenticPixels(image,exception);
14113 (void) SetImageChannelMask(image,channel_mask);
14116 InheritPerlException(exception,perl_exception);
14117 exception=DestroyExceptionInfo(exception);
14118 SvREFCNT_dec(perl_exception);
14122 ###############################################################################
14130 ###############################################################################
14135 Image::Magick ref=NO_INIT
14174 PERL_UNUSED_VAR(ref);
14175 PERL_UNUSED_VAR(ix);
14176 exception=AcquireExceptionInfo();
14177 perl_exception=newSVpv("",0);
14181 if (sv_isobject(ST(0)) == 0)
14183 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14185 goto PerlException;
14187 reference=SvRV(ST(0));
14188 hv=SvSTASH(reference);
14190 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14192 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14193 if (image == (Image *) NULL)
14195 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14197 goto PerlException;
14199 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14205 for (i=2; i < items; i+=2)
14207 attribute=(char *) SvPV(ST(i-1),na);
14208 switch (*attribute)
14213 if (LocaleCompare(attribute,"offset") == 0)
14215 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14225 if (LocaleCompare(attribute,"stack") == 0)
14227 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14231 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14237 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14243 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14249 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14251 if (image == (Image *) NULL)
14252 goto PerlException;
14253 for ( ; image; image=image->next)
14255 AddImageToRegistry(sv,image);
14257 av_push(av,sv_bless(rv,hv));
14260 exception=DestroyExceptionInfo(exception);
14261 ST(0)=av_reference;
14262 SvREFCNT_dec(perl_exception);
14266 InheritPerlException(exception,perl_exception);
14267 exception=DestroyExceptionInfo(exception);
14268 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14269 SvPOK_on(perl_exception);
14270 ST(0)=sv_2mortal(perl_exception);
14275 ###############################################################################
14279 # S t a t i s t i c s #
14283 ###############################################################################
14287 Statistics(ref,...)
14288 Image::Magick ref=NO_INIT
14290 StatisticsImage = 1
14292 statisticsimage = 3
14295 #define ChannelStatistics(channel) \
14297 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14298 (double) channel_statistics[channel].depth); \
14299 PUSHs(sv_2mortal(newSVpv(message,0))); \
14300 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14301 channel_statistics[channel].minima/scale); \
14302 PUSHs(sv_2mortal(newSVpv(message,0))); \
14303 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14304 channel_statistics[channel].maxima/scale); \
14305 PUSHs(sv_2mortal(newSVpv(message,0))); \
14306 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14307 channel_statistics[channel].mean/scale); \
14308 PUSHs(sv_2mortal(newSVpv(message,0))); \
14309 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14310 channel_statistics[channel].standard_deviation/scale); \
14311 PUSHs(sv_2mortal(newSVpv(message,0))); \
14312 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14313 channel_statistics[channel].kurtosis); \
14314 PUSHs(sv_2mortal(newSVpv(message,0))); \
14315 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14316 channel_statistics[channel].skewness); \
14317 PUSHs(sv_2mortal(newSVpv(message,0))); \
14318 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14319 channel_statistics[channel].entropy); \
14320 PUSHs(sv_2mortal(newSVpv(message,0))); \
14327 message[MagickPathExtent];
14330 *channel_statistics;
14351 PERL_UNUSED_VAR(ref);
14352 PERL_UNUSED_VAR(ix);
14353 exception=AcquireExceptionInfo();
14354 perl_exception=newSVpv("",0);
14356 if (sv_isobject(ST(0)) == 0)
14358 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14360 goto PerlException;
14362 reference=SvRV(ST(0));
14365 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14366 if (image == (Image *) NULL)
14368 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14370 goto PerlException;
14373 for ( ; image; image=image->next)
14375 channel_statistics=GetImageStatistics(image,exception);
14376 if (channel_statistics == (ChannelStatistics *) NULL)
14379 EXTEND(sp,35*count);
14380 scale=(double) QuantumRange;
14381 ChannelStatistics(RedChannel);
14382 ChannelStatistics(GreenChannel);
14383 ChannelStatistics(BlueChannel);
14384 if (image->colorspace == CMYKColorspace)
14385 ChannelStatistics(BlackChannel);
14386 if (image->alpha_trait != UndefinedPixelTrait)
14387 ChannelStatistics(AlphaChannel);
14388 channel_statistics=(ChannelStatistics *)
14389 RelinquishMagickMemory(channel_statistics);
14393 InheritPerlException(exception,perl_exception);
14394 exception=DestroyExceptionInfo(exception);
14395 SvREFCNT_dec(perl_exception);
14399 ###############################################################################
14403 # S y n c A u t h e n t i c P i x e l s #
14407 ###############################################################################
14411 SyncAuthenticPixels(ref,...)
14412 Image::Magick ref = NO_INIT
14414 Syncauthenticpixels = 1
14415 SyncImagePixels = 2
14416 syncimagepixels = 3
14435 PERL_UNUSED_VAR(ref);
14436 PERL_UNUSED_VAR(ix);
14437 exception=AcquireExceptionInfo();
14438 perl_exception=newSVpv("",0);
14439 if (sv_isobject(ST(0)) == 0)
14441 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14443 goto PerlException;
14446 reference=SvRV(ST(0));
14447 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14448 if (image == (Image *) NULL)
14450 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14452 goto PerlException;
14455 status=SyncAuthenticPixels(image,exception);
14456 if (status != MagickFalse)
14460 InheritPerlException(exception,perl_exception);
14461 exception=DestroyExceptionInfo(exception);
14462 SvREFCNT_dec(perl_exception); /* throw away all errors */
14466 ###############################################################################
14470 # T r a n s f o r m #
14474 ###############################################################################
14479 Image::Magick ref=NO_INIT
14517 PERL_UNUSED_VAR(ref);
14518 PERL_UNUSED_VAR(ix);
14519 exception=AcquireExceptionInfo();
14520 perl_exception=newSVpv("",0);
14524 if (sv_isobject(ST(0)) == 0)
14526 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14528 goto PerlException;
14530 reference=SvRV(ST(0));
14531 hv=SvSTASH(reference);
14533 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14535 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14536 if (image == (Image *) NULL)
14538 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14540 goto PerlException;
14542 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14546 crop_geometry=(char *) NULL;
14547 geometry=(char *) NULL;
14548 for (i=2; i < items; i+=2)
14550 attribute=(char *) SvPV(ST(i-1),na);
14551 switch (*attribute)
14556 if (LocaleCompare(attribute,"crop") == 0)
14558 crop_geometry=SvPV(ST(i),na);
14561 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14568 if (LocaleCompare(attribute,"geometry") == 0)
14570 geometry=SvPV(ST(i),na);
14573 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14579 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14585 for ( ; image; image=image->next)
14587 clone=CloneImage(image,0,0,MagickTrue,exception);
14588 if (clone == (Image *) NULL)
14589 goto PerlException;
14590 TransformImage(&clone,crop_geometry,geometry,exception);
14591 for ( ; clone; clone=clone->next)
14593 AddImageToRegistry(sv,clone);
14595 av_push(av,sv_bless(rv,hv));
14599 exception=DestroyExceptionInfo(exception);
14600 ST(0)=av_reference;
14601 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14605 InheritPerlException(exception,perl_exception);
14606 exception=DestroyExceptionInfo(exception);
14607 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14608 SvPOK_on(perl_exception);
14609 ST(0)=sv_2mortal(perl_exception);
14614 ###############################################################################
14622 ###############################################################################
14627 Image::Magick ref=NO_INIT
14635 filename[MagickPathExtent];
14659 PERL_UNUSED_VAR(ref);
14660 PERL_UNUSED_VAR(ix);
14661 exception=AcquireExceptionInfo();
14662 perl_exception=newSVpv("",0);
14664 package_info=(struct PackageInfo *) NULL;
14665 if (sv_isobject(ST(0)) == 0)
14667 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14669 goto PerlException;
14671 reference=SvRV(ST(0));
14672 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14673 if (image == (Image *) NULL)
14675 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14677 goto PerlException;
14679 package_info=ClonePackageInfo(info,exception);
14681 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14684 for (i=2; i < items; i+=2)
14685 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14687 (void) CopyMagickString(filename,package_info->image_info->filename,
14690 for (next=image; next; next=next->next)
14692 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14693 next->scene=scene++;
14695 *package_info->image_info->magick='\0';
14696 SetImageInfo(package_info->image_info,(unsigned int)
14697 GetImageListLength(image),exception);
14698 for (next=image; next; next=next->next)
14700 (void) WriteImage(package_info->image_info,next,exception);
14702 if (package_info->image_info->adjoin)
14707 if (package_info != (struct PackageInfo *) NULL)
14708 DestroyPackageInfo(package_info);
14709 InheritPerlException(exception,perl_exception);
14710 exception=DestroyExceptionInfo(exception);
14711 sv_setiv(perl_exception,(IV) number_images);
14712 SvPOK_on(perl_exception);
14713 ST(0)=sv_2mortal(perl_exception);