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-2014 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define 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[MaxTextExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MaxTextExtent,"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} } },
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 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
424 {"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 { "Sans", { {"matrix", ArrayReference} } },
535 { "Color", { {"color", StringReference} } },
536 { "Mode", { {"geometry", StringReference},
537 {"width", IntegerReference},{"height", IntegerReference},
538 {"channel", MagickChannelOptions} } },
539 { "Statistic", { {"geometry", StringReference},
540 {"width", IntegerReference},{"height", IntegerReference},
541 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
542 { "Perceptible", { {"epsilon", RealReference},
543 {"channel", MagickChannelOptions} } },
544 { "Poly", { {"terms", ArrayReference},
545 {"channel", MagickChannelOptions} } },
546 { "Grayscale", { {"method", MagickNoiseOptions} } },
550 *magick_registry = (SplayTreeInfo *) NULL;
553 Forward declarations.
556 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
559 strEQcase(const char *,const char *);
562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566 % C l o n e P a c k a g e I n f o %
570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
572 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
575 % The format of the ClonePackageInfo routine is:
577 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
580 % A description of each parameter follows:
582 % o info: a structure of type info.
584 % o exception: Return any errors or warnings in this structure.
587 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
588 ExceptionInfo *exception)
593 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
594 if (clone_info == (struct PackageInfo *) NULL)
596 ThrowPerlException(exception,ResourceLimitError,
597 "UnableToClonePackageInfo",PackageName);
598 return((struct PackageInfo *) NULL);
600 if (info == (struct PackageInfo *) NULL)
602 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
606 clone_info->image_info=CloneImageInfo(info->image_info);
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
621 % constant() returns a double value for the specified name.
623 % The format of the constant routine is:
625 % double constant(char *name,ssize_t sans)
627 % A description of each parameter follows:
629 % o value: Method constant returns a double value for the specified name.
631 % o name: The name of the constant.
633 % o sans: This integer value is not used.
636 static double constant(char *name,ssize_t sans)
644 if (strEQ(name,"BlobError"))
646 if (strEQ(name,"BlobWarning"))
652 if (strEQ(name,"CacheError"))
654 if (strEQ(name,"CacheWarning"))
655 return(CacheWarning);
656 if (strEQ(name,"CoderError"))
658 if (strEQ(name,"CoderWarning"))
659 return(CoderWarning);
660 if (strEQ(name,"ConfigureError"))
661 return(ConfigureError);
662 if (strEQ(name,"ConfigureWarning"))
663 return(ConfigureWarning);
664 if (strEQ(name,"CorruptImageError"))
665 return(CorruptImageError);
666 if (strEQ(name,"CorruptImageWarning"))
667 return(CorruptImageWarning);
672 if (strEQ(name,"DelegateError"))
673 return(DelegateError);
674 if (strEQ(name,"DelegateWarning"))
675 return(DelegateWarning);
676 if (strEQ(name,"DrawError"))
678 if (strEQ(name,"DrawWarning"))
684 if (strEQ(name,"ErrorException"))
685 return(ErrorException);
686 if (strEQ(name,"ExceptionError"))
688 if (strEQ(name,"ExceptionWarning"))
689 return(CoderWarning);
694 if (strEQ(name,"FatalErrorException"))
695 return(FatalErrorException);
696 if (strEQ(name,"FileOpenError"))
697 return(FileOpenError);
698 if (strEQ(name,"FileOpenWarning"))
699 return(FileOpenWarning);
704 if (strEQ(name,"ImageError"))
706 if (strEQ(name,"ImageWarning"))
707 return(ImageWarning);
712 if (strEQ(name,"MaxRGB"))
713 return(QuantumRange);
714 if (strEQ(name,"MissingDelegateError"))
715 return(MissingDelegateError);
716 if (strEQ(name,"MissingDelegateWarning"))
717 return(MissingDelegateWarning);
718 if (strEQ(name,"ModuleError"))
720 if (strEQ(name,"ModuleWarning"))
721 return(ModuleWarning);
726 if (strEQ(name,"Opaque"))
728 if (strEQ(name,"OptionError"))
730 if (strEQ(name,"OptionWarning"))
731 return(OptionWarning);
736 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
737 return(MAGICKCORE_QUANTUM_DEPTH);
738 if (strEQ(name,"QuantumDepth"))
739 return(MAGICKCORE_QUANTUM_DEPTH);
740 if (strEQ(name,"QuantumRange"))
741 return(QuantumRange);
746 if (strEQ(name,"ResourceLimitError"))
747 return(ResourceLimitError);
748 if (strEQ(name,"ResourceLimitWarning"))
749 return(ResourceLimitWarning);
750 if (strEQ(name,"RegistryError"))
751 return(RegistryError);
752 if (strEQ(name,"RegistryWarning"))
753 return(RegistryWarning);
758 if (strEQ(name,"StreamError"))
760 if (strEQ(name,"StreamWarning"))
761 return(StreamWarning);
762 if (strEQ(name,"Success"))
768 if (strEQ(name,"Transparent"))
769 return(TransparentAlpha);
770 if (strEQ(name,"TypeError"))
772 if (strEQ(name,"TypeWarning"))
778 if (strEQ(name,"WarningException"))
779 return(WarningException);
784 if (strEQ(name,"XServerError"))
785 return(XServerError);
786 if (strEQ(name,"XServerWarning"))
787 return(XServerWarning);
796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800 % D e s t r o y P a c k a g e I n f o %
804 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
806 % Method DestroyPackageInfo frees a previously created info structure.
808 % The format of the DestroyPackageInfo routine is:
810 % DestroyPackageInfo(struct PackageInfo *info)
812 % A description of each parameter follows:
814 % o info: a structure of type info.
817 static void DestroyPackageInfo(struct PackageInfo *info)
819 info->image_info=DestroyImageInfo(info->image_info);
820 info=(struct PackageInfo *) RelinquishMagickMemory(info);
824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
834 % Method GetList is recursively called by SetupList to traverse the
835 % Image__Magick reference. If building an reference_vector (see SetupList),
836 % *current is the current position in *reference_vector and *last is the final
837 % entry in *reference_vector.
839 % The format of the GetList routine is:
843 % A description of each parameter follows:
845 % o info: a structure of type info.
848 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
849 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
854 if (reference == (SV *) NULL)
856 switch (SvTYPE(reference))
876 previous=(Image *) NULL;
880 for (i=0; i <= n; i++)
886 if (rv && *rv && sv_isobject(*rv))
888 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
890 if (image == (Image *) NULL)
892 if (image == previous)
894 image=CloneImage(image,0,0,MagickTrue,exception);
895 if (image == (Image *) NULL)
898 image->previous=previous;
899 *(previous ? &previous->next : &head)=image;
900 for (previous=image; previous->next; previous=previous->next) ;
908 Blessed scalar, one image.
910 image=INT2PTR(Image *,SvIV(reference));
911 if (image == (Image *) NULL)
913 image->previous=(Image *) NULL;
914 image->next=(Image *) NULL;
915 if (reference_vector)
917 if (*current == *last)
920 if (*reference_vector == (SV **) NULL)
921 *reference_vector=(SV **) AcquireQuantumMemory(*last,
922 sizeof(*reference_vector));
924 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
925 *last,sizeof(*reference_vector));
927 if (*reference_vector == (SV **) NULL)
929 ThrowPerlException(exception,ResourceLimitError,
930 "MemoryAllocationFailed",PackageName);
931 return((Image *) NULL);
933 (*reference_vector)[*current]=reference;
934 (*reference_vector)[++(*current)]=NULL;
941 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
942 (double) SvTYPE(reference));
943 return((Image *) NULL);
947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 % G e t P a c k a g e I n f o %
955 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
957 % Method GetPackageInfo looks up or creates an info structure for the given
958 % Image__Magick reference. If it does create a new one, the information in
959 % package_info is used to initialize it.
961 % The format of the GetPackageInfo routine is:
963 % struct PackageInfo *GetPackageInfo(void *reference,
964 % struct PackageInfo *package_info,ExceptionInfo *exception)
966 % A description of each parameter follows:
968 % o info: a structure of type info.
970 % o exception: Return any errors or warnings in this structure.
973 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
974 struct PackageInfo *package_info,ExceptionInfo *exception)
977 message[MaxTextExtent];
985 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
986 PackageName,XS_VERSION,reference);
987 sv=perl_get_sv(message,(TRUE | 0x02));
988 if (sv == (SV *) NULL)
990 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
992 return(package_info);
994 if (SvREFCNT(sv) == 0)
995 (void) SvREFCNT_inc(sv);
996 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
998 clone_info=ClonePackageInfo(package_info,exception);
999 sv_setiv(sv,PTR2IV(clone_info));
1004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1008 % S e t A t t r i b u t e %
1012 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1014 % SetAttribute() sets the attribute to the value in sval. This can change
1015 % either or both of image or info.
1017 % The format of the SetAttribute routine is:
1019 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1020 % SV *sval,ExceptionInfo *exception)
1022 % A description of each parameter follows:
1024 % o list: a list of strings.
1026 % o string: a character string.
1030 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1038 value=InterpretSiPrefixValue(string,&q);
1040 value*=interval/100.0;
1044 static inline double StringToDouble(const char *string,char **sentinal)
1046 return(InterpretLocaleValue(string,sentinal));
1049 static double StringToDoubleInterval(const char *string,const double interval)
1057 value=InterpretLocaleValue(string,&q);
1059 value*=interval/100.0;
1063 static inline ssize_t StringToLong(const char *value)
1065 return(strtol(value,(char **) NULL,10));
1068 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1069 const char *attribute,SV *sval,ExceptionInfo *exception)
1096 if (LocaleCompare(attribute,"adjoin") == 0)
1098 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1099 SvPV(sval,na)) : SvIV(sval);
1102 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1107 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1110 if (LocaleCompare(attribute,"alpha") == 0)
1112 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1113 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1116 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1120 for ( ; image; image=image->next)
1121 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1125 if (LocaleCompare(attribute,"antialias") == 0)
1127 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1128 SvPV(sval,na)) : SvIV(sval);
1131 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1136 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1139 if (LocaleCompare(attribute,"area-limit") == 0)
1144 limit=MagickResourceInfinity;
1145 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1146 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1148 (void) SetMagickResourceLimit(AreaResource,limit);
1151 if (LocaleCompare(attribute,"attenuate") == 0)
1154 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1157 if (LocaleCompare(attribute,"authenticate") == 0)
1160 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1164 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1165 for ( ; image; image=image->next)
1166 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1172 if (LocaleCompare(attribute,"background") == 0)
1174 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1177 info->image_info->background_color=target_color;
1178 for ( ; image; image=image->next)
1179 image->background_color=target_color;
1182 if (LocaleCompare(attribute,"blue-primary") == 0)
1184 for ( ; image; image=image->next)
1186 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1187 image->chromaticity.blue_primary.x=geometry_info.rho;
1188 image->chromaticity.blue_primary.y=geometry_info.sigma;
1189 if ((flags & SigmaValue) == 0)
1190 image->chromaticity.blue_primary.y=
1191 image->chromaticity.blue_primary.x;
1195 if (LocaleCompare(attribute,"bordercolor") == 0)
1197 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1200 info->image_info->border_color=target_color;
1201 for ( ; image; image=image->next)
1202 image->border_color=target_color;
1206 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1207 for ( ; image; image=image->next)
1208 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1214 if (LocaleCompare(attribute,"cache-threshold") == 0)
1216 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1217 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1218 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1219 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1222 if (LocaleCompare(attribute,"clip-mask") == 0)
1227 clip_mask=(Image *) NULL;
1229 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1230 for ( ; image; image=image->next)
1231 SetImageMask(image,clip_mask,exception);
1234 if (LocaleNCompare(attribute,"colormap",8) == 0)
1236 for ( ; image; image=image->next)
1244 if (image->storage_class == DirectClass)
1247 items=sscanf(attribute,"%*[^[][%ld",&i);
1249 if (i > (ssize_t) image->colors)
1251 if ((strchr(SvPV(sval,na),',') == 0) ||
1252 (strchr(SvPV(sval,na),')') != 0))
1253 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1254 image->colormap+i,exception);
1257 color=image->colormap+i;
1258 pixel.red=color->red;
1259 pixel.green=color->green;
1260 pixel.blue=color->blue;
1261 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1262 pixel.red=geometry_info.rho;
1263 pixel.green=geometry_info.sigma;
1264 pixel.blue=geometry_info.xi;
1265 color->red=ClampToQuantum(pixel.red);
1266 color->green=ClampToQuantum(pixel.green);
1267 color->blue=ClampToQuantum(pixel.blue);
1272 if (LocaleCompare(attribute,"colorspace") == 0)
1274 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1275 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1278 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1282 for ( ; image; image=image->next)
1283 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1287 if (LocaleCompare(attribute,"comment") == 0)
1289 for ( ; image; image=image->next)
1290 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1291 info ? info->image_info : (ImageInfo *) NULL,image,
1292 SvPV(sval,na),exception),exception);
1295 if (LocaleCompare(attribute,"compression") == 0)
1297 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1298 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1301 ThrowPerlException(exception,OptionError,
1302 "UnrecognizedImageCompression",SvPV(sval,na));
1306 info->image_info->compression=(CompressionType) sp;
1307 for ( ; image; image=image->next)
1308 image->compression=(CompressionType) sp;
1312 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1313 for ( ; image; image=image->next)
1314 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1320 if (LocaleCompare(attribute,"debug") == 0)
1322 SetLogEventMask(SvPV(sval,na));
1325 if (LocaleCompare(attribute,"delay") == 0)
1327 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1328 for ( ; image; image=image->next)
1330 image->delay=(size_t) floor(geometry_info.rho+0.5);
1331 if ((flags & SigmaValue) != 0)
1332 image->ticks_per_second=(ssize_t)
1333 floor(geometry_info.sigma+0.5);
1337 if (LocaleCompare(attribute,"disk-limit") == 0)
1342 limit=MagickResourceInfinity;
1343 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1344 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1346 (void) SetMagickResourceLimit(DiskResource,limit);
1349 if (LocaleCompare(attribute,"density") == 0)
1351 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1353 ThrowPerlException(exception,OptionError,"MissingGeometry",
1358 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1359 for ( ; image; image=image->next)
1361 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1362 image->resolution.x=geometry_info.rho;
1363 image->resolution.y=geometry_info.sigma;
1364 if ((flags & SigmaValue) == 0)
1365 image->resolution.y=image->resolution.x;
1369 if (LocaleCompare(attribute,"depth") == 0)
1372 info->image_info->depth=SvIV(sval);
1373 for ( ; image; image=image->next)
1374 (void) SetImageDepth(image,SvIV(sval),exception);
1377 if (LocaleCompare(attribute,"dispose") == 0)
1379 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1380 SvPV(sval,na)) : SvIV(sval);
1383 ThrowPerlException(exception,OptionError,
1384 "UnrecognizedDisposeMethod",SvPV(sval,na));
1387 for ( ; image; image=image->next)
1388 image->dispose=(DisposeType) sp;
1391 if (LocaleCompare(attribute,"dither") == 0)
1395 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1396 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1399 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1403 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1407 if (LocaleCompare(attribute,"display") == 0)
1411 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1415 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1416 for ( ; image; image=image->next)
1417 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1423 if (LocaleCompare(attribute,"endian") == 0)
1425 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1426 SvPV(sval,na)) : SvIV(sval);
1429 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1434 info->image_info->endian=(EndianType) sp;
1435 for ( ; image; image=image->next)
1436 image->endian=(EndianType) sp;
1439 if (LocaleCompare(attribute,"extract") == 0)
1442 Set image extract geometry.
1444 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1448 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1449 for ( ; image; image=image->next)
1450 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1456 if (LocaleCompare(attribute,"filename") == 0)
1459 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1461 for ( ; image; image=image->next)
1462 (void) CopyMagickString(image->filename,SvPV(sval,na),
1466 if (LocaleCompare(attribute,"file") == 0)
1474 if (info == (struct PackageInfo *) NULL)
1476 io_info=IoIFP(sv_2io(sval));
1477 if (io_info == (PerlIO *) NULL)
1479 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1483 file=PerlIO_findFILE(io_info);
1484 if (file == (FILE *) NULL)
1486 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1490 SetImageInfoFile(info->image_info,file);
1493 if (LocaleCompare(attribute,"fill") == 0)
1496 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1499 if (LocaleCompare(attribute,"font") == 0)
1502 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1505 if (LocaleCompare(attribute,"foreground") == 0)
1507 if (LocaleCompare(attribute,"fuzz") == 0)
1510 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1512 for ( ; image; image=image->next)
1513 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1518 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1519 for ( ; image; image=image->next)
1520 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1526 if (LocaleCompare(attribute,"gamma") == 0)
1528 for ( ; image; image=image->next)
1529 image->gamma=SvNV(sval);
1532 if (LocaleCompare(attribute,"gravity") == 0)
1534 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1535 SvPV(sval,na)) : SvIV(sval);
1538 ThrowPerlException(exception,OptionError,
1539 "UnrecognizedGravityType",SvPV(sval,na));
1543 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1544 for ( ; image; image=image->next)
1545 image->gravity=(GravityType) sp;
1548 if (LocaleCompare(attribute,"green-primary") == 0)
1550 for ( ; image; image=image->next)
1552 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1553 image->chromaticity.green_primary.x=geometry_info.rho;
1554 image->chromaticity.green_primary.y=geometry_info.sigma;
1555 if ((flags & SigmaValue) == 0)
1556 image->chromaticity.green_primary.y=
1557 image->chromaticity.green_primary.x;
1562 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1563 for ( ; image; image=image->next)
1564 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1570 if (LocaleNCompare(attribute,"index",5) == 0)
1584 for ( ; image; image=image->next)
1586 if (image->storage_class != PseudoClass)
1590 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1592 image_view=AcquireAuthenticCacheView(image,exception);
1593 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1594 if (q != (Quantum *) NULL)
1596 items=sscanf(SvPV(sval,na),"%ld",&index);
1597 if ((index >= 0) && (index < (ssize_t) image->colors))
1598 SetPixelIndex(image,index,q);
1599 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1601 image_view=DestroyCacheView(image_view);
1605 if (LocaleCompare(attribute,"iterations") == 0)
1608 for ( ; image; image=image->next)
1609 image->iterations=SvIV(sval);
1612 if (LocaleCompare(attribute,"interlace") == 0)
1614 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1615 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1618 ThrowPerlException(exception,OptionError,
1619 "UnrecognizedInterlaceType",SvPV(sval,na));
1623 info->image_info->interlace=(InterlaceType) sp;
1624 for ( ; image; image=image->next)
1625 image->interlace=(InterlaceType) sp;
1629 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1630 for ( ; image; image=image->next)
1631 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1637 if (LocaleCompare(attribute,"label") == 0)
1639 for ( ; image; image=image->next)
1640 (void) SetImageProperty(image,"label",InterpretImageProperties(
1641 info ? info->image_info : (ImageInfo *) NULL,image,
1642 SvPV(sval,na),exception),exception);
1645 if (LocaleCompare(attribute,"loop") == 0)
1648 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1649 for ( ; image; image=image->next)
1650 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1656 if (LocaleCompare(attribute,"magick") == 0)
1659 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1660 "%s:",SvPV(sval,na));
1661 for ( ; image; image=image->next)
1662 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1665 if (LocaleCompare(attribute,"map-limit") == 0)
1670 limit=MagickResourceInfinity;
1671 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1672 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1674 (void) SetMagickResourceLimit(MapResource,limit);
1677 if (LocaleCompare(attribute,"mask") == 0)
1682 mask=(Image *) NULL;
1684 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1685 for ( ; image; image=image->next)
1686 SetImageMask(image,mask,exception);
1689 if (LocaleCompare(attribute,"mattecolor") == 0)
1691 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1694 info->image_info->matte_color=target_color;
1695 for ( ; image; image=image->next)
1696 image->matte_color=target_color;
1699 if (LocaleCompare(attribute,"matte") == 0)
1701 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1702 SvPV(sval,na)) : SvIV(sval);
1705 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1709 for ( ; image; image=image->next)
1710 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1713 if (LocaleCompare(attribute,"memory-limit") == 0)
1718 limit=MagickResourceInfinity;
1719 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1720 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1722 (void) SetMagickResourceLimit(MemoryResource,limit);
1725 if (LocaleCompare(attribute,"monochrome") == 0)
1727 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1728 SvPV(sval,na)) : SvIV(sval);
1731 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1736 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1737 for ( ; image; image=image->next)
1738 (void) SetImageType(image,BilevelType,exception);
1742 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1743 for ( ; image; image=image->next)
1744 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1750 if (LocaleCompare(attribute,"option") == 0)
1753 DefineImageOption(info->image_info,SvPV(sval,na));
1756 if (LocaleCompare(attribute,"orientation") == 0)
1758 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1759 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1762 ThrowPerlException(exception,OptionError,
1763 "UnrecognizedOrientationType",SvPV(sval,na));
1767 info->image_info->orientation=(OrientationType) sp;
1768 for ( ; image; image=image->next)
1769 image->orientation=(OrientationType) sp;
1773 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1774 for ( ; image; image=image->next)
1775 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1781 if (LocaleCompare(attribute,"page") == 0)
1786 geometry=GetPageGeometry(SvPV(sval,na));
1788 (void) CloneString(&info->image_info->page,geometry);
1789 for ( ; image; image=image->next)
1790 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1791 geometry=(char *) RelinquishMagickMemory(geometry);
1794 if (LocaleNCompare(attribute,"pixel",5) == 0)
1808 for ( ; image; image=image->next)
1810 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1814 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1816 image_view=AcquireVirtualCacheView(image,exception);
1817 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1818 if (q != (Quantum *) NULL)
1820 if ((strchr(SvPV(sval,na),',') == 0) ||
1821 (strchr(SvPV(sval,na),')') != 0))
1822 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1826 GetPixelInfo(image,&pixel);
1827 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1828 pixel.red=geometry_info.rho;
1829 if ((flags & SigmaValue) != 0)
1830 pixel.green=geometry_info.sigma;
1831 if ((flags & XiValue) != 0)
1832 pixel.blue=geometry_info.xi;
1833 if ((flags & PsiValue) != 0)
1834 pixel.alpha=geometry_info.psi;
1835 if ((flags & ChiValue) != 0)
1836 pixel.black=geometry_info.chi;
1838 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1839 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1840 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1841 if (image->colorspace == CMYKColorspace)
1842 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1843 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1844 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1846 image_view=DestroyCacheView(image_view);
1850 if (LocaleCompare(attribute,"pointsize") == 0)
1854 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1855 info->image_info->pointsize=geometry_info.rho;
1859 if (LocaleCompare(attribute,"preview") == 0)
1861 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1862 SvPV(sval,na)) : SvIV(sval);
1865 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1870 info->image_info->preview_type=(PreviewType) sp;
1874 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1875 for ( ; image; image=image->next)
1876 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1882 if (LocaleCompare(attribute,"quality") == 0)
1885 info->image_info->quality=SvIV(sval);
1886 for ( ; image; image=image->next)
1887 image->quality=SvIV(sval);
1891 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1892 for ( ; image; image=image->next)
1893 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1899 if (LocaleCompare(attribute,"red-primary") == 0)
1901 for ( ; image; image=image->next)
1903 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1904 image->chromaticity.red_primary.x=geometry_info.rho;
1905 image->chromaticity.red_primary.y=geometry_info.sigma;
1906 if ((flags & SigmaValue) == 0)
1907 image->chromaticity.red_primary.y=
1908 image->chromaticity.red_primary.x;
1912 if (LocaleCompare(attribute,"render") == 0)
1914 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1915 SvPV(sval,na)) : SvIV(sval);
1918 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1922 for ( ; image; image=image->next)
1923 image->rendering_intent=(RenderingIntent) sp;
1926 if (LocaleCompare(attribute,"repage") == 0)
1931 for ( ; image; image=image->next)
1933 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1934 if ((flags & WidthValue) != 0)
1936 if ((flags & HeightValue) == 0)
1937 geometry.height=geometry.width;
1938 image->page.width=geometry.width;
1939 image->page.height=geometry.height;
1941 if ((flags & AspectValue) != 0)
1943 if ((flags & XValue) != 0)
1944 image->page.x+=geometry.x;
1945 if ((flags & YValue) != 0)
1946 image->page.y+=geometry.y;
1950 if ((flags & XValue) != 0)
1952 image->page.x=geometry.x;
1953 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1954 image->page.width=image->columns+geometry.x;
1956 if ((flags & YValue) != 0)
1958 image->page.y=geometry.y;
1959 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1960 image->page.height=image->rows+geometry.y;
1967 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1968 for ( ; image; image=image->next)
1969 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1975 if (LocaleCompare(attribute,"sampling-factor") == 0)
1977 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1979 ThrowPerlException(exception,OptionError,"MissingGeometry",
1984 (void) CloneString(&info->image_info->sampling_factor,
1988 if (LocaleCompare(attribute,"scene") == 0)
1990 for ( ; image; image=image->next)
1991 image->scene=SvIV(sval);
1994 if (LocaleCompare(attribute,"server") == 0)
1996 if (LocaleCompare(attribute,"size") == 0)
2000 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2002 ThrowPerlException(exception,OptionError,"MissingGeometry",
2006 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2010 if (LocaleCompare(attribute,"stroke") == 0)
2013 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2017 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2018 for ( ; image; image=image->next)
2019 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2025 if (LocaleCompare(attribute,"texture") == 0)
2028 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2031 if (LocaleCompare(attribute,"thread-limit") == 0)
2036 limit=MagickResourceInfinity;
2037 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2038 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2040 (void) SetMagickResourceLimit(ThreadResource,limit);
2043 if (LocaleCompare(attribute,"tile-offset") == 0)
2048 geometry=GetPageGeometry(SvPV(sval,na));
2050 (void) CloneString(&info->image_info->page,geometry);
2051 for ( ; image; image=image->next)
2052 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2054 geometry=(char *) RelinquishMagickMemory(geometry);
2057 if (LocaleCompare(attribute,"time-limit") == 0)
2062 limit=MagickResourceInfinity;
2063 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2064 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2066 (void) SetMagickResourceLimit(TimeResource,limit);
2069 if (LocaleCompare(attribute,"transparent-color") == 0)
2071 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2074 info->image_info->transparent_color=target_color;
2075 for ( ; image; image=image->next)
2076 image->transparent_color=target_color;
2079 if (LocaleCompare(attribute,"type") == 0)
2081 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2082 SvPV(sval,na)) : SvIV(sval);
2085 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2090 info->image_info->type=(ImageType) sp;
2091 for ( ; image; image=image->next)
2092 SetImageType(image,(ImageType) sp,exception);
2096 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2097 for ( ; image; image=image->next)
2098 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2104 if (LocaleCompare(attribute,"units") == 0)
2106 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2107 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2110 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2115 info->image_info->units=(ResolutionType) sp;
2116 for ( ; image; image=image->next)
2121 units=(ResolutionType) sp;
2122 if (image->units != units)
2123 switch (image->units)
2125 case UndefinedResolution:
2126 case PixelsPerInchResolution:
2128 if (units == PixelsPerCentimeterResolution)
2130 image->resolution.x*=2.54;
2131 image->resolution.y*=2.54;
2135 case PixelsPerCentimeterResolution:
2137 if (units == PixelsPerInchResolution)
2139 image->resolution.x/=2.54;
2140 image->resolution.y/=2.54;
2150 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2151 for ( ; image; image=image->next)
2152 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2158 if (LocaleCompare(attribute,"verbose") == 0)
2160 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2161 SvPV(sval,na)) : SvIV(sval);
2164 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2169 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2172 if (LocaleCompare(attribute,"view") == 0)
2175 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2178 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2180 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2181 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2184 ThrowPerlException(exception,OptionError,
2185 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2188 for ( ; image; image=image->next)
2189 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2193 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2194 for ( ; image; image=image->next)
2195 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2201 if (LocaleCompare(attribute,"white-point") == 0)
2203 for ( ; image; image=image->next)
2205 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2206 image->chromaticity.white_point.x=geometry_info.rho;
2207 image->chromaticity.white_point.y=geometry_info.sigma;
2208 if ((flags & SigmaValue) == 0)
2209 image->chromaticity.white_point.y=
2210 image->chromaticity.white_point.x;
2215 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2216 for ( ; image; image=image->next)
2217 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2223 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2224 for ( ; image; image=image->next)
2225 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2236 % S e t u p L i s t %
2240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2242 % Method SetupList returns the list of all the images linked by their
2243 % image->next and image->previous link lists for use with ImageMagick. If
2244 % info is non-NULL, an info structure is returned in *info. If
2245 % reference_vector is non-NULL,an array of SV* are returned in
2246 % *reference_vector. Reference_vector is used when the images are going to be
2247 % replaced with new Image*'s.
2249 % The format of the SetupList routine is:
2251 % Image *SetupList(SV *reference,struct PackageInfo **info,
2252 % SV ***reference_vector,ExceptionInfo *exception)
2254 % A description of each parameter follows:
2256 % o list: a list of strings.
2258 % o string: a character string.
2260 % o exception: Return any errors or warnings in this structure.
2263 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2264 SV ***reference_vector,ExceptionInfo *exception)
2273 if (reference_vector)
2274 *reference_vector=NULL;
2279 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2280 if (info && (SvTYPE(reference) == SVt_PVAV))
2281 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2291 % s t r E Q c a s e %
2295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2297 % strEQcase() compares two strings and returns 0 if they are the
2298 % same or if the second string runs out first. The comparison is case
2301 % The format of the strEQcase routine is:
2303 % ssize_t strEQcase(const char *p,const char *q)
2305 % A description of each parameter follows:
2307 % o p: a character string.
2309 % o q: a character string.
2313 static ssize_t strEQcase(const char *p,const char *q)
2321 for (i=0 ; (c=(*q)) != 0; i++)
2323 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2324 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2329 return(((*q == 0) && (*p == 0)) ? i : 0);
2333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2337 % I m a g e : : M a g i c k %
2341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2345 MODULE = Image::Magick PACKAGE = Image::Magick
2350 MagickCoreGenesis("PerlMagick",MagickFalse);
2351 SetWarningHandler(NULL);
2352 SetErrorHandler(NULL);
2353 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2354 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2360 if (magick_registry != (SplayTreeInfo *) NULL)
2361 magick_registry=DestroySplayTree(magick_registry);
2362 MagickCoreTerminus();
2366 constant(name,argument)
2371 ###############################################################################
2379 ###############################################################################
2384 Image::Magick ref=NO_INIT
2408 PERL_UNUSED_VAR(ref);
2409 PERL_UNUSED_VAR(ix);
2410 exception=AcquireExceptionInfo();
2411 perl_exception=newSVpv("",0);
2412 package_info=(struct PackageInfo *) NULL;
2413 if (sv_isobject(ST(0)) == 0)
2415 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2419 reference=SvRV(ST(0));
2420 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2421 if (image == (Image *) NULL)
2423 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2427 package_info=ClonePackageInfo(info,exception);
2429 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2432 for (i=2; i < items; i+=2)
2433 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2435 (void) AnimateImages(package_info->image_info,image,exception);
2436 (void) CatchImageException(image);
2439 if (package_info != (struct PackageInfo *) NULL)
2440 DestroyPackageInfo(package_info);
2441 InheritPerlException(exception,perl_exception);
2442 exception=DestroyExceptionInfo(exception);
2443 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2444 SvPOK_on(perl_exception);
2445 ST(0)=sv_2mortal(perl_exception);
2450 ###############################################################################
2458 ###############################################################################
2463 Image::Magick ref=NO_INIT
2501 PERL_UNUSED_VAR(ref);
2502 PERL_UNUSED_VAR(ix);
2503 exception=AcquireExceptionInfo();
2504 perl_exception=newSVpv("",0);
2508 if (sv_isobject(ST(0)) == 0)
2510 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2514 reference=SvRV(ST(0));
2515 hv=SvSTASH(reference);
2517 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2519 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2520 if (image == (Image *) NULL)
2522 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2526 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2531 for (i=2; i < items; i+=2)
2533 attribute=(char *) SvPV(ST(i-1),na);
2539 if (LocaleCompare(attribute,"stack") == 0)
2541 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2545 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2551 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2557 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2563 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2564 if (image == (Image *) NULL)
2566 for ( ; image; image=image->next)
2568 AddImageToRegistry(sv,image);
2570 av_push(av,sv_bless(rv,hv));
2573 exception=DestroyExceptionInfo(exception);
2575 SvREFCNT_dec(perl_exception);
2579 InheritPerlException(exception,perl_exception);
2580 exception=DestroyExceptionInfo(exception);
2581 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2582 SvPOK_on(perl_exception);
2583 ST(0)=sv_2mortal(perl_exception);
2588 ###############################################################################
2596 ###############################################################################
2601 Image::Magick ref=NO_INIT
2632 PERL_UNUSED_VAR(ref);
2633 PERL_UNUSED_VAR(ix);
2634 exception=AcquireExceptionInfo();
2635 perl_exception=newSVpv("",0);
2637 if (sv_isobject(ST(0)) == 0)
2639 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2643 reference=SvRV(ST(0));
2644 hv=SvSTASH(reference);
2645 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2646 if (image == (Image *) NULL)
2648 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2652 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2653 if (image == (Image *) NULL)
2656 Create blessed Perl array for the returned image.
2659 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2661 AddImageToRegistry(sv,image);
2663 av_push(av,sv_bless(rv,hv));
2665 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2666 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2667 "average-%.*s",(int) (MaxTextExtent-9),
2668 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2669 (void) CopyMagickString(image->filename,info->image_info->filename,
2671 SetImageInfo(info->image_info,0,exception);
2672 exception=DestroyExceptionInfo(exception);
2673 SvREFCNT_dec(perl_exception);
2677 InheritPerlException(exception,perl_exception);
2678 exception=DestroyExceptionInfo(exception);
2679 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2680 SvPOK_on(perl_exception);
2681 ST(0)=sv_2mortal(perl_exception);
2686 ###############################################################################
2690 # B l o b T o I m a g e #
2694 ###############################################################################
2698 BlobToImage(ref,...)
2699 Image::Magick ref=NO_INIT
2745 PERL_UNUSED_VAR(ref);
2746 PERL_UNUSED_VAR(ix);
2747 exception=AcquireExceptionInfo();
2748 perl_exception=newSVpv("",0);
2751 ac=(items < 2) ? 1 : items-1;
2752 length=(STRLEN *) NULL;
2753 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2754 if (list == (char **) NULL)
2756 ThrowPerlException(exception,ResourceLimitError,
2757 "MemoryAllocationFailed",PackageName);
2760 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2761 if (length == (STRLEN *) NULL)
2763 ThrowPerlException(exception,ResourceLimitError,
2764 "MemoryAllocationFailed",PackageName);
2767 if (sv_isobject(ST(0)) == 0)
2769 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2773 reference=SvRV(ST(0));
2774 hv=SvSTASH(reference);
2775 if (SvTYPE(reference) != SVt_PVAV)
2777 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2781 av=(AV *) reference;
2782 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2787 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2790 for (n=0, i=0; i < ac; i++)
2792 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2793 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2795 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2800 list[n]=(char *) NULL;
2802 for (i=number_images=0; i < n; i++)
2804 image=BlobToImage(info->image_info,list[i],length[i],exception);
2805 if (image == (Image *) NULL)
2807 for ( ; image; image=image->next)
2809 AddImageToRegistry(sv,image);
2811 av_push(av,sv_bless(rv,hv));
2819 for (i=0; i < n; i++)
2820 if (list[i] != (char *) NULL)
2821 for (p=keep; list[i] != *p++; )
2822 if (*p == (char *) NULL)
2824 list[i]=(char *) RelinquishMagickMemory(list[i]);
2830 list=(char **) RelinquishMagickMemory(list);
2832 length=(STRLEN *) RelinquishMagickMemory(length);
2833 InheritPerlException(exception,perl_exception);
2834 exception=DestroyExceptionInfo(exception);
2835 sv_setiv(perl_exception,(IV) number_images);
2836 SvPOK_on(perl_exception);
2837 ST(0)=sv_2mortal(perl_exception);
2842 ###############################################################################
2846 # C h a n n e l F x #
2850 ###############################################################################
2855 Image::Magick ref=NO_INIT
2867 expression[MaxTextExtent];
2895 PERL_UNUSED_VAR(ref);
2896 PERL_UNUSED_VAR(ix);
2897 exception=AcquireExceptionInfo();
2898 perl_exception=newSVpv("",0);
2902 if (sv_isobject(ST(0)) == 0)
2904 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2908 reference=SvRV(ST(0));
2909 hv=SvSTASH(reference);
2911 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2913 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2914 if (image == (Image *) NULL)
2916 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2920 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2924 channel=DefaultChannels;
2925 (void) CopyMagickString(expression,"u",MaxTextExtent);
2927 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2929 for (i=2; i < items; i+=2)
2931 attribute=(char *) SvPV(ST(i-1),na);
2937 if (LocaleCompare(attribute,"channel") == 0)
2942 option=ParseChannelOption(SvPV(ST(i),na));
2945 ThrowPerlException(exception,OptionError,
2946 "UnrecognizedType",SvPV(ST(i),na));
2949 channel=(ChannelType) option;
2952 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2959 if (LocaleCompare(attribute,"expression") == 0)
2961 (void) CopyMagickString(expression,SvPV(ST(i),na),
2965 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2971 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2977 channel_mask=SetImageChannelMask(image,channel);
2978 image=ChannelFxImage(image,expression,exception);
2979 if (image != (Image *) NULL)
2980 (void) SetImageChannelMask(image,channel_mask);
2981 if (image == (Image *) NULL)
2983 for ( ; image; image=image->next)
2985 AddImageToRegistry(sv,image);
2987 av_push(av,sv_bless(rv,hv));
2990 exception=DestroyExceptionInfo(exception);
2992 SvREFCNT_dec(perl_exception); /* can't return warning messages */
2996 InheritPerlException(exception,perl_exception);
2997 exception=DestroyExceptionInfo(exception);
2998 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2999 SvPOK_on(perl_exception);
3000 ST(0)=sv_2mortal(perl_exception);
3005 ###############################################################################
3013 ###############################################################################
3018 Image::Magick ref=NO_INIT
3051 PERL_UNUSED_VAR(ref);
3052 PERL_UNUSED_VAR(ix);
3053 exception=AcquireExceptionInfo();
3054 perl_exception=newSVpv("",0);
3056 if (sv_isobject(ST(0)) == 0)
3058 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3062 reference=SvRV(ST(0));
3063 hv=SvSTASH(reference);
3064 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3065 if (image == (Image *) NULL)
3067 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3072 Create blessed Perl array for the returned image.
3075 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3077 for ( ; image; image=image->next)
3079 clone=CloneImage(image,0,0,MagickTrue,exception);
3080 if (clone == (Image *) NULL)
3082 AddImageToRegistry(sv,clone);
3084 av_push(av,sv_bless(rv,hv));
3087 exception=DestroyExceptionInfo(exception);
3088 SvREFCNT_dec(perl_exception);
3092 InheritPerlException(exception,perl_exception);
3093 exception=DestroyExceptionInfo(exception);
3094 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3095 SvPOK_on(perl_exception);
3096 ST(0)=sv_2mortal(perl_exception);
3101 ###############################################################################
3109 ###############################################################################
3117 PERL_UNUSED_VAR(ref);
3118 if (magick_registry != (SplayTreeInfo *) NULL)
3123 ResetSplayTreeIterator(magick_registry);
3124 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3125 while (p != (Image *) NULL)
3128 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3134 ###############################################################################
3142 ###############################################################################
3147 Image::Magick ref=NO_INIT
3176 PERL_UNUSED_VAR(ref);
3177 PERL_UNUSED_VAR(ix);
3178 exception=AcquireExceptionInfo();
3179 perl_exception=newSVpv("",0);
3181 if (sv_isobject(ST(0)) == 0)
3183 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3187 reference=SvRV(ST(0));
3188 hv=SvSTASH(reference);
3190 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3192 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3193 if (image == (Image *) NULL)
3195 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3199 image=CoalesceImages(image,exception);
3200 if (image == (Image *) NULL)
3202 for ( ; image; image=image->next)
3204 AddImageToRegistry(sv,image);
3206 av_push(av,sv_bless(rv,hv));
3209 exception=DestroyExceptionInfo(exception);
3211 SvREFCNT_dec(perl_exception);
3215 InheritPerlException(exception,perl_exception);
3216 exception=DestroyExceptionInfo(exception);
3217 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3218 SvPOK_on(perl_exception);
3219 ST(0)=sv_2mortal(perl_exception);
3224 ###############################################################################
3232 ###############################################################################
3237 Image::Magick ref=NO_INIT
3283 PERL_UNUSED_VAR(ref);
3284 PERL_UNUSED_VAR(ix);
3285 exception=AcquireExceptionInfo();
3286 perl_exception=newSVpv("",0);
3290 if (sv_isobject(ST(0)) == 0)
3292 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3296 reference=SvRV(ST(0));
3297 hv=SvSTASH(reference);
3299 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3301 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3302 if (image == (Image *) NULL)
3304 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3308 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3312 reconstruct_image=image;
3313 metric=RootMeanSquaredErrorMetric;
3314 for (i=2; i < items; i+=2)
3316 attribute=(char *) SvPV(ST(i-1),na);
3322 if (LocaleCompare(attribute,"channel") == 0)
3327 option=ParseChannelOption(SvPV(ST(i),na));
3330 ThrowPerlException(exception,OptionError,
3331 "UnrecognizedType",SvPV(ST(i),na));
3334 SetPixelChannelMask(image,(ChannelType) option);
3337 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3344 if (LocaleCompare(attribute,"fuzz") == 0)
3346 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3349 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3356 if (LocaleCompare(attribute,"image") == 0)
3358 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3359 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3362 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3369 if (LocaleCompare(attribute,"metric") == 0)
3371 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3375 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3379 metric=(MetricType) option;
3382 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3394 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3396 if (difference_image != (Image *) NULL)
3398 difference_image->error.mean_error_per_pixel=distortion;
3399 AddImageToRegistry(sv,difference_image);
3401 av_push(av,sv_bless(rv,hv));
3404 exception=DestroyExceptionInfo(exception);
3406 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3410 InheritPerlException(exception,perl_exception);
3411 exception=DestroyExceptionInfo(exception);
3412 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3413 SvPOK_on(perl_exception);
3414 ST(0)=sv_2mortal(perl_exception);
3419 ###############################################################################
3423 # C o m p l e x I m a g e s #
3427 ###############################################################################
3432 Image::Magick ref=NO_INIT
3469 PERL_UNUSED_VAR(ref);
3470 PERL_UNUSED_VAR(ix);
3471 exception=AcquireExceptionInfo();
3472 perl_exception=newSVpv("",0);
3474 if (sv_isobject(ST(0)) == 0)
3476 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3480 reference=SvRV(ST(0));
3481 hv=SvSTASH(reference);
3482 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3483 if (image == (Image *) NULL)
3485 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3489 op=UndefinedComplexOperator;
3495 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3499 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3503 op=(ComplexOperator) in;
3506 for (i=2; i < items; i+=2)
3508 attribute=(char *) SvPV(ST(i-1),na);
3514 if (LocaleCompare(attribute,"operator") == 0)
3519 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3520 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3523 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3527 op=(ComplexOperator) in;
3530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3536 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3542 image=ComplexImages(image,op,exception);
3543 if (image == (Image *) NULL)
3546 Create blessed Perl array for the returned image.
3549 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3551 AddImageToRegistry(sv,image);
3553 av_push(av,sv_bless(rv,hv));
3555 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3556 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3557 "complex-%.*s",(int) (MaxTextExtent-9),
3558 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3559 (void) CopyMagickString(image->filename,info->image_info->filename,
3561 SetImageInfo(info->image_info,0,exception);
3562 exception=DestroyExceptionInfo(exception);
3563 SvREFCNT_dec(perl_exception);
3567 InheritPerlException(exception,perl_exception);
3568 exception=DestroyExceptionInfo(exception);
3569 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3570 SvPOK_on(perl_exception);
3571 ST(0)=sv_2mortal(perl_exception);
3576 ###############################################################################
3580 # C o m p a r e L a y e r s #
3584 ###############################################################################
3589 Image::Magick ref=NO_INIT
3591 CompareImagesLayers = 1
3593 compareimagelayers = 3
3630 PERL_UNUSED_VAR(ref);
3631 PERL_UNUSED_VAR(ix);
3632 exception=AcquireExceptionInfo();
3633 perl_exception=newSVpv("",0);
3635 if (sv_isobject(ST(0)) == 0)
3637 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3641 reference=SvRV(ST(0));
3642 hv=SvSTASH(reference);
3644 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3646 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3647 if (image == (Image *) NULL)
3649 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3653 method=CompareAnyLayer;
3654 for (i=2; i < items; i+=2)
3656 attribute=(char *) SvPV(ST(i-1),na);
3662 if (LocaleCompare(attribute,"method") == 0)
3664 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3668 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3672 method=(LayerMethod) option;
3675 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3687 image=CompareImagesLayers(image,method,exception);
3688 if (image == (Image *) NULL)
3690 for ( ; image; image=image->next)
3692 AddImageToRegistry(sv,image);
3694 av_push(av,sv_bless(rv,hv));
3697 exception=DestroyExceptionInfo(exception);
3699 SvREFCNT_dec(perl_exception);
3703 InheritPerlException(exception,perl_exception);
3704 exception=DestroyExceptionInfo(exception);
3705 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3706 SvPOK_on(perl_exception);
3707 ST(0)=sv_2mortal(perl_exception);
3712 ###############################################################################
3720 ###############################################################################
3725 Image::Magick ref=NO_INIT
3731 PERL_UNUSED_VAR(ref);
3732 if (sv_isobject(ST(0)) == 0)
3733 croak("ReferenceIsNotMyType");
3734 reference=SvRV(ST(0));
3735 switch (SvTYPE(reference))
3740 message[MaxTextExtent];
3758 Array (AV *) reference
3760 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3761 XS_VERSION,reference);
3762 hv=gv_stashpv(PackageName, FALSE);
3765 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3769 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3771 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3772 DestroyPackageInfo(info);
3774 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3784 Blessed scalar = (Image *) SvIV(reference)
3786 image=INT2PTR(Image *,SvIV(reference));
3787 if (image != (Image *) NULL)
3788 DeleteImageFromRegistry(reference,image);
3797 ###############################################################################
3805 ###############################################################################
3810 Image::Magick ref=NO_INIT
3834 PERL_UNUSED_VAR(ref);
3835 PERL_UNUSED_VAR(ix);
3836 exception=AcquireExceptionInfo();
3837 perl_exception=newSVpv("",0);
3838 package_info=(struct PackageInfo *) NULL;
3839 if (sv_isobject(ST(0)) == 0)
3841 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3845 reference=SvRV(ST(0));
3846 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3847 if (image == (Image *) NULL)
3849 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3853 package_info=ClonePackageInfo(info,exception);
3855 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3858 for (i=2; i < items; i+=2)
3859 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3861 (void) DisplayImages(package_info->image_info,image,exception);
3862 (void) CatchImageException(image);
3865 if (package_info != (struct PackageInfo *) NULL)
3866 DestroyPackageInfo(package_info);
3867 InheritPerlException(exception,perl_exception);
3868 exception=DestroyExceptionInfo(exception);
3869 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3870 SvPOK_on(perl_exception);
3871 ST(0)=sv_2mortal(perl_exception);
3876 ###############################################################################
3880 # E v a l u a t e I m a g e s #
3884 ###############################################################################
3889 Image::Magick ref=NO_INIT
3911 MagickEvaluateOperator
3926 PERL_UNUSED_VAR(ref);
3927 PERL_UNUSED_VAR(ix);
3928 exception=AcquireExceptionInfo();
3929 perl_exception=newSVpv("",0);
3931 if (sv_isobject(ST(0)) == 0)
3933 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3937 reference=SvRV(ST(0));
3938 hv=SvSTASH(reference);
3939 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3940 if (image == (Image *) NULL)
3942 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3946 op=MeanEvaluateOperator;
3952 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3956 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3960 op=(MagickEvaluateOperator) in;
3963 for (i=2; i < items; i+=2)
3965 attribute=(char *) SvPV(ST(i-1),na);
3971 if (LocaleCompare(attribute,"operator") == 0)
3976 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3977 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3980 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3984 op=(MagickEvaluateOperator) in;
3987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3999 image=EvaluateImages(image,op,exception);
4000 if (image == (Image *) NULL)
4003 Create blessed Perl array for the returned image.
4006 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4008 AddImageToRegistry(sv,image);
4010 av_push(av,sv_bless(rv,hv));
4012 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4013 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4014 "evaluate-%.*s",(int) (MaxTextExtent-9),
4015 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4016 (void) CopyMagickString(image->filename,info->image_info->filename,
4018 SetImageInfo(info->image_info,0,exception);
4019 exception=DestroyExceptionInfo(exception);
4020 SvREFCNT_dec(perl_exception);
4024 InheritPerlException(exception,perl_exception);
4025 exception=DestroyExceptionInfo(exception);
4026 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4027 SvPOK_on(perl_exception);
4028 ST(0)=sv_2mortal(perl_exception);
4033 ###############################################################################
4041 ###############################################################################
4046 Image::Magick ref=NO_INIT
4053 #define ChannelFeatures(channel,direction) \
4055 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4056 channel_features[channel].angular_second_moment[direction]); \
4057 PUSHs(sv_2mortal(newSVpv(message,0))); \
4058 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4059 channel_features[channel].contrast[direction]); \
4060 PUSHs(sv_2mortal(newSVpv(message,0))); \
4061 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4062 channel_features[channel].contrast[direction]); \
4063 PUSHs(sv_2mortal(newSVpv(message,0))); \
4064 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4065 channel_features[channel].variance_sum_of_squares[direction]); \
4066 PUSHs(sv_2mortal(newSVpv(message,0))); \
4067 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4068 channel_features[channel].inverse_difference_moment[direction]); \
4069 PUSHs(sv_2mortal(newSVpv(message,0))); \
4070 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4071 channel_features[channel].sum_average[direction]); \
4072 PUSHs(sv_2mortal(newSVpv(message,0))); \
4073 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4074 channel_features[channel].sum_variance[direction]); \
4075 PUSHs(sv_2mortal(newSVpv(message,0))); \
4076 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4077 channel_features[channel].sum_entropy[direction]); \
4078 PUSHs(sv_2mortal(newSVpv(message,0))); \
4079 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4080 channel_features[channel].entropy[direction]); \
4081 PUSHs(sv_2mortal(newSVpv(message,0))); \
4082 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4083 channel_features[channel].difference_variance[direction]); \
4084 PUSHs(sv_2mortal(newSVpv(message,0))); \
4085 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4086 channel_features[channel].difference_entropy[direction]); \
4087 PUSHs(sv_2mortal(newSVpv(message,0))); \
4088 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4089 channel_features[channel].measure_of_correlation_1[direction]); \
4090 PUSHs(sv_2mortal(newSVpv(message,0))); \
4091 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4092 channel_features[channel].measure_of_correlation_2[direction]); \
4093 PUSHs(sv_2mortal(newSVpv(message,0))); \
4094 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4095 channel_features[channel].maximum_correlation_coefficient[direction]); \
4096 PUSHs(sv_2mortal(newSVpv(message,0))); \
4104 message[MaxTextExtent];
4131 PERL_UNUSED_VAR(ref);
4132 PERL_UNUSED_VAR(ix);
4133 exception=AcquireExceptionInfo();
4134 perl_exception=newSVpv("",0);
4136 if (sv_isobject(ST(0)) == 0)
4138 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4142 reference=SvRV(ST(0));
4145 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4146 if (image == (Image *) NULL)
4148 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4152 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4154 for (i=2; i < items; i+=2)
4156 attribute=(char *) SvPV(ST(i-1),na);
4162 if (LocaleCompare(attribute,"distance") == 0)
4164 distance=StringToLong((char *) SvPV(ST(1),na));
4167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4173 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4180 for ( ; image; image=image->next)
4182 channel_features=GetImageFeatures(image,distance,exception);
4183 if (channel_features == (ChannelFeatures *) NULL)
4186 EXTEND(sp,75*count);
4187 for (i=0; i < 4; i++)
4189 ChannelFeatures(RedChannel,i);
4190 ChannelFeatures(GreenChannel,i);
4191 ChannelFeatures(BlueChannel,i);
4192 if (image->colorspace == CMYKColorspace)
4193 ChannelFeatures(BlackChannel,i);
4194 if (image->alpha_trait == BlendPixelTrait)
4195 ChannelFeatures(AlphaChannel,i);
4197 channel_features=(ChannelFeatures *)
4198 RelinquishMagickMemory(channel_features);
4202 InheritPerlException(exception,perl_exception);
4203 exception=DestroyExceptionInfo(exception);
4204 SvREFCNT_dec(perl_exception);
4208 ###############################################################################
4216 ###############################################################################
4221 Image::Magick ref=NO_INIT
4259 PERL_UNUSED_VAR(ref);
4260 PERL_UNUSED_VAR(ix);
4261 exception=AcquireExceptionInfo();
4262 perl_exception=newSVpv("",0);
4264 if (sv_isobject(ST(0)) == 0)
4266 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4270 reference=SvRV(ST(0));
4271 hv=SvSTASH(reference);
4272 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4273 if (image == (Image *) NULL)
4275 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4279 background_color=image->background_color;
4281 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4282 &background_color,exception);
4284 for (i=2; i < items; i+=2)
4286 attribute=(char *) SvPV(ST(i-1),na);
4292 if (LocaleCompare(attribute,"background") == 0)
4294 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4295 AllCompliance,&background_color,exception);
4298 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4304 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4310 image->background_color=background_color;
4311 image=MergeImageLayers(image,FlattenLayer,exception);
4312 if (image == (Image *) NULL)
4315 Create blessed Perl array for the returned image.
4318 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4320 AddImageToRegistry(sv,image);
4322 av_push(av,sv_bless(rv,hv));
4324 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4325 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4326 "flatten-%.*s",(int) (MaxTextExtent-9),
4327 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4328 (void) CopyMagickString(image->filename,info->image_info->filename,
4330 SetImageInfo(info->image_info,0,exception);
4331 exception=DestroyExceptionInfo(exception);
4332 SvREFCNT_dec(perl_exception);
4336 InheritPerlException(exception,perl_exception);
4337 exception=DestroyExceptionInfo(exception);
4338 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4339 SvPOK_on(perl_exception); /* return messages in string context */
4340 ST(0)=sv_2mortal(perl_exception);
4345 ###############################################################################
4353 ###############################################################################
4358 Image::Magick ref=NO_INIT
4370 expression[MaxTextExtent];
4398 PERL_UNUSED_VAR(ref);
4399 PERL_UNUSED_VAR(ix);
4400 exception=AcquireExceptionInfo();
4401 perl_exception=newSVpv("",0);
4405 if (sv_isobject(ST(0)) == 0)
4407 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4411 reference=SvRV(ST(0));
4412 hv=SvSTASH(reference);
4414 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4416 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4417 if (image == (Image *) NULL)
4419 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4423 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4427 channel=DefaultChannels;
4428 (void) CopyMagickString(expression,"u",MaxTextExtent);
4430 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4432 for (i=2; i < items; i+=2)
4434 attribute=(char *) SvPV(ST(i-1),na);
4440 if (LocaleCompare(attribute,"channel") == 0)
4445 option=ParseChannelOption(SvPV(ST(i),na));
4448 ThrowPerlException(exception,OptionError,
4449 "UnrecognizedType",SvPV(ST(i),na));
4452 channel=(ChannelType) option;
4455 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4462 if (LocaleCompare(attribute,"expression") == 0)
4464 (void) CopyMagickString(expression,SvPV(ST(i),na),
4468 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4480 channel_mask=SetImageChannelMask(image,channel);
4481 image=FxImage(image,expression,exception);
4482 if (image != (Image *) NULL)
4483 (void) SetImageChannelMask(image,channel_mask);
4484 if (image == (Image *) NULL)
4486 for ( ; image; image=image->next)
4488 AddImageToRegistry(sv,image);
4490 av_push(av,sv_bless(rv,hv));
4493 exception=DestroyExceptionInfo(exception);
4495 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4499 InheritPerlException(exception,perl_exception);
4500 exception=DestroyExceptionInfo(exception);
4501 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4502 SvPOK_on(perl_exception);
4503 ST(0)=sv_2mortal(perl_exception);
4508 ###############################################################################
4516 ###############################################################################
4521 Image::Magick ref=NO_INIT
4532 color[MaxTextExtent];
4557 PERL_UNUSED_VAR(ref);
4558 PERL_UNUSED_VAR(ix);
4559 exception=AcquireExceptionInfo();
4560 perl_exception=newSVpv("",0);
4561 if (sv_isobject(ST(0)) == 0)
4563 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4567 reference=SvRV(ST(0));
4568 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4569 if (image == (Image *) NULL && !info)
4572 for (i=1; i < items; i++)
4574 attribute=(char *) SvPV(ST(i),na);
4581 if (LocaleCompare(attribute,"adjoin") == 0)
4584 s=newSViv((ssize_t) info->image_info->adjoin);
4585 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4588 if (LocaleCompare(attribute,"antialias") == 0)
4591 s=newSViv((ssize_t) info->image_info->antialias);
4592 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4595 if (LocaleCompare(attribute,"area") == 0)
4597 s=newSViv(GetMagickResource(AreaResource));
4598 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4601 if (LocaleCompare(attribute,"attenuate") == 0)
4606 value=GetImageProperty(image,attribute,exception);
4607 if (value != (const char *) NULL)
4609 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4612 if (LocaleCompare(attribute,"authenticate") == 0)
4619 option=GetImageOption(info->image_info,attribute);
4620 if (option != (const char *) NULL)
4621 s=newSVpv(option,0);
4623 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4626 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4633 if (LocaleCompare(attribute,"background") == 0)
4635 if (image == (Image *) NULL)
4637 (void) FormatLocaleString(color,MaxTextExtent,
4638 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4639 image->background_color.green,image->background_color.blue,
4640 image->background_color.alpha);
4642 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4645 if (LocaleCompare(attribute,"base-columns") == 0)
4647 if (image != (Image *) NULL)
4648 s=newSViv((ssize_t) image->magick_columns);
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 if (LocaleCompare(attribute,"base-filename") == 0)
4654 if (image != (Image *) NULL)
4655 s=newSVpv(image->magick_filename,0);
4656 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4659 if (LocaleCompare(attribute,"base-height") == 0)
4661 if (image != (Image *) NULL)
4662 s=newSViv((ssize_t) image->magick_rows);
4663 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4666 if (LocaleCompare(attribute,"base-rows") == 0)
4668 if (image != (Image *) NULL)
4669 s=newSViv((ssize_t) image->magick_rows);
4670 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4673 if (LocaleCompare(attribute,"base-width") == 0)
4675 if (image != (Image *) NULL)
4676 s=newSViv((ssize_t) image->magick_columns);
4677 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4680 if (LocaleCompare(attribute,"blue-primary") == 0)
4682 if (image == (Image *) NULL)
4684 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4685 image->chromaticity.blue_primary.x,
4686 image->chromaticity.blue_primary.y);
4688 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4691 if (LocaleCompare(attribute,"bordercolor") == 0)
4693 if (image == (Image *) NULL)
4695 (void) FormatLocaleString(color,MaxTextExtent,
4696 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4697 image->border_color.green,image->border_color.blue,
4698 image->border_color.alpha);
4700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4703 if (LocaleCompare(attribute,"bounding-box") == 0)
4706 geometry[MaxTextExtent];
4711 if (image == (Image *) NULL)
4713 page=GetImageBoundingBox(image,exception);
4714 (void) FormatLocaleString(geometry,MaxTextExtent,
4715 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4716 page.height,(double) page.x,(double) page.y);
4717 s=newSVpv(geometry,0);
4718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4721 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4728 if (LocaleCompare(attribute,"class") == 0)
4730 if (image == (Image *) NULL)
4732 s=newSViv(image->storage_class);
4733 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4734 image->storage_class));
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 if (LocaleCompare(attribute,"clip-mask") == 0)
4741 if (image != (Image *) NULL)
4750 if (image->read_mask == MagickFalse)
4751 ClipImage(image,exception);
4752 mask_image=GetImageMask(image,exception);
4753 if (mask_image != (Image *) NULL)
4755 AddImageToRegistry(sv,mask_image);
4756 s=sv_bless(newRV(sv),SvSTASH(reference));
4759 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4762 if (LocaleCompare(attribute,"clip-path") == 0)
4764 if (image != (Image *) NULL)
4773 if (image->read_mask != MagickFalse)
4774 ClipImage(image,exception);
4775 mask_image=GetImageMask(image,exception);
4776 if (mask_image != (Image *) NULL)
4778 AddImageToRegistry(sv,mask_image);
4779 s=sv_bless(newRV(sv),SvSTASH(reference));
4782 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4785 if (LocaleCompare(attribute,"compression") == 0)
4787 j=info ? info->image_info->compression : image ?
4788 image->compression : UndefinedCompression;
4790 if (info->image_info->compression == UndefinedCompression)
4791 j=image->compression;
4793 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4796 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4799 if (LocaleCompare(attribute,"colorspace") == 0)
4801 j=image ? image->colorspace : RGBColorspace;
4803 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4806 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4809 if (LocaleCompare(attribute,"colors") == 0)
4811 if (image != (Image *) NULL)
4812 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4814 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4817 if (LocaleNCompare(attribute,"colormap",8) == 0)
4822 if (image == (Image *) NULL || !image->colormap)
4825 items=sscanf(attribute,"%*[^[][%ld",&j);
4827 if (j > (ssize_t) image->colors)
4829 (void) FormatLocaleString(color,MaxTextExtent,
4830 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4831 image->colormap[j].green,image->colormap[j].blue,
4832 image->colormap[j].alpha);
4834 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4837 if (LocaleCompare(attribute,"columns") == 0)
4839 if (image != (Image *) NULL)
4840 s=newSViv((ssize_t) image->columns);
4841 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4844 if (LocaleCompare(attribute,"comment") == 0)
4849 value=GetImageProperty(image,attribute,exception);
4850 if (value != (const char *) NULL)
4852 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4855 if (LocaleCompare(attribute,"copyright") == 0)
4857 s=newSVpv(GetMagickCopyright(),0);
4858 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4861 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4868 if (LocaleCompare(attribute,"density") == 0)
4871 geometry[MaxTextExtent];
4873 if (image == (Image *) NULL)
4875 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4876 image->resolution.x,image->resolution.y);
4877 s=newSVpv(geometry,0);
4878 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4881 if (LocaleCompare(attribute,"delay") == 0)
4883 if (image != (Image *) NULL)
4884 s=newSViv((ssize_t) image->delay);
4885 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4888 if (LocaleCompare(attribute,"depth") == 0)
4890 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4891 if (image != (Image *) NULL)
4892 s=newSViv((ssize_t) GetImageDepth(image,exception));
4893 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4896 if (LocaleCompare(attribute,"directory") == 0)
4898 if (image && image->directory)
4899 s=newSVpv(image->directory,0);
4900 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4903 if (LocaleCompare(attribute,"dispose") == 0)
4905 if (image == (Image *) NULL)
4908 s=newSViv(image->dispose);
4910 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4912 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4915 if (LocaleCompare(attribute,"disk") == 0)
4917 s=newSViv(GetMagickResource(DiskResource));
4918 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4921 if (LocaleCompare(attribute,"dither") == 0)
4924 s=newSViv((ssize_t) info->image_info->dither);
4925 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4928 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4930 if (info && info->image_info->server_name)
4931 s=newSVpv(info->image_info->server_name,0);
4932 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4935 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4942 if (LocaleCompare(attribute,"elapsed-time") == 0)
4944 if (image != (Image *) NULL)
4945 s=newSVnv(GetElapsedTime(&image->timer));
4946 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4949 if (LocaleCompare(attribute,"endian") == 0)
4951 j=info ? info->image_info->endian : image ? image->endian :
4954 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4956 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4959 if (LocaleCompare(attribute,"error") == 0)
4961 if (image != (Image *) NULL)
4962 s=newSVnv(image->error.mean_error_per_pixel);
4963 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4966 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4973 if (LocaleCompare(attribute,"filesize") == 0)
4975 if (image != (Image *) NULL)
4976 s=newSViv((ssize_t) GetBlobSize(image));
4977 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4980 if (LocaleCompare(attribute,"filename") == 0)
4982 if (info && info->image_info->filename &&
4983 *info->image_info->filename)
4984 s=newSVpv(info->image_info->filename,0);
4985 if (image != (Image *) NULL)
4986 s=newSVpv(image->filename,0);
4987 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4990 if (LocaleCompare(attribute,"filter") == 0)
4992 s=image ? newSViv(image->filter) : newSViv(0);
4993 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4996 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4999 if (LocaleCompare(attribute,"font") == 0)
5001 if (info && info->image_info->font)
5002 s=newSVpv(info->image_info->font,0);
5003 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5006 if (LocaleCompare(attribute,"foreground") == 0)
5008 if (LocaleCompare(attribute,"format") == 0)
5013 magick_info=(const MagickInfo *) NULL;
5014 if (info && (*info->image_info->magick != '\0'))
5015 magick_info=GetMagickInfo(info->image_info->magick,exception);
5016 if (image != (Image *) NULL)
5017 magick_info=GetMagickInfo(image->magick,exception);
5018 if ((magick_info != (const MagickInfo *) NULL) &&
5019 (*magick_info->description != '\0'))
5020 s=newSVpv((char *) magick_info->description,0);
5021 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5024 if (LocaleCompare(attribute,"fuzz") == 0)
5027 s=newSVnv(info->image_info->fuzz);
5028 if (image != (Image *) NULL)
5029 s=newSVnv(image->fuzz);
5030 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5033 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5040 if (LocaleCompare(attribute,"gamma") == 0)
5042 if (image != (Image *) NULL)
5043 s=newSVnv(image->gamma);
5044 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5047 if (LocaleCompare(attribute,"geometry") == 0)
5049 if (image && image->geometry)
5050 s=newSVpv(image->geometry,0);
5051 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5054 if (LocaleCompare(attribute,"gravity") == 0)
5056 s=image ? newSViv(image->gravity) : newSViv(0);
5057 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5060 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5063 if (LocaleCompare(attribute,"green-primary") == 0)
5065 if (image == (Image *) NULL)
5067 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5068 image->chromaticity.green_primary.x,
5069 image->chromaticity.green_primary.y);
5071 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5074 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5081 if (LocaleCompare(attribute,"height") == 0)
5083 if (image != (Image *) NULL)
5084 s=newSViv((ssize_t) image->rows);
5085 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5088 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5095 if (LocaleCompare(attribute,"icc") == 0)
5097 if (image != (Image *) NULL)
5102 profile=GetImageProfile(image,"icc");
5103 if (profile != (StringInfo *) NULL)
5104 s=newSVpv((const char *) GetStringInfoDatum(profile),
5105 GetStringInfoLength(profile));
5107 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5110 if (LocaleCompare(attribute,"icm") == 0)
5112 if (image != (Image *) NULL)
5117 profile=GetImageProfile(image,"icm");
5118 if (profile != (const StringInfo *) NULL)
5119 s=newSVpv((const char *) GetStringInfoDatum(profile),
5120 GetStringInfoLength(profile));
5122 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5125 if (LocaleCompare(attribute,"id") == 0)
5127 if (image != (Image *) NULL)
5138 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
5140 status=SetImageRegistry(ImageRegistryType,key,image,
5145 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5148 if (LocaleNCompare(attribute,"index",5) == 0)
5151 name[MaxTextExtent];
5160 register const Quantum
5166 if (image == (Image *) NULL)
5168 if (image->storage_class != PseudoClass)
5172 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5174 image_view=AcquireVirtualCacheView(image,exception);
5175 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5176 if (p != (const Quantum *) NULL)
5178 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5179 GetPixelIndex(image,p));
5181 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5183 image_view=DestroyCacheView(image_view);
5186 if (LocaleCompare(attribute,"iptc") == 0)
5188 if (image != (Image *) NULL)
5193 profile=GetImageProfile(image,"iptc");
5194 if (profile != (const StringInfo *) NULL)
5195 s=newSVpv((const char *) GetStringInfoDatum(profile),
5196 GetStringInfoLength(profile));
5198 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5201 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5203 if (image != (Image *) NULL)
5204 s=newSViv((ssize_t) image->iterations);
5205 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5208 if (LocaleCompare(attribute,"interlace") == 0)
5210 j=info ? info->image_info->interlace : image ? image->interlace :
5213 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5216 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5219 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5226 if (LocaleCompare(attribute,"label") == 0)
5231 if (image == (Image *) NULL)
5233 value=GetImageProperty(image,"Label",exception);
5234 if (value != (const char *) NULL)
5236 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5239 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5241 if (image != (Image *) NULL)
5242 s=newSViv((ssize_t) image->iterations);
5243 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5246 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5253 if (LocaleCompare(attribute,"magick") == 0)
5255 if (info && *info->image_info->magick)
5256 s=newSVpv(info->image_info->magick,0);
5257 if (image != (Image *) NULL)
5258 s=newSVpv(image->magick,0);
5259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5262 if (LocaleCompare(attribute,"map") == 0)
5264 s=newSViv(GetMagickResource(MapResource));
5265 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5268 if (LocaleCompare(attribute,"maximum-error") == 0)
5270 if (image != (Image *) NULL)
5271 s=newSVnv(image->error.normalized_maximum_error);
5272 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5275 if (LocaleCompare(attribute,"memory") == 0)
5277 s=newSViv(GetMagickResource(MemoryResource));
5278 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5281 if (LocaleCompare(attribute,"mean-error") == 0)
5283 if (image != (Image *) NULL)
5284 s=newSVnv(image->error.normalized_mean_error);
5285 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5288 if (LocaleCompare(attribute,"mime") == 0)
5290 if (info && *info->image_info->magick)
5291 s=newSVpv(MagickToMime(info->image_info->magick),0);
5292 if (image != (Image *) NULL)
5293 s=newSVpv(MagickToMime(image->magick),0);
5294 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5297 if (LocaleCompare(attribute,"mattecolor") == 0)
5299 if (image == (Image *) NULL)
5301 (void) FormatLocaleString(color,MaxTextExtent,
5302 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
5303 image->matte_color.green,image->matte_color.blue,
5304 image->matte_color.alpha);
5306 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5309 if (LocaleCompare(attribute,"matte") == 0)
5311 if (image != (Image *) NULL)
5312 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5314 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5317 if (LocaleCompare(attribute,"mime") == 0)
5323 if (info && *info->image_info->magick)
5324 magick=info->image_info->magick;
5325 if (image != (Image *) NULL)
5326 magick=image->magick;
5332 mime=MagickToMime(magick);
5334 mime=(char *) RelinquishMagickMemory(mime);
5336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5339 if (LocaleCompare(attribute,"monochrome") == 0)
5341 if (image == (Image *) NULL)
5343 j=info ? info->image_info->monochrome :
5344 IsImageMonochrome(image,exception);
5346 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5349 if (LocaleCompare(attribute,"montage") == 0)
5351 if (image && image->montage)
5352 s=newSVpv(image->montage,0);
5353 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5356 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5363 if (LocaleCompare(attribute,"orientation") == 0)
5365 j=info ? info->image_info->orientation : image ?
5366 image->orientation : UndefinedOrientation;
5368 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5371 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5374 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5381 if (LocaleCompare(attribute,"page") == 0)
5383 if (info && info->image_info->page)
5384 s=newSVpv(info->image_info->page,0);
5385 if (image != (Image *) NULL)
5388 geometry[MaxTextExtent];
5390 (void) FormatLocaleString(geometry,MaxTextExtent,
5391 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5392 (double) image->page.height,(double) image->page.x,(double)
5394 s=newSVpv(geometry,0);
5396 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5399 if (LocaleCompare(attribute,"page.x") == 0)
5401 if (image != (Image *) NULL)
5402 s=newSViv((ssize_t) image->page.x);
5403 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5406 if (LocaleCompare(attribute,"page.y") == 0)
5408 if (image != (Image *) NULL)
5409 s=newSViv((ssize_t) image->page.y);
5410 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5413 if (LocaleNCompare(attribute,"pixel",5) == 0)
5416 tuple[MaxTextExtent];
5425 register const Quantum
5428 if (image == (Image *) NULL)
5432 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5434 p=GetVirtualPixels(image,x,y,1,1,exception);
5435 if (image->colorspace != CMYKColorspace)
5436 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5437 QuantumFormat "," QuantumFormat "," QuantumFormat,
5438 GetPixelRed(image,p),GetPixelGreen(image,p),
5439 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5441 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5442 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5443 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5444 GetPixelBlue(image,p),GetPixelBlack(image,p),
5445 GetPixelAlpha(image,p));
5447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5450 if (LocaleCompare(attribute,"pointsize") == 0)
5453 s=newSViv((ssize_t) info->image_info->pointsize);
5454 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5457 if (LocaleCompare(attribute,"preview") == 0)
5459 s=newSViv(info->image_info->preview_type);
5460 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5461 info->image_info->preview_type));
5463 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5473 if (LocaleCompare(attribute,"quality") == 0)
5476 s=newSViv((ssize_t) info->image_info->quality);
5477 if (image != (Image *) NULL)
5478 s=newSViv((ssize_t) image->quality);
5479 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5482 if (LocaleCompare(attribute,"quantum") == 0)
5485 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5486 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5489 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5496 if (LocaleCompare(attribute,"rendering-intent") == 0)
5498 s=newSViv(image->rendering_intent);
5499 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5500 image->rendering_intent));
5502 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5505 if (LocaleCompare(attribute,"red-primary") == 0)
5507 if (image == (Image *) NULL)
5509 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5510 image->chromaticity.red_primary.x,
5511 image->chromaticity.red_primary.y);
5513 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5516 if (LocaleCompare(attribute,"rows") == 0)
5518 if (image != (Image *) NULL)
5519 s=newSViv((ssize_t) image->rows);
5520 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5523 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5530 if (LocaleCompare(attribute,"sampling-factor") == 0)
5532 if (info && info->image_info->sampling_factor)
5533 s=newSVpv(info->image_info->sampling_factor,0);
5534 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5537 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5539 if (info && info->image_info->server_name)
5540 s=newSVpv(info->image_info->server_name,0);
5541 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5544 if (LocaleCompare(attribute,"size") == 0)
5546 if (info && info->image_info->size)
5547 s=newSVpv(info->image_info->size,0);
5548 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5551 if (LocaleCompare(attribute,"scene") == 0)
5553 if (image != (Image *) NULL)
5554 s=newSViv((ssize_t) image->scene);
5555 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5558 if (LocaleCompare(attribute,"scenes") == 0)
5560 if (image != (Image *) NULL)
5561 s=newSViv((ssize_t) info->image_info->number_scenes);
5562 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5565 if (LocaleCompare(attribute,"signature") == 0)
5570 if (image == (Image *) NULL)
5572 (void) SignatureImage(image,exception);
5573 value=GetImageProperty(image,"Signature",exception);
5574 if (value != (const char *) NULL)
5576 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5579 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5586 if (LocaleCompare(attribute,"taint") == 0)
5588 if (image != (Image *) NULL)
5589 s=newSViv((ssize_t) IsTaintImage(image));
5590 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5593 if (LocaleCompare(attribute,"texture") == 0)
5595 if (info && info->image_info->texture)
5596 s=newSVpv(info->image_info->texture,0);
5597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5600 if (LocaleCompare(attribute,"total-ink-density") == 0)
5602 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5603 if (image != (Image *) NULL)
5604 s=newSVnv(GetImageTotalInkDensity(image,exception));
5605 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5608 if (LocaleCompare(attribute,"transparent-color") == 0)
5610 if (image == (Image *) NULL)
5612 (void) FormatLocaleString(color,MaxTextExtent,
5613 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5614 image->transparent_color.green,image->transparent_color.blue,
5615 image->transparent_color.alpha);
5617 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5620 if (LocaleCompare(attribute,"type") == 0)
5622 if (image == (Image *) NULL)
5624 j=(ssize_t) GetImageType(image,exception);
5626 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5628 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5631 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5638 if (LocaleCompare(attribute,"units") == 0)
5640 j=info ? info->image_info->units : image ? image->units :
5641 UndefinedResolution;
5642 if (info && (info->image_info->units == UndefinedResolution))
5645 if (j == UndefinedResolution)
5646 s=newSVpv("undefined units",0);
5648 if (j == PixelsPerInchResolution)
5649 s=newSVpv("pixels / inch",0);
5651 s=newSVpv("pixels / centimeter",0);
5652 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5655 if (LocaleCompare(attribute,"user-time") == 0)
5657 if (image != (Image *) NULL)
5658 s=newSVnv(GetUserTime(&image->timer));
5659 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5662 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5669 if (LocaleCompare(attribute,"verbose") == 0)
5672 s=newSViv((ssize_t) info->image_info->verbose);
5673 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5676 if (LocaleCompare(attribute,"version") == 0)
5678 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5679 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5682 if (LocaleCompare(attribute,"view") == 0)
5684 if (info && info->image_info->view)
5685 s=newSVpv(info->image_info->view,0);
5686 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5689 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5691 if (image == (Image *) NULL)
5693 j=(ssize_t) GetImageVirtualPixelMethod(image);
5695 (void) sv_setpv(s,CommandOptionToMnemonic(
5696 MagickVirtualPixelOptions,j));
5698 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5708 if (LocaleCompare(attribute,"white-point") == 0)
5710 if (image == (Image *) NULL)
5712 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5713 image->chromaticity.white_point.x,
5714 image->chromaticity.white_point.y);
5716 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5719 if (LocaleCompare(attribute,"width") == 0)
5721 if (image != (Image *) NULL)
5722 s=newSViv((ssize_t) image->columns);
5723 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5726 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5733 if (LocaleCompare(attribute,"x-resolution") == 0)
5735 if (image != (Image *) NULL)
5736 s=newSVnv(image->resolution.x);
5737 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5740 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5747 if (LocaleCompare(attribute,"y-resolution") == 0)
5749 if (image != (Image *) NULL)
5750 s=newSVnv(image->resolution.y);
5751 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5754 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5761 if (image == (Image *) NULL)
5762 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5766 value=GetImageProperty(image,attribute,exception);
5767 if (value != (const char *) NULL)
5770 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5773 if (*attribute != '%')
5774 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5781 meta=InterpretImageProperties(info ? info->image_info :
5782 (ImageInfo *) NULL,image,attribute,exception);
5784 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5785 meta=(char *) RelinquishMagickMemory(meta);
5789 exception=DestroyExceptionInfo(exception);
5790 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5794 ###############################################################################
5798 # G e t A u t h e n t i c P i x e l s #
5802 ###############################################################################
5806 GetAuthenticPixels(ref,...)
5807 Image::Magick ref = NO_INIT
5809 getauthenticpixels = 1
5839 PERL_UNUSED_VAR(ref);
5840 PERL_UNUSED_VAR(ix);
5841 exception=AcquireExceptionInfo();
5842 perl_exception=newSVpv("",0);
5843 if (sv_isobject(ST(0)) == 0)
5845 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5849 reference=SvRV(ST(0));
5851 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5852 if (image == (Image *) NULL)
5854 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5861 region.width=image->columns;
5864 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5865 for (i=2; i < items; i+=2)
5867 attribute=(char *) SvPV(ST(i-1),na);
5873 if (LocaleCompare(attribute,"geometry") == 0)
5875 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5878 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5885 if (LocaleCompare(attribute,"height") == 0)
5887 region.height=SvIV(ST(i));
5890 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5897 if (LocaleCompare(attribute,"x") == 0)
5899 region.x=SvIV(ST(i));
5902 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5909 if (LocaleCompare(attribute,"y") == 0)
5911 region.y=SvIV(ST(i));
5914 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5921 if (LocaleCompare(attribute,"width") == 0)
5923 region.width=SvIV(ST(i));
5926 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5932 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5933 region.height,exception);
5934 if (blob != (void *) NULL)
5938 InheritPerlException(exception,perl_exception);
5939 exception=DestroyExceptionInfo(exception);
5940 SvREFCNT_dec(perl_exception); /* throw away all errors */
5949 ###############################################################################
5953 # G e t V i r t u a l P i x e l s #
5957 ###############################################################################
5961 GetVirtualPixels(ref,...)
5962 Image::Magick ref = NO_INIT
5964 getvirtualpixels = 1
5965 AcquireImagePixels = 2
5966 acquireimagepixels = 3
5994 PERL_UNUSED_VAR(ref);
5995 PERL_UNUSED_VAR(ix);
5996 exception=AcquireExceptionInfo();
5997 perl_exception=newSVpv("",0);
5998 if (sv_isobject(ST(0)) == 0)
6000 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6004 reference=SvRV(ST(0));
6006 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6007 if (image == (Image *) NULL)
6009 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6016 region.width=image->columns;
6019 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6020 for (i=2; i < items; i+=2)
6022 attribute=(char *) SvPV(ST(i-1),na);
6028 if (LocaleCompare(attribute,"geometry") == 0)
6030 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6033 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6040 if (LocaleCompare(attribute,"height") == 0)
6042 region.height=SvIV(ST(i));
6045 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6052 if (LocaleCompare(attribute,"x") == 0)
6054 region.x=SvIV(ST(i));
6057 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6064 if (LocaleCompare(attribute,"y") == 0)
6066 region.y=SvIV(ST(i));
6069 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6076 if (LocaleCompare(attribute,"width") == 0)
6078 region.width=SvIV(ST(i));
6081 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6087 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6088 region.height,exception);
6089 if (blob != (void *) NULL)
6093 InheritPerlException(exception,perl_exception);
6094 exception=DestroyExceptionInfo(exception);
6095 SvREFCNT_dec(perl_exception); /* throw away all errors */
6098 RETVAL = (void *) blob;
6104 ###############################################################################
6108 # G e t A u t h e n t i c M e t a c o n t e n t #
6112 ###############################################################################
6116 GetAuthenticMetacontent(ref,...)
6117 Image::Magick ref = NO_INIT
6119 getauthenticmetacontent = 1
6140 PERL_UNUSED_VAR(ref);
6141 PERL_UNUSED_VAR(ix);
6142 exception=AcquireExceptionInfo();
6143 perl_exception=newSVpv("",0);
6144 if (sv_isobject(ST(0)) == 0)
6146 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6150 reference=SvRV(ST(0));
6152 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6153 if (image == (Image *) NULL)
6155 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6160 blob=(void *) GetAuthenticMetacontent(image);
6161 if (blob != (void *) NULL)
6165 InheritPerlException(exception,perl_exception);
6166 exception=DestroyExceptionInfo(exception);
6167 SvREFCNT_dec(perl_exception); /* throw away all errors */
6176 ###############################################################################
6180 # G e t V i r t u a l M e t a c o n t e n t #
6184 ###############################################################################
6188 GetVirtualMetacontent(ref,...)
6189 Image::Magick ref = NO_INIT
6191 getvirtualmetacontent = 1
6210 PERL_UNUSED_VAR(ref);
6211 PERL_UNUSED_VAR(ix);
6212 exception=AcquireExceptionInfo();
6213 perl_exception=newSVpv("",0);
6214 if (sv_isobject(ST(0)) == 0)
6216 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6220 reference=SvRV(ST(0));
6222 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6223 if (image == (Image *) NULL)
6225 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6230 blob=(void *) GetVirtualMetacontent(image);
6231 if (blob != (void *) NULL)
6235 InheritPerlException(exception,perl_exception);
6236 exception=DestroyExceptionInfo(exception);
6237 SvREFCNT_dec(perl_exception); /* throw away all errors */
6246 ###############################################################################
6250 # H i s t o g r a m #
6254 ###############################################################################
6259 Image::Magick ref=NO_INIT
6270 message[MaxTextExtent];
6297 PERL_UNUSED_VAR(ref);
6298 PERL_UNUSED_VAR(ix);
6299 exception=AcquireExceptionInfo();
6300 perl_exception=newSVpv("",0);
6302 if (sv_isobject(ST(0)) == 0)
6304 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6308 reference=SvRV(ST(0));
6311 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6312 if (image == (Image *) NULL)
6314 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6318 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6320 for ( ; image; image=image->next)
6322 histogram=GetImageHistogram(image,&number_colors,exception);
6323 if (histogram == (PixelInfo *) NULL)
6325 count+=(ssize_t) number_colors;
6327 for (i=0; i < (ssize_t) number_colors; i++)
6329 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6331 PUSHs(sv_2mortal(newSVpv(message,0)));
6332 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6333 histogram[i].green);
6334 PUSHs(sv_2mortal(newSVpv(message,0)));
6335 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6337 PUSHs(sv_2mortal(newSVpv(message,0)));
6338 if (image->colorspace == CMYKColorspace)
6340 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6341 histogram[i].black);
6342 PUSHs(sv_2mortal(newSVpv(message,0)));
6344 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6345 histogram[i].alpha);
6346 PUSHs(sv_2mortal(newSVpv(message,0)));
6347 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6348 histogram[i].count);
6349 PUSHs(sv_2mortal(newSVpv(message,0)));
6351 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6355 InheritPerlException(exception,perl_exception);
6356 exception=DestroyExceptionInfo(exception);
6357 SvREFCNT_dec(perl_exception);
6361 ###############################################################################
6369 ###############################################################################
6374 Image::Magick ref=NO_INIT
6398 register const Quantum
6412 *reference; /* reference is the SV* of ref=SvIV(reference) */
6414 PERL_UNUSED_VAR(ref);
6415 PERL_UNUSED_VAR(ix);
6416 exception=AcquireExceptionInfo();
6417 perl_exception=newSVpv("",0);
6418 reference=SvRV(ST(0));
6419 av=(AV *) reference;
6420 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6422 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6423 if (image == (Image *) NULL)
6425 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6429 normalize=MagickTrue;
6432 region.width=image->columns;
6435 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6436 for (i=2; i < items; i+=2)
6438 attribute=(char *) SvPV(ST(i-1),na);
6444 if (LocaleCompare(attribute,"channel") == 0)
6449 option=ParseChannelOption(SvPV(ST(i),na));
6452 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6456 SetPixelChannelMask(image,(ChannelType) option);
6459 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6466 if (LocaleCompare(attribute,"geometry") == 0)
6468 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6471 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6478 if (LocaleCompare(attribute,"normalize") == 0)
6480 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6484 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6488 normalize=option != 0 ? MagickTrue : MagickFalse;
6491 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6498 if (LocaleCompare(attribute,"x") == 0)
6500 region.x=SvIV(ST(i));
6503 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6510 if (LocaleCompare(attribute,"y") == 0)
6512 region.y=SvIV(ST(i));
6515 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6521 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6527 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6528 if (p == (const Quantum *) NULL)
6536 if (normalize != MagickFalse)
6537 scale=1.0/QuantumRange;
6538 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6539 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6540 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6541 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6542 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6543 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6544 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6545 (image->colorspace == CMYKColorspace))
6546 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6547 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6548 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6552 InheritPerlException(exception,perl_exception);
6553 exception=DestroyExceptionInfo(exception);
6554 SvREFCNT_dec(perl_exception);
6558 ###############################################################################
6562 # G e t P i x e l s #
6566 ###############################################################################
6571 Image::Magick ref=NO_INIT
6610 *reference; /* reference is the SV* of ref=SvIV(reference) */
6612 PERL_UNUSED_VAR(ref);
6613 PERL_UNUSED_VAR(ix);
6614 exception=AcquireExceptionInfo();
6615 perl_exception=newSVpv("",0);
6616 reference=SvRV(ST(0));
6617 av=(AV *) reference;
6618 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6620 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6621 if (image == (Image *) NULL)
6623 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6628 if (image->alpha_trait == BlendPixelTrait)
6630 if (image->colorspace == CMYKColorspace)
6633 if (image->alpha_trait == BlendPixelTrait)
6636 normalize=MagickFalse;
6639 region.width=image->columns;
6642 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6643 for (i=2; i < items; i+=2)
6645 attribute=(char *) SvPV(ST(i-1),na);
6651 if (LocaleCompare(attribute,"geometry") == 0)
6653 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6656 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6663 if (LocaleCompare(attribute,"height") == 0)
6665 region.height=SvIV(ST(i));
6668 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6675 if (LocaleCompare(attribute,"map") == 0)
6680 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6687 if (LocaleCompare(attribute,"normalize") == 0)
6689 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6693 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6697 normalize=option != 0 ? MagickTrue : MagickFalse;
6700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6707 if (LocaleCompare(attribute,"width") == 0)
6709 region.width=SvIV(ST(i));
6712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6719 if (LocaleCompare(attribute,"x") == 0)
6721 region.x=SvIV(ST(i));
6724 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6731 if (LocaleCompare(attribute,"y") == 0)
6733 region.y=SvIV(ST(i));
6736 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6742 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6748 if (normalize != MagickFalse)
6753 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6754 region.height*sizeof(*pixels));
6755 if (pixels == (float *) NULL)
6757 ThrowPerlException(exception,ResourceLimitError,
6758 "MemoryAllocationFailed",PackageName);
6761 status=ExportImagePixels(image,region.x,region.y,region.width,
6762 region.height,map,FloatPixel,pixels,exception);
6763 if (status == MagickFalse)
6767 EXTEND(sp,strlen(map)*region.width*region.height);
6768 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6769 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6771 pixels=(float *) RelinquishMagickMemory(pixels);
6778 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6779 region.height*sizeof(*pixels));
6780 if (pixels == (Quantum *) NULL)
6782 ThrowPerlException(exception,ResourceLimitError,
6783 "MemoryAllocationFailed",PackageName);
6786 status=ExportImagePixels(image,region.x,region.y,region.width,
6787 region.height,map,QuantumPixel,pixels,exception);
6788 if (status == MagickFalse)
6792 EXTEND(sp,strlen(map)*region.width*region.height);
6793 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6794 PUSHs(sv_2mortal(newSViv(pixels[i])));
6796 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6800 InheritPerlException(exception,perl_exception);
6801 exception=DestroyExceptionInfo(exception);
6802 SvREFCNT_dec(perl_exception);
6806 ###############################################################################
6810 # I m a g e T o B l o b #
6814 ###############################################################################
6818 ImageToBlob(ref,...)
6819 Image::Magick ref=NO_INIT
6828 filename[MaxTextExtent];
6857 PERL_UNUSED_VAR(ref);
6858 PERL_UNUSED_VAR(ix);
6859 exception=AcquireExceptionInfo();
6860 perl_exception=newSVpv("",0);
6861 package_info=(struct PackageInfo *) NULL;
6862 if (sv_isobject(ST(0)) == 0)
6864 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6868 reference=SvRV(ST(0));
6869 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6870 if (image == (Image *) NULL)
6872 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6876 package_info=ClonePackageInfo(info,exception);
6877 for (i=2; i < items; i+=2)
6878 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6879 (void) CopyMagickString(filename,package_info->image_info->filename,
6882 for (next=image; next; next=next->next)
6884 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6885 next->scene=scene++;
6887 SetImageInfo(package_info->image_info,(unsigned int)
6888 GetImageListLength(image),exception);
6889 EXTEND(sp,(ssize_t) GetImageListLength(image));
6890 for ( ; image; image=image->next)
6893 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6894 if (blob != (char *) NULL)
6896 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6897 blob=(unsigned char *) RelinquishMagickMemory(blob);
6899 if (package_info->image_info->adjoin)
6904 if (package_info != (struct PackageInfo *) NULL)
6905 DestroyPackageInfo(package_info);
6906 InheritPerlException(exception,perl_exception);
6907 exception=DestroyExceptionInfo(exception);
6908 SvREFCNT_dec(perl_exception); /* throw away all errors */
6912 ###############################################################################
6920 ###############################################################################
6925 Image::Magick ref=NO_INIT
6929 OptimizeImageLayers = 3
6931 optimizeimagelayers = 5
6973 PERL_UNUSED_VAR(ref);
6974 PERL_UNUSED_VAR(ix);
6975 exception=AcquireExceptionInfo();
6976 perl_exception=newSVpv("",0);
6978 if (sv_isobject(ST(0)) == 0)
6980 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6984 reference=SvRV(ST(0));
6985 hv=SvSTASH(reference);
6987 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6989 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6990 if (image == (Image *) NULL)
6992 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6996 compose=image->compose;
6997 method=OptimizeLayer;
6998 for (i=2; i < items; i+=2)
7000 attribute=(char *) SvPV(ST(i-1),na);
7006 if (LocaleCompare(attribute,"compose") == 0)
7008 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7009 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7012 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7016 compose=(CompositeOperator) sp;
7019 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7026 if (LocaleCompare(attribute,"method") == 0)
7028 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7032 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7036 method=(LayerMethod) option;
7039 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7045 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7051 layers=(Image *) NULL;
7054 case CompareAnyLayer:
7055 case CompareClearLayer:
7056 case CompareOverlayLayer:
7059 layers=CompareImagesLayers(image,method,exception);
7066 layers=MergeImageLayers(image,method,exception);
7071 layers=DisposeImages(image,exception);
7074 case OptimizeImageLayer:
7076 layers=OptimizeImageLayers(image,exception);
7079 case OptimizePlusLayer:
7081 layers=OptimizePlusImageLayers(image,exception);
7084 case OptimizeTransLayer:
7086 OptimizeImageTransparency(image,exception);
7089 case RemoveDupsLayer:
7091 RemoveDuplicateLayers(&image,exception);
7094 case RemoveZeroLayer:
7096 RemoveZeroDelayLayers(&image,exception);
7105 General Purpose, GIF Animation Optimizer.
7107 layers=CoalesceImages(image,exception);
7108 if (layers == (Image *) NULL)
7111 layers=OptimizeImageLayers(image,exception);
7112 if (layers == (Image *) NULL)
7114 image=DestroyImageList(image);
7116 layers=(Image *) NULL;
7117 OptimizeImageTransparency(image,exception);
7118 quantize_info=AcquireQuantizeInfo(info->image_info);
7119 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7120 quantize_info=DestroyQuantizeInfo(quantize_info);
7123 case CompositeLayer:
7132 Split image sequence at the first 'NULL:' image.
7135 while (source != (Image *) NULL)
7137 source=GetNextImageInList(source);
7138 if ((source != (Image *) NULL) &&
7139 (LocaleCompare(source->magick,"NULL") == 0))
7142 if (source != (Image *) NULL)
7144 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7145 (GetNextImageInList(source) == (Image *) NULL))
7146 source=(Image *) NULL;
7150 Separate the two lists, junk the null: image.
7152 source=SplitImageList(source->previous);
7153 DeleteImageFromList(&source);
7156 if (source == (Image *) NULL)
7158 (void) ThrowMagickException(exception,GetMagickModule(),
7159 OptionError,"MissingNullSeparator","layers Composite");
7163 Adjust offset with gravity and virtual canvas.
7165 SetGeometry(image,&geometry);
7166 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7167 geometry.width=source->page.width != 0 ? source->page.width :
7169 geometry.height=source->page.height != 0 ? source->page.height :
7171 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7172 image->columns,image->page.height != 0 ? image->page.height :
7173 image->rows,image->gravity,&geometry);
7174 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7175 source=DestroyImageList(source);
7179 if (layers != (Image *) NULL)
7182 image=CloneImage(image,0,0,MagickTrue,exception);
7183 if (image == (Image *) NULL)
7185 for ( ; image; image=image->next)
7187 AddImageToRegistry(sv,image);
7189 av_push(av,sv_bless(rv,hv));
7192 exception=DestroyExceptionInfo(exception);
7194 SvREFCNT_dec(perl_exception);
7198 InheritPerlException(exception,perl_exception);
7199 exception=DestroyExceptionInfo(exception);
7200 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7201 SvPOK_on(perl_exception);
7202 ST(0)=sv_2mortal(perl_exception);
7207 ###############################################################################
7211 # M a g i c k T o M i m e #
7215 ###############################################################################
7219 MagickToMime(ref,name)
7220 Image::Magick ref=NO_INIT
7229 PERL_UNUSED_VAR(ref);
7230 PERL_UNUSED_VAR(ix);
7231 mime=MagickToMime(name);
7232 RETVAL=newSVpv(mime,0);
7233 mime=(char *) RelinquishMagickMemory(mime);
7239 ###############################################################################
7247 ###############################################################################
7252 Image::Magick ref=NO_INIT
7289 MedianConvolveImage = 36
7295 ReduceNoiseImage = 42
7321 ColorFloodfillImage= 68
7327 CycleColormapImage = 74
7337 MatteFloodfillImage= 84
7345 NumberColorsImage = 92
7355 SignatureImage = 102
7365 TransparentImage = 112
7367 ThresholdImage = 114
7381 DeconstructImage = 130
7383 GaussianBlurImage = 132
7389 UnsharpMaskImage = 138
7391 MotionBlurImage = 140
7393 OrderedDitherImage = 142
7400 AffineTransform = 149
7401 AffineTransformImage = 150
7403 DifferenceImage = 152
7404 AdaptiveThreshold = 153
7405 AdaptiveThresholdImage = 154
7410 BlackThreshold = 159
7411 BlackThresholdImage= 160
7412 WhiteThreshold = 161
7413 WhiteThresholdImage= 162
7415 RadialBlurImage = 164
7417 ThumbnailImage = 166
7427 PosterizeImage = 176
7433 SepiaToneImage = 182
7434 SigmoidalContrast = 183
7435 SigmoidalContrastImage = 184
7440 ContrastStretch = 189
7441 ContrastStretchImage = 190
7446 AdaptiveSharpen = 195
7447 AdaptiveSharpenImage = 196
7449 TransposeImage = 198
7451 TransverseImage = 200
7453 AutoOrientImage = 202
7455 AdaptiveBlurImage = 204
7459 UniqueColorsImage = 208
7460 AdaptiveResize = 209
7461 AdaptiveResizeImage= 210
7465 LinearStretchImage = 214
7467 ColorMatrixImage = 216
7472 FloodfillPaint = 221
7473 FloodfillPaintImage= 222
7479 LiquidRescaleImage = 228
7489 SparseColorImage = 238
7493 SelectiveBlurImage = 242
7497 BlueShiftImage = 246
7498 ForwardFourierTransform = 247
7499 ForwardFourierTransformImage = 248
7500 InverseFourierTransform = 249
7501 InverseFourierTransformImage = 250
7502 ColorDecisionList = 251
7503 ColorDecisionListImage = 252
7505 AutoGammaImage = 254
7507 AutoLevelImage = 256
7509 LevelImageColors = 258
7512 BrightnessContrast = 261
7513 BrightnessContrastImage = 262
7515 MorphologyImage = 264
7521 StatisticImage = 270
7523 PerceptibleImage = 272
7527 GrayscaleImage = 276
7536 attribute_flag[MaxArguments],
7537 message[MaxTextExtent];
7598 argument_list[MaxArguments];
7600 PERL_UNUSED_VAR(ref);
7601 PERL_UNUSED_VAR(ix);
7602 exception=AcquireExceptionInfo();
7603 perl_exception=newSVpv("",0);
7604 reference_vector=NULL;
7608 if (sv_isobject(ST(0)) == 0)
7610 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7614 reference=SvRV(ST(0));
7615 region_info.width=0;
7616 region_info.height=0;
7619 region_image=(Image *) NULL;
7620 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7621 if (ix && (ix != 666))
7624 Called as Method(...)
7627 rp=(&Methods[ix-1]);
7633 Called as Mogrify("Method",...)
7635 attribute=(char *) SvPV(ST(1),na);
7638 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7639 attribute=(char *) SvPV(ST(2),na);
7642 for (rp=Methods; ; rp++)
7644 if (rp >= EndOf(Methods))
7646 ThrowPerlException(exception,OptionError,
7647 "UnrecognizedPerlMagickMethod",attribute);
7650 if (strEQcase(attribute,rp->name))
7656 if (image == (Image *) NULL)
7658 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7661 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7662 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7663 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7680 pp=(Arguments *) NULL;
7688 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7690 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7692 if (strEQcase(attribute,qq->method) > ssize_test)
7695 ssize_test=strEQcase(attribute,qq->method);
7698 if (pp == (Arguments *) NULL)
7700 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7702 goto continue_outer_loop;
7704 al=(&argument_list[pp-rp->arguments]);
7707 case ArrayReference:
7709 if (SvTYPE(sv) != SVt_RV)
7711 (void) FormatLocaleString(message,MaxTextExtent,
7712 "invalid %.60s value",pp->method);
7713 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7714 goto continue_outer_loop;
7716 al->array_reference=SvRV(sv);
7721 al->real_reference=SvNV(sv);
7726 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7729 case ImageReference:
7731 if (!sv_isobject(sv) ||
7732 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7733 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7735 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7741 case IntegerReference:
7743 al->integer_reference=SvIV(sv);
7746 case StringReference:
7748 al->string_reference=(char *) SvPV(sv,al->length);
7749 if (sv_isobject(sv))
7750 al->image_reference=SetupList(aTHX_ SvRV(sv),
7751 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7757 Is a string; look up name.
7759 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7761 al->string_reference=(char *) SvPV(sv,al->length);
7762 al->integer_reference=(-1);
7765 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7766 MagickFalse,SvPV(sv,na));
7767 if (pp->type == MagickChannelOptions)
7768 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7769 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7771 (void) FormatLocaleString(message,MaxTextExtent,
7772 "invalid %.60s value",pp->method);
7773 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7774 goto continue_outer_loop;
7779 attribute_flag[pp-rp->arguments]++;
7780 continue_outer_loop: ;
7782 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7783 pv=reference_vector;
7784 SetGeometryInfo(&geometry_info);
7785 channel=DefaultChannels;
7786 for (next=image; next; next=next->next)
7789 SetGeometry(image,&geometry);
7790 if ((region_info.width*region_info.height) != 0)
7793 image=CropImage(image,®ion_info,exception);
7799 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7800 ThrowPerlException(exception,OptionError,
7801 "UnrecognizedPerlMagickMethod",message);
7804 case 1: /* Comment */
7806 if (attribute_flag[0] == 0)
7807 argument_list[0].string_reference=(char *) NULL;
7808 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7809 info ? info->image_info : (ImageInfo *) NULL,image,
7810 argument_list[0].string_reference,exception),exception);
7815 if (attribute_flag[0] == 0)
7816 argument_list[0].string_reference=(char *) NULL;
7817 (void) SetImageProperty(image,"label",InterpretImageProperties(
7818 info ? info->image_info : (ImageInfo *) NULL,image,
7819 argument_list[0].string_reference,exception),exception);
7822 case 3: /* AddNoise */
7827 if (attribute_flag[0] == 0)
7828 argument_list[0].integer_reference=UniformNoise;
7830 if (attribute_flag[1] != 0)
7831 attenuate=argument_list[1].real_reference;
7832 if (attribute_flag[2] != 0)
7833 channel=(ChannelType) argument_list[2].integer_reference;
7834 channel_mask=SetImageChannelMask(image,channel);
7835 image=AddNoiseImage(image,(NoiseType)
7836 argument_list[0].integer_reference,attenuate,exception);
7837 if (image != (Image *) NULL)
7838 (void) SetImageChannelMask(image,channel_mask);
7841 case 4: /* Colorize */
7846 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7847 0,0,&target,exception);
7848 if (attribute_flag[0] != 0)
7849 (void) QueryColorCompliance(argument_list[0].string_reference,
7850 AllCompliance,&target,exception);
7851 if (attribute_flag[1] == 0)
7852 argument_list[1].string_reference="100%";
7853 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7857 case 5: /* Border */
7864 if (attribute_flag[0] != 0)
7865 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7866 &geometry,exception);
7867 if (attribute_flag[1] != 0)
7868 geometry.width=argument_list[1].integer_reference;
7869 if (attribute_flag[2] != 0)
7870 geometry.height=argument_list[2].integer_reference;
7871 if (attribute_flag[3] != 0)
7872 QueryColorCompliance(argument_list[3].string_reference,
7873 AllCompliance,&image->border_color,exception);
7874 if (attribute_flag[4] != 0)
7875 QueryColorCompliance(argument_list[4].string_reference,
7876 AllCompliance,&image->border_color,exception);
7877 if (attribute_flag[5] != 0)
7878 QueryColorCompliance(argument_list[5].string_reference,
7879 AllCompliance,&image->border_color,exception);
7880 compose=image->compose;
7881 if (attribute_flag[6] != 0)
7882 compose=(CompositeOperator) argument_list[6].integer_reference;
7883 image=BorderImage(image,&geometry,compose,exception);
7888 if (attribute_flag[0] != 0)
7890 flags=ParseGeometry(argument_list[0].string_reference,
7892 if ((flags & SigmaValue) == 0)
7893 geometry_info.sigma=1.0;
7895 if (attribute_flag[1] != 0)
7896 geometry_info.rho=argument_list[1].real_reference;
7897 if (attribute_flag[2] != 0)
7898 geometry_info.sigma=argument_list[2].real_reference;
7899 if (attribute_flag[3] != 0)
7900 channel=(ChannelType) argument_list[3].integer_reference;
7901 channel_mask=SetImageChannelMask(image,channel);
7902 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7904 if (image != (Image *) NULL)
7905 (void) SetImageChannelMask(image,channel_mask);
7910 if (attribute_flag[0] != 0)
7911 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7912 &geometry,exception);
7913 if (attribute_flag[1] != 0)
7914 geometry.width=argument_list[1].integer_reference;
7915 if (attribute_flag[2] != 0)
7916 geometry.height=argument_list[2].integer_reference;
7917 if (attribute_flag[3] != 0)
7918 geometry.x=argument_list[3].integer_reference;
7919 if (attribute_flag[4] != 0)
7920 geometry.y=argument_list[4].integer_reference;
7921 image=ChopImage(image,&geometry,exception);
7926 if (attribute_flag[6] != 0)
7927 image->gravity=(GravityType) argument_list[6].integer_reference;
7928 if (attribute_flag[0] != 0)
7929 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7930 &geometry,exception);
7931 if (attribute_flag[1] != 0)
7932 geometry.width=argument_list[1].integer_reference;
7933 if (attribute_flag[2] != 0)
7934 geometry.height=argument_list[2].integer_reference;
7935 if (attribute_flag[3] != 0)
7936 geometry.x=argument_list[3].integer_reference;
7937 if (attribute_flag[4] != 0)
7938 geometry.y=argument_list[4].integer_reference;
7939 if (attribute_flag[5] != 0)
7940 image->fuzz=StringToDoubleInterval(
7941 argument_list[5].string_reference,(double) QuantumRange+1.0);
7942 image=CropImage(image,&geometry,exception);
7945 case 9: /* Despeckle */
7947 image=DespeckleImage(image,exception);
7952 if (attribute_flag[0] != 0)
7953 geometry_info.rho=argument_list[0].real_reference;
7954 image=EdgeImage(image,geometry_info.rho,exception);
7957 case 11: /* Emboss */
7959 if (attribute_flag[0] != 0)
7961 flags=ParseGeometry(argument_list[0].string_reference,
7963 if ((flags & SigmaValue) == 0)
7964 geometry_info.sigma=1.0;
7966 if (attribute_flag[1] != 0)
7967 geometry_info.rho=argument_list[1].real_reference;
7968 if (attribute_flag[2] != 0)
7969 geometry_info.sigma=argument_list[2].real_reference;
7970 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7974 case 12: /* Enhance */
7976 image=EnhanceImage(image,exception);
7981 image=FlipImage(image,exception);
7986 image=FlopImage(image,exception);
7989 case 15: /* Frame */
7997 if (attribute_flag[0] != 0)
7999 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8000 &geometry,exception);
8001 frame_info.width=geometry.width;
8002 frame_info.height=geometry.height;
8003 frame_info.outer_bevel=geometry.x;
8004 frame_info.inner_bevel=geometry.y;
8006 if (attribute_flag[1] != 0)
8007 frame_info.width=argument_list[1].integer_reference;
8008 if (attribute_flag[2] != 0)
8009 frame_info.height=argument_list[2].integer_reference;
8010 if (attribute_flag[3] != 0)
8011 frame_info.inner_bevel=argument_list[3].integer_reference;
8012 if (attribute_flag[4] != 0)
8013 frame_info.outer_bevel=argument_list[4].integer_reference;
8014 if (attribute_flag[5] != 0)
8015 QueryColorCompliance(argument_list[5].string_reference,
8016 AllCompliance,&fill_color,exception);
8017 if (attribute_flag[6] != 0)
8018 QueryColorCompliance(argument_list[6].string_reference,
8019 AllCompliance,&fill_color,exception);
8020 frame_info.x=(ssize_t) frame_info.width;
8021 frame_info.y=(ssize_t) frame_info.height;
8022 frame_info.width=image->columns+2*frame_info.x;
8023 frame_info.height=image->rows+2*frame_info.y;
8024 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8025 image->matte_color=fill_color;
8026 compose=image->compose;
8027 if (attribute_flag[7] != 0)
8028 compose=(CompositeOperator) argument_list[7].integer_reference;
8029 image=FrameImage(image,&frame_info,compose,exception);
8032 case 16: /* Implode */
8034 PixelInterpolateMethod
8037 if (attribute_flag[0] == 0)
8038 argument_list[0].real_reference=0.5;
8039 method=UndefinedInterpolatePixel;
8040 if (attribute_flag[1] != 0)
8041 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8042 image=ImplodeImage(image,argument_list[0].real_reference,
8046 case 17: /* Magnify */
8048 image=MagnifyImage(image,exception);
8051 case 18: /* MedianFilter */
8053 if (attribute_flag[0] != 0)
8055 flags=ParseGeometry(argument_list[0].string_reference,
8057 if ((flags & SigmaValue) == 0)
8058 geometry_info.sigma=geometry_info.rho;
8060 if (attribute_flag[1] != 0)
8061 geometry_info.rho=argument_list[1].real_reference;
8062 if (attribute_flag[2] != 0)
8063 geometry_info.sigma=argument_list[2].real_reference;
8064 if (attribute_flag[3] != 0)
8065 channel=(ChannelType) argument_list[3].integer_reference;
8066 channel_mask=SetImageChannelMask(image,channel);
8067 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8068 (size_t) geometry_info.sigma,exception);
8069 if (image != (Image *) NULL)
8070 (void) SetImageChannelMask(image,channel_mask);
8073 case 19: /* Minify */
8075 image=MinifyImage(image,exception);
8078 case 20: /* OilPaint */
8080 if (attribute_flag[0] == 0)
8081 argument_list[0].real_reference=0.0;
8082 if (attribute_flag[1] == 0)
8083 argument_list[1].real_reference=1.0;
8084 image=OilPaintImage(image,argument_list[0].real_reference,
8085 argument_list[1].real_reference,exception);
8088 case 21: /* ReduceNoise */
8090 if (attribute_flag[0] != 0)
8092 flags=ParseGeometry(argument_list[0].string_reference,
8094 if ((flags & SigmaValue) == 0)
8095 geometry_info.sigma=1.0;
8097 if (attribute_flag[1] != 0)
8098 geometry_info.rho=argument_list[1].real_reference;
8099 if (attribute_flag[2] != 0)
8100 geometry_info.sigma=argument_list[2].real_reference;
8101 if (attribute_flag[3] != 0)
8102 channel=(ChannelType) argument_list[3].integer_reference;
8103 channel_mask=SetImageChannelMask(image,channel);
8104 image=StatisticImage(image,NonpeakStatistic,(size_t)
8105 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8106 if (image != (Image *) NULL)
8107 (void) SetImageChannelMask(image,channel_mask);
8112 if (attribute_flag[0] != 0)
8113 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8114 &geometry,exception);
8115 if (attribute_flag[1] != 0)
8116 geometry.x=argument_list[1].integer_reference;
8117 if (attribute_flag[2] != 0)
8118 geometry.y=argument_list[2].integer_reference;
8119 image=RollImage(image,geometry.x,geometry.y,exception);
8122 case 23: /* Rotate */
8124 if (attribute_flag[0] == 0)
8125 argument_list[0].real_reference=90.0;
8126 if (attribute_flag[1] != 0)
8128 QueryColorCompliance(argument_list[1].string_reference,
8129 AllCompliance,&image->background_color,exception);
8130 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
8131 (image->alpha_trait != BlendPixelTrait))
8132 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8134 image=RotateImage(image,argument_list[0].real_reference,exception);
8137 case 24: /* Sample */
8139 if (attribute_flag[0] != 0)
8140 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8141 &geometry,exception);
8142 if (attribute_flag[1] != 0)
8143 geometry.width=argument_list[1].integer_reference;
8144 if (attribute_flag[2] != 0)
8145 geometry.height=argument_list[2].integer_reference;
8146 image=SampleImage(image,geometry.width,geometry.height,exception);
8149 case 25: /* Scale */
8151 if (attribute_flag[0] != 0)
8152 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8153 &geometry,exception);
8154 if (attribute_flag[1] != 0)
8155 geometry.width=argument_list[1].integer_reference;
8156 if (attribute_flag[2] != 0)
8157 geometry.height=argument_list[2].integer_reference;
8158 image=ScaleImage(image,geometry.width,geometry.height,exception);
8161 case 26: /* Shade */
8163 if (attribute_flag[0] != 0)
8165 flags=ParseGeometry(argument_list[0].string_reference,
8167 if ((flags & SigmaValue) == 0)
8168 geometry_info.sigma=0.0;
8170 if (attribute_flag[1] != 0)
8171 geometry_info.rho=argument_list[1].real_reference;
8172 if (attribute_flag[2] != 0)
8173 geometry_info.sigma=argument_list[2].real_reference;
8174 image=ShadeImage(image,
8175 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8176 geometry_info.rho,geometry_info.sigma,exception);
8179 case 27: /* Sharpen */
8181 if (attribute_flag[0] != 0)
8183 flags=ParseGeometry(argument_list[0].string_reference,
8185 if ((flags & SigmaValue) == 0)
8186 geometry_info.sigma=1.0;
8188 if (attribute_flag[1] != 0)
8189 geometry_info.rho=argument_list[1].real_reference;
8190 if (attribute_flag[2] != 0)
8191 geometry_info.sigma=argument_list[2].real_reference;
8192 if (attribute_flag[3] != 0)
8193 channel=(ChannelType) argument_list[3].integer_reference;
8194 channel_mask=SetImageChannelMask(image,channel);
8195 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8197 if (image != (Image *) NULL)
8198 (void) SetImageChannelMask(image,channel_mask);
8201 case 28: /* Shear */
8203 if (attribute_flag[0] != 0)
8205 flags=ParseGeometry(argument_list[0].string_reference,
8207 if ((flags & SigmaValue) == 0)
8208 geometry_info.sigma=geometry_info.rho;
8210 if (attribute_flag[1] != 0)
8211 geometry_info.rho=argument_list[1].real_reference;
8212 if (attribute_flag[2] != 0)
8213 geometry_info.sigma=argument_list[2].real_reference;
8214 if (attribute_flag[3] != 0)
8215 QueryColorCompliance(argument_list[3].string_reference,
8216 AllCompliance,&image->background_color,exception);
8217 if (attribute_flag[4] != 0)
8218 QueryColorCompliance(argument_list[4].string_reference,
8219 AllCompliance,&image->background_color,exception);
8220 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8224 case 29: /* Spread */
8226 PixelInterpolateMethod
8229 if (attribute_flag[0] == 0)
8230 argument_list[0].real_reference=1.0;
8231 method=UndefinedInterpolatePixel;
8232 if (attribute_flag[1] != 0)
8233 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8234 image=SpreadImage(image,argument_list[0].real_reference,method,
8238 case 30: /* Swirl */
8240 PixelInterpolateMethod
8243 if (attribute_flag[0] == 0)
8244 argument_list[0].real_reference=50.0;
8245 method=UndefinedInterpolatePixel;
8246 if (attribute_flag[1] != 0)
8247 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8248 image=SwirlImage(image,argument_list[0].real_reference,
8252 case 31: /* Resize */
8255 if (attribute_flag[0] != 0)
8256 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8257 &geometry,exception);
8258 if (attribute_flag[1] != 0)
8259 geometry.width=argument_list[1].integer_reference;
8260 if (attribute_flag[2] != 0)
8261 geometry.height=argument_list[2].integer_reference;
8262 if (attribute_flag[3] == 0)
8263 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8264 if (attribute_flag[4] != 0)
8265 SetImageArtifact(image,"filter:support",
8266 argument_list[4].string_reference);
8267 image=ResizeImage(image,geometry.width,geometry.height,
8268 (FilterTypes) argument_list[3].integer_reference,
8272 case 33: /* Annotate */
8277 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8279 if (attribute_flag[0] != 0)
8284 text=InterpretImageProperties(info ? info->image_info :
8285 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8287 (void) CloneString(&draw_info->text,text);
8288 text=DestroyString(text);
8290 if (attribute_flag[1] != 0)
8291 (void) CloneString(&draw_info->font,
8292 argument_list[1].string_reference);
8293 if (attribute_flag[2] != 0)
8294 draw_info->pointsize=argument_list[2].real_reference;
8295 if (attribute_flag[3] != 0)
8296 (void) CloneString(&draw_info->density,
8297 argument_list[3].string_reference);
8298 if (attribute_flag[4] != 0)
8299 (void) QueryColorCompliance(argument_list[4].string_reference,
8300 AllCompliance,&draw_info->undercolor,exception);
8301 if (attribute_flag[5] != 0)
8303 (void) QueryColorCompliance(argument_list[5].string_reference,
8304 AllCompliance,&draw_info->stroke,exception);
8305 if (argument_list[5].image_reference != (Image *) NULL)
8306 draw_info->stroke_pattern=CloneImage(
8307 argument_list[5].image_reference,0,0,MagickTrue,exception);
8309 if (attribute_flag[6] != 0)
8311 (void) QueryColorCompliance(argument_list[6].string_reference,
8312 AllCompliance,&draw_info->fill,exception);
8313 if (argument_list[6].image_reference != (Image *) NULL)
8314 draw_info->fill_pattern=CloneImage(
8315 argument_list[6].image_reference,0,0,MagickTrue,exception);
8317 if (attribute_flag[7] != 0)
8319 (void) CloneString(&draw_info->geometry,
8320 argument_list[7].string_reference);
8321 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8322 &geometry,exception);
8323 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8324 geometry_info.sigma=geometry_info.xi;
8326 if (attribute_flag[8] != 0)
8327 (void) QueryColorCompliance(argument_list[8].string_reference,
8328 AllCompliance,&draw_info->fill,exception);
8329 if (attribute_flag[11] != 0)
8330 draw_info->gravity=(GravityType)
8331 argument_list[11].integer_reference;
8332 if (attribute_flag[25] != 0)
8337 av=(AV *) argument_list[25].array_reference;
8338 if ((av_len(av) != 3) && (av_len(av) != 5))
8340 ThrowPerlException(exception,OptionError,
8341 "affine matrix must have 4 or 6 elements",PackageName);
8344 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8345 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8346 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8347 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8348 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8349 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8351 ThrowPerlException(exception,OptionError,
8352 "affine matrix is singular",PackageName);
8355 if (av_len(av) == 5)
8357 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8358 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8361 for (j=12; j < 17; j++)
8363 if (attribute_flag[j] == 0)
8365 value=argument_list[j].string_reference;
8366 angle=argument_list[j].real_reference;
8367 current=draw_info->affine;
8368 GetAffineMatrix(&affine);
8376 flags=ParseGeometry(value,&geometry_info);
8377 affine.tx=geometry_info.xi;
8378 affine.ty=geometry_info.psi;
8379 if ((flags & PsiValue) == 0)
8380 affine.ty=affine.tx;
8388 flags=ParseGeometry(value,&geometry_info);
8389 affine.sx=geometry_info.rho;
8390 affine.sy=geometry_info.sigma;
8391 if ((flags & SigmaValue) == 0)
8392 affine.sy=affine.sx;
8402 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8403 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8404 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8405 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8413 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8421 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8425 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8426 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8427 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8428 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8429 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8431 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8434 if (attribute_flag[9] == 0)
8435 argument_list[9].real_reference=0.0;
8436 if (attribute_flag[10] == 0)
8437 argument_list[10].real_reference=0.0;
8438 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8441 geometry[MaxTextExtent];
8443 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8444 (double) argument_list[9].real_reference+draw_info->affine.tx,
8445 (double) argument_list[10].real_reference+draw_info->affine.ty);
8446 (void) CloneString(&draw_info->geometry,geometry);
8448 if (attribute_flag[17] != 0)
8449 draw_info->stroke_width=argument_list[17].real_reference;
8450 if (attribute_flag[18] != 0)
8452 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8453 MagickTrue : MagickFalse;
8454 draw_info->stroke_antialias=draw_info->text_antialias;
8456 if (attribute_flag[19] != 0)
8457 (void) CloneString(&draw_info->family,
8458 argument_list[19].string_reference);
8459 if (attribute_flag[20] != 0)
8460 draw_info->style=(StyleType) argument_list[20].integer_reference;
8461 if (attribute_flag[21] != 0)
8462 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8463 if (attribute_flag[22] != 0)
8464 draw_info->weight=argument_list[22].integer_reference;
8465 if (attribute_flag[23] != 0)
8466 draw_info->align=(AlignType) argument_list[23].integer_reference;
8467 if (attribute_flag[24] != 0)
8468 (void) CloneString(&draw_info->encoding,
8469 argument_list[24].string_reference);
8470 if (attribute_flag[25] != 0)
8471 draw_info->fill_pattern=CloneImage(
8472 argument_list[25].image_reference,0,0,MagickTrue,exception);
8473 if (attribute_flag[26] != 0)
8474 draw_info->fill_pattern=CloneImage(
8475 argument_list[26].image_reference,0,0,MagickTrue,exception);
8476 if (attribute_flag[27] != 0)
8477 draw_info->stroke_pattern=CloneImage(
8478 argument_list[27].image_reference,0,0,MagickTrue,exception);
8479 if (attribute_flag[29] != 0)
8480 draw_info->kerning=argument_list[29].real_reference;
8481 if (attribute_flag[30] != 0)
8482 draw_info->interline_spacing=argument_list[30].real_reference;
8483 if (attribute_flag[31] != 0)
8484 draw_info->interword_spacing=argument_list[31].real_reference;
8485 if (attribute_flag[32] != 0)
8486 draw_info->direction=(DirectionType)
8487 argument_list[32].integer_reference;
8488 (void) AnnotateImage(image,draw_info,exception);
8489 draw_info=DestroyDrawInfo(draw_info);
8492 case 34: /* ColorFloodfill */
8503 draw_info=CloneDrawInfo(info ? info->image_info :
8504 (ImageInfo *) NULL,(DrawInfo *) NULL);
8505 if (attribute_flag[0] != 0)
8506 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8507 &geometry,exception);
8508 if (attribute_flag[1] != 0)
8509 geometry.x=argument_list[1].integer_reference;
8510 if (attribute_flag[2] != 0)
8511 geometry.y=argument_list[2].integer_reference;
8512 if (attribute_flag[3] != 0)
8513 (void) QueryColorCompliance(argument_list[3].string_reference,
8514 AllCompliance,&draw_info->fill,exception);
8515 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8516 geometry.x,geometry.y,&target,exception);
8518 if (attribute_flag[4] != 0)
8520 QueryColorCompliance(argument_list[4].string_reference,
8521 AllCompliance,&target,exception);
8524 if (attribute_flag[5] != 0)
8525 image->fuzz=StringToDoubleInterval(
8526 argument_list[5].string_reference,(double) QuantumRange+1.0);
8527 if (attribute_flag[6] != 0)
8528 invert=(MagickBooleanType) argument_list[6].integer_reference;
8529 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8530 geometry.y,invert,exception);
8531 draw_info=DestroyDrawInfo(draw_info);
8534 case 35: /* Composite */
8537 composite_geometry[MaxTextExtent];
8546 compose=OverCompositeOp;
8547 if (attribute_flag[0] != 0)
8548 composite_image=argument_list[0].image_reference;
8551 ThrowPerlException(exception,OptionError,
8552 "CompositeImageRequired",PackageName);
8556 Parameter Handling used for BOTH normal and tiled composition.
8558 if (attribute_flag[1] != 0) /* compose */
8559 compose=(CompositeOperator) argument_list[1].integer_reference;
8560 if (attribute_flag[6] != 0) /* opacity */
8562 if (compose != DissolveCompositeOp)
8563 (void) SetImageAlpha(composite_image,(Quantum)
8564 StringToDoubleInterval(argument_list[6].string_reference,
8565 (double) QuantumRange+1.0),exception);
8587 Handle dissolve composite operator (patch by
8590 (void) CloneString(&image->geometry,
8591 argument_list[6].string_reference);
8592 opacity=(Quantum) StringToDoubleInterval(
8593 argument_list[6].string_reference,(double) QuantumRange+
8595 if (composite_image->alpha_trait == BlendPixelTrait)
8596 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8597 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8598 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8600 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8601 composite_image->columns,1,exception);
8602 for (x=0; x < (ssize_t) composite_image->columns; x++)
8604 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8605 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8607 q+=GetPixelChannels(composite_image);
8609 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8610 if (sync == MagickFalse)
8613 composite_view=DestroyCacheView(composite_view);
8616 if (attribute_flag[9] != 0) /* "color=>" */
8617 QueryColorCompliance(argument_list[9].string_reference,
8618 AllCompliance,&composite_image->background_color,exception);
8619 if (attribute_flag[12] != 0) /* "interpolate=>" */
8620 image->interpolate=(PixelInterpolateMethod)
8621 argument_list[12].integer_reference;
8622 if (attribute_flag[13] != 0) /* "args=>" */
8623 (void) SetImageArtifact(composite_image,"compose:args",
8624 argument_list[13].string_reference);
8625 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8626 (void) SetImageArtifact(composite_image,"compose:args",
8627 argument_list[14].string_reference);
8628 clip_to_self=MagickTrue;
8629 if (attribute_flag[15] != 0)
8630 clip_to_self=(MagickBooleanType)
8631 argument_list[15].integer_reference;
8633 Tiling Composition (with orthogonal rotate).
8635 rotate_image=(Image *) NULL;
8636 if (attribute_flag[8] != 0) /* "rotate=>" */
8641 rotate_image=RotateImage(composite_image,
8642 argument_list[8].real_reference,exception);
8643 if (rotate_image == (Image *) NULL)
8646 if ((attribute_flag[7] != 0) &&
8647 (argument_list[7].integer_reference != 0)) /* tile */
8654 Tile the composite image.
8656 if (attribute_flag[8] != 0) /* "tile=>" */
8657 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8660 (void) SetImageArtifact(composite_image,
8661 "compose:outside-overlay","false");
8662 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8663 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8665 if (attribute_flag[8] != 0) /* rotate */
8666 (void) CompositeImage(image,rotate_image,compose,
8667 MagickTrue,x,y,exception);
8669 (void) CompositeImage(image,composite_image,compose,
8670 MagickTrue,x,y,exception);
8672 if (attribute_flag[8] != 0) /* rotate */
8673 rotate_image=DestroyImage(rotate_image);
8677 Parameter Handling used used ONLY for normal composition.
8679 if (attribute_flag[5] != 0) /* gravity */
8680 image->gravity=(GravityType) argument_list[5].integer_reference;
8681 if (attribute_flag[2] != 0) /* geometry offset */
8683 SetGeometry(image,&geometry);
8684 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8686 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8689 if (attribute_flag[3] != 0) /* x offset */
8690 geometry.x=argument_list[3].integer_reference;
8691 if (attribute_flag[4] != 0) /* y offset */
8692 geometry.y=argument_list[4].integer_reference;
8693 if (attribute_flag[10] != 0) /* mask */
8695 if ((image->compose == DisplaceCompositeOp) ||
8696 (image->compose == DistortCompositeOp))
8699 Merge Y displacement into X displacement image.
8701 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8703 (void) CompositeImage(composite_image,
8704 argument_list[10].image_reference,CopyGreenCompositeOp,
8705 MagickTrue,0,0,exception);
8713 Set a blending mask for the composition.
8715 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8716 MagickTrue,exception);
8717 (void) SetImageMask(composite_image,mask_image,exception);
8718 mask_image=DestroyImage(mask_image);
8721 if (attribute_flag[11] != 0) /* channel */
8722 channel=(ChannelType) argument_list[11].integer_reference;
8724 Composite two images (normal composition).
8726 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8727 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8728 (double) composite_image->rows,(double) geometry.x,(double)
8730 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8732 channel_mask=SetImageChannelMask(image,channel);
8733 if (attribute_flag[8] == 0) /* no rotate */
8734 CompositeImage(image,composite_image,compose,clip_to_self,
8735 geometry.x,geometry.y,exception);
8739 Position adjust rotated image then composite.
8741 geometry.x-=(ssize_t) (rotate_image->columns-
8742 composite_image->columns)/2;
8743 geometry.y-=(ssize_t) (rotate_image->rows-
8744 composite_image->rows)/2;
8745 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8746 geometry.y,exception);
8747 rotate_image=DestroyImage(rotate_image);
8749 if (attribute_flag[10] != 0) /* mask */
8751 if ((image->compose == DisplaceCompositeOp) ||
8752 (image->compose == DistortCompositeOp))
8753 composite_image=DestroyImage(composite_image);
8755 (void) SetImageMask(image,(Image *) NULL,exception);
8757 (void) SetImageChannelMask(image,channel_mask);
8760 case 36: /* Contrast */
8762 if (attribute_flag[0] == 0)
8763 argument_list[0].integer_reference=0;
8764 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8765 MagickTrue : MagickFalse,exception);
8768 case 37: /* CycleColormap */
8770 if (attribute_flag[0] == 0)
8771 argument_list[0].integer_reference=6;
8772 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8781 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8783 (void) CloneString(&draw_info->primitive,"point");
8784 if (attribute_flag[0] != 0)
8786 if (argument_list[0].integer_reference < 0)
8787 (void) CloneString(&draw_info->primitive,
8788 argument_list[0].string_reference);
8790 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8791 MagickPrimitiveOptions,argument_list[0].integer_reference));
8793 if (attribute_flag[1] != 0)
8795 if (LocaleCompare(draw_info->primitive,"path") == 0)
8797 (void) ConcatenateString(&draw_info->primitive," '");
8798 ConcatenateString(&draw_info->primitive,
8799 argument_list[1].string_reference);
8800 (void) ConcatenateString(&draw_info->primitive,"'");
8804 (void) ConcatenateString(&draw_info->primitive," ");
8805 ConcatenateString(&draw_info->primitive,
8806 argument_list[1].string_reference);
8809 if (attribute_flag[2] != 0)
8811 (void) ConcatenateString(&draw_info->primitive," ");
8812 (void) ConcatenateString(&draw_info->primitive,
8813 CommandOptionToMnemonic(MagickMethodOptions,
8814 argument_list[2].integer_reference));
8816 if (attribute_flag[3] != 0)
8818 (void) QueryColorCompliance(argument_list[3].string_reference,
8819 AllCompliance,&draw_info->stroke,exception);
8820 if (argument_list[3].image_reference != (Image *) NULL)
8821 draw_info->stroke_pattern=CloneImage(
8822 argument_list[3].image_reference,0,0,MagickTrue,exception);
8824 if (attribute_flag[4] != 0)
8826 (void) QueryColorCompliance(argument_list[4].string_reference,
8827 AllCompliance,&draw_info->fill,exception);
8828 if (argument_list[4].image_reference != (Image *) NULL)
8829 draw_info->fill_pattern=CloneImage(
8830 argument_list[4].image_reference,0,0,MagickTrue,exception);
8832 if (attribute_flag[5] != 0)
8833 draw_info->stroke_width=argument_list[5].real_reference;
8834 if (attribute_flag[6] != 0)
8835 (void) CloneString(&draw_info->font,
8836 argument_list[6].string_reference);
8837 if (attribute_flag[7] != 0)
8838 (void) QueryColorCompliance(argument_list[7].string_reference,
8839 AllCompliance,&draw_info->border_color,exception);
8840 if (attribute_flag[8] != 0)
8841 draw_info->affine.tx=argument_list[8].real_reference;
8842 if (attribute_flag[9] != 0)
8843 draw_info->affine.ty=argument_list[9].real_reference;
8844 if (attribute_flag[20] != 0)
8849 av=(AV *) argument_list[20].array_reference;
8850 if ((av_len(av) != 3) && (av_len(av) != 5))
8852 ThrowPerlException(exception,OptionError,
8853 "affine matrix must have 4 or 6 elements",PackageName);
8856 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8857 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8858 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8859 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8860 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8861 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8863 ThrowPerlException(exception,OptionError,
8864 "affine matrix is singular",PackageName);
8867 if (av_len(av) == 5)
8869 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8870 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8873 for (j=10; j < 15; j++)
8875 if (attribute_flag[j] == 0)
8877 value=argument_list[j].string_reference;
8878 angle=argument_list[j].real_reference;
8879 current=draw_info->affine;
8880 GetAffineMatrix(&affine);
8888 flags=ParseGeometry(value,&geometry_info);
8889 affine.tx=geometry_info.xi;
8890 affine.ty=geometry_info.psi;
8891 if ((flags & PsiValue) == 0)
8892 affine.ty=affine.tx;
8900 flags=ParseGeometry(value,&geometry_info);
8901 affine.sx=geometry_info.rho;
8902 affine.sy=geometry_info.sigma;
8903 if ((flags & SigmaValue) == 0)
8904 affine.sy=affine.sx;
8914 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8915 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8916 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8917 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8925 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8933 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8937 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8938 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8939 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8940 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8941 draw_info->affine.tx=
8942 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8943 draw_info->affine.ty=
8944 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8946 if (attribute_flag[15] != 0)
8947 draw_info->fill_pattern=CloneImage(
8948 argument_list[15].image_reference,0,0,MagickTrue,exception);
8949 if (attribute_flag[16] != 0)
8950 draw_info->pointsize=argument_list[16].real_reference;
8951 if (attribute_flag[17] != 0)
8953 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8954 ? MagickTrue : MagickFalse;
8955 draw_info->text_antialias=draw_info->stroke_antialias;
8957 if (attribute_flag[18] != 0)
8958 (void) CloneString(&draw_info->density,
8959 argument_list[18].string_reference);
8960 if (attribute_flag[19] != 0)
8961 draw_info->stroke_width=argument_list[19].real_reference;
8962 if (attribute_flag[21] != 0)
8963 draw_info->dash_offset=argument_list[21].real_reference;
8964 if (attribute_flag[22] != 0)
8969 av=(AV *) argument_list[22].array_reference;
8970 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8971 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8972 if (draw_info->dash_pattern != (double *) NULL)
8974 for (i=0; i <= av_len(av); i++)
8975 draw_info->dash_pattern[i]=(double)
8976 SvNV(*(av_fetch(av,i,0)));
8977 draw_info->dash_pattern[i]=0.0;
8980 if (attribute_flag[23] != 0)
8981 image->interpolate=(PixelInterpolateMethod)
8982 argument_list[23].integer_reference;
8983 if ((attribute_flag[24] != 0) &&
8984 (draw_info->fill_pattern != (Image *) NULL))
8985 flags=ParsePageGeometry(draw_info->fill_pattern,
8986 argument_list[24].string_reference,
8987 &draw_info->fill_pattern->tile_offset,exception);
8988 if (attribute_flag[25] != 0)
8990 (void) ConcatenateString(&draw_info->primitive," '");
8991 (void) ConcatenateString(&draw_info->primitive,
8992 argument_list[25].string_reference);
8993 (void) ConcatenateString(&draw_info->primitive,"'");
8995 if (attribute_flag[26] != 0)
8996 draw_info->fill_pattern=CloneImage(
8997 argument_list[26].image_reference,0,0,MagickTrue,exception);
8998 if (attribute_flag[27] != 0)
8999 draw_info->stroke_pattern=CloneImage(
9000 argument_list[27].image_reference,0,0,MagickTrue,exception);
9001 if (attribute_flag[28] != 0)
9002 (void) CloneString(&draw_info->primitive,
9003 argument_list[28].string_reference);
9004 if (attribute_flag[29] != 0)
9005 draw_info->kerning=argument_list[29].real_reference;
9006 if (attribute_flag[30] != 0)
9007 draw_info->interline_spacing=argument_list[30].real_reference;
9008 if (attribute_flag[31] != 0)
9009 draw_info->interword_spacing=argument_list[31].real_reference;
9010 if (attribute_flag[32] != 0)
9011 draw_info->direction=(DirectionType)
9012 argument_list[32].integer_reference;
9013 DrawImage(image,draw_info,exception);
9014 draw_info=DestroyDrawInfo(draw_info);
9017 case 39: /* Equalize */
9019 if (attribute_flag[0] != 0)
9020 channel=(ChannelType) argument_list[0].integer_reference;
9021 channel_mask=SetImageChannelMask(image,channel);
9022 EqualizeImage(image,exception);
9023 (void) SetImageChannelMask(image,channel_mask);
9026 case 40: /* Gamma */
9028 if (attribute_flag[1] != 0)
9029 channel=(ChannelType) argument_list[1].integer_reference;
9030 if (attribute_flag[2] == 0)
9031 argument_list[2].real_reference=1.0;
9032 if (attribute_flag[3] == 0)
9033 argument_list[3].real_reference=1.0;
9034 if (attribute_flag[4] == 0)
9035 argument_list[4].real_reference=1.0;
9036 if (attribute_flag[0] == 0)
9038 (void) FormatLocaleString(message,MaxTextExtent,
9039 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9040 (double) argument_list[3].real_reference,
9041 (double) argument_list[4].real_reference);
9042 argument_list[0].string_reference=message;
9044 (void) GammaImage(image,StringToDouble(
9045 argument_list[0].string_reference,(char **) NULL),exception);
9053 if (attribute_flag[0] == 0)
9055 ThrowPerlException(exception,OptionError,"MapImageRequired",
9059 quantize_info=AcquireQuantizeInfo(info->image_info);
9060 if (attribute_flag[1] != 0)
9061 quantize_info->dither_method=(DitherMethod)
9062 argument_list[1].integer_reference;
9063 (void) RemapImages(quantize_info,image,
9064 argument_list[0].image_reference,exception);
9065 quantize_info=DestroyQuantizeInfo(quantize_info);
9068 case 42: /* MatteFloodfill */
9079 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9081 if (attribute_flag[0] != 0)
9082 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9083 &geometry,exception);
9084 if (attribute_flag[1] != 0)
9085 geometry.x=argument_list[1].integer_reference;
9086 if (attribute_flag[2] != 0)
9087 geometry.y=argument_list[2].integer_reference;
9088 if (image->alpha_trait != BlendPixelTrait)
9089 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9090 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9091 geometry.x,geometry.y,&target,exception);
9092 if (attribute_flag[4] != 0)
9093 QueryColorCompliance(argument_list[4].string_reference,
9094 AllCompliance,&target,exception);
9095 if (attribute_flag[3] != 0)
9096 target.alpha=StringToDoubleInterval(
9097 argument_list[3].string_reference,(double) (double) QuantumRange+
9099 if (attribute_flag[5] != 0)
9100 image->fuzz=StringToDoubleInterval(
9101 argument_list[5].string_reference,(double) QuantumRange+1.0);
9103 if (attribute_flag[6] != 0)
9104 invert=(MagickBooleanType) argument_list[6].integer_reference;
9105 channel_mask=SetImageChannelMask(image,AlphaChannel);
9106 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9107 geometry.y,invert,exception);
9108 (void) SetImageChannelMask(image,channel_mask);
9109 draw_info=DestroyDrawInfo(draw_info);
9112 case 43: /* Modulate */
9115 modulate[MaxTextExtent];
9117 geometry_info.rho=100.0;
9118 geometry_info.sigma=100.0;
9119 geometry_info.xi=100.0;
9120 if (attribute_flag[0] != 0)
9121 (void)ParseGeometry(argument_list[0].string_reference,
9123 if (attribute_flag[1] != 0)
9124 geometry_info.xi=argument_list[1].real_reference;
9125 if (attribute_flag[2] != 0)
9126 geometry_info.sigma=argument_list[2].real_reference;
9127 if (attribute_flag[3] != 0)
9129 geometry_info.sigma=argument_list[3].real_reference;
9130 SetImageArtifact(image,"modulate:colorspace","HWB");
9132 if (attribute_flag[4] != 0)
9134 geometry_info.rho=argument_list[4].real_reference;
9135 SetImageArtifact(image,"modulate:colorspace","HSB");
9137 if (attribute_flag[5] != 0)
9139 geometry_info.sigma=argument_list[5].real_reference;
9140 SetImageArtifact(image,"modulate:colorspace","HSL");
9142 if (attribute_flag[6] != 0)
9144 geometry_info.rho=argument_list[6].real_reference;
9145 SetImageArtifact(image,"modulate:colorspace","HWB");
9147 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
9148 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9149 (void) ModulateImage(image,modulate,exception);
9152 case 44: /* Negate */
9154 if (attribute_flag[0] == 0)
9155 argument_list[0].integer_reference=0;
9156 if (attribute_flag[1] != 0)
9157 channel=(ChannelType) argument_list[1].integer_reference;
9158 channel_mask=SetImageChannelMask(image,channel);
9159 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9160 MagickTrue : MagickFalse,exception);
9161 (void) SetImageChannelMask(image,channel_mask);
9164 case 45: /* Normalize */
9166 if (attribute_flag[0] != 0)
9167 channel=(ChannelType) argument_list[0].integer_reference;
9168 channel_mask=SetImageChannelMask(image,channel);
9169 NormalizeImage(image,exception);
9170 (void) SetImageChannelMask(image,channel_mask);
9173 case 46: /* NumberColors */
9175 case 47: /* Opaque */
9184 (void) QueryColorCompliance("none",AllCompliance,&target,
9186 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9188 if (attribute_flag[0] != 0)
9189 (void) QueryColorCompliance(argument_list[0].string_reference,
9190 AllCompliance,&target,exception);
9191 if (attribute_flag[1] != 0)
9192 (void) QueryColorCompliance(argument_list[1].string_reference,
9193 AllCompliance,&fill_color,exception);
9194 if (attribute_flag[2] != 0)
9195 image->fuzz=StringToDoubleInterval(
9196 argument_list[2].string_reference,(double) QuantumRange+1.0);
9197 if (attribute_flag[3] != 0)
9198 channel=(ChannelType) argument_list[3].integer_reference;
9200 if (attribute_flag[4] != 0)
9201 invert=(MagickBooleanType) argument_list[4].integer_reference;
9202 channel_mask=SetImageChannelMask(image,channel);
9203 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9204 (void) SetImageChannelMask(image,channel_mask);
9207 case 48: /* Quantize */
9212 quantize_info=AcquireQuantizeInfo(info->image_info);
9213 if (attribute_flag[0] != 0)
9214 quantize_info->number_colors=(size_t)
9215 argument_list[0].integer_reference;
9216 if (attribute_flag[1] != 0)
9217 quantize_info->tree_depth=(size_t)
9218 argument_list[1].integer_reference;
9219 if (attribute_flag[2] != 0)
9220 quantize_info->colorspace=(ColorspaceType)
9221 argument_list[2].integer_reference;
9222 if (attribute_flag[3] != 0)
9223 quantize_info->dither_method=(DitherMethod)
9224 argument_list[3].integer_reference;
9225 MagickTrue : MagickFalse;
9226 if (attribute_flag[4] != 0)
9227 quantize_info->measure_error=
9228 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9229 if (attribute_flag[6] != 0)
9230 (void) QueryColorCompliance(argument_list[6].string_reference,
9231 &image->transparent_color,exception);
9232 if (attribute_flag[7] != 0)
9233 quantize_info->dither_method=(DitherMethod)
9234 argument_list[7].integer_reference;
9235 if (attribute_flag[5] && argument_list[5].integer_reference)
9236 (void) QuantizeImages(quantize_info,image,exception);
9237 else if ((image->storage_class == DirectClass) ||
9238 (image->colors > quantize_info->number_colors) ||
9239 (quantize_info->colorspace == GRAYColorspace))
9240 (void) QuantizeImage(quantize_info,image,exception);
9242 CompressImageColormap(image,exception);
9243 quantize_info=DestroyQuantizeInfo(quantize_info);
9246 case 49: /* Raise */
9248 if (attribute_flag[0] != 0)
9249 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9250 &geometry,exception);
9251 if (attribute_flag[1] != 0)
9252 geometry.width=argument_list[1].integer_reference;
9253 if (attribute_flag[2] != 0)
9254 geometry.height=argument_list[2].integer_reference;
9255 if (attribute_flag[3] == 0)
9256 argument_list[3].integer_reference=1;
9257 (void) RaiseImage(image,&geometry,
9258 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9262 case 50: /* Segment */
9269 smoothing_threshold;
9274 cluster_threshold=1.0;
9275 smoothing_threshold=1.5;
9276 colorspace=sRGBColorspace;
9277 verbose=MagickFalse;
9278 if (attribute_flag[0] != 0)
9280 flags=ParseGeometry(argument_list[0].string_reference,
9282 cluster_threshold=geometry_info.rho;
9283 if (flags & SigmaValue)
9284 smoothing_threshold=geometry_info.sigma;
9286 if (attribute_flag[1] != 0)
9287 cluster_threshold=argument_list[1].real_reference;
9288 if (attribute_flag[2] != 0)
9289 smoothing_threshold=argument_list[2].real_reference;
9290 if (attribute_flag[3] != 0)
9291 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9292 if (attribute_flag[4] != 0)
9293 verbose=argument_list[4].integer_reference != 0 ?
9294 MagickTrue : MagickFalse;
9295 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9296 smoothing_threshold,exception);
9299 case 51: /* Signature */
9301 (void) SignatureImage(image,exception);
9304 case 52: /* Solarize */
9306 geometry_info.rho=QuantumRange/2.0;
9307 if (attribute_flag[0] != 0)
9308 flags=ParseGeometry(argument_list[0].string_reference,
9310 if (attribute_flag[1] != 0)
9311 geometry_info.rho=StringToDoubleInterval(
9312 argument_list[1].string_reference,(double) QuantumRange+1.0);
9313 (void) SolarizeImage(image,geometry_info.rho,exception);
9318 (void) SyncImage(image,exception);
9321 case 54: /* Texture */
9323 if (attribute_flag[0] == 0)
9325 TextureImage(image,argument_list[0].image_reference,exception);
9328 case 55: /* Evalute */
9330 MagickEvaluateOperator
9333 op=SetEvaluateOperator;
9334 if (attribute_flag[0] == MagickFalse)
9335 argument_list[0].real_reference=0.0;
9336 if (attribute_flag[1] != MagickFalse)
9337 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9338 if (attribute_flag[2] != MagickFalse)
9339 channel=(ChannelType) argument_list[2].integer_reference;
9340 channel_mask=SetImageChannelMask(image,channel);
9341 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9343 (void) SetImageChannelMask(image,channel_mask);
9346 case 56: /* Transparent */
9357 (void) QueryColorCompliance("none",AllCompliance,&target,
9359 if (attribute_flag[0] != 0)
9360 (void) QueryColorCompliance(argument_list[0].string_reference,
9361 AllCompliance,&target,exception);
9362 opacity=TransparentAlpha;
9363 if (attribute_flag[1] != 0)
9364 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9365 (double) QuantumRange+1.0);
9366 if (attribute_flag[2] != 0)
9367 image->fuzz=StringToDoubleInterval(
9368 argument_list[2].string_reference,(double) QuantumRange+1.0);
9369 if (attribute_flag[3] == 0)
9370 argument_list[3].integer_reference=0;
9372 if (attribute_flag[3] != 0)
9373 invert=(MagickBooleanType) argument_list[3].integer_reference;
9374 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9378 case 57: /* Threshold */
9383 if (attribute_flag[0] == 0)
9384 argument_list[0].string_reference="50%";
9385 if (attribute_flag[1] != 0)
9386 channel=(ChannelType) argument_list[1].integer_reference;
9387 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9388 (double) QuantumRange+1.0);
9389 channel_mask=SetImageChannelMask(image,channel);
9390 (void) BilevelImage(image,threshold,exception);
9391 (void) SetImageChannelMask(image,channel_mask);
9394 case 58: /* Charcoal */
9396 if (attribute_flag[0] != 0)
9398 flags=ParseGeometry(argument_list[0].string_reference,
9400 if ((flags & SigmaValue) == 0)
9401 geometry_info.sigma=1.0;
9403 if (attribute_flag[1] != 0)
9404 geometry_info.rho=argument_list[1].real_reference;
9405 if (attribute_flag[2] != 0)
9406 geometry_info.sigma=argument_list[2].real_reference;
9407 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9413 if (attribute_flag[0] != 0)
9414 image->fuzz=StringToDoubleInterval(
9415 argument_list[0].string_reference,(double) QuantumRange+1.0);
9416 image=TrimImage(image,exception);
9421 PixelInterpolateMethod
9424 if (attribute_flag[0] != 0)
9426 flags=ParseGeometry(argument_list[0].string_reference,
9428 if ((flags & SigmaValue) == 0)
9429 geometry_info.sigma=1.0;
9431 if (attribute_flag[1] != 0)
9432 geometry_info.rho=argument_list[1].real_reference;
9433 if (attribute_flag[2] != 0)
9434 geometry_info.sigma=argument_list[2].real_reference;
9435 method=UndefinedInterpolatePixel;
9436 if (attribute_flag[3] != 0)
9437 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9438 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9442 case 61: /* Separate */
9444 if (attribute_flag[0] != 0)
9445 channel=(ChannelType) argument_list[0].integer_reference;
9446 image=SeparateImage(image,channel,exception);
9449 case 63: /* Stereo */
9451 if (attribute_flag[0] == 0)
9453 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9457 if (attribute_flag[1] != 0)
9458 geometry.x=argument_list[1].integer_reference;
9459 if (attribute_flag[2] != 0)
9460 geometry.y=argument_list[2].integer_reference;
9461 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9462 geometry.x,geometry.y,exception);
9465 case 64: /* Stegano */
9467 if (attribute_flag[0] == 0)
9469 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9473 if (attribute_flag[1] == 0)
9474 argument_list[1].integer_reference=0;
9475 image->offset=argument_list[1].integer_reference;
9476 image=SteganoImage(image,argument_list[0].image_reference,exception);
9479 case 65: /* Deconstruct */
9481 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9484 case 66: /* GaussianBlur */
9486 if (attribute_flag[0] != 0)
9488 flags=ParseGeometry(argument_list[0].string_reference,
9490 if ((flags & SigmaValue) == 0)
9491 geometry_info.sigma=1.0;
9493 if (attribute_flag[1] != 0)
9494 geometry_info.rho=argument_list[1].real_reference;
9495 if (attribute_flag[2] != 0)
9496 geometry_info.sigma=argument_list[2].real_reference;
9497 if (attribute_flag[3] != 0)
9498 channel=(ChannelType) argument_list[3].integer_reference;
9499 channel_mask=SetImageChannelMask(image,channel);
9500 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9502 if (image != (Image *) NULL)
9503 (void) SetImageChannelMask(image,channel_mask);
9506 case 67: /* Convolve */
9511 kernel=(KernelInfo *) NULL;
9512 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9514 if (attribute_flag[0] != 0)
9522 kernel=AcquireKernelInfo((const char *) NULL);
9523 if (kernel == (KernelInfo *) NULL)
9525 av=(AV *) argument_list[0].array_reference;
9526 order=(size_t) sqrt(av_len(av)+1);
9527 kernel->width=order;
9528 kernel->height=order;
9529 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9530 order*sizeof(*kernel->values));
9531 if (kernel->values == (MagickRealType *) NULL)
9533 kernel=DestroyKernelInfo(kernel);
9534 ThrowPerlException(exception,ResourceLimitFatalError,
9535 "MemoryAllocationFailed",PackageName);
9538 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9539 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9540 for ( ; j < (ssize_t) (order*order); j++)
9541 kernel->values[j]=0.0;
9543 if (attribute_flag[1] != 0)
9544 channel=(ChannelType) argument_list[1].integer_reference;
9545 if (attribute_flag[2] != 0)
9546 SetImageArtifact(image,"filter:blur",
9547 argument_list[2].string_reference);
9548 if (attribute_flag[3] != 0)
9550 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9551 if (kernel == (KernelInfo *) NULL)
9554 channel_mask=SetImageChannelMask(image,channel);
9555 image=ConvolveImage(image,kernel,exception);
9556 if (image != (Image *) NULL)
9557 (void) SetImageChannelMask(image,channel_mask);
9558 kernel=DestroyKernelInfo(kernel);
9561 case 68: /* Profile */
9576 if (attribute_flag[0] != 0)
9577 name=argument_list[0].string_reference;
9578 if (attribute_flag[2] != 0)
9579 image->rendering_intent=(RenderingIntent)
9580 argument_list[2].integer_reference;
9581 if (attribute_flag[3] != 0)
9582 image->black_point_compensation=
9583 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9584 if (attribute_flag[1] != 0)
9586 if (argument_list[1].length == 0)
9589 Remove a profile from the image.
9591 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9596 Associate user supplied profile with the image.
9598 profile=AcquireStringInfo(argument_list[1].length);
9599 SetStringInfoDatum(profile,(const unsigned char *)
9600 argument_list[1].string_reference);
9601 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9602 (size_t) GetStringInfoLength(profile),exception);
9603 profile=DestroyStringInfo(profile);
9607 Associate a profile with the image.
9609 profile_info=CloneImageInfo(info ? info->image_info :
9610 (ImageInfo *) NULL);
9611 profile_image=ReadImages(profile_info,name,exception);
9612 if (profile_image == (Image *) NULL)
9614 ResetImageProfileIterator(profile_image);
9615 name=GetNextImageProfile(profile_image);
9616 while (name != (const char *) NULL)
9621 profile=GetImageProfile(profile_image,name);
9622 if (profile != (const StringInfo *) NULL)
9623 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9624 (size_t) GetStringInfoLength(profile),exception);
9625 name=GetNextImageProfile(profile_image);
9627 profile_image=DestroyImage(profile_image);
9628 profile_info=DestroyImageInfo(profile_info);
9631 case 69: /* UnsharpMask */
9633 if (attribute_flag[0] != 0)
9635 flags=ParseGeometry(argument_list[0].string_reference,
9637 if ((flags & SigmaValue) == 0)
9638 geometry_info.sigma=1.0;
9639 if ((flags & XiValue) == 0)
9640 geometry_info.xi=1.0;
9641 if ((flags & PsiValue) == 0)
9642 geometry_info.psi=0.5;
9644 if (attribute_flag[1] != 0)
9645 geometry_info.rho=argument_list[1].real_reference;
9646 if (attribute_flag[2] != 0)
9647 geometry_info.sigma=argument_list[2].real_reference;
9648 if (attribute_flag[3] != 0)
9649 geometry_info.xi=argument_list[3].real_reference;
9650 if (attribute_flag[4] != 0)
9651 geometry_info.psi=argument_list[4].real_reference;
9652 if (attribute_flag[5] != 0)
9653 channel=(ChannelType) argument_list[5].integer_reference;
9654 channel_mask=SetImageChannelMask(image,channel);
9655 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9656 geometry_info.xi,geometry_info.psi,exception);
9657 if (image != (Image *) NULL)
9658 (void) SetImageChannelMask(image,channel_mask);
9661 case 70: /* MotionBlur */
9663 if (attribute_flag[0] != 0)
9665 flags=ParseGeometry(argument_list[0].string_reference,
9667 if ((flags & SigmaValue) == 0)
9668 geometry_info.sigma=1.0;
9669 if ((flags & XiValue) == 0)
9670 geometry_info.xi=1.0;
9672 if (attribute_flag[1] != 0)
9673 geometry_info.rho=argument_list[1].real_reference;
9674 if (attribute_flag[2] != 0)
9675 geometry_info.sigma=argument_list[2].real_reference;
9676 if (attribute_flag[3] != 0)
9677 geometry_info.xi=argument_list[3].real_reference;
9678 if (attribute_flag[4] != 0)
9679 channel=(ChannelType) argument_list[4].integer_reference;
9680 channel_mask=SetImageChannelMask(image,channel);
9681 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9682 geometry_info.xi,exception);
9683 if (image != (Image *) NULL)
9684 (void) SetImageChannelMask(image,channel_mask);
9687 case 71: /* OrderedDither */
9689 if (attribute_flag[0] == 0)
9690 argument_list[0].string_reference="o8x8";
9691 if (attribute_flag[1] != 0)
9692 channel=(ChannelType) argument_list[1].integer_reference;
9693 channel_mask=SetImageChannelMask(image,channel);
9694 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9696 (void) SetImageChannelMask(image,channel_mask);
9699 case 72: /* Shave */
9701 if (attribute_flag[0] != 0)
9702 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9703 &geometry,exception);
9704 if (attribute_flag[1] != 0)
9705 geometry.width=argument_list[1].integer_reference;
9706 if (attribute_flag[2] != 0)
9707 geometry.height=argument_list[2].integer_reference;
9708 image=ShaveImage(image,&geometry,exception);
9711 case 73: /* Level */
9719 white_point=(double) image->columns*image->rows;
9721 if (attribute_flag[0] != 0)
9723 flags=ParseGeometry(argument_list[0].string_reference,
9725 black_point=geometry_info.rho;
9726 if ((flags & SigmaValue) != 0)
9727 white_point=geometry_info.sigma;
9728 if ((flags & XiValue) != 0)
9729 gamma=geometry_info.xi;
9730 if ((flags & PercentValue) != 0)
9732 black_point*=(double) (QuantumRange/100.0);
9733 white_point*=(double) (QuantumRange/100.0);
9735 if ((flags & SigmaValue) == 0)
9736 white_point=(double) QuantumRange-black_point;
9738 if (attribute_flag[1] != 0)
9739 black_point=argument_list[1].real_reference;
9740 if (attribute_flag[2] != 0)
9741 white_point=argument_list[2].real_reference;
9742 if (attribute_flag[3] != 0)
9743 gamma=argument_list[3].real_reference;
9744 if (attribute_flag[4] != 0)
9745 channel=(ChannelType) argument_list[4].integer_reference;
9746 if (attribute_flag[5] != 0)
9748 argument_list[0].real_reference=argument_list[5].real_reference;
9749 attribute_flag[0]=attribute_flag[5];
9751 channel_mask=SetImageChannelMask(image,channel);
9752 (void) LevelImage(image,black_point,white_point,gamma,exception);
9753 (void) SetImageChannelMask(image,channel_mask);
9758 if (attribute_flag[0] == 0)
9759 argument_list[0].string_reference="#1";
9760 if (attribute_flag[1] == 0)
9761 argument_list[1].integer_reference=MagickTrue;
9762 (void) ClipImagePath(image,argument_list[0].string_reference,
9763 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9767 case 75: /* AffineTransform */
9772 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9774 if (attribute_flag[0] != 0)
9779 av=(AV *) argument_list[0].array_reference;
9780 if ((av_len(av) != 3) && (av_len(av) != 5))
9782 ThrowPerlException(exception,OptionError,
9783 "affine matrix must have 4 or 6 elements",PackageName);
9786 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9787 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9788 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9789 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9790 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9791 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9793 ThrowPerlException(exception,OptionError,
9794 "affine matrix is singular",PackageName);
9797 if (av_len(av) == 5)
9799 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9800 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9803 for (j=1; j < 6; j++)
9805 if (attribute_flag[j] == 0)
9807 value=argument_list[j].string_reference;
9808 angle=argument_list[j].real_reference;
9809 current=draw_info->affine;
9810 GetAffineMatrix(&affine);
9818 flags=ParseGeometry(value,&geometry_info);
9819 affine.tx=geometry_info.xi;
9820 affine.ty=geometry_info.psi;
9821 if ((flags & PsiValue) == 0)
9822 affine.ty=affine.tx;
9830 flags=ParseGeometry(value,&geometry_info);
9831 affine.sx=geometry_info.rho;
9832 affine.sy=geometry_info.sigma;
9833 if ((flags & SigmaValue) == 0)
9834 affine.sy=affine.sx;
9844 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9845 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9846 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9847 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9855 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9863 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9867 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9868 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9869 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9870 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9871 draw_info->affine.tx=
9872 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9873 draw_info->affine.ty=
9874 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9876 if (attribute_flag[6] != 0)
9877 image->interpolate=(PixelInterpolateMethod)
9878 argument_list[6].integer_reference;
9879 if (attribute_flag[7] != 0)
9880 QueryColorCompliance(argument_list[7].string_reference,
9881 AllCompliance,&image->background_color,exception);
9882 image=AffineTransformImage(image,&draw_info->affine,exception);
9883 draw_info=DestroyDrawInfo(draw_info);
9886 case 76: /* Difference */
9888 if (attribute_flag[0] == 0)
9890 ThrowPerlException(exception,OptionError,
9891 "ReferenceImageRequired",PackageName);
9894 if (attribute_flag[1] != 0)
9895 image->fuzz=StringToDoubleInterval(
9896 argument_list[1].string_reference,(double) QuantumRange+1.0);
9897 (void) IsImagesEqual(image,argument_list[0].image_reference,
9901 case 77: /* AdaptiveThreshold */
9903 if (attribute_flag[0] != 0)
9905 flags=ParseGeometry(argument_list[0].string_reference,
9907 if ((flags & PercentValue) != 0)
9908 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9910 if (attribute_flag[1] != 0)
9911 geometry_info.rho=argument_list[1].integer_reference;
9912 if (attribute_flag[2] != 0)
9913 geometry_info.sigma=argument_list[2].integer_reference;
9914 if (attribute_flag[3] != 0)
9915 geometry_info.xi=argument_list[3].integer_reference;;
9916 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9917 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9920 case 78: /* Resample */
9926 if (attribute_flag[0] != 0)
9928 flags=ParseGeometry(argument_list[0].string_reference,
9930 if ((flags & SigmaValue) == 0)
9931 geometry_info.sigma=geometry_info.rho;
9933 if (attribute_flag[1] != 0)
9934 geometry_info.rho=argument_list[1].real_reference;
9935 if (attribute_flag[2] != 0)
9936 geometry_info.sigma=argument_list[2].real_reference;
9937 if (attribute_flag[3] == 0)
9938 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9939 if (attribute_flag[4] == 0)
9940 SetImageArtifact(image,"filter:support",
9941 argument_list[4].string_reference);
9942 width=(size_t) (geometry_info.rho*image->columns/
9943 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9944 height=(size_t) (geometry_info.sigma*image->rows/
9945 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9946 image=ResizeImage(image,width,height,(FilterTypes)
9947 argument_list[3].integer_reference,exception);
9948 if (image != (Image *) NULL)
9950 image->resolution.x=geometry_info.rho;
9951 image->resolution.y=geometry_info.sigma;
9955 case 79: /* Describe */
9957 if (attribute_flag[0] == 0)
9958 argument_list[0].file_reference=(FILE *) NULL;
9959 if (attribute_flag[1] != 0)
9960 (void) SetImageArtifact(image,"identify:features",
9961 argument_list[1].string_reference);
9962 (void) IdentifyImage(image,argument_list[0].file_reference,
9963 MagickTrue,exception);
9966 case 80: /* BlackThreshold */
9968 if (attribute_flag[0] == 0)
9969 argument_list[0].string_reference="50%";
9970 if (attribute_flag[2] != 0)
9971 channel=(ChannelType) argument_list[2].integer_reference;
9972 channel_mask=SetImageChannelMask(image,channel);
9973 BlackThresholdImage(image,argument_list[0].string_reference,
9975 (void) SetImageChannelMask(image,channel_mask);
9978 case 81: /* WhiteThreshold */
9980 if (attribute_flag[0] == 0)
9981 argument_list[0].string_reference="50%";
9982 if (attribute_flag[2] != 0)
9983 channel=(ChannelType) argument_list[2].integer_reference;
9984 channel_mask=SetImageChannelMask(image,channel);
9985 WhiteThresholdImage(image,argument_list[0].string_reference,
9987 (void) SetImageChannelMask(image,channel_mask);
9990 case 82: /* RadialBlur */
9992 if (attribute_flag[0] != 0)
9994 flags=ParseGeometry(argument_list[0].string_reference,
9997 if (attribute_flag[1] != 0)
9998 geometry_info.rho=argument_list[1].real_reference;
9999 if (attribute_flag[2] != 0)
10000 channel=(ChannelType) argument_list[2].integer_reference;
10001 channel_mask=SetImageChannelMask(image,channel);
10002 image=RotationalBlurImage(image,geometry_info.rho,exception);
10003 if (image != (Image *) NULL)
10004 (void) SetImageChannelMask(image,channel_mask);
10007 case 83: /* Thumbnail */
10009 if (attribute_flag[0] != 0)
10010 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10011 &geometry,exception);
10012 if (attribute_flag[1] != 0)
10013 geometry.width=argument_list[1].integer_reference;
10014 if (attribute_flag[2] != 0)
10015 geometry.height=argument_list[2].integer_reference;
10016 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10019 case 84: /* Strip */
10021 (void) StripImage(image,exception);
10024 case 85: /* Tint */
10029 GetPixelInfo(image,&tint);
10030 if (attribute_flag[0] != 0)
10031 (void) QueryColorCompliance(argument_list[0].string_reference,
10032 AllCompliance,&tint,exception);
10033 if (attribute_flag[1] == 0)
10034 argument_list[1].string_reference="100";
10035 image=TintImage(image,argument_list[1].string_reference,&tint,
10039 case 86: /* Channel */
10041 if (attribute_flag[0] != 0)
10042 channel=(ChannelType) argument_list[0].integer_reference;
10043 image=SeparateImage(image,channel,exception);
10046 case 87: /* Splice */
10048 if (attribute_flag[0] != 0)
10049 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10050 &geometry,exception);
10051 if (attribute_flag[1] != 0)
10052 geometry.width=argument_list[1].integer_reference;
10053 if (attribute_flag[2] != 0)
10054 geometry.height=argument_list[2].integer_reference;
10055 if (attribute_flag[3] != 0)
10056 geometry.x=argument_list[3].integer_reference;
10057 if (attribute_flag[4] != 0)
10058 geometry.y=argument_list[4].integer_reference;
10059 if (attribute_flag[5] != 0)
10060 image->fuzz=StringToDoubleInterval(
10061 argument_list[5].string_reference,(double) QuantumRange+1.0);
10062 if (attribute_flag[6] != 0)
10063 (void) QueryColorCompliance(argument_list[6].string_reference,
10064 AllCompliance,&image->background_color,exception);
10065 if (attribute_flag[7] != 0)
10066 image->gravity=(GravityType) argument_list[7].integer_reference;
10067 image=SpliceImage(image,&geometry,exception);
10070 case 88: /* Posterize */
10072 if (attribute_flag[0] == 0)
10073 argument_list[0].integer_reference=3;
10074 if (attribute_flag[1] == 0)
10075 argument_list[1].integer_reference=0;
10076 (void) PosterizeImage(image,argument_list[0].integer_reference,
10077 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10078 NoDitherMethod,exception);
10081 case 89: /* Shadow */
10083 if (attribute_flag[0] != 0)
10085 flags=ParseGeometry(argument_list[0].string_reference,
10087 if ((flags & SigmaValue) == 0)
10088 geometry_info.sigma=1.0;
10089 if ((flags & XiValue) == 0)
10090 geometry_info.xi=4.0;
10091 if ((flags & PsiValue) == 0)
10092 geometry_info.psi=4.0;
10094 if (attribute_flag[1] != 0)
10095 geometry_info.rho=argument_list[1].real_reference;
10096 if (attribute_flag[2] != 0)
10097 geometry_info.sigma=argument_list[2].real_reference;
10098 if (attribute_flag[3] != 0)
10099 geometry_info.xi=argument_list[3].integer_reference;
10100 if (attribute_flag[4] != 0)
10101 geometry_info.psi=argument_list[4].integer_reference;
10102 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10103 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10104 ceil(geometry_info.psi-0.5),exception);
10107 case 90: /* Identify */
10109 if (attribute_flag[0] == 0)
10110 argument_list[0].file_reference=(FILE *) NULL;
10111 if (attribute_flag[1] != 0)
10112 (void) SetImageArtifact(image,"identify:features",
10113 argument_list[1].string_reference);
10114 if ((attribute_flag[2] != 0) &&
10115 (argument_list[2].integer_reference != 0))
10116 (void) SetImageArtifact(image,"identify:unique","true");
10117 (void) IdentifyImage(image,argument_list[0].file_reference,
10118 MagickTrue,exception);
10121 case 91: /* SepiaTone */
10123 if (attribute_flag[0] == 0)
10124 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10125 image=SepiaToneImage(image,argument_list[0].real_reference,
10129 case 92: /* SigmoidalContrast */
10134 if (attribute_flag[0] != 0)
10136 flags=ParseGeometry(argument_list[0].string_reference,
10138 if ((flags & SigmaValue) == 0)
10139 geometry_info.sigma=QuantumRange/2.0;
10140 if ((flags & PercentValue) != 0)
10141 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10143 if (attribute_flag[1] != 0)
10144 geometry_info.rho=argument_list[1].real_reference;
10145 if (attribute_flag[2] != 0)
10146 geometry_info.sigma=argument_list[2].real_reference;
10147 if (attribute_flag[3] != 0)
10148 channel=(ChannelType) argument_list[3].integer_reference;
10149 sharpen=MagickTrue;
10150 if (attribute_flag[4] != 0)
10151 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10153 channel_mask=SetImageChannelMask(image,channel);
10154 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10155 geometry_info.sigma,exception);
10156 (void) SetImageChannelMask(image,channel_mask);
10159 case 93: /* Extent */
10161 if (attribute_flag[7] != 0)
10162 image->gravity=(GravityType) argument_list[7].integer_reference;
10163 if (attribute_flag[0] != 0)
10168 flags=ParseGravityGeometry(image,
10169 argument_list[0].string_reference,&geometry,exception);
10171 if (geometry.width == 0)
10172 geometry.width=image->columns;
10173 if (geometry.height == 0)
10174 geometry.height=image->rows;
10176 if (attribute_flag[1] != 0)
10177 geometry.width=argument_list[1].integer_reference;
10178 if (attribute_flag[2] != 0)
10179 geometry.height=argument_list[2].integer_reference;
10180 if (attribute_flag[3] != 0)
10181 geometry.x=argument_list[3].integer_reference;
10182 if (attribute_flag[4] != 0)
10183 geometry.y=argument_list[4].integer_reference;
10184 if (attribute_flag[5] != 0)
10185 image->fuzz=StringToDoubleInterval(
10186 argument_list[5].string_reference,(double) QuantumRange+1.0);
10187 if (attribute_flag[6] != 0)
10188 (void) QueryColorCompliance(argument_list[6].string_reference,
10189 AllCompliance,&image->background_color,exception);
10190 image=ExtentImage(image,&geometry,exception);
10193 case 94: /* Vignette */
10195 if (attribute_flag[0] != 0)
10197 flags=ParseGeometry(argument_list[0].string_reference,
10199 if ((flags & SigmaValue) == 0)
10200 geometry_info.sigma=1.0;
10201 if ((flags & XiValue) == 0)
10202 geometry_info.xi=0.1*image->columns;
10203 if ((flags & PsiValue) == 0)
10204 geometry_info.psi=0.1*image->rows;
10206 if (attribute_flag[1] != 0)
10207 geometry_info.rho=argument_list[1].real_reference;
10208 if (attribute_flag[2] != 0)
10209 geometry_info.sigma=argument_list[2].real_reference;
10210 if (attribute_flag[3] != 0)
10211 geometry_info.xi=argument_list[3].integer_reference;
10212 if (attribute_flag[4] != 0)
10213 geometry_info.psi=argument_list[4].integer_reference;
10214 if (attribute_flag[5] != 0)
10215 (void) QueryColorCompliance(argument_list[5].string_reference,
10216 AllCompliance,&image->background_color,exception);
10217 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10218 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10219 ceil(geometry_info.psi-0.5),exception);
10222 case 95: /* ContrastStretch */
10229 white_point=(double) image->columns*image->rows;
10230 if (attribute_flag[0] != 0)
10232 flags=ParseGeometry(argument_list[0].string_reference,
10234 black_point=geometry_info.rho;
10235 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10237 if ((flags & PercentValue) != 0)
10239 black_point*=(double) image->columns*image->rows/100.0;
10240 white_point*=(double) image->columns*image->rows/100.0;
10242 white_point=(double) image->columns*image->rows-
10245 if (attribute_flag[1] != 0)
10246 black_point=argument_list[1].real_reference;
10247 if (attribute_flag[2] != 0)
10248 white_point=argument_list[2].real_reference;
10249 if (attribute_flag[4] != 0)
10250 channel=(ChannelType) argument_list[4].integer_reference;
10251 channel_mask=SetImageChannelMask(image,channel);
10252 (void) ContrastStretchImage(image,black_point,white_point,exception);
10253 (void) SetImageChannelMask(image,channel_mask);
10256 case 96: /* Sans0 */
10260 case 97: /* Sans1 */
10264 case 98: /* AdaptiveSharpen */
10266 if (attribute_flag[0] != 0)
10268 flags=ParseGeometry(argument_list[0].string_reference,
10270 if ((flags & SigmaValue) == 0)
10271 geometry_info.sigma=1.0;
10272 if ((flags & XiValue) == 0)
10273 geometry_info.xi=0.0;
10275 if (attribute_flag[1] != 0)
10276 geometry_info.rho=argument_list[1].real_reference;
10277 if (attribute_flag[2] != 0)
10278 geometry_info.sigma=argument_list[2].real_reference;
10279 if (attribute_flag[3] != 0)
10280 geometry_info.xi=argument_list[3].real_reference;
10281 if (attribute_flag[4] != 0)
10282 channel=(ChannelType) argument_list[4].integer_reference;
10283 channel_mask=SetImageChannelMask(image,channel);
10284 image=AdaptiveSharpenImage(image,geometry_info.rho,
10285 geometry_info.sigma,exception);
10286 if (image != (Image *) NULL)
10287 (void) SetImageChannelMask(image,channel_mask);
10290 case 99: /* Transpose */
10292 image=TransposeImage(image,exception);
10295 case 100: /* Tranverse */
10297 image=TransverseImage(image,exception);
10300 case 101: /* AutoOrient */
10302 image=AutoOrientImage(image,image->orientation,exception);
10305 case 102: /* AdaptiveBlur */
10307 if (attribute_flag[0] != 0)
10309 flags=ParseGeometry(argument_list[0].string_reference,
10311 if ((flags & SigmaValue) == 0)
10312 geometry_info.sigma=1.0;
10313 if ((flags & XiValue) == 0)
10314 geometry_info.xi=0.0;
10316 if (attribute_flag[1] != 0)
10317 geometry_info.rho=argument_list[1].real_reference;
10318 if (attribute_flag[2] != 0)
10319 geometry_info.sigma=argument_list[2].real_reference;
10320 if (attribute_flag[3] != 0)
10321 channel=(ChannelType) argument_list[3].integer_reference;
10322 channel_mask=SetImageChannelMask(image,channel);
10323 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10325 if (image != (Image *) NULL)
10326 (void) SetImageChannelMask(image,channel_mask);
10329 case 103: /* Sketch */
10331 if (attribute_flag[0] != 0)
10333 flags=ParseGeometry(argument_list[0].string_reference,
10335 if ((flags & SigmaValue) == 0)
10336 geometry_info.sigma=1.0;
10337 if ((flags & XiValue) == 0)
10338 geometry_info.xi=1.0;
10340 if (attribute_flag[1] != 0)
10341 geometry_info.rho=argument_list[1].real_reference;
10342 if (attribute_flag[2] != 0)
10343 geometry_info.sigma=argument_list[2].real_reference;
10344 if (attribute_flag[3] != 0)
10345 geometry_info.xi=argument_list[3].real_reference;
10346 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10347 geometry_info.xi,exception);
10350 case 104: /* UniqueColors */
10352 image=UniqueImageColors(image,exception);
10355 case 105: /* AdaptiveResize */
10357 if (attribute_flag[0] != 0)
10358 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10359 &geometry,exception);
10360 if (attribute_flag[1] != 0)
10361 geometry.width=argument_list[1].integer_reference;
10362 if (attribute_flag[2] != 0)
10363 geometry.height=argument_list[2].integer_reference;
10364 if (attribute_flag[3] != 0)
10365 image->filter=(FilterTypes) argument_list[4].integer_reference;
10366 if (attribute_flag[4] != 0)
10367 SetImageArtifact(image,"filter:support",
10368 argument_list[4].string_reference);
10369 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10373 case 106: /* ClipMask */
10378 if (attribute_flag[0] == 0)
10380 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10382 goto PerlException;
10384 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10386 (void) SetImageMask(image,mask_image,exception);
10387 mask_image=DestroyImage(mask_image);
10390 case 107: /* LinearStretch */
10397 white_point=(double) image->columns*image->rows;
10398 if (attribute_flag[0] != 0)
10400 flags=ParseGeometry(argument_list[0].string_reference,
10402 if ((flags & SigmaValue) != 0)
10403 white_point=geometry_info.sigma;
10404 if ((flags & PercentValue) != 0)
10406 black_point*=(double) image->columns*image->rows/100.0;
10407 white_point*=(double) image->columns*image->rows/100.0;
10409 if ((flags & SigmaValue) == 0)
10410 white_point=(double) image->columns*image->rows-black_point;
10412 if (attribute_flag[1] != 0)
10413 black_point=argument_list[1].real_reference;
10414 if (attribute_flag[2] != 0)
10415 white_point=argument_list[2].real_reference;
10416 (void) LinearStretchImage(image,black_point,white_point,exception);
10419 case 108: /* ColorMatrix */
10433 if (attribute_flag[0] == 0)
10435 av=(AV *) argument_list[0].array_reference;
10436 order=(size_t) sqrt(av_len(av)+1);
10437 color_matrix=(double *) AcquireQuantumMemory(order,order*
10438 sizeof(*color_matrix));
10439 if (color_matrix == (double *) NULL)
10441 ThrowPerlException(exception,ResourceLimitFatalError,
10442 "MemoryAllocationFailed",PackageName);
10443 goto PerlException;
10445 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10446 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10447 for ( ; j < (ssize_t) (order*order); j++)
10448 color_matrix[j]=0.0;
10449 kernel_info=AcquireKernelInfo((const char *) NULL);
10450 if (kernel_info == (KernelInfo *) NULL)
10452 kernel_info->width=order;
10453 kernel_info->height=order;
10454 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10455 order*sizeof(*kernel_info->values));
10456 if (kernel_info->values != (MagickRealType *) NULL)
10458 for (i=0; i < (ssize_t) (order*order); i++)
10459 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10460 image=ColorMatrixImage(image,kernel_info,exception);
10462 kernel_info=DestroyKernelInfo(kernel_info);
10463 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10466 case 109: /* Mask */
10471 if (attribute_flag[0] == 0)
10473 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10475 goto PerlException;
10477 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10478 MagickTrue,exception);
10479 (void) SetImageMask(image,mask_image,exception);
10480 mask_image=DestroyImage(mask_image);
10483 case 110: /* Polaroid */
10494 PixelInterpolateMethod
10497 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10498 (DrawInfo *) NULL);
10499 caption=(char *) NULL;
10500 if (attribute_flag[0] != 0)
10501 caption=InterpretImageProperties(info ? info->image_info :
10502 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10505 if (attribute_flag[1] != 0)
10506 angle=argument_list[1].real_reference;
10507 if (attribute_flag[2] != 0)
10508 (void) CloneString(&draw_info->font,
10509 argument_list[2].string_reference);
10510 if (attribute_flag[3] != 0)
10511 (void) QueryColorCompliance(argument_list[3].string_reference,
10512 AllCompliance,&draw_info->stroke,exception);
10513 if (attribute_flag[4] != 0)
10514 (void) QueryColorCompliance(argument_list[4].string_reference,
10515 AllCompliance,&draw_info->fill,exception);
10516 if (attribute_flag[5] != 0)
10517 draw_info->stroke_width=argument_list[5].real_reference;
10518 if (attribute_flag[6] != 0)
10519 draw_info->pointsize=argument_list[6].real_reference;
10520 if (attribute_flag[7] != 0)
10521 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10522 if (attribute_flag[8] != 0)
10523 (void) QueryColorCompliance(argument_list[8].string_reference,
10524 AllCompliance,&image->background_color,exception);
10525 method=UndefinedInterpolatePixel;
10526 if (attribute_flag[9] != 0)
10527 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10528 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10529 draw_info=DestroyDrawInfo(draw_info);
10530 if (caption != (char *) NULL)
10531 caption=DestroyString(caption);
10534 case 111: /* FloodfillPaint */
10545 draw_info=CloneDrawInfo(info ? info->image_info :
10546 (ImageInfo *) NULL,(DrawInfo *) NULL);
10547 if (attribute_flag[0] != 0)
10548 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10549 &geometry,exception);
10550 if (attribute_flag[1] != 0)
10551 geometry.x=argument_list[1].integer_reference;
10552 if (attribute_flag[2] != 0)
10553 geometry.y=argument_list[2].integer_reference;
10554 if (attribute_flag[3] != 0)
10555 (void) QueryColorCompliance(argument_list[3].string_reference,
10556 AllCompliance,&draw_info->fill,exception);
10557 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10558 geometry.x,geometry.y,&target,exception);
10559 if (attribute_flag[4] != 0)
10560 QueryColorCompliance(argument_list[4].string_reference,
10561 AllCompliance,&target,exception);
10562 if (attribute_flag[5] != 0)
10563 image->fuzz=StringToDoubleInterval(
10564 argument_list[5].string_reference,(double) QuantumRange+1.0);
10565 if (attribute_flag[6] != 0)
10566 channel=(ChannelType) argument_list[6].integer_reference;
10567 invert=MagickFalse;
10568 if (attribute_flag[7] != 0)
10569 invert=(MagickBooleanType) argument_list[7].integer_reference;
10570 channel_mask=SetImageChannelMask(image,channel);
10571 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10572 geometry.y,invert,exception);
10573 (void) SetImageChannelMask(image,channel_mask);
10574 draw_info=DestroyDrawInfo(draw_info);
10577 case 112: /* Distort */
10589 number_coordinates;
10594 if (attribute_flag[0] == 0)
10596 method=UndefinedDistortion;
10597 if (attribute_flag[1] != 0)
10598 method=(DistortImageMethod) argument_list[1].integer_reference;
10599 av=(AV *) argument_list[0].array_reference;
10600 number_coordinates=(size_t) av_len(av)+1;
10601 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10602 sizeof(*coordinates));
10603 if (coordinates == (double *) NULL)
10605 ThrowPerlException(exception,ResourceLimitFatalError,
10606 "MemoryAllocationFailed",PackageName);
10607 goto PerlException;
10609 for (j=0; j < (ssize_t) number_coordinates; j++)
10610 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10611 virtual_pixel=UndefinedVirtualPixelMethod;
10612 if (attribute_flag[2] != 0)
10613 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10614 argument_list[2].integer_reference,exception);
10615 image=DistortImage(image,method,number_coordinates,coordinates,
10616 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10618 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10619 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10621 coordinates=(double *) RelinquishMagickMemory(coordinates);
10624 case 113: /* Clut */
10626 PixelInterpolateMethod
10629 if (attribute_flag[0] == 0)
10631 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10633 goto PerlException;
10635 method=UndefinedInterpolatePixel;
10636 if (attribute_flag[1] != 0)
10637 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10638 if (attribute_flag[2] != 0)
10639 channel=(ChannelType) argument_list[2].integer_reference;
10640 channel_mask=SetImageChannelMask(image,channel);
10641 (void) ClutImage(image,argument_list[0].image_reference,method,
10643 (void) SetImageChannelMask(image,channel_mask);
10646 case 114: /* LiquidRescale */
10648 if (attribute_flag[0] != 0)
10649 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10650 &geometry,exception);
10651 if (attribute_flag[1] != 0)
10652 geometry.width=argument_list[1].integer_reference;
10653 if (attribute_flag[2] != 0)
10654 geometry.height=argument_list[2].integer_reference;
10655 if (attribute_flag[3] == 0)
10656 argument_list[3].real_reference=1.0;
10657 if (attribute_flag[4] == 0)
10658 argument_list[4].real_reference=0.0;
10659 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10660 argument_list[3].real_reference,argument_list[4].real_reference,
10664 case 115: /* EncipherImage */
10666 (void) EncipherImage(image,argument_list[0].string_reference,
10670 case 116: /* DecipherImage */
10672 (void) DecipherImage(image,argument_list[0].string_reference,
10676 case 117: /* Deskew */
10678 geometry_info.rho=QuantumRange/2.0;
10679 if (attribute_flag[0] != 0)
10680 flags=ParseGeometry(argument_list[0].string_reference,
10682 if (attribute_flag[1] != 0)
10683 geometry_info.rho=StringToDoubleInterval(
10684 argument_list[1].string_reference,(double) QuantumRange+1.0);
10685 image=DeskewImage(image,geometry_info.rho,exception);
10688 case 118: /* Remap */
10693 if (attribute_flag[0] == 0)
10695 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10697 goto PerlException;
10699 quantize_info=AcquireQuantizeInfo(info->image_info);
10700 if (attribute_flag[1] != 0)
10701 quantize_info->dither_method=(DitherMethod)
10702 argument_list[1].integer_reference;
10703 (void) RemapImages(quantize_info,image,
10704 argument_list[0].image_reference,exception);
10705 quantize_info=DestroyQuantizeInfo(quantize_info);
10708 case 119: /* SparseColor */
10720 number_coordinates;
10725 if (attribute_flag[0] == 0)
10727 method=UndefinedColorInterpolate;
10728 if (attribute_flag[1] != 0)
10729 method=(SparseColorMethod) argument_list[1].integer_reference;
10730 av=(AV *) argument_list[0].array_reference;
10731 number_coordinates=(size_t) av_len(av)+1;
10732 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10733 sizeof(*coordinates));
10734 if (coordinates == (double *) NULL)
10736 ThrowPerlException(exception,ResourceLimitFatalError,
10737 "MemoryAllocationFailed",PackageName);
10738 goto PerlException;
10740 for (j=0; j < (ssize_t) number_coordinates; j++)
10741 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10742 virtual_pixel=UndefinedVirtualPixelMethod;
10743 if (attribute_flag[2] != 0)
10744 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10745 argument_list[2].integer_reference,exception);
10746 if (attribute_flag[3] != 0)
10747 channel=(ChannelType) argument_list[3].integer_reference;
10748 channel_mask=SetImageChannelMask(image,channel);
10749 image=SparseColorImage(image,method,number_coordinates,coordinates,
10751 if (image != (Image *) NULL)
10752 (void) SetImageChannelMask(image,channel_mask);
10753 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10754 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10756 coordinates=(double *) RelinquishMagickMemory(coordinates);
10759 case 120: /* Function */
10776 if (attribute_flag[0] == 0)
10778 function=UndefinedFunction;
10779 if (attribute_flag[1] != 0)
10780 function=(MagickFunction) argument_list[1].integer_reference;
10781 av=(AV *) argument_list[0].array_reference;
10782 number_parameters=(size_t) av_len(av)+1;
10783 parameters=(double *) AcquireQuantumMemory(number_parameters,
10784 sizeof(*parameters));
10785 if (parameters == (double *) NULL)
10787 ThrowPerlException(exception,ResourceLimitFatalError,
10788 "MemoryAllocationFailed",PackageName);
10789 goto PerlException;
10791 for (j=0; j < (ssize_t) number_parameters; j++)
10792 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10793 virtual_pixel=UndefinedVirtualPixelMethod;
10794 if (attribute_flag[2] != 0)
10795 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10796 argument_list[2].integer_reference,exception);
10797 (void) FunctionImage(image,function,number_parameters,parameters,
10799 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10800 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10802 parameters=(double *) RelinquishMagickMemory(parameters);
10805 case 121: /* SelectiveBlur */
10807 if (attribute_flag[0] != 0)
10809 flags=ParseGeometry(argument_list[0].string_reference,
10811 if ((flags & SigmaValue) == 0)
10812 geometry_info.sigma=1.0;
10813 if ((flags & PercentValue) != 0)
10814 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10816 if (attribute_flag[1] != 0)
10817 geometry_info.rho=argument_list[1].real_reference;
10818 if (attribute_flag[2] != 0)
10819 geometry_info.sigma=argument_list[2].real_reference;
10820 if (attribute_flag[3] != 0)
10821 geometry_info.xi=argument_list[3].integer_reference;;
10822 if (attribute_flag[5] != 0)
10823 channel=(ChannelType) argument_list[5].integer_reference;
10824 channel_mask=SetImageChannelMask(image,channel);
10825 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10826 geometry_info.xi,exception);
10827 if (image != (Image *) NULL)
10828 (void) SetImageChannelMask(image,channel_mask);
10831 case 122: /* HaldClut */
10833 if (attribute_flag[0] == 0)
10835 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10837 goto PerlException;
10839 if (attribute_flag[1] != 0)
10840 channel=(ChannelType) argument_list[1].integer_reference;
10841 channel_mask=SetImageChannelMask(image,channel);
10842 (void) HaldClutImage(image,argument_list[0].image_reference,
10844 (void) SetImageChannelMask(image,channel_mask);
10847 case 123: /* BlueShift */
10849 if (attribute_flag[0] != 0)
10850 (void) ParseGeometry(argument_list[0].string_reference,
10852 image=BlueShiftImage(image,geometry_info.rho,exception);
10855 case 124: /* ForwardFourierTransformImage */
10857 image=ForwardFourierTransformImage(image,
10858 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10862 case 125: /* InverseFourierTransformImage */
10864 image=InverseFourierTransformImage(image,image->next,
10865 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10869 case 126: /* ColorDecisionList */
10871 if (attribute_flag[0] == 0)
10872 argument_list[0].string_reference=(char *) NULL;
10873 (void) ColorDecisionListImage(image,
10874 argument_list[0].string_reference,exception);
10877 case 127: /* AutoGamma */
10879 if (attribute_flag[0] != 0)
10880 channel=(ChannelType) argument_list[0].integer_reference;
10881 channel_mask=SetImageChannelMask(image,channel);
10882 (void) AutoGammaImage(image,exception);
10883 (void) SetImageChannelMask(image,channel_mask);
10886 case 128: /* AutoLevel */
10888 if (attribute_flag[0] != 0)
10889 channel=(ChannelType) argument_list[0].integer_reference;
10890 channel_mask=SetImageChannelMask(image,channel);
10891 (void) AutoLevelImage(image,exception);
10892 (void) SetImageChannelMask(image,channel_mask);
10895 case 129: /* LevelColors */
10901 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10903 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10905 if (attribute_flag[1] != 0)
10906 (void) QueryColorCompliance(
10907 argument_list[1].string_reference,AllCompliance,&black_point,
10909 if (attribute_flag[2] != 0)
10910 (void) QueryColorCompliance(
10911 argument_list[2].string_reference,AllCompliance,&white_point,
10913 if (attribute_flag[3] != 0)
10914 channel=(ChannelType) argument_list[3].integer_reference;
10915 channel_mask=SetImageChannelMask(image,channel);
10916 (void) LevelImageColors(image,&black_point,&white_point,
10917 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10919 (void) SetImageChannelMask(image,channel_mask);
10922 case 130: /* Clamp */
10924 if (attribute_flag[0] != 0)
10925 channel=(ChannelType) argument_list[0].integer_reference;
10926 channel_mask=SetImageChannelMask(image,channel);
10927 (void) ClampImage(image,exception);
10928 (void) SetImageChannelMask(image,channel_mask);
10931 case 131: /* BrightnessContrast */
10939 if (attribute_flag[0] != 0)
10941 flags=ParseGeometry(argument_list[0].string_reference,
10943 brightness=geometry_info.rho;
10944 if ((flags & SigmaValue) == 0)
10945 contrast=geometry_info.sigma;
10947 if (attribute_flag[1] != 0)
10948 brightness=argument_list[1].real_reference;
10949 if (attribute_flag[2] != 0)
10950 contrast=argument_list[2].real_reference;
10951 if (attribute_flag[4] != 0)
10952 channel=(ChannelType) argument_list[4].integer_reference;
10953 channel_mask=SetImageChannelMask(image,channel);
10954 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10955 (void) SetImageChannelMask(image,channel_mask);
10958 case 132: /* Morphology */
10969 if (attribute_flag[0] == 0)
10971 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10972 if (kernel == (KernelInfo *) NULL)
10974 if (attribute_flag[1] != 0)
10975 channel=(ChannelType) argument_list[1].integer_reference;
10976 method=UndefinedMorphology;
10977 if (attribute_flag[2] != 0)
10978 method=argument_list[2].integer_reference;
10980 if (attribute_flag[3] != 0)
10981 iterations=argument_list[3].integer_reference;
10982 channel_mask=SetImageChannelMask(image,channel);
10983 image=MorphologyImage(image,method,iterations,kernel,exception);
10984 if (image != (Image *) NULL)
10985 (void) SetImageChannelMask(image,channel_mask);
10986 kernel=DestroyKernelInfo(kernel);
10989 case 133: /* Mode */
10991 if (attribute_flag[0] != 0)
10993 flags=ParseGeometry(argument_list[0].string_reference,
10995 if ((flags & SigmaValue) == 0)
10996 geometry_info.sigma=1.0;
10998 if (attribute_flag[1] != 0)
10999 geometry_info.rho=argument_list[1].real_reference;
11000 if (attribute_flag[2] != 0)
11001 geometry_info.sigma=argument_list[2].real_reference;
11002 if (attribute_flag[3] != 0)
11003 channel=(ChannelType) argument_list[3].integer_reference;
11004 channel_mask=SetImageChannelMask(image,channel);
11005 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11006 (size_t) geometry_info.sigma,exception);
11007 if (image != (Image *) NULL)
11008 (void) SetImageChannelMask(image,channel_mask);
11011 case 134: /* Statistic */
11016 statistic=UndefinedStatistic;
11017 if (attribute_flag[0] != 0)
11019 flags=ParseGeometry(argument_list[0].string_reference,
11021 if ((flags & SigmaValue) == 0)
11022 geometry_info.sigma=1.0;
11024 if (attribute_flag[1] != 0)
11025 geometry_info.rho=argument_list[1].real_reference;
11026 if (attribute_flag[2] != 0)
11027 geometry_info.sigma=argument_list[2].real_reference;
11028 if (attribute_flag[3] != 0)
11029 channel=(ChannelType) argument_list[3].integer_reference;
11030 if (attribute_flag[4] != 0)
11031 statistic=(StatisticType) argument_list[4].integer_reference;
11032 channel_mask=SetImageChannelMask(image,channel);
11033 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11034 (size_t) geometry_info.sigma,exception);
11035 if (image != (Image *) NULL)
11036 (void) SetImageChannelMask(image,channel_mask);
11039 case 135: /* Perceptible */
11044 epsilon=MagickEpsilon;
11045 if (attribute_flag[0] != 0)
11046 epsilon=argument_list[0].real_reference;
11047 if (attribute_flag[1] != 0)
11048 channel=(ChannelType) argument_list[1].integer_reference;
11049 channel_mask=SetImageChannelMask(image,channel);
11050 (void) PerceptibleImage(image,epsilon,exception);
11051 (void) SetImageChannelMask(image,channel_mask);
11054 case 136: /* Poly */
11065 if (attribute_flag[0] == 0)
11067 if (attribute_flag[1] != 0)
11068 channel=(ChannelType) argument_list[1].integer_reference;
11069 av=(AV *) argument_list[0].array_reference;
11070 number_terms=(size_t) av_len(av);
11071 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11072 if (terms == (double *) NULL)
11074 ThrowPerlException(exception,ResourceLimitFatalError,
11075 "MemoryAllocationFailed",PackageName);
11076 goto PerlException;
11078 for (j=0; j < av_len(av); j++)
11079 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11080 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11081 terms=(double *) RelinquishMagickMemory(terms);
11084 case 137: /* Grayscale */
11086 PixelIntensityMethod
11089 method=UndefinedPixelIntensityMethod;
11090 if (attribute_flag[0] != 0)
11091 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11092 (void) GrayscaleImage(image,method,exception);
11096 if (next != (Image *) NULL)
11097 (void) CatchImageException(next);
11098 if (region_image != (Image *) NULL)
11103 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11104 region_info.x,region_info.y,exception);
11106 (void) CatchImageException(region_image);
11107 image=DestroyImage(image);
11108 image=region_image;
11110 if (image != (Image *) NULL)
11113 if (next && (next != image))
11115 image->next=next->next;
11116 if (image->next != (Image *) NULL)
11117 image->next->previous=image;
11118 DeleteImageFromRegistry(*pv,next);
11120 sv_setiv(*pv,PTR2IV(image));
11128 if (reference_vector)
11129 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11130 InheritPerlException(exception,perl_exception);
11131 exception=DestroyExceptionInfo(exception);
11132 sv_setiv(perl_exception,(IV) number_images);
11133 SvPOK_on(perl_exception);
11134 ST(0)=sv_2mortal(perl_exception);
11139 ###############################################################################
11147 ###############################################################################
11152 Image::Magick ref=NO_INIT
11197 PERL_UNUSED_VAR(ref);
11198 PERL_UNUSED_VAR(ix);
11199 exception=AcquireExceptionInfo();
11200 perl_exception=newSVpv("",0);
11203 if (sv_isobject(ST(0)) == 0)
11205 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11207 goto PerlException;
11209 reference=SvRV(ST(0));
11210 hv=SvSTASH(reference);
11212 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11214 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11215 if (image == (Image *) NULL)
11217 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11219 goto PerlException;
11224 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11225 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11226 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11228 for (i=2; i < items; i+=2)
11230 attribute=(char *) SvPV(ST(i-1),na);
11231 switch (*attribute)
11236 if (LocaleCompare(attribute,"background") == 0)
11238 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11239 &montage_info->background_color,exception);
11240 for (next=image; next; next=next->next)
11241 next->background_color=montage_info->background_color;
11244 if (LocaleCompare(attribute,"border") == 0)
11246 montage_info->border_width=SvIV(ST(i));
11249 if (LocaleCompare(attribute,"bordercolor") == 0)
11251 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11252 &montage_info->border_color,exception);
11253 for (next=image; next; next=next->next)
11254 next->border_color=montage_info->border_color;
11257 if (LocaleCompare(attribute,"borderwidth") == 0)
11259 montage_info->border_width=SvIV(ST(i));
11262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11269 if (LocaleCompare(attribute,"compose") == 0)
11271 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11272 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11275 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11279 for (next=image; next; next=next->next)
11280 next->compose=(CompositeOperator) sp;
11283 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11290 if (LocaleCompare(attribute,"fill") == 0)
11292 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11293 &montage_info->fill,exception);
11296 if (LocaleCompare(attribute,"font") == 0)
11298 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11301 if (LocaleCompare(attribute,"frame") == 0)
11307 if (IsGeometry(p) == MagickFalse)
11309 ThrowPerlException(exception,OptionError,"MissingGeometry",
11313 (void) CloneString(&montage_info->frame,p);
11315 montage_info->frame=(char *) NULL;
11318 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11325 if (LocaleCompare(attribute,"geometry") == 0)
11331 if (IsGeometry(p) == MagickFalse)
11333 ThrowPerlException(exception,OptionError,"MissingGeometry",
11337 (void) CloneString(&montage_info->geometry,p);
11339 montage_info->geometry=(char *) NULL;
11342 if (LocaleCompare(attribute,"gravity") == 0)
11347 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11348 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11351 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11355 montage_info->gravity=(GravityType) in;
11356 for (next=image; next; next=next->next)
11357 next->gravity=(GravityType) in;
11360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11367 if (LocaleCompare(attribute,"label") == 0)
11369 for (next=image; next; next=next->next)
11370 (void) SetImageProperty(next,"label",InterpretImageProperties(
11371 info ? info->image_info : (ImageInfo *) NULL,next,
11372 SvPV(ST(i),na),exception),exception);
11375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11382 if (LocaleCompare(attribute,"mattecolor") == 0)
11384 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11385 &montage_info->matte_color,exception);
11386 for (next=image; next; next=next->next)
11387 next->matte_color=montage_info->matte_color;
11390 if (LocaleCompare(attribute,"mode") == 0)
11395 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11396 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11401 ThrowPerlException(exception,OptionError,
11402 "UnrecognizedModeType",SvPV(ST(i),na));
11407 (void) CloneString(&montage_info->frame,"15x15+3+3");
11408 montage_info->shadow=MagickTrue;
11413 montage_info->frame=(char *) NULL;
11414 montage_info->shadow=MagickFalse;
11415 montage_info->border_width=0;
11418 case ConcatenateMode:
11420 montage_info->frame=(char *) NULL;
11421 montage_info->shadow=MagickFalse;
11422 (void) CloneString(&montage_info->geometry,"+0+0");
11423 montage_info->border_width=0;
11428 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11435 if (LocaleCompare(attribute,"pointsize") == 0)
11437 montage_info->pointsize=SvIV(ST(i));
11440 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11447 if (LocaleCompare(attribute,"shadow") == 0)
11449 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11450 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11453 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11457 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11460 if (LocaleCompare(attribute,"stroke") == 0)
11462 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11463 &montage_info->stroke,exception);
11466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11473 if (LocaleCompare(attribute,"texture") == 0)
11475 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11478 if (LocaleCompare(attribute,"tile") == 0)
11480 char *p=SvPV(ST(i),na);
11481 if (IsGeometry(p) == MagickFalse)
11483 ThrowPerlException(exception,OptionError,"MissingGeometry",
11487 (void) CloneString(&montage_info->tile,p);
11489 montage_info->tile=(char *) NULL;
11492 if (LocaleCompare(attribute,"title") == 0)
11494 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11497 if (LocaleCompare(attribute,"transparent") == 0)
11502 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11503 &transparent_color,exception);
11504 for (next=image; next; next=next->next)
11505 (void) TransparentPaintImage(next,&transparent_color,
11506 TransparentAlpha,MagickFalse,exception);
11509 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11515 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11521 image=MontageImageList(info->image_info,montage_info,image,exception);
11522 montage_info=DestroyMontageInfo(montage_info);
11523 if (image == (Image *) NULL)
11524 goto PerlException;
11525 if (transparent_color.alpha != TransparentAlpha)
11526 for (next=image; next; next=next->next)
11527 (void) TransparentPaintImage(next,&transparent_color,
11528 TransparentAlpha,MagickFalse,exception);
11529 for ( ; image; image=image->next)
11531 AddImageToRegistry(sv,image);
11533 av_push(av,sv_bless(rv,hv));
11536 exception=DestroyExceptionInfo(exception);
11537 ST(0)=av_reference;
11538 SvREFCNT_dec(perl_exception);
11542 InheritPerlException(exception,perl_exception);
11543 exception=DestroyExceptionInfo(exception);
11544 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11545 SvPOK_on(perl_exception);
11546 ST(0)=sv_2mortal(perl_exception);
11551 ###############################################################################
11559 ###############################################################################
11564 Image::Magick ref=NO_INIT
11602 PERL_UNUSED_VAR(ref);
11603 PERL_UNUSED_VAR(ix);
11604 exception=AcquireExceptionInfo();
11605 perl_exception=newSVpv("",0);
11609 if (sv_isobject(ST(0)) == 0)
11611 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11613 goto PerlException;
11615 reference=SvRV(ST(0));
11616 hv=SvSTASH(reference);
11618 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11620 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11621 if (image == (Image *) NULL)
11623 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11625 goto PerlException;
11627 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11632 for (i=2; i < items; i+=2)
11634 attribute=(char *) SvPV(ST(i-1),na);
11635 switch (*attribute)
11640 if (LocaleCompare(attribute,"frames") == 0)
11642 number_frames=SvIV(ST(i));
11645 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11651 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11657 image=MorphImages(image,number_frames,exception);
11658 if (image == (Image *) NULL)
11659 goto PerlException;
11660 for ( ; image; image=image->next)
11662 AddImageToRegistry(sv,image);
11664 av_push(av,sv_bless(rv,hv));
11667 exception=DestroyExceptionInfo(exception);
11668 ST(0)=av_reference;
11669 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11673 InheritPerlException(exception,perl_exception);
11674 exception=DestroyExceptionInfo(exception);
11675 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11676 SvPOK_on(perl_exception);
11677 ST(0)=sv_2mortal(perl_exception);
11682 ###############################################################################
11690 ###############################################################################
11695 Image::Magick ref=NO_INIT
11723 PERL_UNUSED_VAR(ref);
11724 PERL_UNUSED_VAR(ix);
11725 exception=AcquireExceptionInfo();
11726 perl_exception=newSVpv("",0);
11728 if (sv_isobject(ST(0)) == 0)
11730 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11732 goto PerlException;
11734 reference=SvRV(ST(0));
11735 hv=SvSTASH(reference);
11736 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11737 if (image == (Image *) NULL)
11739 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11741 goto PerlException;
11743 image=MergeImageLayers(image,MosaicLayer,exception);
11745 Create blessed Perl array for the returned image.
11748 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11750 AddImageToRegistry(sv,image);
11752 av_push(av,sv_bless(rv,hv));
11754 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11755 (void) CopyMagickString(info->image_info->filename,image->filename,
11757 SetImageInfo(info->image_info,0,exception);
11758 exception=DestroyExceptionInfo(exception);
11759 SvREFCNT_dec(perl_exception);
11763 InheritPerlException(exception,perl_exception);
11764 exception=DestroyExceptionInfo(exception);
11765 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11766 SvPOK_on(perl_exception); /* return messages in string context */
11767 ST(0)=sv_2mortal(perl_exception);
11772 ###############################################################################
11780 ###############################################################################
11785 Image::Magick ref=NO_INIT
11835 PERL_UNUSED_VAR(ref);
11836 PERL_UNUSED_VAR(ix);
11837 exception=AcquireExceptionInfo();
11838 perl_exception=newSVpv("",0);
11839 package_info=(struct PackageInfo *) NULL;
11840 ac=(items < 2) ? 1 : items-1;
11841 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11843 length=(STRLEN *) NULL;
11844 if (list == (char **) NULL)
11846 ThrowPerlException(exception,ResourceLimitError,
11847 "MemoryAllocationFailed",PackageName);
11848 goto PerlException;
11851 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11852 if (length == (STRLEN *) NULL)
11854 ThrowPerlException(exception,ResourceLimitError,
11855 "MemoryAllocationFailed",PackageName);
11856 goto PerlException;
11858 if (sv_isobject(ST(0)) == 0)
11860 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11862 goto PerlException;
11864 reference=SvRV(ST(0));
11865 if (SvTYPE(reference) != SVt_PVAV)
11867 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11869 goto PerlException;
11871 av=(AV *) reference;
11872 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11874 package_info=ClonePackageInfo(info,exception);
11877 *list=(char *) (*package_info->image_info->filename ?
11878 package_info->image_info->filename : "XC:black");
11880 for (n=0, i=0; i < ac; i++)
11882 list[n]=(char *) SvPV(ST(i+1),length[n]);
11883 if ((items >= 3) && strEQcase(list[n],"blob"))
11889 blob=(void *) (SvPV(ST(i+1),length[n]));
11890 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11892 if ((items >= 3) && strEQcase(list[n],"filename"))
11894 if ((items >= 3) && strEQcase(list[n],"file"))
11903 io_info=IoIFP(sv_2io(ST(i+1)));
11904 if (io_info == (PerlIO *) NULL)
11906 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11910 file=PerlIO_findFILE(io_info);
11911 if (file == (FILE *) NULL)
11913 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11917 SetImageInfoFile(package_info->image_info,file);
11919 if ((items >= 3) && strEQcase(list[n],"magick"))
11923 list[n]=(char *) NULL;
11925 status=ExpandFilenames(&n,&list);
11926 if (status == MagickFalse)
11928 ThrowPerlException(exception,ResourceLimitError,
11929 "MemoryAllocationFailed",PackageName);
11930 goto PerlException;
11933 for (i=0; i < n; i++)
11935 (void) CopyMagickString(package_info->image_info->filename,list[i],
11937 image=PingImage(package_info->image_info,exception);
11938 if (image == (Image *) NULL)
11940 if ((package_info->image_info->file != (FILE *) NULL) ||
11941 (package_info->image_info->blob != (void *) NULL))
11942 DisassociateImageStream(image);
11943 count+=GetImageListLength(image);
11944 EXTEND(sp,4*count);
11945 for (next=image; next; next=next->next)
11947 PUSHs(sv_2mortal(newSViv(next->columns)));
11948 PUSHs(sv_2mortal(newSViv(next->rows)));
11949 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11950 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11952 image=DestroyImageList(image);
11957 for (i=0; i < n; i++)
11958 if (list[i] != (char *) NULL)
11959 for (p=keep; list[i] != *p++; )
11962 list[i]=(char *) RelinquishMagickMemory(list[i]);
11967 if (package_info != (struct PackageInfo *) NULL)
11968 DestroyPackageInfo(package_info);
11969 if (list && (list != keep))
11970 list=(char **) RelinquishMagickMemory(list);
11972 keep=(char **) RelinquishMagickMemory(keep);
11974 length=(STRLEN *) RelinquishMagickMemory(length);
11975 InheritPerlException(exception,perl_exception);
11976 exception=DestroyExceptionInfo(exception);
11977 SvREFCNT_dec(perl_exception); /* throw away all errors */
11981 ###############################################################################
11989 ###############################################################################
11994 Image::Magick ref=NO_INIT
12027 PERL_UNUSED_VAR(ref);
12028 PERL_UNUSED_VAR(ix);
12029 exception=AcquireExceptionInfo();
12030 perl_exception=newSVpv("",0);
12033 if (sv_isobject(ST(0)) == 0)
12035 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12037 goto PerlException;
12039 reference=SvRV(ST(0));
12040 hv=SvSTASH(reference);
12042 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12044 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12045 if (image == (Image *) NULL)
12047 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12049 goto PerlException;
12051 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12052 preview_type=GammaPreview;
12054 preview_type=(PreviewType)
12055 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12056 for ( ; image; image=image->next)
12058 preview_image=PreviewImage(image,preview_type,exception);
12059 if (preview_image == (Image *) NULL)
12060 goto PerlException;
12061 AddImageToRegistry(sv,preview_image);
12063 av_push(av,sv_bless(rv,hv));
12066 exception=DestroyExceptionInfo(exception);
12067 ST(0)=av_reference;
12068 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12072 InheritPerlException(exception,perl_exception);
12073 exception=DestroyExceptionInfo(exception);
12074 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12075 SvPOK_on(perl_exception);
12076 ST(0)=sv_2mortal(perl_exception);
12081 ###############################################################################
12085 # Q u e r y C o l o r #
12089 ###############################################################################
12093 QueryColor(ref,...)
12094 Image::Magick ref=NO_INIT
12114 PERL_UNUSED_VAR(ref);
12115 PERL_UNUSED_VAR(ix);
12116 exception=AcquireExceptionInfo();
12117 perl_exception=newSVpv("",0);
12126 colorlist=GetColorInfoList("*",&colors,exception);
12128 for (i=0; i < (ssize_t) colors; i++)
12130 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12132 colorlist=(const ColorInfo **)
12133 RelinquishMagickMemory((ColorInfo **) colorlist);
12134 goto PerlException;
12136 EXTEND(sp,5*items);
12137 for (i=1; i < items; i++)
12139 name=(char *) SvPV(ST(i),na);
12140 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12145 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12146 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12147 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12148 if (color.colorspace == CMYKColorspace)
12149 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12150 if (color.alpha_trait == BlendPixelTrait)
12151 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12155 InheritPerlException(exception,perl_exception);
12156 exception=DestroyExceptionInfo(exception);
12157 SvREFCNT_dec(perl_exception);
12161 ###############################################################################
12165 # Q u e r y C o l o r N a m e #
12169 ###############################################################################
12173 QueryColorname(ref,...)
12174 Image::Magick ref=NO_INIT
12183 message[MaxTextExtent];
12202 *reference; /* reference is the SV* of ref=SvIV(reference) */
12204 PERL_UNUSED_VAR(ref);
12205 PERL_UNUSED_VAR(ix);
12206 exception=AcquireExceptionInfo();
12207 perl_exception=newSVpv("",0);
12208 reference=SvRV(ST(0));
12209 av=(AV *) reference;
12210 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12212 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12213 if (image == (Image *) NULL)
12215 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12217 goto PerlException;
12220 for (i=1; i < items; i++)
12222 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12224 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12226 PUSHs(sv_2mortal(newSVpv(message,0)));
12230 InheritPerlException(exception,perl_exception);
12231 exception=DestroyExceptionInfo(exception);
12232 SvREFCNT_dec(perl_exception);
12236 ###############################################################################
12240 # Q u e r y F o n t #
12244 ###############################################################################
12249 Image::Magick ref=NO_INIT
12256 message[MaxTextExtent];
12267 volatile const TypeInfo
12270 PERL_UNUSED_VAR(ref);
12271 PERL_UNUSED_VAR(ix);
12272 exception=AcquireExceptionInfo();
12273 perl_exception=newSVpv("",0);
12282 typelist=GetTypeInfoList("*",&types,exception);
12284 for (i=0; i < (ssize_t) types; i++)
12286 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12288 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12290 goto PerlException;
12292 EXTEND(sp,10*items);
12293 for (i=1; i < items; i++)
12295 name=(char *) SvPV(ST(i),na);
12296 type_info=GetTypeInfo(name,exception);
12297 if (type_info == (TypeInfo *) NULL)
12302 if (type_info->name == (char *) NULL)
12305 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12306 if (type_info->description == (char *) NULL)
12309 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12310 if (type_info->family == (char *) NULL)
12313 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12314 if (type_info->style == UndefinedStyle)
12317 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12318 type_info->style),0)));
12319 if (type_info->stretch == UndefinedStretch)
12322 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12323 type_info->stretch),0)));
12324 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12325 type_info->weight);
12326 PUSHs(sv_2mortal(newSVpv(message,0)));
12327 if (type_info->encoding == (char *) NULL)
12330 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12331 if (type_info->foundry == (char *) NULL)
12334 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12335 if (type_info->format == (char *) NULL)
12338 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12339 if (type_info->metrics == (char *) NULL)
12342 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12343 if (type_info->glyphs == (char *) NULL)
12346 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12350 InheritPerlException(exception,perl_exception);
12351 exception=DestroyExceptionInfo(exception);
12352 SvREFCNT_dec(perl_exception);
12356 ###############################################################################
12360 # Q u e r y F o n t M e t r i c s #
12364 ###############################################################################
12368 QueryFontMetrics(ref,...)
12369 Image::Magick ref=NO_INIT
12371 queryfontmetrics = 1
12418 *reference; /* reference is the SV* of ref=SvIV(reference) */
12423 PERL_UNUSED_VAR(ref);
12424 PERL_UNUSED_VAR(ix);
12425 exception=AcquireExceptionInfo();
12426 package_info=(struct PackageInfo *) NULL;
12427 perl_exception=newSVpv("",0);
12428 reference=SvRV(ST(0));
12429 av=(AV *) reference;
12430 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12432 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12433 if (image == (Image *) NULL)
12435 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12437 goto PerlException;
12439 package_info=ClonePackageInfo(info,exception);
12440 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12441 CloneString(&draw_info->text,"");
12442 current=draw_info->affine;
12443 GetAffineMatrix(&affine);
12446 EXTEND(sp,7*items);
12447 for (i=2; i < items; i+=2)
12449 attribute=(char *) SvPV(ST(i-1),na);
12450 switch (*attribute)
12455 if (LocaleCompare(attribute,"antialias") == 0)
12457 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12461 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12465 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12468 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12475 if (LocaleCompare(attribute,"density") == 0)
12477 CloneString(&draw_info->density,SvPV(ST(i),na));
12480 if (LocaleCompare(attribute,"direction") == 0)
12482 draw_info->direction=(DirectionType) ParseCommandOption(
12483 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12486 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12493 if (LocaleCompare(attribute,"encoding") == 0)
12495 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12498 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12505 if (LocaleCompare(attribute,"family") == 0)
12507 CloneString(&draw_info->family,SvPV(ST(i),na));
12510 if (LocaleCompare(attribute,"fill") == 0)
12513 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12514 &draw_info->fill,exception);
12517 if (LocaleCompare(attribute,"font") == 0)
12519 CloneString(&draw_info->font,SvPV(ST(i),na));
12522 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12529 if (LocaleCompare(attribute,"geometry") == 0)
12531 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12534 if (LocaleCompare(attribute,"gravity") == 0)
12536 draw_info->gravity=(GravityType) ParseCommandOption(
12537 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12547 if (LocaleCompare(attribute,"interline-spacing") == 0)
12549 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12550 draw_info->interline_spacing=geometry_info.rho;
12553 if (LocaleCompare(attribute,"interword-spacing") == 0)
12555 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12556 draw_info->interword_spacing=geometry_info.rho;
12559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12566 if (LocaleCompare(attribute,"kerning") == 0)
12568 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12569 draw_info->kerning=geometry_info.rho;
12572 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12579 if (LocaleCompare(attribute,"pointsize") == 0)
12581 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12582 draw_info->pointsize=geometry_info.rho;
12585 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12592 if (LocaleCompare(attribute,"rotate") == 0)
12594 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12595 affine.rx=geometry_info.rho;
12596 affine.ry=geometry_info.sigma;
12597 if ((flags & SigmaValue) == 0)
12598 affine.ry=affine.rx;
12601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12608 if (LocaleCompare(attribute,"scale") == 0)
12610 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12611 affine.sx=geometry_info.rho;
12612 affine.sy=geometry_info.sigma;
12613 if ((flags & SigmaValue) == 0)
12614 affine.sy=affine.sx;
12617 if (LocaleCompare(attribute,"skew") == 0)
12623 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12624 x_angle=geometry_info.rho;
12625 y_angle=geometry_info.sigma;
12626 if ((flags & SigmaValue) == 0)
12628 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12629 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12632 if (LocaleCompare(attribute,"stroke") == 0)
12635 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12636 &draw_info->stroke,exception);
12639 if (LocaleCompare(attribute,"style") == 0)
12641 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12645 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12649 draw_info->style=(StyleType) type;
12652 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12659 if (LocaleCompare(attribute,"text") == 0)
12661 CloneString(&draw_info->text,SvPV(ST(i),na));
12664 if (LocaleCompare(attribute,"translate") == 0)
12666 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12667 affine.tx=geometry_info.rho;
12668 affine.ty=geometry_info.sigma;
12669 if ((flags & SigmaValue) == 0)
12670 affine.ty=affine.tx;
12673 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12680 if (LocaleCompare(attribute,"weight") == 0)
12682 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12683 draw_info->weight=(size_t) geometry_info.rho;
12686 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12693 if (LocaleCompare(attribute,"x") == 0)
12695 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12696 x=geometry_info.rho;
12699 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12706 if (LocaleCompare(attribute,"y") == 0)
12708 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12709 y=geometry_info.rho;
12712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12718 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12724 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12725 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12726 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12727 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12728 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12729 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12730 if (draw_info->geometry == (char *) NULL)
12732 draw_info->geometry=AcquireString((char *) NULL);
12733 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12734 "%.15g,%.15g",x,y);
12736 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12737 (void) CatchImageException(image);
12738 if (status == MagickFalse)
12742 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12743 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12744 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12745 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12746 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12747 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12748 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12749 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12750 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12751 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12752 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12753 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12754 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12756 draw_info=DestroyDrawInfo(draw_info);
12759 if (package_info != (struct PackageInfo *) NULL)
12760 DestroyPackageInfo(package_info);
12761 InheritPerlException(exception,perl_exception);
12762 exception=DestroyExceptionInfo(exception);
12763 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12767 ###############################################################################
12771 # 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 #
12775 ###############################################################################
12779 QueryMultilineFontMetrics(ref,...)
12780 Image::Magick ref=NO_INIT
12782 querymultilinefontmetrics = 1
12829 *reference; /* reference is the SV* of ref=SvIV(reference) */
12834 PERL_UNUSED_VAR(ref);
12835 PERL_UNUSED_VAR(ix);
12836 exception=AcquireExceptionInfo();
12837 package_info=(struct PackageInfo *) NULL;
12838 perl_exception=newSVpv("",0);
12839 reference=SvRV(ST(0));
12840 av=(AV *) reference;
12841 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12843 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12844 if (image == (Image *) NULL)
12846 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12848 goto PerlException;
12850 package_info=ClonePackageInfo(info,exception);
12851 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12852 CloneString(&draw_info->text,"");
12853 current=draw_info->affine;
12854 GetAffineMatrix(&affine);
12857 EXTEND(sp,7*items);
12858 for (i=2; i < items; i+=2)
12860 attribute=(char *) SvPV(ST(i-1),na);
12861 switch (*attribute)
12866 if (LocaleCompare(attribute,"antialias") == 0)
12868 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12872 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12876 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12879 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12886 if (LocaleCompare(attribute,"density") == 0)
12888 CloneString(&draw_info->density,SvPV(ST(i),na));
12891 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12898 if (LocaleCompare(attribute,"encoding") == 0)
12900 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12903 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12910 if (LocaleCompare(attribute,"family") == 0)
12912 CloneString(&draw_info->family,SvPV(ST(i),na));
12915 if (LocaleCompare(attribute,"fill") == 0)
12918 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12919 &draw_info->fill,exception);
12922 if (LocaleCompare(attribute,"font") == 0)
12924 CloneString(&draw_info->font,SvPV(ST(i),na));
12927 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12934 if (LocaleCompare(attribute,"geometry") == 0)
12936 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12939 if (LocaleCompare(attribute,"gravity") == 0)
12941 draw_info->gravity=(GravityType) ParseCommandOption(
12942 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12945 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12952 if (LocaleCompare(attribute,"pointsize") == 0)
12954 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12955 draw_info->pointsize=geometry_info.rho;
12958 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12965 if (LocaleCompare(attribute,"rotate") == 0)
12967 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12968 affine.rx=geometry_info.rho;
12969 affine.ry=geometry_info.sigma;
12970 if ((flags & SigmaValue) == 0)
12971 affine.ry=affine.rx;
12974 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12981 if (LocaleCompare(attribute,"scale") == 0)
12983 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12984 affine.sx=geometry_info.rho;
12985 affine.sy=geometry_info.sigma;
12986 if ((flags & SigmaValue) == 0)
12987 affine.sy=affine.sx;
12990 if (LocaleCompare(attribute,"skew") == 0)
12996 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12997 x_angle=geometry_info.rho;
12998 y_angle=geometry_info.sigma;
12999 if ((flags & SigmaValue) == 0)
13001 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13002 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13005 if (LocaleCompare(attribute,"stroke") == 0)
13008 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13009 &draw_info->stroke,exception);
13012 if (LocaleCompare(attribute,"style") == 0)
13014 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13018 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13022 draw_info->style=(StyleType) type;
13025 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13032 if (LocaleCompare(attribute,"text") == 0)
13034 CloneString(&draw_info->text,SvPV(ST(i),na));
13037 if (LocaleCompare(attribute,"translate") == 0)
13039 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13040 affine.tx=geometry_info.rho;
13041 affine.ty=geometry_info.sigma;
13042 if ((flags & SigmaValue) == 0)
13043 affine.ty=affine.tx;
13046 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13053 if (LocaleCompare(attribute,"weight") == 0)
13055 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13056 draw_info->weight=(size_t) geometry_info.rho;
13059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13066 if (LocaleCompare(attribute,"x") == 0)
13068 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13069 x=geometry_info.rho;
13072 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13079 if (LocaleCompare(attribute,"y") == 0)
13081 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13082 y=geometry_info.rho;
13085 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13097 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13098 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13099 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13100 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13101 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13102 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13103 if (draw_info->geometry == (char *) NULL)
13105 draw_info->geometry=AcquireString((char *) NULL);
13106 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
13107 "%.15g,%.15g",x,y);
13109 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13110 (void) CatchException(exception);
13111 if (status == MagickFalse)
13115 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13116 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13117 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13118 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13119 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13120 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13121 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13122 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13123 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13124 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13125 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13126 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13127 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13129 draw_info=DestroyDrawInfo(draw_info);
13132 if (package_info != (struct PackageInfo *) NULL)
13133 DestroyPackageInfo(package_info);
13134 InheritPerlException(exception,perl_exception);
13135 exception=DestroyExceptionInfo(exception);
13136 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13140 ###############################################################################
13144 # Q u e r y F o r m a t #
13148 ###############################################################################
13152 QueryFormat(ref,...)
13153 Image::Magick ref=NO_INIT
13170 volatile const MagickInfo
13173 PERL_UNUSED_VAR(ref);
13174 PERL_UNUSED_VAR(ix);
13175 exception=AcquireExceptionInfo();
13176 perl_exception=newSVpv("",0);
13180 format[MaxTextExtent];
13188 format_list=GetMagickInfoList("*",&types,exception);
13190 for (i=0; i < (ssize_t) types; i++)
13192 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13193 LocaleLower(format);
13194 PUSHs(sv_2mortal(newSVpv(format,0)));
13196 format_list=(const MagickInfo **)
13197 RelinquishMagickMemory((MagickInfo *) format_list);
13198 goto PerlException;
13200 EXTEND(sp,8*items);
13201 for (i=1; i < items; i++)
13203 name=(char *) SvPV(ST(i),na);
13204 magick_info=GetMagickInfo(name,exception);
13205 if (magick_info == (const MagickInfo *) NULL)
13210 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13211 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13212 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13213 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13214 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13215 if (magick_info->description == (char *) NULL)
13218 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13219 if (magick_info->module == (char *) NULL)
13222 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13226 InheritPerlException(exception,perl_exception);
13227 exception=DestroyExceptionInfo(exception);
13228 SvREFCNT_dec(perl_exception);
13232 ###############################################################################
13236 # Q u e r y O p t i o n #
13240 ###############################################################################
13244 QueryOption(ref,...)
13245 Image::Magick ref=NO_INIT
13266 PERL_UNUSED_VAR(ref);
13267 PERL_UNUSED_VAR(ix);
13268 exception=AcquireExceptionInfo();
13269 perl_exception=newSVpv("",0);
13270 EXTEND(sp,8*items);
13271 for (i=1; i < items; i++)
13273 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13275 options=GetCommandOptions((CommandOption) option);
13276 if (options == (char **) NULL)
13280 for (j=0; options[j] != (char *) NULL; j++)
13281 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13282 options=DestroyStringList(options);
13286 InheritPerlException(exception,perl_exception);
13287 exception=DestroyExceptionInfo(exception);
13288 SvREFCNT_dec(perl_exception);
13292 ###############################################################################
13300 ###############################################################################
13305 Image::Magick ref=NO_INIT
13352 *perl_exception, /* Perl variable for storing messages */
13357 PERL_UNUSED_VAR(ref);
13358 PERL_UNUSED_VAR(ix);
13359 exception=AcquireExceptionInfo();
13360 perl_exception=newSVpv("",0);
13362 package_info=(struct PackageInfo *) NULL;
13364 ac=(items < 2) ? 1 : items-1;
13365 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13367 length=(STRLEN *) NULL;
13368 if (list == (char **) NULL)
13370 ThrowPerlException(exception,ResourceLimitError,
13371 "MemoryAllocationFailed",PackageName);
13372 goto PerlException;
13374 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13375 if (length == (STRLEN *) NULL)
13377 ThrowPerlException(exception,ResourceLimitError,
13378 "MemoryAllocationFailed",PackageName);
13379 goto PerlException;
13381 if (sv_isobject(ST(0)) == 0)
13383 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13385 goto PerlException;
13387 reference=SvRV(ST(0));
13388 hv=SvSTASH(reference);
13389 if (SvTYPE(reference) != SVt_PVAV)
13391 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13393 goto PerlException;
13395 av=(AV *) reference;
13396 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13398 package_info=ClonePackageInfo(info,exception);
13401 *list=(char *) (*package_info->image_info->filename ?
13402 package_info->image_info->filename : "XC:black");
13404 for (n=0, i=0; i < ac; i++)
13406 list[n]=(char *) SvPV(ST(i+1),length[n]);
13407 if ((items >= 3) && strEQcase(list[n],"blob"))
13413 blob=(void *) (SvPV(ST(i+1),length[n]));
13414 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13416 if ((items >= 3) && strEQcase(list[n],"filename"))
13418 if ((items >= 3) && strEQcase(list[n],"file"))
13427 io_info=IoIFP(sv_2io(ST(i+1)));
13428 if (io_info == (PerlIO *) NULL)
13430 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13434 file=PerlIO_findFILE(io_info);
13435 if (file == (FILE *) NULL)
13437 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13441 SetImageInfoFile(package_info->image_info,file);
13443 if ((items >= 3) && strEQcase(list[n],"magick"))
13447 list[n]=(char *) NULL;
13449 status=ExpandFilenames(&n,&list);
13450 if (status == MagickFalse)
13452 ThrowPerlException(exception,ResourceLimitError,
13453 "MemoryAllocationFailed",PackageName);
13454 goto PerlException;
13457 for (i=0; i < n; i++)
13459 if ((package_info->image_info->file == (FILE *) NULL) &&
13460 (package_info->image_info->blob == (void *) NULL))
13461 image=ReadImages(package_info->image_info,list[i],exception);
13464 image=ReadImages(package_info->image_info,
13465 package_info->image_info->filename,exception);
13466 if (image != (Image *) NULL)
13467 DisassociateImageStream(image);
13469 if (image == (Image *) NULL)
13471 for ( ; image; image=image->next)
13473 AddImageToRegistry(sv,image);
13475 av_push(av,sv_bless(rv,hv));
13483 for (i=0; i < n; i++)
13484 if (list[i] != (char *) NULL)
13485 for (p=keep; list[i] != *p++; )
13486 if (*p == (char *) NULL)
13488 list[i]=(char *) RelinquishMagickMemory(list[i]);
13493 if (package_info != (struct PackageInfo *) NULL)
13494 DestroyPackageInfo(package_info);
13495 if (list && (list != keep))
13496 list=(char **) RelinquishMagickMemory(list);
13498 keep=(char **) RelinquishMagickMemory(keep);
13500 length=(STRLEN *) RelinquishMagickMemory(length);
13501 InheritPerlException(exception,perl_exception);
13502 exception=DestroyExceptionInfo(exception);
13503 sv_setiv(perl_exception,(IV) number_images);
13504 SvPOK_on(perl_exception);
13505 ST(0)=sv_2mortal(perl_exception);
13510 ###############################################################################
13518 ###############################################################################
13523 Image::Magick ref=NO_INIT
13546 PERL_UNUSED_VAR(ref);
13547 PERL_UNUSED_VAR(ix);
13548 exception=AcquireExceptionInfo();
13549 perl_exception=newSVpv("",0);
13550 reference=SvRV(ST(0));
13551 av=(AV *) reference;
13552 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13554 for (i=1; i < items; i++)
13555 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13556 SvPV(ST(i),na),exception);
13557 InheritPerlException(exception,perl_exception);
13558 exception=DestroyExceptionInfo(exception);
13559 SvREFCNT_dec(perl_exception); /* throw away all errors */
13563 ###############################################################################
13571 ###############################################################################
13576 Image::Magick ref=NO_INIT
13599 *reference; /* reference is the SV* of ref=SvIV(reference) */
13601 PERL_UNUSED_VAR(ref);
13602 PERL_UNUSED_VAR(ix);
13603 exception=AcquireExceptionInfo();
13604 perl_exception=newSVpv("",0);
13605 if (sv_isobject(ST(0)) == 0)
13607 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13609 goto PerlException;
13611 reference=SvRV(ST(0));
13612 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13614 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13616 for (i=2; i < items; i+=2)
13617 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13620 InheritPerlException(exception,perl_exception);
13621 exception=DestroyExceptionInfo(exception);
13622 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13623 SvPOK_on(perl_exception);
13624 ST(0)=sv_2mortal(perl_exception);
13629 ###############################################################################
13633 # S e t P i x e l #
13637 ###############################################################################
13642 Image::Magick ref=NO_INIT
13684 *reference; /* reference is the SV* of ref=SvIV(reference) */
13686 PERL_UNUSED_VAR(ref);
13687 PERL_UNUSED_VAR(ix);
13688 exception=AcquireExceptionInfo();
13689 perl_exception=newSVpv("",0);
13690 reference=SvRV(ST(0));
13691 av=(AV *) reference;
13692 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13694 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13695 if (image == (Image *) NULL)
13697 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13699 goto PerlException;
13702 normalize=MagickTrue;
13705 region.width=image->columns;
13708 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13709 channel=DefaultChannels;
13710 for (i=2; i < items; i+=2)
13712 attribute=(char *) SvPV(ST(i-1),na);
13713 switch (*attribute)
13718 if (LocaleCompare(attribute,"channel") == 0)
13723 option=ParseChannelOption(SvPV(ST(i),na));
13726 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13730 channel=(ChannelType) option;
13733 if (LocaleCompare(attribute,"color") == 0)
13735 if (SvTYPE(ST(i)) != SVt_RV)
13738 message[MaxTextExtent];
13740 (void) FormatLocaleString(message,MaxTextExtent,
13741 "invalid %.60s value",attribute);
13742 ThrowPerlException(exception,OptionError,message,
13745 av=(AV *) SvRV(ST(i));
13748 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13755 if (LocaleCompare(attribute,"geometry") == 0)
13757 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13767 if (LocaleCompare(attribute,"normalize") == 0)
13769 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13773 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13777 normalize=option != 0 ? MagickTrue : MagickFalse;
13780 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13787 if (LocaleCompare(attribute,"x") == 0)
13789 region.x=SvIV(ST(i));
13792 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13799 if (LocaleCompare(attribute,"y") == 0)
13801 region.y=SvIV(ST(i));
13804 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13810 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13816 (void) SetImageStorageClass(image,DirectClass,exception);
13817 channel_mask=SetImageChannelMask(image,channel);
13818 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13819 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13820 (SvTYPE(av) != SVt_PVAV))
13832 if (normalize != MagickFalse)
13833 scale=QuantumRange;
13834 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13837 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13838 av_fetch(av,i,0)))),q);
13841 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13844 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13845 av_fetch(av,i,0)))),q);
13848 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13851 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13852 av_fetch(av,i,0)))),q);
13855 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13856 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13858 SetPixelBlack(image,ClampToQuantum(scale*
13859 SvNV(*(av_fetch(av,i,0)))),q);
13862 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13865 SetPixelAlpha(image,ClampToQuantum(scale*
13866 SvNV(*(av_fetch(av,i,0)))),q);
13869 (void) SyncAuthenticPixels(image,exception);
13871 (void) SetImageChannelMask(image,channel_mask);
13874 InheritPerlException(exception,perl_exception);
13875 exception=DestroyExceptionInfo(exception);
13876 SvREFCNT_dec(perl_exception);
13880 ###############################################################################
13888 ###############################################################################
13893 Image::Magick ref=NO_INIT
13932 PERL_UNUSED_VAR(ref);
13933 PERL_UNUSED_VAR(ix);
13934 exception=AcquireExceptionInfo();
13935 perl_exception=newSVpv("",0);
13939 if (sv_isobject(ST(0)) == 0)
13941 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13943 goto PerlException;
13945 reference=SvRV(ST(0));
13946 hv=SvSTASH(reference);
13948 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13950 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13951 if (image == (Image *) NULL)
13953 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13955 goto PerlException;
13957 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13963 for (i=2; i < items; i+=2)
13965 attribute=(char *) SvPV(ST(i-1),na);
13966 switch (*attribute)
13971 if (LocaleCompare(attribute,"offset") == 0)
13973 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13976 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13983 if (LocaleCompare(attribute,"stack") == 0)
13985 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13989 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13995 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14001 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14007 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14009 if (image == (Image *) NULL)
14010 goto PerlException;
14011 for ( ; image; image=image->next)
14013 AddImageToRegistry(sv,image);
14015 av_push(av,sv_bless(rv,hv));
14018 exception=DestroyExceptionInfo(exception);
14019 ST(0)=av_reference;
14020 SvREFCNT_dec(perl_exception);
14024 InheritPerlException(exception,perl_exception);
14025 exception=DestroyExceptionInfo(exception);
14026 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14027 SvPOK_on(perl_exception);
14028 ST(0)=sv_2mortal(perl_exception);
14033 ###############################################################################
14037 # S t a t i s t i c s #
14041 ###############################################################################
14045 Statistics(ref,...)
14046 Image::Magick ref=NO_INIT
14048 StatisticsImage = 1
14050 statisticsimage = 3
14053 #define ChannelStatistics(channel) \
14055 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
14056 (double) channel_statistics[channel].depth); \
14057 PUSHs(sv_2mortal(newSVpv(message,0))); \
14058 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14059 channel_statistics[channel].minima/scale); \
14060 PUSHs(sv_2mortal(newSVpv(message,0))); \
14061 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14062 channel_statistics[channel].maxima/scale); \
14063 PUSHs(sv_2mortal(newSVpv(message,0))); \
14064 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14065 channel_statistics[channel].mean/scale); \
14066 PUSHs(sv_2mortal(newSVpv(message,0))); \
14067 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14068 channel_statistics[channel].standard_deviation/scale); \
14069 PUSHs(sv_2mortal(newSVpv(message,0))); \
14070 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14071 channel_statistics[channel].kurtosis); \
14072 PUSHs(sv_2mortal(newSVpv(message,0))); \
14073 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14074 channel_statistics[channel].skewness); \
14075 PUSHs(sv_2mortal(newSVpv(message,0))); \
14082 message[MaxTextExtent];
14085 *channel_statistics;
14106 PERL_UNUSED_VAR(ref);
14107 PERL_UNUSED_VAR(ix);
14108 exception=AcquireExceptionInfo();
14109 perl_exception=newSVpv("",0);
14111 if (sv_isobject(ST(0)) == 0)
14113 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14115 goto PerlException;
14117 reference=SvRV(ST(0));
14120 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14121 if (image == (Image *) NULL)
14123 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14125 goto PerlException;
14127 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14129 for ( ; image; image=image->next)
14131 channel_statistics=GetImageStatistics(image,exception);
14132 if (channel_statistics == (ChannelStatistics *) NULL)
14135 EXTEND(sp,35*count);
14136 scale=(double) QuantumRange;
14137 ChannelStatistics(RedChannel);
14138 ChannelStatistics(GreenChannel);
14139 ChannelStatistics(BlueChannel);
14140 if (image->colorspace == CMYKColorspace)
14141 ChannelStatistics(BlackChannel);
14142 if (image->alpha_trait == BlendPixelTrait)
14143 ChannelStatistics(AlphaChannel);
14144 channel_statistics=(ChannelStatistics *)
14145 RelinquishMagickMemory(channel_statistics);
14149 InheritPerlException(exception,perl_exception);
14150 exception=DestroyExceptionInfo(exception);
14151 SvREFCNT_dec(perl_exception);
14155 ###############################################################################
14159 # S y n c A u t h e n t i c P i x e l s #
14163 ###############################################################################
14167 SyncAuthenticPixels(ref,...)
14168 Image::Magick ref = NO_INIT
14170 Syncauthenticpixels = 1
14171 SyncImagePixels = 2
14172 syncimagepixels = 3
14191 PERL_UNUSED_VAR(ref);
14192 PERL_UNUSED_VAR(ix);
14193 exception=AcquireExceptionInfo();
14194 perl_exception=newSVpv("",0);
14195 if (sv_isobject(ST(0)) == 0)
14197 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14199 goto PerlException;
14202 reference=SvRV(ST(0));
14203 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14204 if (image == (Image *) NULL)
14206 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14208 goto PerlException;
14211 status=SyncAuthenticPixels(image,exception);
14212 if (status != MagickFalse)
14216 InheritPerlException(exception,perl_exception);
14217 exception=DestroyExceptionInfo(exception);
14218 SvREFCNT_dec(perl_exception); /* throw away all errors */
14222 ###############################################################################
14226 # T r a n s f o r m #
14230 ###############################################################################
14235 Image::Magick ref=NO_INIT
14273 PERL_UNUSED_VAR(ref);
14274 PERL_UNUSED_VAR(ix);
14275 exception=AcquireExceptionInfo();
14276 perl_exception=newSVpv("",0);
14280 if (sv_isobject(ST(0)) == 0)
14282 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14284 goto PerlException;
14286 reference=SvRV(ST(0));
14287 hv=SvSTASH(reference);
14289 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14291 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14292 if (image == (Image *) NULL)
14294 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14296 goto PerlException;
14298 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14302 crop_geometry=(char *) NULL;
14303 geometry=(char *) NULL;
14304 for (i=2; i < items; i+=2)
14306 attribute=(char *) SvPV(ST(i-1),na);
14307 switch (*attribute)
14312 if (LocaleCompare(attribute,"crop") == 0)
14314 crop_geometry=SvPV(ST(i),na);
14317 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14324 if (LocaleCompare(attribute,"geometry") == 0)
14326 geometry=SvPV(ST(i),na);
14329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14335 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14341 for ( ; image; image=image->next)
14343 clone=CloneImage(image,0,0,MagickTrue,exception);
14344 if (clone == (Image *) NULL)
14345 goto PerlException;
14346 TransformImage(&clone,crop_geometry,geometry,exception);
14347 for ( ; clone; clone=clone->next)
14349 AddImageToRegistry(sv,clone);
14351 av_push(av,sv_bless(rv,hv));
14355 exception=DestroyExceptionInfo(exception);
14356 ST(0)=av_reference;
14357 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14361 InheritPerlException(exception,perl_exception);
14362 exception=DestroyExceptionInfo(exception);
14363 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14364 SvPOK_on(perl_exception);
14365 ST(0)=sv_2mortal(perl_exception);
14370 ###############################################################################
14378 ###############################################################################
14383 Image::Magick ref=NO_INIT
14391 filename[MaxTextExtent];
14415 PERL_UNUSED_VAR(ref);
14416 PERL_UNUSED_VAR(ix);
14417 exception=AcquireExceptionInfo();
14418 perl_exception=newSVpv("",0);
14420 package_info=(struct PackageInfo *) NULL;
14421 if (sv_isobject(ST(0)) == 0)
14423 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14425 goto PerlException;
14427 reference=SvRV(ST(0));
14428 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14429 if (image == (Image *) NULL)
14431 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14433 goto PerlException;
14435 package_info=ClonePackageInfo(info,exception);
14437 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14440 for (i=2; i < items; i+=2)
14441 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14443 (void) CopyMagickString(filename,package_info->image_info->filename,
14446 for (next=image; next; next=next->next)
14448 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14449 next->scene=scene++;
14451 SetImageInfo(package_info->image_info,(unsigned int)
14452 GetImageListLength(image),exception);
14453 for (next=image; next; next=next->next)
14455 (void) WriteImage(package_info->image_info,next,exception);
14457 if (package_info->image_info->adjoin)
14462 if (package_info != (struct PackageInfo *) NULL)
14463 DestroyPackageInfo(package_info);
14464 InheritPerlException(exception,perl_exception);
14465 exception=DestroyExceptionInfo(exception);
14466 sv_setiv(perl_exception,(IV) number_images);
14467 SvPOK_on(perl_exception);
14468 ST(0)=sv_2mortal(perl_exception);