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-2012 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 MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv(PTR2IV(image)); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
218 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
219 {"height", IntegerReference}, {"x", IntegerReference},
220 {"y", IntegerReference} } },
221 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
222 {"height", IntegerReference}, {"x", IntegerReference},
223 {"y", IntegerReference}, {"fuzz", StringReference},
224 {"gravity", MagickGravityOptions} } },
226 { "Edge", { {"radius", RealReference} } },
227 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
228 {"sigma", RealReference} } },
232 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
233 {"height", IntegerReference}, {"inner", IntegerReference},
234 {"outer", IntegerReference}, {"fill", StringReference},
235 {"color", StringReference}, {"compose", MagickComposeOptions} } },
236 { "Implode", { {"amount", RealReference},
237 {"interpolate", MagickInterpolateOptions} } },
239 { "MedianFilter", { {"geometry", StringReference},
240 {"width", IntegerReference}, {"height", IntegerReference},
241 {"channel", MagickChannelOptions} } },
243 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
244 { "ReduceNoise", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
247 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
248 {"y", IntegerReference} } },
249 { "Rotate", { {"degrees", RealReference},
250 {"background", StringReference} } },
251 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
252 {"height", IntegerReference} } },
253 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
254 {"height", IntegerReference} } },
255 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
256 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
257 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
258 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
259 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
260 {"y", RealReference}, { "fill", StringReference},
261 {"color", StringReference} } },
262 { "Spread", { {"radius", RealReference},
263 {"interpolate", MagickInterpolateOptions} } },
264 { "Swirl", { {"degrees", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
267 {"height", IntegerReference}, {"filter", MagickFilterOptions},
268 {"support", StringReference } } },
269 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", RealReference } } },
272 { "Annotate", { {"text", StringReference}, {"font", StringReference},
273 {"pointsize", RealReference}, {"density", StringReference},
274 {"undercolor", StringReference}, {"stroke", StringReference},
275 {"fill", StringReference}, {"geometry", StringReference},
276 {"sans", StringReference}, {"x", RealReference},
277 {"y", RealReference}, {"gravity", MagickGravityOptions},
278 {"translate", StringReference}, {"scale", StringReference},
279 {"rotate", RealReference}, {"skewX", RealReference},
280 {"skewY", RealReference}, {"strokewidth", RealReference},
281 {"antialias", MagickBooleanOptions}, {"family", StringReference},
282 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
283 {"weight", IntegerReference}, {"align", MagickAlignOptions},
284 {"encoding", StringReference}, {"affine", ArrayReference},
285 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
286 {"tile", ImageReference}, {"kerning", RealReference},
287 {"interline-spacing", RealReference},
288 {"interword-spacing", RealReference},
289 {"direction", MagickDirectionOptions} } },
290 { "ColorFloodfill", { {"geometry", StringReference},
291 {"x", IntegerReference}, {"y", IntegerReference},
292 {"fill", StringReference}, {"bordercolor", StringReference},
293 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
294 { "Composite", { {"image", ImageReference},
295 {"compose", MagickComposeOptions}, {"geometry", StringReference},
296 {"x", IntegerReference}, {"y", IntegerReference},
297 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
298 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
299 {"color", StringReference}, {"mask", ImageReference},
300 {"channel", MagickChannelOptions},
301 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
302 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
303 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
304 { "CycleColormap", { {"display", IntegerReference} } },
305 { "Draw", { {"primitive", MagickPrimitiveOptions},
306 {"points", StringReference}, {"method", MagickMethodOptions},
307 {"stroke", StringReference}, {"fill", StringReference},
308 {"strokewidth", RealReference}, {"font", StringReference},
309 {"bordercolor", StringReference}, {"x", RealReference},
310 {"y", RealReference}, {"translate", StringReference},
311 {"scale", StringReference}, {"rotate", RealReference},
312 {"skewX", RealReference}, {"skewY", RealReference},
313 {"tile", ImageReference}, {"pointsize", RealReference},
314 {"antialias", MagickBooleanOptions}, {"density", StringReference},
315 {"linewidth", RealReference}, {"affine", ArrayReference},
316 {"stroke-dashoffset", RealReference},
317 {"stroke-dasharray", ArrayReference},
318 {"interpolate", MagickInterpolateOptions},
319 {"origin", StringReference}, {"text", StringReference},
320 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
321 {"vector-graphics", StringReference}, {"kerning", RealReference},
322 {"interline-spacing", RealReference},
323 {"interword-spacing", RealReference},
324 {"direction", MagickDirectionOptions} } },
325 { "Equalize", { {"channel", MagickChannelOptions} } },
326 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
327 {"red", RealReference}, {"green", RealReference},
328 {"blue", RealReference} } },
329 { "Map", { {"image", ImageReference},
330 {"dither-method", MagickDitherOptions} } },
331 { "MatteFloodfill", { {"geometry", StringReference},
332 {"x", IntegerReference}, {"y", IntegerReference},
333 {"opacity", StringReference}, {"bordercolor", StringReference},
334 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
335 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
336 {"saturation", RealReference}, {"whiteness", RealReference},
337 {"brightness", RealReference}, {"lightness", RealReference},
338 {"blackness", RealReference} } },
339 { "Negate", { {"gray", MagickBooleanOptions},
340 {"channel", MagickChannelOptions} } },
341 { "Normalize", { {"channel", MagickChannelOptions} } },
343 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
344 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
345 {"invert", MagickBooleanOptions} } },
346 { "Quantize", { {"colors", IntegerReference},
347 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
348 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
349 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
350 {"dither-method", MagickDitherOptions} } },
351 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
352 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
353 { "Segment", { {"geometry", StringReference},
354 {"cluster-threshold", RealReference},
355 {"smoothing-threshold", RealReference},
356 {"colorspace", MagickColorspaceOptions},
357 {"verbose", MagickBooleanOptions} } },
359 { "Solarize", { {"geometry", StringReference},
360 {"threshold", StringReference} } },
362 { "Texture", { {"texture", ImageReference} } },
363 { "Evaluate", { {"value", RealReference},
364 {"operator", MagickEvaluateOptions},
365 {"channel", MagickChannelOptions} } },
366 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
367 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
368 { "Threshold", { {"threshold", StringReference},
369 {"channel", MagickChannelOptions} } },
370 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
371 {"sigma", RealReference} } },
372 { "Trim", { {"fuzz", StringReference} } },
373 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
374 {"wavelength", RealReference},
375 {"interpolate", MagickInterpolateOptions} } },
376 { "Separate", { {"channel", MagickChannelOptions} } },
378 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
379 {"y", IntegerReference} } },
380 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
382 { "GaussianBlur", { {"geometry", StringReference},
383 {"radius", RealReference}, {"sigma", RealReference},
384 {"channel", MagickChannelOptions} } },
385 { "Convolve", { {"coefficients", ArrayReference},
386 {"channel", MagickChannelOptions}, {"bias", StringReference},
387 {"kernel", StringReference} } },
388 { "Profile", { {"name", StringReference}, {"profile", StringReference},
389 { "rendering-intent", MagickIntentOptions},
390 { "black-point-compensation", MagickBooleanOptions} } },
391 { "UnsharpMask", { {"geometry", StringReference},
392 {"radius", RealReference}, {"sigma", RealReference},
393 {"amount", RealReference}, {"threshold", RealReference},
394 {"channel", MagickChannelOptions} } },
395 { "MotionBlur", { {"geometry", StringReference},
396 {"radius", RealReference}, {"sigma", RealReference},
397 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
398 { "OrderedDither", { {"threshold", StringReference},
399 {"channel", MagickChannelOptions} } },
400 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
401 {"height", IntegerReference} } },
402 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
403 {"white-point", RealReference}, {"gamma", RealReference},
404 {"channel", MagickChannelOptions}, {"level", StringReference} } },
405 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
406 { "AffineTransform", { {"affine", ArrayReference},
407 {"translate", StringReference}, {"scale", StringReference},
408 {"rotate", RealReference}, {"skewX", RealReference},
409 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
410 {"background", StringReference} } },
411 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
412 { "AdaptiveThreshold", { {"geometry", StringReference},
413 {"width", IntegerReference}, {"height", IntegerReference} } },
414 { "Resample", { {"density", StringReference}, {"x", RealReference},
415 {"y", RealReference}, {"filter", MagickFilterOptions},
416 {"support", RealReference } } },
417 { "Describe", { {"file", FileReference} } },
418 { "BlackThreshold", { {"threshold", StringReference},
419 {"channel", MagickChannelOptions} } },
420 { "WhiteThreshold", { {"threshold", StringReference},
421 {"channel", MagickChannelOptions} } },
422 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
423 {"channel", MagickChannelOptions} } },
424 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
425 {"height", IntegerReference} } },
427 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
428 { "Channel", { {"channel", MagickChannelOptions} } },
429 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
430 {"height", IntegerReference}, {"x", IntegerReference},
431 {"y", IntegerReference}, {"fuzz", StringReference},
432 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
433 { "Posterize", { {"levels", IntegerReference},
434 {"dither", MagickBooleanOptions} } },
435 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
436 {"sigma", RealReference}, {"x", IntegerReference},
437 {"y", IntegerReference} } },
438 { "Identify", { {"file", FileReference}, {"features", StringReference},
439 {"unique", MagickBooleanOptions} } },
440 { "SepiaTone", { {"threshold", RealReference} } },
441 { "SigmoidalContrast", { {"geometry", StringReference},
442 {"contrast", RealReference}, {"mid-point", RealReference},
443 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
444 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
445 {"height", IntegerReference}, {"x", IntegerReference},
446 {"y", IntegerReference}, {"fuzz", StringReference},
447 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
448 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
449 {"sigma", RealReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"background", StringReference} } },
451 { "ContrastStretch", { {"levels", StringReference},
452 {"black-point", RealReference},{"white-point", RealReference},
453 {"channel", MagickChannelOptions} } },
456 { "AdaptiveSharpen", { {"geometry", StringReference},
457 {"radius", RealReference}, {"sigma", RealReference},
458 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
462 { "AdaptiveBlur", { {"geometry", StringReference},
463 {"radius", RealReference}, {"sigma", RealReference},
464 {"channel", MagickChannelOptions} } },
465 { "Sketch", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"angle", RealReference} } },
469 { "AdaptiveResize", { {"geometry", StringReference},
470 {"width", IntegerReference}, {"height", IntegerReference},
471 {"filter", MagickFilterOptions}, {"support", StringReference },
472 {"blur", RealReference } } },
473 { "ClipMask", { {"mask", ImageReference} } },
474 { "LinearStretch", { {"levels", StringReference},
475 {"black-point", RealReference},{"white-point", RealReference} } },
476 { "ColorMatrix", { {"matrix", ArrayReference} } },
477 { "Mask", { {"mask", ImageReference} } },
478 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
479 {"font", StringReference}, {"stroke", StringReference},
480 {"fill", StringReference}, {"strokewidth", RealReference},
481 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
482 {"background", StringReference},
483 {"interpolate", MagickInterpolateOptions} } },
484 { "FloodfillPaint", { {"geometry", StringReference},
485 {"x", IntegerReference}, {"y", IntegerReference},
486 {"fill", StringReference}, {"bordercolor", StringReference},
487 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
488 {"invert", MagickBooleanOptions} } },
489 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
490 {"virtual-pixel", MagickVirtualPixelOptions},
491 {"best-fit", MagickBooleanOptions} } },
492 { "Clut", { {"image", ImageReference},
493 {"interpolate", MagickInterpolateOptions},
494 {"channel", MagickChannelOptions} } },
495 { "LiquidRescale", { {"geometry", StringReference},
496 {"width", IntegerReference}, {"height", IntegerReference},
497 {"delta-x", RealReference}, {"rigidity", RealReference } } },
498 { "Encipher", { {"passphrase", StringReference} } },
499 { "Decipher", { {"passphrase", StringReference} } },
500 { "Deskew", { {"geometry", StringReference},
501 {"threshold", StringReference} } },
502 { "Remap", { {"image", ImageReference},
503 {"dither-method", MagickDitherOptions} } },
504 { "SparseColor", { {"points", ArrayReference},
505 {"method", MagickSparseColorOptions},
506 {"virtual-pixel", MagickVirtualPixelOptions},
507 {"channel", MagickChannelOptions} } },
508 { "Function", { {"parameters", ArrayReference},
509 {"function", MagickFunctionOptions},
510 {"virtual-pixel", MagickVirtualPixelOptions} } },
511 { "SelectiveBlur", { {"geometry", StringReference},
512 {"radius", RealReference}, {"sigma", RealReference},
513 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
514 { "HaldClut", { {"image", ImageReference},
515 {"channel", MagickChannelOptions} } },
516 { "BlueShift", { {"factor", StringReference} } },
517 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
518 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "ColorDecisionList", {
520 {"color-correction-collection", StringReference} } },
521 { "AutoGamma", { {"channel", MagickChannelOptions} } },
522 { "AutoLevel", { {"channel", MagickChannelOptions} } },
523 { "LevelColors", { {"invert", MagickBooleanOptions},
524 {"black-point", StringReference}, {"white-point", StringReference},
525 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
526 { "Clamp", { {"channel", MagickChannelOptions} } },
527 { "BrightnessContrast", { {"levels", StringReference},
528 {"brightness", RealReference},{"contrast", RealReference},
529 {"channel", MagickChannelOptions} } },
530 { "Morphology", { {"kernel", StringReference},
531 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
532 {"iterations", IntegerReference} } },
533 { "Sans", { {"matrix", ArrayReference} } },
534 { "Color", { {"color", StringReference} } },
535 { "Mode", { {"geometry", StringReference},
536 {"width", IntegerReference},{"height", IntegerReference},
537 {"channel", MagickChannelOptions} } },
538 { "Statistic", { {"geometry", StringReference},
539 {"width", IntegerReference},{"height", IntegerReference},
540 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
544 *magick_registry = (SplayTreeInfo *) NULL;
547 Forward declarations.
550 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
553 strEQcase(const char *,const char *);
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
560 % C l o n e P a c k a g e I n f o %
564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
569 % The format of the ClonePackageInfo routine is:
571 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
574 % A description of each parameter follows:
576 % o info: a structure of type info.
578 % o exception: Return any errors or warnings in this structure.
581 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
582 ExceptionInfo *exception)
587 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
588 if (clone_info == (struct PackageInfo *) NULL)
590 ThrowPerlException(exception,ResourceLimitError,
591 "UnableToClonePackageInfo",PackageName);
592 return((struct PackageInfo *) NULL);
594 if (info == (struct PackageInfo *) NULL)
596 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
600 clone_info->image_info=CloneImageInfo(info->image_info);
605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615 % constant() returns a double value for the specified name.
617 % The format of the constant routine is:
619 % double constant(char *name,ssize_t sans)
621 % A description of each parameter follows:
623 % o value: Method constant returns a double value for the specified name.
625 % o name: The name of the constant.
627 % o sans: This integer value is not used.
630 static double constant(char *name,ssize_t sans)
638 if (strEQ(name,"BlobError"))
640 if (strEQ(name,"BlobWarning"))
646 if (strEQ(name,"CacheError"))
648 if (strEQ(name,"CacheWarning"))
649 return(CacheWarning);
650 if (strEQ(name,"CoderError"))
652 if (strEQ(name,"CoderWarning"))
653 return(CoderWarning);
654 if (strEQ(name,"ConfigureError"))
655 return(ConfigureError);
656 if (strEQ(name,"ConfigureWarning"))
657 return(ConfigureWarning);
658 if (strEQ(name,"CorruptImageError"))
659 return(CorruptImageError);
660 if (strEQ(name,"CorruptImageWarning"))
661 return(CorruptImageWarning);
666 if (strEQ(name,"DelegateError"))
667 return(DelegateError);
668 if (strEQ(name,"DelegateWarning"))
669 return(DelegateWarning);
670 if (strEQ(name,"DrawError"))
672 if (strEQ(name,"DrawWarning"))
678 if (strEQ(name,"ErrorException"))
679 return(ErrorException);
680 if (strEQ(name,"ExceptionError"))
682 if (strEQ(name,"ExceptionWarning"))
683 return(CoderWarning);
688 if (strEQ(name,"FatalErrorException"))
689 return(FatalErrorException);
690 if (strEQ(name,"FileOpenError"))
691 return(FileOpenError);
692 if (strEQ(name,"FileOpenWarning"))
693 return(FileOpenWarning);
698 if (strEQ(name,"ImageError"))
700 if (strEQ(name,"ImageWarning"))
701 return(ImageWarning);
706 if (strEQ(name,"MaxRGB"))
707 return(QuantumRange);
708 if (strEQ(name,"MissingDelegateError"))
709 return(MissingDelegateError);
710 if (strEQ(name,"MissingDelegateWarning"))
711 return(MissingDelegateWarning);
712 if (strEQ(name,"ModuleError"))
714 if (strEQ(name,"ModuleWarning"))
715 return(ModuleWarning);
720 if (strEQ(name,"Opaque"))
722 if (strEQ(name,"OptionError"))
724 if (strEQ(name,"OptionWarning"))
725 return(OptionWarning);
730 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
731 return(MAGICKCORE_QUANTUM_DEPTH);
732 if (strEQ(name,"QuantumDepth"))
733 return(MAGICKCORE_QUANTUM_DEPTH);
734 if (strEQ(name,"QuantumRange"))
735 return(QuantumRange);
740 if (strEQ(name,"ResourceLimitError"))
741 return(ResourceLimitError);
742 if (strEQ(name,"ResourceLimitWarning"))
743 return(ResourceLimitWarning);
744 if (strEQ(name,"RegistryError"))
745 return(RegistryError);
746 if (strEQ(name,"RegistryWarning"))
747 return(RegistryWarning);
752 if (strEQ(name,"StreamError"))
754 if (strEQ(name,"StreamWarning"))
755 return(StreamWarning);
756 if (strEQ(name,"Success"))
762 if (strEQ(name,"Transparent"))
763 return(TransparentAlpha);
764 if (strEQ(name,"TypeError"))
766 if (strEQ(name,"TypeWarning"))
772 if (strEQ(name,"WarningException"))
773 return(WarningException);
778 if (strEQ(name,"XServerError"))
779 return(XServerError);
780 if (strEQ(name,"XServerWarning"))
781 return(XServerWarning);
790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
794 % D e s t r o y P a c k a g e I n f o %
798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800 % Method DestroyPackageInfo frees a previously created info structure.
802 % The format of the DestroyPackageInfo routine is:
804 % DestroyPackageInfo(struct PackageInfo *info)
806 % A description of each parameter follows:
808 % o info: a structure of type info.
811 static void DestroyPackageInfo(struct PackageInfo *info)
813 info->image_info=DestroyImageInfo(info->image_info);
814 info=(struct PackageInfo *) RelinquishMagickMemory(info);
818 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 % Method GetList is recursively called by SetupList to traverse the
829 % Image__Magick reference. If building an reference_vector (see SetupList),
830 % *current is the current position in *reference_vector and *last is the final
831 % entry in *reference_vector.
833 % The format of the GetList routine is:
837 % A description of each parameter follows:
839 % o info: a structure of type info.
842 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
843 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
848 if (reference == (SV *) NULL)
850 switch (SvTYPE(reference))
870 previous=(Image *) NULL;
874 for (i=0; i <= n; i++)
880 if (rv && *rv && sv_isobject(*rv))
882 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
884 if (image == (Image *) NULL)
886 if (image == previous)
888 image=CloneImage(image,0,0,MagickTrue,exception);
889 if (image == (Image *) NULL)
892 image->previous=previous;
893 *(previous ? &previous->next : &head)=image;
894 for (previous=image; previous->next; previous=previous->next) ;
902 Blessed scalar, one image.
904 image=INT2PTR(Image *,SvIV(reference));
905 if (image == (Image *) NULL)
907 image->previous=(Image *) NULL;
908 image->next=(Image *) NULL;
909 if (reference_vector)
911 if (*current == *last)
914 if (*reference_vector == (SV **) NULL)
915 *reference_vector=(SV **) AcquireQuantumMemory(*last,
916 sizeof(*reference_vector));
918 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
919 *last,sizeof(*reference_vector));
921 if (*reference_vector == (SV **) NULL)
923 ThrowPerlException(exception,ResourceLimitError,
924 "MemoryAllocationFailed",PackageName);
925 return((Image *) NULL);
927 (*reference_vector)[*current]=reference;
928 (*reference_vector)[++(*current)]=NULL;
935 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
936 (double) SvTYPE(reference));
937 return((Image *) NULL);
941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
945 % G e t P a c k a g e I n f o %
949 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 % Method GetPackageInfo looks up or creates an info structure for the given
952 % Image__Magick reference. If it does create a new one, the information in
953 % package_info is used to initialize it.
955 % The format of the GetPackageInfo routine is:
957 % struct PackageInfo *GetPackageInfo(void *reference,
958 % struct PackageInfo *package_info,ExceptionInfo *exception)
960 % A description of each parameter follows:
962 % o info: a structure of type info.
964 % o exception: Return any errors or warnings in this structure.
967 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
968 struct PackageInfo *package_info,ExceptionInfo *exception)
971 message[MaxTextExtent];
979 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
980 PackageName,XS_VERSION,reference);
981 sv=perl_get_sv(message,(TRUE | 0x02));
982 if (sv == (SV *) NULL)
984 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
986 return(package_info);
988 if (SvREFCNT(sv) == 0)
989 (void) SvREFCNT_inc(sv);
990 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
992 clone_info=ClonePackageInfo(package_info,exception);
993 sv_setiv(sv,PTR2IV(clone_info));
998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1002 % S e t A t t r i b u t e %
1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1008 % SetAttribute() sets the attribute to the value in sval. This can change
1009 % either or both of image or info.
1011 % The format of the SetAttribute routine is:
1013 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1014 % SV *sval,ExceptionInfo *exception)
1016 % A description of each parameter follows:
1018 % o list: a list of strings.
1020 % o string: a character string.
1024 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1032 value=InterpretSiPrefixValue(string,&q);
1034 value*=interval/100.0;
1038 static inline double StringToDouble(const char *string,char **sentinal)
1040 return(InterpretLocaleValue(string,sentinal));
1043 static double StringToDoubleInterval(const char *string,const double interval)
1051 value=InterpretLocaleValue(string,&q);
1053 value*=interval/100.0;
1057 static inline ssize_t StringToLong(const char *value)
1059 return(strtol(value,(char **) NULL,10));
1062 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1063 const char *attribute,SV *sval,ExceptionInfo *exception)
1090 if (LocaleCompare(attribute,"adjoin") == 0)
1092 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1093 SvPV(sval,na)) : SvIV(sval);
1096 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1101 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1104 if (LocaleCompare(attribute,"alpha") == 0)
1106 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
1107 SvPV(sval,na)) : SvIV(sval);
1110 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1114 for ( ; image; image=image->next)
1115 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,exception);
1118 if (LocaleCompare(attribute,"antialias") == 0)
1120 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1121 SvPV(sval,na)) : SvIV(sval);
1124 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1129 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1132 if (LocaleCompare(attribute,"area-limit") == 0)
1137 limit=MagickResourceInfinity;
1138 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1139 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1141 (void) SetMagickResourceLimit(AreaResource,limit);
1144 if (LocaleCompare(attribute,"attenuate") == 0)
1147 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1150 if (LocaleCompare(attribute,"authenticate") == 0)
1153 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1157 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1158 for ( ; image; image=image->next)
1159 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1165 if (LocaleCompare(attribute,"background") == 0)
1167 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1170 info->image_info->background_color=target_color;
1171 for ( ; image; image=image->next)
1172 image->background_color=target_color;
1175 if (LocaleCompare(attribute,"blue-primary") == 0)
1177 for ( ; image; image=image->next)
1179 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1180 image->chromaticity.blue_primary.x=geometry_info.rho;
1181 image->chromaticity.blue_primary.y=geometry_info.sigma;
1182 if ((flags & SigmaValue) == 0)
1183 image->chromaticity.blue_primary.y=
1184 image->chromaticity.blue_primary.x;
1188 if (LocaleCompare(attribute,"bordercolor") == 0)
1190 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1193 info->image_info->border_color=target_color;
1194 for ( ; image; image=image->next)
1195 image->border_color=target_color;
1199 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1200 for ( ; image; image=image->next)
1201 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1207 if (LocaleCompare(attribute,"cache-threshold") == 0)
1209 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1210 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1211 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1212 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1215 if (LocaleCompare(attribute,"clip-mask") == 0)
1220 clip_mask=(Image *) NULL;
1222 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1223 for ( ; image; image=image->next)
1224 SetImageMask(image,clip_mask,exception);
1227 if (LocaleNCompare(attribute,"colormap",8) == 0)
1229 for ( ; image; image=image->next)
1237 if (image->storage_class == DirectClass)
1240 items=sscanf(attribute,"%*[^[][%ld",&i);
1242 if (i > (ssize_t) image->colors)
1244 if ((strchr(SvPV(sval,na),',') == 0) ||
1245 (strchr(SvPV(sval,na),')') != 0))
1246 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1247 image->colormap+i,exception);
1250 color=image->colormap+i;
1251 pixel.red=color->red;
1252 pixel.green=color->green;
1253 pixel.blue=color->blue;
1254 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1255 pixel.red=geometry_info.rho;
1256 pixel.green=geometry_info.sigma;
1257 pixel.blue=geometry_info.xi;
1258 color->red=ClampToQuantum(pixel.red);
1259 color->green=ClampToQuantum(pixel.green);
1260 color->blue=ClampToQuantum(pixel.blue);
1265 if (LocaleCompare(attribute,"colorspace") == 0)
1267 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1268 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1271 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1275 for ( ; image; image=image->next)
1276 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1280 if (LocaleCompare(attribute,"comment") == 0)
1282 for ( ; image; image=image->next)
1283 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1284 info ? info->image_info : (ImageInfo *) NULL,image,
1285 SvPV(sval,na),exception),exception);
1288 if (LocaleCompare(attribute,"compression") == 0)
1290 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1291 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1294 ThrowPerlException(exception,OptionError,
1295 "UnrecognizedImageCompression",SvPV(sval,na));
1299 info->image_info->compression=(CompressionType) sp;
1300 for ( ; image; image=image->next)
1301 image->compression=(CompressionType) sp;
1305 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1306 for ( ; image; image=image->next)
1307 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1313 if (LocaleCompare(attribute,"debug") == 0)
1315 SetLogEventMask(SvPV(sval,na));
1318 if (LocaleCompare(attribute,"delay") == 0)
1320 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1321 for ( ; image; image=image->next)
1323 image->delay=(size_t) floor(geometry_info.rho+0.5);
1324 if ((flags & SigmaValue) != 0)
1325 image->ticks_per_second=(ssize_t)
1326 floor(geometry_info.sigma+0.5);
1330 if (LocaleCompare(attribute,"disk-limit") == 0)
1335 limit=MagickResourceInfinity;
1336 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1337 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1339 (void) SetMagickResourceLimit(DiskResource,limit);
1342 if (LocaleCompare(attribute,"density") == 0)
1344 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1346 ThrowPerlException(exception,OptionError,"MissingGeometry",
1351 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1352 for ( ; image; image=image->next)
1354 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1355 image->resolution.x=geometry_info.rho;
1356 image->resolution.y=geometry_info.sigma;
1357 if ((flags & SigmaValue) == 0)
1358 image->resolution.y=image->resolution.x;
1362 if (LocaleCompare(attribute,"depth") == 0)
1365 info->image_info->depth=SvIV(sval);
1366 for ( ; image; image=image->next)
1367 (void) SetImageDepth(image,SvIV(sval),exception);
1370 if (LocaleCompare(attribute,"dispose") == 0)
1372 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1373 SvPV(sval,na)) : SvIV(sval);
1376 ThrowPerlException(exception,OptionError,
1377 "UnrecognizedDisposeMethod",SvPV(sval,na));
1380 for ( ; image; image=image->next)
1381 image->dispose=(DisposeType) sp;
1384 if (LocaleCompare(attribute,"dither") == 0)
1388 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1389 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1392 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1396 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1400 if (LocaleCompare(attribute,"display") == 0)
1404 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1408 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1409 for ( ; image; image=image->next)
1410 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1416 if (LocaleCompare(attribute,"endian") == 0)
1418 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1419 SvPV(sval,na)) : SvIV(sval);
1422 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1427 info->image_info->endian=(EndianType) sp;
1428 for ( ; image; image=image->next)
1429 image->endian=(EndianType) sp;
1432 if (LocaleCompare(attribute,"extract") == 0)
1435 Set image extract geometry.
1437 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1441 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1442 for ( ; image; image=image->next)
1443 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1449 if (LocaleCompare(attribute,"filename") == 0)
1452 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1454 for ( ; image; image=image->next)
1455 (void) CopyMagickString(image->filename,SvPV(sval,na),
1459 if (LocaleCompare(attribute,"file") == 0)
1467 if (info == (struct PackageInfo *) NULL)
1469 io_info=IoIFP(sv_2io(sval));
1470 if (io_info == (PerlIO *) NULL)
1472 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1476 file=PerlIO_findFILE(io_info);
1477 if (file == (FILE *) NULL)
1479 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1483 SetImageInfoFile(info->image_info,file);
1486 if (LocaleCompare(attribute,"fill") == 0)
1489 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1492 if (LocaleCompare(attribute,"font") == 0)
1495 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1498 if (LocaleCompare(attribute,"foreground") == 0)
1500 if (LocaleCompare(attribute,"fuzz") == 0)
1503 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1505 for ( ; image; image=image->next)
1506 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1511 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1512 for ( ; image; image=image->next)
1513 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1519 if (LocaleCompare(attribute,"gamma") == 0)
1521 for ( ; image; image=image->next)
1522 image->gamma=SvNV(sval);
1525 if (LocaleCompare(attribute,"gravity") == 0)
1527 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1528 SvPV(sval,na)) : SvIV(sval);
1531 ThrowPerlException(exception,OptionError,
1532 "UnrecognizedGravityType",SvPV(sval,na));
1536 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1537 for ( ; image; image=image->next)
1538 image->gravity=(GravityType) sp;
1541 if (LocaleCompare(attribute,"green-primary") == 0)
1543 for ( ; image; image=image->next)
1545 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1546 image->chromaticity.green_primary.x=geometry_info.rho;
1547 image->chromaticity.green_primary.y=geometry_info.sigma;
1548 if ((flags & SigmaValue) == 0)
1549 image->chromaticity.green_primary.y=
1550 image->chromaticity.green_primary.x;
1555 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1556 for ( ; image; image=image->next)
1557 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1563 if (LocaleNCompare(attribute,"index",5) == 0)
1577 for ( ; image; image=image->next)
1579 if (image->storage_class != PseudoClass)
1583 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1585 image_view=AcquireAuthenticCacheView(image,exception);
1586 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1587 if (q != (Quantum *) NULL)
1589 items=sscanf(SvPV(sval,na),"%ld",&index);
1590 if ((index >= 0) && (index < (ssize_t) image->colors))
1591 SetPixelIndex(image,index,q);
1592 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1594 image_view=DestroyCacheView(image_view);
1598 if (LocaleCompare(attribute,"iterations") == 0)
1601 for ( ; image; image=image->next)
1602 image->iterations=SvIV(sval);
1605 if (LocaleCompare(attribute,"interlace") == 0)
1607 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1608 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1611 ThrowPerlException(exception,OptionError,
1612 "UnrecognizedInterlaceType",SvPV(sval,na));
1616 info->image_info->interlace=(InterlaceType) sp;
1617 for ( ; image; image=image->next)
1618 image->interlace=(InterlaceType) sp;
1622 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1623 for ( ; image; image=image->next)
1624 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1630 if (LocaleCompare(attribute,"label") == 0)
1632 for ( ; image; image=image->next)
1633 (void) SetImageProperty(image,"label",InterpretImageProperties(
1634 info ? info->image_info : (ImageInfo *) NULL,image,
1635 SvPV(sval,na),exception),exception);
1638 if (LocaleCompare(attribute,"loop") == 0)
1641 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1642 for ( ; image; image=image->next)
1643 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1649 if (LocaleCompare(attribute,"magick") == 0)
1652 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1653 "%s:",SvPV(sval,na));
1654 for ( ; image; image=image->next)
1655 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1658 if (LocaleCompare(attribute,"map-limit") == 0)
1663 limit=MagickResourceInfinity;
1664 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1665 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1667 (void) SetMagickResourceLimit(MapResource,limit);
1670 if (LocaleCompare(attribute,"mask") == 0)
1675 mask=(Image *) NULL;
1677 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1678 for ( ; image; image=image->next)
1679 SetImageMask(image,mask,exception);
1682 if (LocaleCompare(attribute,"mattecolor") == 0)
1684 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1687 info->image_info->matte_color=target_color;
1688 for ( ; image; image=image->next)
1689 image->matte_color=target_color;
1692 if (LocaleCompare(attribute,"matte") == 0)
1694 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1695 SvPV(sval,na)) : SvIV(sval);
1698 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1702 for ( ; image; image=image->next)
1703 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1706 if (LocaleCompare(attribute,"memory-limit") == 0)
1711 limit=MagickResourceInfinity;
1712 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1713 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1715 (void) SetMagickResourceLimit(MemoryResource,limit);
1718 if (LocaleCompare(attribute,"monochrome") == 0)
1720 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1721 SvPV(sval,na)) : SvIV(sval);
1724 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1729 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1730 for ( ; image; image=image->next)
1731 (void) SetImageType(image,BilevelType,exception);
1735 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1736 for ( ; image; image=image->next)
1737 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1743 if (LocaleCompare(attribute,"option") == 0)
1746 DefineImageOption(info->image_info,SvPV(sval,na));
1749 if (LocaleCompare(attribute,"orientation") == 0)
1751 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1752 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1755 ThrowPerlException(exception,OptionError,
1756 "UnrecognizedOrientationType",SvPV(sval,na));
1760 info->image_info->orientation=(OrientationType) sp;
1761 for ( ; image; image=image->next)
1762 image->orientation=(OrientationType) sp;
1766 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1767 for ( ; image; image=image->next)
1768 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1774 if (LocaleCompare(attribute,"page") == 0)
1779 geometry=GetPageGeometry(SvPV(sval,na));
1781 (void) CloneString(&info->image_info->page,geometry);
1782 for ( ; image; image=image->next)
1783 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1784 geometry=(char *) RelinquishMagickMemory(geometry);
1787 if (LocaleNCompare(attribute,"pixel",5) == 0)
1801 for ( ; image; image=image->next)
1803 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1807 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1809 image_view=AcquireVirtualCacheView(image,exception);
1810 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1811 if (q != (Quantum *) NULL)
1813 if ((strchr(SvPV(sval,na),',') == 0) ||
1814 (strchr(SvPV(sval,na),')') != 0))
1815 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1819 GetPixelInfo(image,&pixel);
1820 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1821 pixel.red=geometry_info.rho;
1822 if ((flags & SigmaValue) != 0)
1823 pixel.green=geometry_info.sigma;
1824 if ((flags & XiValue) != 0)
1825 pixel.blue=geometry_info.xi;
1826 if ((flags & PsiValue) != 0)
1827 pixel.alpha=geometry_info.psi;
1828 if ((flags & ChiValue) != 0)
1829 pixel.black=geometry_info.chi;
1831 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1832 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1833 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1834 if (image->colorspace == CMYKColorspace)
1835 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1836 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1837 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1839 image_view=DestroyCacheView(image_view);
1843 if (LocaleCompare(attribute,"pointsize") == 0)
1847 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1848 info->image_info->pointsize=geometry_info.rho;
1852 if (LocaleCompare(attribute,"preview") == 0)
1854 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1855 SvPV(sval,na)) : SvIV(sval);
1858 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1863 info->image_info->preview_type=(PreviewType) sp;
1867 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1868 for ( ; image; image=image->next)
1869 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1875 if (LocaleCompare(attribute,"quality") == 0)
1878 info->image_info->quality=SvIV(sval);
1879 for ( ; image; image=image->next)
1880 image->quality=SvIV(sval);
1884 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1885 for ( ; image; image=image->next)
1886 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1892 if (LocaleCompare(attribute,"red-primary") == 0)
1894 for ( ; image; image=image->next)
1896 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1897 image->chromaticity.red_primary.x=geometry_info.rho;
1898 image->chromaticity.red_primary.y=geometry_info.sigma;
1899 if ((flags & SigmaValue) == 0)
1900 image->chromaticity.red_primary.y=
1901 image->chromaticity.red_primary.x;
1905 if (LocaleCompare(attribute,"render") == 0)
1907 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1908 SvPV(sval,na)) : SvIV(sval);
1911 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1915 for ( ; image; image=image->next)
1916 image->rendering_intent=(RenderingIntent) sp;
1919 if (LocaleCompare(attribute,"repage") == 0)
1924 for ( ; image; image=image->next)
1926 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1927 if ((flags & WidthValue) != 0)
1929 if ((flags & HeightValue) == 0)
1930 geometry.height=geometry.width;
1931 image->page.width=geometry.width;
1932 image->page.height=geometry.height;
1934 if ((flags & AspectValue) != 0)
1936 if ((flags & XValue) != 0)
1937 image->page.x+=geometry.x;
1938 if ((flags & YValue) != 0)
1939 image->page.y+=geometry.y;
1943 if ((flags & XValue) != 0)
1945 image->page.x=geometry.x;
1946 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1947 image->page.width=image->columns+geometry.x;
1949 if ((flags & YValue) != 0)
1951 image->page.y=geometry.y;
1952 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1953 image->page.height=image->rows+geometry.y;
1960 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1961 for ( ; image; image=image->next)
1962 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1968 if (LocaleCompare(attribute,"sampling-factor") == 0)
1970 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1972 ThrowPerlException(exception,OptionError,"MissingGeometry",
1977 (void) CloneString(&info->image_info->sampling_factor,
1981 if (LocaleCompare(attribute,"scene") == 0)
1983 for ( ; image; image=image->next)
1984 image->scene=SvIV(sval);
1987 if (LocaleCompare(attribute,"server") == 0)
1989 if (LocaleCompare(attribute,"size") == 0)
1993 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1995 ThrowPerlException(exception,OptionError,"MissingGeometry",
1999 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2003 if (LocaleCompare(attribute,"stroke") == 0)
2006 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2010 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2011 for ( ; image; image=image->next)
2012 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2018 if (LocaleCompare(attribute,"texture") == 0)
2021 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2024 if (LocaleCompare(attribute,"thread-limit") == 0)
2029 limit=MagickResourceInfinity;
2030 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2031 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2033 (void) SetMagickResourceLimit(ThreadResource,limit);
2036 if (LocaleCompare(attribute,"tile-offset") == 0)
2041 geometry=GetPageGeometry(SvPV(sval,na));
2043 (void) CloneString(&info->image_info->page,geometry);
2044 for ( ; image; image=image->next)
2045 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2047 geometry=(char *) RelinquishMagickMemory(geometry);
2050 if (LocaleCompare(attribute,"time-limit") == 0)
2055 limit=MagickResourceInfinity;
2056 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2057 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2059 (void) SetMagickResourceLimit(TimeResource,limit);
2062 if (LocaleCompare(attribute,"transparent-color") == 0)
2064 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2067 info->image_info->transparent_color=target_color;
2068 for ( ; image; image=image->next)
2069 image->transparent_color=target_color;
2072 if (LocaleCompare(attribute,"type") == 0)
2074 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2075 SvPV(sval,na)) : SvIV(sval);
2078 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2083 info->image_info->type=(ImageType) sp;
2084 for ( ; image; image=image->next)
2085 SetImageType(image,(ImageType) sp,exception);
2089 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2090 for ( ; image; image=image->next)
2091 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2097 if (LocaleCompare(attribute,"units") == 0)
2099 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2100 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2103 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2108 info->image_info->units=(ResolutionType) sp;
2109 for ( ; image; image=image->next)
2114 units=(ResolutionType) sp;
2115 if (image->units != units)
2116 switch (image->units)
2118 case UndefinedResolution:
2119 case PixelsPerInchResolution:
2121 if (units == PixelsPerCentimeterResolution)
2123 image->resolution.x*=2.54;
2124 image->resolution.y*=2.54;
2128 case PixelsPerCentimeterResolution:
2130 if (units == PixelsPerInchResolution)
2132 image->resolution.x/=2.54;
2133 image->resolution.y/=2.54;
2143 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2144 for ( ; image; image=image->next)
2145 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2151 if (LocaleCompare(attribute,"verbose") == 0)
2153 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2154 SvPV(sval,na)) : SvIV(sval);
2157 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2162 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2165 if (LocaleCompare(attribute,"view") == 0)
2168 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2171 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2173 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2174 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2177 ThrowPerlException(exception,OptionError,
2178 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2181 for ( ; image; image=image->next)
2182 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2186 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2187 for ( ; image; image=image->next)
2188 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2194 if (LocaleCompare(attribute,"white-point") == 0)
2196 for ( ; image; image=image->next)
2198 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2199 image->chromaticity.white_point.x=geometry_info.rho;
2200 image->chromaticity.white_point.y=geometry_info.sigma;
2201 if ((flags & SigmaValue) == 0)
2202 image->chromaticity.white_point.y=
2203 image->chromaticity.white_point.x;
2208 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2209 for ( ; image; image=image->next)
2210 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2216 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2217 for ( ; image; image=image->next)
2218 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2229 % S e t u p L i s t %
2233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2235 % Method SetupList returns the list of all the images linked by their
2236 % image->next and image->previous link lists for use with ImageMagick. If
2237 % info is non-NULL, an info structure is returned in *info. If
2238 % reference_vector is non-NULL,an array of SV* are returned in
2239 % *reference_vector. Reference_vector is used when the images are going to be
2240 % replaced with new Image*'s.
2242 % The format of the SetupList routine is:
2244 % Image *SetupList(SV *reference,struct PackageInfo **info,
2245 % SV ***reference_vector,ExceptionInfo *exception)
2247 % A description of each parameter follows:
2249 % o list: a list of strings.
2251 % o string: a character string.
2253 % o exception: Return any errors or warnings in this structure.
2256 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2257 SV ***reference_vector,ExceptionInfo *exception)
2266 if (reference_vector)
2267 *reference_vector=NULL;
2272 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2273 if (info && (SvTYPE(reference) == SVt_PVAV))
2274 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2280 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2284 % s t r E Q c a s e %
2288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2290 % strEQcase() compares two strings and returns 0 if they are the
2291 % same or if the second string runs out first. The comparison is case
2294 % The format of the strEQcase routine is:
2296 % ssize_t strEQcase(const char *p,const char *q)
2298 % A description of each parameter follows:
2300 % o p: a character string.
2302 % o q: a character string.
2306 static ssize_t strEQcase(const char *p,const char *q)
2314 for (i=0 ; (c=(*q)) != 0; i++)
2316 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2317 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2322 return(((*q == 0) && (*p == 0)) ? i : 0);
2326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2330 % I m a g e : : M a g i c k %
2334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2338 MODULE = Image::Magick PACKAGE = Image::Magick
2343 MagickCoreGenesis("PerlMagick",MagickFalse);
2344 SetWarningHandler(NULL);
2345 SetErrorHandler(NULL);
2346 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2347 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2353 if (magick_registry != (SplayTreeInfo *) NULL)
2354 magick_registry=DestroySplayTree(magick_registry);
2355 MagickCoreTerminus();
2359 constant(name,argument)
2364 ###############################################################################
2372 ###############################################################################
2377 Image::Magick ref=NO_INIT
2401 PERL_UNUSED_VAR(ref);
2402 PERL_UNUSED_VAR(ix);
2403 exception=AcquireExceptionInfo();
2404 perl_exception=newSVpv("",0);
2405 package_info=(struct PackageInfo *) NULL;
2406 if (sv_isobject(ST(0)) == 0)
2408 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2412 reference=SvRV(ST(0));
2413 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2414 if (image == (Image *) NULL)
2416 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2420 package_info=ClonePackageInfo(info,exception);
2422 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2425 for (i=2; i < items; i+=2)
2426 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2428 (void) AnimateImages(package_info->image_info,image,exception);
2429 (void) CatchImageException(image);
2432 if (package_info != (struct PackageInfo *) NULL)
2433 DestroyPackageInfo(package_info);
2434 InheritPerlException(exception,perl_exception);
2435 exception=DestroyExceptionInfo(exception);
2436 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2437 SvPOK_on(perl_exception);
2438 ST(0)=sv_2mortal(perl_exception);
2443 ###############################################################################
2451 ###############################################################################
2456 Image::Magick ref=NO_INIT
2494 PERL_UNUSED_VAR(ref);
2495 PERL_UNUSED_VAR(ix);
2496 exception=AcquireExceptionInfo();
2497 perl_exception=newSVpv("",0);
2501 if (sv_isobject(ST(0)) == 0)
2503 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2507 reference=SvRV(ST(0));
2508 hv=SvSTASH(reference);
2510 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2513 if (image == (Image *) NULL)
2515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2519 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2524 for (i=2; i < items; i+=2)
2526 attribute=(char *) SvPV(ST(i-1),na);
2532 if (LocaleCompare(attribute,"stack") == 0)
2534 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2538 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2556 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2557 if (image == (Image *) NULL)
2559 for ( ; image; image=image->next)
2561 AddImageToRegistry(sv,image);
2563 av_push(av,sv_bless(rv,hv));
2566 exception=DestroyExceptionInfo(exception);
2568 SvREFCNT_dec(perl_exception);
2572 InheritPerlException(exception,perl_exception);
2573 exception=DestroyExceptionInfo(exception);
2574 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2575 SvPOK_on(perl_exception);
2576 ST(0)=sv_2mortal(perl_exception);
2581 ###############################################################################
2589 ###############################################################################
2594 Image::Magick ref=NO_INIT
2625 PERL_UNUSED_VAR(ref);
2626 PERL_UNUSED_VAR(ix);
2627 exception=AcquireExceptionInfo();
2628 perl_exception=newSVpv("",0);
2630 if (sv_isobject(ST(0)) == 0)
2632 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2636 reference=SvRV(ST(0));
2637 hv=SvSTASH(reference);
2638 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2639 if (image == (Image *) NULL)
2641 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2645 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2646 if (image == (Image *) NULL)
2649 Create blessed Perl array for the returned image.
2652 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2654 AddImageToRegistry(sv,image);
2656 av_push(av,sv_bless(rv,hv));
2658 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2659 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2660 "average-%.*s",(int) (MaxTextExtent-9),
2661 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2662 (void) CopyMagickString(image->filename,info->image_info->filename,
2664 SetImageInfo(info->image_info,0,exception);
2665 exception=DestroyExceptionInfo(exception);
2666 SvREFCNT_dec(perl_exception);
2670 InheritPerlException(exception,perl_exception);
2671 exception=DestroyExceptionInfo(exception);
2672 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2673 SvPOK_on(perl_exception);
2674 ST(0)=sv_2mortal(perl_exception);
2679 ###############################################################################
2683 # B l o b T o I m a g e #
2687 ###############################################################################
2691 BlobToImage(ref,...)
2692 Image::Magick ref=NO_INIT
2738 PERL_UNUSED_VAR(ref);
2739 PERL_UNUSED_VAR(ix);
2740 exception=AcquireExceptionInfo();
2741 perl_exception=newSVpv("",0);
2744 ac=(items < 2) ? 1 : items-1;
2745 length=(STRLEN *) NULL;
2746 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2747 if (list == (char **) NULL)
2749 ThrowPerlException(exception,ResourceLimitError,
2750 "MemoryAllocationFailed",PackageName);
2753 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2754 if (length == (STRLEN *) NULL)
2756 ThrowPerlException(exception,ResourceLimitError,
2757 "MemoryAllocationFailed",PackageName);
2760 if (sv_isobject(ST(0)) == 0)
2762 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2766 reference=SvRV(ST(0));
2767 hv=SvSTASH(reference);
2768 if (SvTYPE(reference) != SVt_PVAV)
2770 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2774 av=(AV *) reference;
2775 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2780 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2783 for (n=0, i=0; i < ac; i++)
2785 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2786 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2788 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2793 list[n]=(char *) NULL;
2795 for (i=number_images=0; i < n; i++)
2797 image=BlobToImage(info->image_info,list[i],length[i],exception);
2798 if (image == (Image *) NULL)
2800 for ( ; image; image=image->next)
2802 AddImageToRegistry(sv,image);
2804 av_push(av,sv_bless(rv,hv));
2812 for (i=0; i < n; i++)
2813 if (list[i] != (char *) NULL)
2814 for (p=keep; list[i] != *p++; )
2815 if (*p == (char *) NULL)
2817 list[i]=(char *) RelinquishMagickMemory(list[i]);
2823 list=(char **) RelinquishMagickMemory(list);
2825 length=(STRLEN *) RelinquishMagickMemory(length);
2826 InheritPerlException(exception,perl_exception);
2827 exception=DestroyExceptionInfo(exception);
2828 sv_setiv(perl_exception,(IV) number_images);
2829 SvPOK_on(perl_exception);
2830 ST(0)=sv_2mortal(perl_exception);
2835 ###############################################################################
2839 # C h a n n e l F x #
2843 ###############################################################################
2848 Image::Magick ref=NO_INIT
2860 expression[MaxTextExtent];
2888 PERL_UNUSED_VAR(ref);
2889 PERL_UNUSED_VAR(ix);
2890 exception=AcquireExceptionInfo();
2891 perl_exception=newSVpv("",0);
2895 if (sv_isobject(ST(0)) == 0)
2897 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2901 reference=SvRV(ST(0));
2902 hv=SvSTASH(reference);
2904 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2906 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2907 if (image == (Image *) NULL)
2909 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2913 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2917 channel=DefaultChannels;
2918 (void) CopyMagickString(expression,"u",MaxTextExtent);
2920 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2922 for (i=2; i < items; i+=2)
2924 attribute=(char *) SvPV(ST(i-1),na);
2930 if (LocaleCompare(attribute,"channel") == 0)
2935 option=ParseChannelOption(SvPV(ST(i),na));
2938 ThrowPerlException(exception,OptionError,
2939 "UnrecognizedType",SvPV(ST(i),na));
2942 channel=(ChannelType) option;
2945 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2952 if (LocaleCompare(attribute,"expression") == 0)
2954 (void) CopyMagickString(expression,SvPV(ST(i),na),
2958 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2964 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2970 channel_mask=SetImageChannelMask(image,channel);
2971 image=ChannelFxImage(image,expression,exception);
2972 if (image != (Image *) NULL)
2973 (void) SetImageChannelMask(image,channel_mask);
2974 if (image == (Image *) NULL)
2976 for ( ; image; image=image->next)
2978 AddImageToRegistry(sv,image);
2980 av_push(av,sv_bless(rv,hv));
2983 exception=DestroyExceptionInfo(exception);
2985 SvREFCNT_dec(perl_exception); /* can't return warning messages */
2989 InheritPerlException(exception,perl_exception);
2990 exception=DestroyExceptionInfo(exception);
2991 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2992 SvPOK_on(perl_exception);
2993 ST(0)=sv_2mortal(perl_exception);
2998 ###############################################################################
3006 ###############################################################################
3011 Image::Magick ref=NO_INIT
3044 PERL_UNUSED_VAR(ref);
3045 PERL_UNUSED_VAR(ix);
3046 exception=AcquireExceptionInfo();
3047 perl_exception=newSVpv("",0);
3049 if (sv_isobject(ST(0)) == 0)
3051 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3055 reference=SvRV(ST(0));
3056 hv=SvSTASH(reference);
3057 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3058 if (image == (Image *) NULL)
3060 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3065 Create blessed Perl array for the returned image.
3068 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3070 for ( ; image; image=image->next)
3072 clone=CloneImage(image,0,0,MagickTrue,exception);
3073 if (clone == (Image *) NULL)
3075 AddImageToRegistry(sv,clone);
3077 av_push(av,sv_bless(rv,hv));
3080 exception=DestroyExceptionInfo(exception);
3081 SvREFCNT_dec(perl_exception);
3085 InheritPerlException(exception,perl_exception);
3086 exception=DestroyExceptionInfo(exception);
3087 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3088 SvPOK_on(perl_exception);
3089 ST(0)=sv_2mortal(perl_exception);
3094 ###############################################################################
3102 ###############################################################################
3110 PERL_UNUSED_VAR(ref);
3111 if (magick_registry != (SplayTreeInfo *) NULL)
3116 ResetSplayTreeIterator(magick_registry);
3117 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3118 while (p != (Image *) NULL)
3121 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3127 ###############################################################################
3135 ###############################################################################
3140 Image::Magick ref=NO_INIT
3169 PERL_UNUSED_VAR(ref);
3170 PERL_UNUSED_VAR(ix);
3171 exception=AcquireExceptionInfo();
3172 perl_exception=newSVpv("",0);
3174 if (sv_isobject(ST(0)) == 0)
3176 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3180 reference=SvRV(ST(0));
3181 hv=SvSTASH(reference);
3183 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3185 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3186 if (image == (Image *) NULL)
3188 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3192 image=CoalesceImages(image,exception);
3193 if (image == (Image *) NULL)
3195 for ( ; image; image=image->next)
3197 AddImageToRegistry(sv,image);
3199 av_push(av,sv_bless(rv,hv));
3202 exception=DestroyExceptionInfo(exception);
3204 SvREFCNT_dec(perl_exception);
3208 InheritPerlException(exception,perl_exception);
3209 exception=DestroyExceptionInfo(exception);
3210 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3211 SvPOK_on(perl_exception);
3212 ST(0)=sv_2mortal(perl_exception);
3217 ###############################################################################
3225 ###############################################################################
3230 Image::Magick ref=NO_INIT
3276 PERL_UNUSED_VAR(ref);
3277 PERL_UNUSED_VAR(ix);
3278 exception=AcquireExceptionInfo();
3279 perl_exception=newSVpv("",0);
3283 if (sv_isobject(ST(0)) == 0)
3285 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3289 reference=SvRV(ST(0));
3290 hv=SvSTASH(reference);
3292 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3294 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3295 if (image == (Image *) NULL)
3297 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3301 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3305 reconstruct_image=image;
3306 metric=RootMeanSquaredErrorMetric;
3307 for (i=2; i < items; i+=2)
3309 attribute=(char *) SvPV(ST(i-1),na);
3315 if (LocaleCompare(attribute,"channel") == 0)
3320 option=ParseChannelOption(SvPV(ST(i),na));
3323 ThrowPerlException(exception,OptionError,
3324 "UnrecognizedType",SvPV(ST(i),na));
3327 SetPixelChannelMask(image,(ChannelType) option);
3330 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3337 if (LocaleCompare(attribute,"fuzz") == 0)
3339 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3342 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3349 if (LocaleCompare(attribute,"image") == 0)
3351 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3352 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3355 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3362 if (LocaleCompare(attribute,"metric") == 0)
3364 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3368 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3372 metric=(MetricType) option;
3375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3381 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3387 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3389 if (difference_image != (Image *) NULL)
3391 difference_image->error.mean_error_per_pixel=distortion;
3392 AddImageToRegistry(sv,difference_image);
3394 av_push(av,sv_bless(rv,hv));
3397 exception=DestroyExceptionInfo(exception);
3399 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3403 InheritPerlException(exception,perl_exception);
3404 exception=DestroyExceptionInfo(exception);
3405 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3406 SvPOK_on(perl_exception);
3407 ST(0)=sv_2mortal(perl_exception);
3412 ###############################################################################
3416 # C o m p a r e L a y e r s #
3420 ###############################################################################
3425 Image::Magick ref=NO_INIT
3427 CompareImagesLayers = 1
3429 compareimagelayers = 3
3466 PERL_UNUSED_VAR(ref);
3467 PERL_UNUSED_VAR(ix);
3468 exception=AcquireExceptionInfo();
3469 perl_exception=newSVpv("",0);
3471 if (sv_isobject(ST(0)) == 0)
3473 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3477 reference=SvRV(ST(0));
3478 hv=SvSTASH(reference);
3480 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3482 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3483 if (image == (Image *) NULL)
3485 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3489 method=CompareAnyLayer;
3490 for (i=2; i < items; i+=2)
3492 attribute=(char *) SvPV(ST(i-1),na);
3498 if (LocaleCompare(attribute,"method") == 0)
3500 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3504 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3508 method=(LayerMethod) option;
3511 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3523 image=CompareImagesLayers(image,method,exception);
3524 if (image == (Image *) NULL)
3526 for ( ; image; image=image->next)
3528 AddImageToRegistry(sv,image);
3530 av_push(av,sv_bless(rv,hv));
3533 exception=DestroyExceptionInfo(exception);
3535 SvREFCNT_dec(perl_exception);
3539 InheritPerlException(exception,perl_exception);
3540 exception=DestroyExceptionInfo(exception);
3541 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3542 SvPOK_on(perl_exception);
3543 ST(0)=sv_2mortal(perl_exception);
3548 ###############################################################################
3556 ###############################################################################
3561 Image::Magick ref=NO_INIT
3567 PERL_UNUSED_VAR(ref);
3568 if (sv_isobject(ST(0)) == 0)
3569 croak("ReferenceIsNotMyType");
3570 reference=SvRV(ST(0));
3571 switch (SvTYPE(reference))
3576 message[MaxTextExtent];
3594 Array (AV *) reference
3596 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3597 XS_VERSION,reference);
3598 hv=gv_stashpv(PackageName, FALSE);
3601 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3605 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3607 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3608 DestroyPackageInfo(info);
3610 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3620 Blessed scalar = (Image *) SvIV(reference)
3622 image=INT2PTR(Image *,SvIV(reference));
3623 if (image != (Image *) NULL)
3624 DeleteImageFromRegistry(reference,image);
3633 ###############################################################################
3641 ###############################################################################
3646 Image::Magick ref=NO_INIT
3670 PERL_UNUSED_VAR(ref);
3671 PERL_UNUSED_VAR(ix);
3672 exception=AcquireExceptionInfo();
3673 perl_exception=newSVpv("",0);
3674 package_info=(struct PackageInfo *) NULL;
3675 if (sv_isobject(ST(0)) == 0)
3677 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3681 reference=SvRV(ST(0));
3682 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3683 if (image == (Image *) NULL)
3685 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3689 package_info=ClonePackageInfo(info,exception);
3691 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3694 for (i=2; i < items; i+=2)
3695 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3697 (void) DisplayImages(package_info->image_info,image,exception);
3698 (void) CatchImageException(image);
3701 if (package_info != (struct PackageInfo *) NULL)
3702 DestroyPackageInfo(package_info);
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 ###############################################################################
3716 # E v a l u a t e I m a g e s #
3720 ###############################################################################
3725 Image::Magick ref=NO_INIT
3747 MagickEvaluateOperator
3762 PERL_UNUSED_VAR(ref);
3763 PERL_UNUSED_VAR(ix);
3764 exception=AcquireExceptionInfo();
3765 perl_exception=newSVpv("",0);
3767 if (sv_isobject(ST(0)) == 0)
3769 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3773 reference=SvRV(ST(0));
3774 hv=SvSTASH(reference);
3775 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3776 if (image == (Image *) NULL)
3778 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3782 op=MeanEvaluateOperator;
3788 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3792 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3796 op=(MagickEvaluateOperator) in;
3799 for (i=2; i < items; i+=2)
3801 attribute=(char *) SvPV(ST(i-1),na);
3807 if (LocaleCompare(attribute,"operator") == 0)
3812 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3813 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3816 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3820 op=(MagickEvaluateOperator) in;
3823 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3829 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3835 image=EvaluateImages(image,op,exception);
3836 if (image == (Image *) NULL)
3839 Create blessed Perl array for the returned image.
3842 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3844 AddImageToRegistry(sv,image);
3846 av_push(av,sv_bless(rv,hv));
3848 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3849 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3850 "evaluate-%.*s",(int) (MaxTextExtent-9),
3851 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3852 (void) CopyMagickString(image->filename,info->image_info->filename,
3854 SetImageInfo(info->image_info,0,exception);
3855 exception=DestroyExceptionInfo(exception);
3856 SvREFCNT_dec(perl_exception);
3860 InheritPerlException(exception,perl_exception);
3861 exception=DestroyExceptionInfo(exception);
3862 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3863 SvPOK_on(perl_exception);
3864 ST(0)=sv_2mortal(perl_exception);
3869 ###############################################################################
3877 ###############################################################################
3882 Image::Magick ref=NO_INIT
3889 #define ChannelFeatures(channel,direction) \
3891 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3892 channel_features[channel].angular_second_moment[direction]); \
3893 PUSHs(sv_2mortal(newSVpv(message,0))); \
3894 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3895 channel_features[channel].contrast[direction]); \
3896 PUSHs(sv_2mortal(newSVpv(message,0))); \
3897 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3898 channel_features[channel].contrast[direction]); \
3899 PUSHs(sv_2mortal(newSVpv(message,0))); \
3900 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3901 channel_features[channel].variance_sum_of_squares[direction]); \
3902 PUSHs(sv_2mortal(newSVpv(message,0))); \
3903 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3904 channel_features[channel].inverse_difference_moment[direction]); \
3905 PUSHs(sv_2mortal(newSVpv(message,0))); \
3906 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3907 channel_features[channel].sum_average[direction]); \
3908 PUSHs(sv_2mortal(newSVpv(message,0))); \
3909 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3910 channel_features[channel].sum_variance[direction]); \
3911 PUSHs(sv_2mortal(newSVpv(message,0))); \
3912 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3913 channel_features[channel].sum_entropy[direction]); \
3914 PUSHs(sv_2mortal(newSVpv(message,0))); \
3915 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3916 channel_features[channel].entropy[direction]); \
3917 PUSHs(sv_2mortal(newSVpv(message,0))); \
3918 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3919 channel_features[channel].difference_variance[direction]); \
3920 PUSHs(sv_2mortal(newSVpv(message,0))); \
3921 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3922 channel_features[channel].difference_entropy[direction]); \
3923 PUSHs(sv_2mortal(newSVpv(message,0))); \
3924 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3925 channel_features[channel].measure_of_correlation_1[direction]); \
3926 PUSHs(sv_2mortal(newSVpv(message,0))); \
3927 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3928 channel_features[channel].measure_of_correlation_2[direction]); \
3929 PUSHs(sv_2mortal(newSVpv(message,0))); \
3930 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3931 channel_features[channel].maximum_correlation_coefficient[direction]); \
3932 PUSHs(sv_2mortal(newSVpv(message,0))); \
3940 message[MaxTextExtent];
3967 PERL_UNUSED_VAR(ref);
3968 PERL_UNUSED_VAR(ix);
3969 exception=AcquireExceptionInfo();
3970 perl_exception=newSVpv("",0);
3972 if (sv_isobject(ST(0)) == 0)
3974 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3978 reference=SvRV(ST(0));
3981 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3982 if (image == (Image *) NULL)
3984 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3988 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3990 for (i=2; i < items; i+=2)
3992 attribute=(char *) SvPV(ST(i-1),na);
3998 if (LocaleCompare(attribute,"distance") == 0)
4000 distance=StringToLong((char *) SvPV(ST(1),na));
4003 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4009 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4016 for ( ; image; image=image->next)
4018 channel_features=GetImageFeatures(image,distance,exception);
4019 if (channel_features == (ChannelFeatures *) NULL)
4022 EXTEND(sp,75*count);
4023 for (i=0; i < 4; i++)
4025 ChannelFeatures(RedChannel,i);
4026 ChannelFeatures(GreenChannel,i);
4027 ChannelFeatures(BlueChannel,i);
4028 if (image->colorspace == CMYKColorspace)
4029 ChannelFeatures(BlackChannel,i);
4030 if (image->alpha_trait == BlendPixelTrait)
4031 ChannelFeatures(AlphaChannel,i);
4033 channel_features=(ChannelFeatures *)
4034 RelinquishMagickMemory(channel_features);
4038 InheritPerlException(exception,perl_exception);
4039 exception=DestroyExceptionInfo(exception);
4040 SvREFCNT_dec(perl_exception);
4044 ###############################################################################
4052 ###############################################################################
4057 Image::Magick ref=NO_INIT
4095 PERL_UNUSED_VAR(ref);
4096 PERL_UNUSED_VAR(ix);
4097 exception=AcquireExceptionInfo();
4098 perl_exception=newSVpv("",0);
4100 if (sv_isobject(ST(0)) == 0)
4102 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4106 reference=SvRV(ST(0));
4107 hv=SvSTASH(reference);
4108 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4109 if (image == (Image *) NULL)
4111 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4115 background_color=image->background_color;
4117 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4118 &background_color,exception);
4120 for (i=2; i < items; i+=2)
4122 attribute=(char *) SvPV(ST(i-1),na);
4128 if (LocaleCompare(attribute,"background") == 0)
4130 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4131 AllCompliance,&background_color,exception);
4134 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4140 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4146 image->background_color=background_color;
4147 image=MergeImageLayers(image,FlattenLayer,exception);
4148 if (image == (Image *) NULL)
4151 Create blessed Perl array for the returned image.
4154 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4156 AddImageToRegistry(sv,image);
4158 av_push(av,sv_bless(rv,hv));
4160 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4161 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4162 "flatten-%.*s",(int) (MaxTextExtent-9),
4163 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4164 (void) CopyMagickString(image->filename,info->image_info->filename,
4166 SetImageInfo(info->image_info,0,exception);
4167 exception=DestroyExceptionInfo(exception);
4168 SvREFCNT_dec(perl_exception);
4172 InheritPerlException(exception,perl_exception);
4173 exception=DestroyExceptionInfo(exception);
4174 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4175 SvPOK_on(perl_exception); /* return messages in string context */
4176 ST(0)=sv_2mortal(perl_exception);
4181 ###############################################################################
4189 ###############################################################################
4194 Image::Magick ref=NO_INIT
4206 expression[MaxTextExtent];
4234 PERL_UNUSED_VAR(ref);
4235 PERL_UNUSED_VAR(ix);
4236 exception=AcquireExceptionInfo();
4237 perl_exception=newSVpv("",0);
4241 if (sv_isobject(ST(0)) == 0)
4243 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4247 reference=SvRV(ST(0));
4248 hv=SvSTASH(reference);
4250 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4252 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4253 if (image == (Image *) NULL)
4255 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4259 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4263 channel=DefaultChannels;
4264 (void) CopyMagickString(expression,"u",MaxTextExtent);
4266 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4268 for (i=2; i < items; i+=2)
4270 attribute=(char *) SvPV(ST(i-1),na);
4276 if (LocaleCompare(attribute,"channel") == 0)
4281 option=ParseChannelOption(SvPV(ST(i),na));
4284 ThrowPerlException(exception,OptionError,
4285 "UnrecognizedType",SvPV(ST(i),na));
4288 channel=(ChannelType) option;
4291 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4298 if (LocaleCompare(attribute,"expression") == 0)
4300 (void) CopyMagickString(expression,SvPV(ST(i),na),
4304 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4310 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4316 channel_mask=SetImageChannelMask(image,channel);
4317 image=FxImage(image,expression,exception);
4318 if (image != (Image *) NULL)
4319 (void) SetImageChannelMask(image,channel_mask);
4320 if (image == (Image *) NULL)
4322 for ( ; image; image=image->next)
4324 AddImageToRegistry(sv,image);
4326 av_push(av,sv_bless(rv,hv));
4329 exception=DestroyExceptionInfo(exception);
4331 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4335 InheritPerlException(exception,perl_exception);
4336 exception=DestroyExceptionInfo(exception);
4337 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4338 SvPOK_on(perl_exception);
4339 ST(0)=sv_2mortal(perl_exception);
4344 ###############################################################################
4352 ###############################################################################
4357 Image::Magick ref=NO_INIT
4368 color[MaxTextExtent];
4393 PERL_UNUSED_VAR(ref);
4394 PERL_UNUSED_VAR(ix);
4395 exception=AcquireExceptionInfo();
4396 perl_exception=newSVpv("",0);
4397 if (sv_isobject(ST(0)) == 0)
4399 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4403 reference=SvRV(ST(0));
4404 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4405 if (image == (Image *) NULL && !info)
4408 for (i=1; i < items; i++)
4410 attribute=(char *) SvPV(ST(i),na);
4417 if (LocaleCompare(attribute,"adjoin") == 0)
4420 s=newSViv((ssize_t) info->image_info->adjoin);
4421 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4424 if (LocaleCompare(attribute,"antialias") == 0)
4427 s=newSViv((ssize_t) info->image_info->antialias);
4428 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4431 if (LocaleCompare(attribute,"area") == 0)
4433 s=newSViv(GetMagickResource(AreaResource));
4434 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4437 if (LocaleCompare(attribute,"attenuate") == 0)
4442 value=GetImageProperty(image,attribute,exception);
4443 if (value != (const char *) NULL)
4445 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4448 if (LocaleCompare(attribute,"authenticate") == 0)
4455 option=GetImageOption(info->image_info,attribute);
4456 if (option != (const char *) NULL)
4457 s=newSVpv(option,0);
4459 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4462 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4469 if (LocaleCompare(attribute,"background") == 0)
4471 if (image == (Image *) NULL)
4473 (void) FormatLocaleString(color,MaxTextExtent,
4474 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4475 image->background_color.green,image->background_color.blue,
4476 image->background_color.alpha);
4478 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4481 if (LocaleCompare(attribute,"base-columns") == 0)
4483 if (image != (Image *) NULL)
4484 s=newSViv((ssize_t) image->magick_columns);
4485 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4488 if (LocaleCompare(attribute,"base-filename") == 0)
4490 if (image != (Image *) NULL)
4491 s=newSVpv(image->magick_filename,0);
4492 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4495 if (LocaleCompare(attribute,"base-height") == 0)
4497 if (image != (Image *) NULL)
4498 s=newSViv((ssize_t) image->magick_rows);
4499 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4502 if (LocaleCompare(attribute,"base-rows") == 0)
4504 if (image != (Image *) NULL)
4505 s=newSViv((ssize_t) image->magick_rows);
4506 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4509 if (LocaleCompare(attribute,"base-width") == 0)
4511 if (image != (Image *) NULL)
4512 s=newSViv((ssize_t) image->magick_columns);
4513 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4516 if (LocaleCompare(attribute,"blue-primary") == 0)
4518 if (image == (Image *) NULL)
4520 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4521 image->chromaticity.blue_primary.x,
4522 image->chromaticity.blue_primary.y);
4524 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4527 if (LocaleCompare(attribute,"bordercolor") == 0)
4529 if (image == (Image *) NULL)
4531 (void) FormatLocaleString(color,MaxTextExtent,
4532 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4533 image->border_color.green,image->border_color.blue,
4534 image->border_color.alpha);
4536 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4539 if (LocaleCompare(attribute,"bounding-box") == 0)
4542 geometry[MaxTextExtent];
4547 if (image == (Image *) NULL)
4549 page=GetImageBoundingBox(image,exception);
4550 (void) FormatLocaleString(geometry,MaxTextExtent,
4551 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4552 page.height,(double) page.x,(double) page.y);
4553 s=newSVpv(geometry,0);
4554 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4557 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4564 if (LocaleCompare(attribute,"class") == 0)
4566 if (image == (Image *) NULL)
4568 s=newSViv(image->storage_class);
4569 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4570 image->storage_class));
4572 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4575 if (LocaleCompare(attribute,"clip-mask") == 0)
4577 if (image != (Image *) NULL)
4586 if (image->mask == MagickFalse)
4587 ClipImage(image,exception);
4588 mask_image=GetImageMask(image,exception);
4589 if (mask_image != (Image *) NULL)
4591 AddImageToRegistry(sv,mask_image);
4592 s=sv_bless(newRV(sv),SvSTASH(reference));
4595 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4598 if (LocaleCompare(attribute,"clip-path") == 0)
4600 if (image != (Image *) NULL)
4609 if (image->mask != MagickFalse)
4610 ClipImage(image,exception);
4611 mask_image=GetImageMask(image,exception);
4612 if (mask_image != (Image *) NULL)
4614 AddImageToRegistry(sv,mask_image);
4615 s=sv_bless(newRV(sv),SvSTASH(reference));
4618 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4621 if (LocaleCompare(attribute,"compression") == 0)
4623 j=info ? info->image_info->compression : image ?
4624 image->compression : UndefinedCompression;
4626 if (info->image_info->compression == UndefinedCompression)
4627 j=image->compression;
4629 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4632 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4635 if (LocaleCompare(attribute,"colorspace") == 0)
4637 j=image ? image->colorspace : RGBColorspace;
4639 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4642 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4645 if (LocaleCompare(attribute,"colors") == 0)
4647 if (image != (Image *) NULL)
4648 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4650 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4653 if (LocaleNCompare(attribute,"colormap",8) == 0)
4658 if (image == (Image *) NULL || !image->colormap)
4661 items=sscanf(attribute,"%*[^[][%ld",&j);
4663 if (j > (ssize_t) image->colors)
4665 (void) FormatLocaleString(color,MaxTextExtent,
4666 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4667 image->colormap[j].green,image->colormap[j].blue,
4668 image->colormap[j].alpha);
4670 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4673 if (LocaleCompare(attribute,"columns") == 0)
4675 if (image != (Image *) NULL)
4676 s=newSViv((ssize_t) image->columns);
4677 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4680 if (LocaleCompare(attribute,"comment") == 0)
4685 value=GetImageProperty(image,attribute,exception);
4686 if (value != (const char *) NULL)
4688 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4691 if (LocaleCompare(attribute,"copyright") == 0)
4693 s=newSVpv(GetMagickCopyright(),0);
4694 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4704 if (LocaleCompare(attribute,"density") == 0)
4707 geometry[MaxTextExtent];
4709 if (image == (Image *) NULL)
4711 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4712 image->resolution.x,image->resolution.y);
4713 s=newSVpv(geometry,0);
4714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4717 if (LocaleCompare(attribute,"delay") == 0)
4719 if (image != (Image *) NULL)
4720 s=newSViv((ssize_t) image->delay);
4721 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4724 if (LocaleCompare(attribute,"depth") == 0)
4726 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4727 if (image != (Image *) NULL)
4728 s=newSViv((ssize_t) GetImageDepth(image,exception));
4729 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4732 if (LocaleCompare(attribute,"directory") == 0)
4734 if (image && image->directory)
4735 s=newSVpv(image->directory,0);
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 if (LocaleCompare(attribute,"dispose") == 0)
4741 if (image == (Image *) NULL)
4744 s=newSViv(image->dispose);
4746 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4748 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4751 if (LocaleCompare(attribute,"disk") == 0)
4753 s=newSViv(GetMagickResource(DiskResource));
4754 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4757 if (LocaleCompare(attribute,"dither") == 0)
4760 s=newSViv((ssize_t) info->image_info->dither);
4761 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4764 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4766 if (info && info->image_info->server_name)
4767 s=newSVpv(info->image_info->server_name,0);
4768 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4771 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4778 if (LocaleCompare(attribute,"elapsed-time") == 0)
4780 if (image != (Image *) NULL)
4781 s=newSVnv(GetElapsedTime(&image->timer));
4782 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4785 if (LocaleCompare(attribute,"endian") == 0)
4787 j=info ? info->image_info->endian : image ? image->endian :
4790 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4792 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4795 if (LocaleCompare(attribute,"error") == 0)
4797 if (image != (Image *) NULL)
4798 s=newSVnv(image->error.mean_error_per_pixel);
4799 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4802 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4809 if (LocaleCompare(attribute,"filesize") == 0)
4811 if (image != (Image *) NULL)
4812 s=newSViv((ssize_t) GetBlobSize(image));
4813 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4816 if (LocaleCompare(attribute,"filename") == 0)
4818 if (info && info->image_info->filename &&
4819 *info->image_info->filename)
4820 s=newSVpv(info->image_info->filename,0);
4821 if (image != (Image *) NULL)
4822 s=newSVpv(image->filename,0);
4823 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4826 if (LocaleCompare(attribute,"filter") == 0)
4828 s=image ? newSViv(image->filter) : newSViv(0);
4829 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4832 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4835 if (LocaleCompare(attribute,"font") == 0)
4837 if (info && info->image_info->font)
4838 s=newSVpv(info->image_info->font,0);
4839 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4842 if (LocaleCompare(attribute,"foreground") == 0)
4844 if (LocaleCompare(attribute,"format") == 0)
4849 magick_info=(const MagickInfo *) NULL;
4850 if (info && (*info->image_info->magick != '\0'))
4851 magick_info=GetMagickInfo(info->image_info->magick,exception);
4852 if (image != (Image *) NULL)
4853 magick_info=GetMagickInfo(image->magick,exception);
4854 if ((magick_info != (const MagickInfo *) NULL) &&
4855 (*magick_info->description != '\0'))
4856 s=newSVpv((char *) magick_info->description,0);
4857 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4860 if (LocaleCompare(attribute,"fuzz") == 0)
4863 s=newSVnv(info->image_info->fuzz);
4864 if (image != (Image *) NULL)
4865 s=newSVnv(image->fuzz);
4866 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4869 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4876 if (LocaleCompare(attribute,"gamma") == 0)
4878 if (image != (Image *) NULL)
4879 s=newSVnv(image->gamma);
4880 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4883 if (LocaleCompare(attribute,"geometry") == 0)
4885 if (image && image->geometry)
4886 s=newSVpv(image->geometry,0);
4887 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4890 if (LocaleCompare(attribute,"gravity") == 0)
4892 s=image ? newSViv(image->gravity) : newSViv(0);
4893 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4896 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4899 if (LocaleCompare(attribute,"green-primary") == 0)
4901 if (image == (Image *) NULL)
4903 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4904 image->chromaticity.green_primary.x,
4905 image->chromaticity.green_primary.y);
4907 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4910 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4917 if (LocaleCompare(attribute,"height") == 0)
4919 if (image != (Image *) NULL)
4920 s=newSViv((ssize_t) image->rows);
4921 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4924 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4931 if (LocaleCompare(attribute,"icc") == 0)
4933 if (image != (Image *) NULL)
4938 profile=GetImageProfile(image,"icc");
4939 if (profile != (StringInfo *) NULL)
4940 s=newSVpv((const char *) GetStringInfoDatum(profile),
4941 GetStringInfoLength(profile));
4943 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4946 if (LocaleCompare(attribute,"icm") == 0)
4948 if (image != (Image *) NULL)
4953 profile=GetImageProfile(image,"icm");
4954 if (profile != (const StringInfo *) NULL)
4955 s=newSVpv((const char *) GetStringInfoDatum(profile),
4956 GetStringInfoLength(profile));
4958 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4961 if (LocaleCompare(attribute,"id") == 0)
4963 if (image != (Image *) NULL)
4974 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4976 status=SetImageRegistry(ImageRegistryType,key,image,
4981 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4984 if (LocaleNCompare(attribute,"index",5) == 0)
4987 name[MaxTextExtent];
4996 register const Quantum
5002 if (image == (Image *) NULL)
5004 if (image->storage_class != PseudoClass)
5008 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5010 image_view=AcquireVirtualCacheView(image,exception);
5011 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5012 if (p != (const Quantum *) NULL)
5014 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5015 GetPixelIndex(image,p));
5017 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 image_view=DestroyCacheView(image_view);
5022 if (LocaleCompare(attribute,"iptc") == 0)
5024 if (image != (Image *) NULL)
5029 profile=GetImageProfile(image,"iptc");
5030 if (profile != (const StringInfo *) NULL)
5031 s=newSVpv((const char *) GetStringInfoDatum(profile),
5032 GetStringInfoLength(profile));
5034 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5037 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5039 if (image != (Image *) NULL)
5040 s=newSViv((ssize_t) image->iterations);
5041 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5044 if (LocaleCompare(attribute,"interlace") == 0)
5046 j=info ? info->image_info->interlace : image ? image->interlace :
5049 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5052 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5055 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5062 if (LocaleCompare(attribute,"label") == 0)
5067 if (image == (Image *) NULL)
5069 value=GetImageProperty(image,"Label",exception);
5070 if (value != (const char *) NULL)
5072 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5075 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5077 if (image != (Image *) NULL)
5078 s=newSViv((ssize_t) image->iterations);
5079 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5089 if (LocaleCompare(attribute,"magick") == 0)
5091 if (info && *info->image_info->magick)
5092 s=newSVpv(info->image_info->magick,0);
5093 if (image != (Image *) NULL)
5094 s=newSVpv(image->magick,0);
5095 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5098 if (LocaleCompare(attribute,"map") == 0)
5100 s=newSViv(GetMagickResource(MapResource));
5101 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5104 if (LocaleCompare(attribute,"maximum-error") == 0)
5106 if (image != (Image *) NULL)
5107 s=newSVnv(image->error.normalized_maximum_error);
5108 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5111 if (LocaleCompare(attribute,"memory") == 0)
5113 s=newSViv(GetMagickResource(MemoryResource));
5114 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5117 if (LocaleCompare(attribute,"mean-error") == 0)
5119 if (image != (Image *) NULL)
5120 s=newSVnv(image->error.normalized_mean_error);
5121 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5124 if (LocaleCompare(attribute,"mime") == 0)
5126 if (info && *info->image_info->magick)
5127 s=newSVpv(MagickToMime(info->image_info->magick),0);
5128 if (image != (Image *) NULL)
5129 s=newSVpv(MagickToMime(image->magick),0);
5130 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5133 if (LocaleCompare(attribute,"mattecolor") == 0)
5135 if (image == (Image *) NULL)
5137 (void) FormatLocaleString(color,MaxTextExtent,
5138 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
5139 image->matte_color.green,image->matte_color.blue,
5140 image->matte_color.alpha);
5142 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5145 if (LocaleCompare(attribute,"matte") == 0)
5147 if (image != (Image *) NULL)
5148 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5150 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5153 if (LocaleCompare(attribute,"mime") == 0)
5159 if (info && *info->image_info->magick)
5160 magick=info->image_info->magick;
5161 if (image != (Image *) NULL)
5162 magick=image->magick;
5168 mime=MagickToMime(magick);
5170 mime=(char *) RelinquishMagickMemory(mime);
5172 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5175 if (LocaleCompare(attribute,"monochrome") == 0)
5177 if (image == (Image *) NULL)
5179 j=info ? info->image_info->monochrome :
5180 IsImageMonochrome(image,exception);
5182 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5185 if (LocaleCompare(attribute,"montage") == 0)
5187 if (image && image->montage)
5188 s=newSVpv(image->montage,0);
5189 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5192 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5199 if (LocaleCompare(attribute,"orientation") == 0)
5201 j=info ? info->image_info->orientation : image ?
5202 image->orientation : UndefinedOrientation;
5204 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5207 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5210 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5217 if (LocaleCompare(attribute,"page") == 0)
5219 if (info && info->image_info->page)
5220 s=newSVpv(info->image_info->page,0);
5221 if (image != (Image *) NULL)
5224 geometry[MaxTextExtent];
5226 (void) FormatLocaleString(geometry,MaxTextExtent,
5227 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5228 (double) image->page.height,(double) image->page.x,(double)
5230 s=newSVpv(geometry,0);
5232 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5235 if (LocaleCompare(attribute,"page.x") == 0)
5237 if (image != (Image *) NULL)
5238 s=newSViv((ssize_t) image->page.x);
5239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5242 if (LocaleCompare(attribute,"page.y") == 0)
5244 if (image != (Image *) NULL)
5245 s=newSViv((ssize_t) image->page.y);
5246 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5249 if (LocaleNCompare(attribute,"pixel",5) == 0)
5252 tuple[MaxTextExtent];
5261 register const Quantum
5264 if (image == (Image *) NULL)
5268 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5270 p=GetVirtualPixels(image,x,y,1,1,exception);
5271 if (image->colorspace != CMYKColorspace)
5272 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5273 QuantumFormat "," QuantumFormat "," QuantumFormat,
5274 GetPixelRed(image,p),GetPixelGreen(image,p),
5275 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5277 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5278 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5279 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5280 GetPixelBlue(image,p),GetPixelBlack(image,p),
5281 GetPixelAlpha(image,p));
5283 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5286 if (LocaleCompare(attribute,"pointsize") == 0)
5289 s=newSViv((ssize_t) info->image_info->pointsize);
5290 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5293 if (LocaleCompare(attribute,"preview") == 0)
5295 s=newSViv(info->image_info->preview_type);
5296 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5297 info->image_info->preview_type));
5299 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5302 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5309 if (LocaleCompare(attribute,"quality") == 0)
5312 s=newSViv((ssize_t) info->image_info->quality);
5313 if (image != (Image *) NULL)
5314 s=newSViv((ssize_t) image->quality);
5315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5318 if (LocaleCompare(attribute,"quantum") == 0)
5321 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5325 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5332 if (LocaleCompare(attribute,"rendering-intent") == 0)
5334 s=newSViv(image->rendering_intent);
5335 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5336 image->rendering_intent));
5338 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5341 if (LocaleCompare(attribute,"red-primary") == 0)
5343 if (image == (Image *) NULL)
5345 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5346 image->chromaticity.red_primary.x,
5347 image->chromaticity.red_primary.y);
5349 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5352 if (LocaleCompare(attribute,"rows") == 0)
5354 if (image != (Image *) NULL)
5355 s=newSViv((ssize_t) image->rows);
5356 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5359 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5366 if (LocaleCompare(attribute,"sampling-factor") == 0)
5368 if (info && info->image_info->sampling_factor)
5369 s=newSVpv(info->image_info->sampling_factor,0);
5370 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5373 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5375 if (info && info->image_info->server_name)
5376 s=newSVpv(info->image_info->server_name,0);
5377 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5380 if (LocaleCompare(attribute,"size") == 0)
5382 if (info && info->image_info->size)
5383 s=newSVpv(info->image_info->size,0);
5384 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5387 if (LocaleCompare(attribute,"scene") == 0)
5389 if (image != (Image *) NULL)
5390 s=newSViv((ssize_t) image->scene);
5391 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5394 if (LocaleCompare(attribute,"scenes") == 0)
5396 if (image != (Image *) NULL)
5397 s=newSViv((ssize_t) info->image_info->number_scenes);
5398 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5401 if (LocaleCompare(attribute,"signature") == 0)
5406 if (image == (Image *) NULL)
5408 (void) SignatureImage(image,exception);
5409 value=GetImageProperty(image,"Signature",exception);
5410 if (value != (const char *) NULL)
5412 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5415 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5422 if (LocaleCompare(attribute,"taint") == 0)
5424 if (image != (Image *) NULL)
5425 s=newSViv((ssize_t) IsTaintImage(image));
5426 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5429 if (LocaleCompare(attribute,"texture") == 0)
5431 if (info && info->image_info->texture)
5432 s=newSVpv(info->image_info->texture,0);
5433 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5436 if (LocaleCompare(attribute,"total-ink-density") == 0)
5438 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5439 if (image != (Image *) NULL)
5440 s=newSVnv(GetImageTotalInkDensity(image,exception));
5441 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5444 if (LocaleCompare(attribute,"transparent-color") == 0)
5446 if (image == (Image *) NULL)
5448 (void) FormatLocaleString(color,MaxTextExtent,
5449 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5450 image->transparent_color.green,image->transparent_color.blue,
5451 image->transparent_color.alpha);
5453 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5456 if (LocaleCompare(attribute,"type") == 0)
5458 if (image == (Image *) NULL)
5460 j=(ssize_t) GetImageType(image,exception);
5462 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5464 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5467 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5474 if (LocaleCompare(attribute,"units") == 0)
5476 j=info ? info->image_info->units : image ? image->units :
5477 UndefinedResolution;
5478 if (info && (info->image_info->units == UndefinedResolution))
5481 if (j == UndefinedResolution)
5482 s=newSVpv("undefined units",0);
5484 if (j == PixelsPerInchResolution)
5485 s=newSVpv("pixels / inch",0);
5487 s=newSVpv("pixels / centimeter",0);
5488 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5491 if (LocaleCompare(attribute,"user-time") == 0)
5493 if (image != (Image *) NULL)
5494 s=newSVnv(GetUserTime(&image->timer));
5495 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5498 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5505 if (LocaleCompare(attribute,"verbose") == 0)
5508 s=newSViv((ssize_t) info->image_info->verbose);
5509 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5512 if (LocaleCompare(attribute,"version") == 0)
5514 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5515 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5518 if (LocaleCompare(attribute,"view") == 0)
5520 if (info && info->image_info->view)
5521 s=newSVpv(info->image_info->view,0);
5522 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5525 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5527 if (image == (Image *) NULL)
5529 j=(ssize_t) GetImageVirtualPixelMethod(image);
5531 (void) sv_setpv(s,CommandOptionToMnemonic(
5532 MagickVirtualPixelOptions,j));
5534 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5537 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5544 if (LocaleCompare(attribute,"white-point") == 0)
5546 if (image == (Image *) NULL)
5548 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5549 image->chromaticity.white_point.x,
5550 image->chromaticity.white_point.y);
5552 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5555 if (LocaleCompare(attribute,"width") == 0)
5557 if (image != (Image *) NULL)
5558 s=newSViv((ssize_t) image->columns);
5559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5569 if (LocaleCompare(attribute,"x-resolution") == 0)
5571 if (image != (Image *) NULL)
5572 s=newSVnv(image->resolution.x);
5573 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5576 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5583 if (LocaleCompare(attribute,"y-resolution") == 0)
5585 if (image != (Image *) NULL)
5586 s=newSVnv(image->resolution.y);
5587 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5590 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5597 if (image == (Image *) NULL)
5598 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5602 value=GetImageProperty(image,attribute,exception);
5603 if (value != (const char *) NULL)
5606 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5609 if (*attribute != '%')
5610 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5617 meta=InterpretImageProperties(info ? info->image_info :
5618 (ImageInfo *) NULL,image,attribute,exception);
5620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5621 meta=(char *) RelinquishMagickMemory(meta);
5625 exception=DestroyExceptionInfo(exception);
5626 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5630 ###############################################################################
5634 # G e t A u t h e n t i c P i x e l s #
5638 ###############################################################################
5642 GetAuthenticPixels(ref,...)
5643 Image::Magick ref = NO_INIT
5645 getauthenticpixels = 1
5675 PERL_UNUSED_VAR(ref);
5676 PERL_UNUSED_VAR(ix);
5677 exception=AcquireExceptionInfo();
5678 perl_exception=newSVpv("",0);
5679 if (sv_isobject(ST(0)) == 0)
5681 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5685 reference=SvRV(ST(0));
5687 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5688 if (image == (Image *) NULL)
5690 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5697 region.width=image->columns;
5700 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5701 for (i=2; i < items; i+=2)
5703 attribute=(char *) SvPV(ST(i-1),na);
5709 if (LocaleCompare(attribute,"geometry") == 0)
5711 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5714 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5721 if (LocaleCompare(attribute,"height") == 0)
5723 region.height=SvIV(ST(i));
5726 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5733 if (LocaleCompare(attribute,"x") == 0)
5735 region.x=SvIV(ST(i));
5738 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5745 if (LocaleCompare(attribute,"y") == 0)
5747 region.y=SvIV(ST(i));
5750 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5757 if (LocaleCompare(attribute,"width") == 0)
5759 region.width=SvIV(ST(i));
5762 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5768 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5769 region.height,exception);
5770 if (blob != (void *) NULL)
5774 InheritPerlException(exception,perl_exception);
5775 exception=DestroyExceptionInfo(exception);
5776 SvREFCNT_dec(perl_exception); /* throw away all errors */
5785 ###############################################################################
5789 # G e t V i r t u a l P i x e l s #
5793 ###############################################################################
5797 GetVirtualPixels(ref,...)
5798 Image::Magick ref = NO_INIT
5800 getvirtualpixels = 1
5801 AcquireImagePixels = 2
5802 acquireimagepixels = 3
5830 PERL_UNUSED_VAR(ref);
5831 PERL_UNUSED_VAR(ix);
5832 exception=AcquireExceptionInfo();
5833 perl_exception=newSVpv("",0);
5834 if (sv_isobject(ST(0)) == 0)
5836 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5840 reference=SvRV(ST(0));
5842 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5843 if (image == (Image *) NULL)
5845 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5852 region.width=image->columns;
5855 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5856 for (i=2; i < items; i+=2)
5858 attribute=(char *) SvPV(ST(i-1),na);
5864 if (LocaleCompare(attribute,"geometry") == 0)
5866 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5869 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5876 if (LocaleCompare(attribute,"height") == 0)
5878 region.height=SvIV(ST(i));
5881 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5888 if (LocaleCompare(attribute,"x") == 0)
5890 region.x=SvIV(ST(i));
5893 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5900 if (LocaleCompare(attribute,"y") == 0)
5902 region.y=SvIV(ST(i));
5905 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5912 if (LocaleCompare(attribute,"width") == 0)
5914 region.width=SvIV(ST(i));
5917 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5923 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5924 region.height,exception);
5925 if (blob != (void *) NULL)
5929 InheritPerlException(exception,perl_exception);
5930 exception=DestroyExceptionInfo(exception);
5931 SvREFCNT_dec(perl_exception); /* throw away all errors */
5934 RETVAL = (void *) blob;
5940 ###############################################################################
5944 # G e t A u t h e n t i c M e t a c o n t e n t #
5948 ###############################################################################
5952 GetAuthenticMetacontent(ref,...)
5953 Image::Magick ref = NO_INIT
5955 getauthenticmetacontent = 1
5976 PERL_UNUSED_VAR(ref);
5977 PERL_UNUSED_VAR(ix);
5978 exception=AcquireExceptionInfo();
5979 perl_exception=newSVpv("",0);
5980 if (sv_isobject(ST(0)) == 0)
5982 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5986 reference=SvRV(ST(0));
5988 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5989 if (image == (Image *) NULL)
5991 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5996 blob=(void *) GetAuthenticMetacontent(image);
5997 if (blob != (void *) NULL)
6001 InheritPerlException(exception,perl_exception);
6002 exception=DestroyExceptionInfo(exception);
6003 SvREFCNT_dec(perl_exception); /* throw away all errors */
6012 ###############################################################################
6016 # G e t V i r t u a l M e t a c o n t e n t #
6020 ###############################################################################
6024 GetVirtualMetacontent(ref,...)
6025 Image::Magick ref = NO_INIT
6027 getvirtualmetacontent = 1
6046 PERL_UNUSED_VAR(ref);
6047 PERL_UNUSED_VAR(ix);
6048 exception=AcquireExceptionInfo();
6049 perl_exception=newSVpv("",0);
6050 if (sv_isobject(ST(0)) == 0)
6052 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6056 reference=SvRV(ST(0));
6058 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6059 if (image == (Image *) NULL)
6061 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6066 blob=(void *) GetVirtualMetacontent(image);
6067 if (blob != (void *) NULL)
6071 InheritPerlException(exception,perl_exception);
6072 exception=DestroyExceptionInfo(exception);
6073 SvREFCNT_dec(perl_exception); /* throw away all errors */
6082 ###############################################################################
6086 # H i s t o g r a m #
6090 ###############################################################################
6095 Image::Magick ref=NO_INIT
6106 message[MaxTextExtent];
6133 PERL_UNUSED_VAR(ref);
6134 PERL_UNUSED_VAR(ix);
6135 exception=AcquireExceptionInfo();
6136 perl_exception=newSVpv("",0);
6138 if (sv_isobject(ST(0)) == 0)
6140 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6144 reference=SvRV(ST(0));
6147 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6148 if (image == (Image *) NULL)
6150 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6154 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6156 for ( ; image; image=image->next)
6158 histogram=GetImageHistogram(image,&number_colors,exception);
6159 if (histogram == (PixelInfo *) NULL)
6161 count+=(ssize_t) number_colors;
6163 for (i=0; i < (ssize_t) number_colors; i++)
6165 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6167 PUSHs(sv_2mortal(newSVpv(message,0)));
6168 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6169 histogram[i].green);
6170 PUSHs(sv_2mortal(newSVpv(message,0)));
6171 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6173 PUSHs(sv_2mortal(newSVpv(message,0)));
6174 if (image->colorspace == CMYKColorspace)
6176 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6177 histogram[i].black);
6178 PUSHs(sv_2mortal(newSVpv(message,0)));
6180 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6181 histogram[i].alpha);
6182 PUSHs(sv_2mortal(newSVpv(message,0)));
6183 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6184 histogram[i].count);
6185 PUSHs(sv_2mortal(newSVpv(message,0)));
6187 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6191 InheritPerlException(exception,perl_exception);
6192 exception=DestroyExceptionInfo(exception);
6193 SvREFCNT_dec(perl_exception);
6197 ###############################################################################
6205 ###############################################################################
6210 Image::Magick ref=NO_INIT
6234 register const Quantum
6248 *reference; /* reference is the SV* of ref=SvIV(reference) */
6250 PERL_UNUSED_VAR(ref);
6251 PERL_UNUSED_VAR(ix);
6252 exception=AcquireExceptionInfo();
6253 perl_exception=newSVpv("",0);
6254 reference=SvRV(ST(0));
6255 av=(AV *) reference;
6256 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6258 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6259 if (image == (Image *) NULL)
6261 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6265 normalize=MagickTrue;
6268 region.width=image->columns;
6271 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6272 for (i=2; i < items; i+=2)
6274 attribute=(char *) SvPV(ST(i-1),na);
6280 if (LocaleCompare(attribute,"channel") == 0)
6285 option=ParseChannelOption(SvPV(ST(i),na));
6288 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6292 SetPixelChannelMask(image,(ChannelType) option);
6295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6302 if (LocaleCompare(attribute,"geometry") == 0)
6304 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6307 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6314 if (LocaleCompare(attribute,"normalize") == 0)
6316 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6320 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6324 normalize=option != 0 ? MagickTrue : MagickFalse;
6327 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6334 if (LocaleCompare(attribute,"x") == 0)
6336 region.x=SvIV(ST(i));
6339 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6346 if (LocaleCompare(attribute,"y") == 0)
6348 region.y=SvIV(ST(i));
6351 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6357 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6363 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6364 if (p == (const Quantum *) NULL)
6372 if (normalize != MagickFalse)
6373 scale=1.0/QuantumRange;
6374 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6375 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6376 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6377 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6378 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6379 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6380 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6381 (image->colorspace == CMYKColorspace))
6382 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6383 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6384 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6388 InheritPerlException(exception,perl_exception);
6389 exception=DestroyExceptionInfo(exception);
6390 SvREFCNT_dec(perl_exception);
6394 ###############################################################################
6398 # G e t P i x e l s #
6402 ###############################################################################
6407 Image::Magick ref=NO_INIT
6446 *reference; /* reference is the SV* of ref=SvIV(reference) */
6448 PERL_UNUSED_VAR(ref);
6449 PERL_UNUSED_VAR(ix);
6450 exception=AcquireExceptionInfo();
6451 perl_exception=newSVpv("",0);
6452 reference=SvRV(ST(0));
6453 av=(AV *) reference;
6454 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6456 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6457 if (image == (Image *) NULL)
6459 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6464 if (image->alpha_trait == BlendPixelTrait)
6466 if (image->colorspace == CMYKColorspace)
6469 if (image->alpha_trait == BlendPixelTrait)
6472 normalize=MagickFalse;
6475 region.width=image->columns;
6478 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6479 for (i=2; i < items; i+=2)
6481 attribute=(char *) SvPV(ST(i-1),na);
6487 if (LocaleCompare(attribute,"geometry") == 0)
6489 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6492 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6499 if (LocaleCompare(attribute,"height") == 0)
6501 region.height=SvIV(ST(i));
6504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6511 if (LocaleCompare(attribute,"map") == 0)
6516 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6523 if (LocaleCompare(attribute,"normalize") == 0)
6525 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6529 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6533 normalize=option != 0 ? MagickTrue : MagickFalse;
6536 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6543 if (LocaleCompare(attribute,"width") == 0)
6545 region.width=SvIV(ST(i));
6548 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6555 if (LocaleCompare(attribute,"x") == 0)
6557 region.x=SvIV(ST(i));
6560 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6567 if (LocaleCompare(attribute,"y") == 0)
6569 region.y=SvIV(ST(i));
6572 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6578 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6584 if (normalize != MagickFalse)
6589 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6590 region.height*sizeof(*pixels));
6591 if (pixels == (float *) NULL)
6593 ThrowPerlException(exception,ResourceLimitError,
6594 "MemoryAllocationFailed",PackageName);
6597 status=ExportImagePixels(image,region.x,region.y,region.width,
6598 region.height,map,FloatPixel,pixels,exception);
6599 if (status == MagickFalse)
6603 EXTEND(sp,strlen(map)*region.width*region.height);
6604 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6605 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6607 pixels=(float *) RelinquishMagickMemory(pixels);
6614 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6615 region.height*sizeof(*pixels));
6616 if (pixels == (Quantum *) NULL)
6618 ThrowPerlException(exception,ResourceLimitError,
6619 "MemoryAllocationFailed",PackageName);
6622 status=ExportImagePixels(image,region.x,region.y,region.width,
6623 region.height,map,QuantumPixel,pixels,exception);
6624 if (status == MagickFalse)
6628 EXTEND(sp,strlen(map)*region.width*region.height);
6629 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6630 PUSHs(sv_2mortal(newSViv(pixels[i])));
6632 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6636 InheritPerlException(exception,perl_exception);
6637 exception=DestroyExceptionInfo(exception);
6638 SvREFCNT_dec(perl_exception);
6642 ###############################################################################
6646 # I m a g e T o B l o b #
6650 ###############################################################################
6654 ImageToBlob(ref,...)
6655 Image::Magick ref=NO_INIT
6664 filename[MaxTextExtent];
6693 PERL_UNUSED_VAR(ref);
6694 PERL_UNUSED_VAR(ix);
6695 exception=AcquireExceptionInfo();
6696 perl_exception=newSVpv("",0);
6697 package_info=(struct PackageInfo *) NULL;
6698 if (sv_isobject(ST(0)) == 0)
6700 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6704 reference=SvRV(ST(0));
6705 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6706 if (image == (Image *) NULL)
6708 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6712 package_info=ClonePackageInfo(info,exception);
6713 for (i=2; i < items; i+=2)
6714 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6715 (void) CopyMagickString(filename,package_info->image_info->filename,
6718 for (next=image; next; next=next->next)
6720 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6721 next->scene=scene++;
6723 SetImageInfo(package_info->image_info,(unsigned int)
6724 GetImageListLength(image),exception);
6725 EXTEND(sp,(ssize_t) GetImageListLength(image));
6726 for ( ; image; image=image->next)
6729 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6730 if (blob != (char *) NULL)
6732 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6733 blob=(unsigned char *) RelinquishMagickMemory(blob);
6735 if (package_info->image_info->adjoin)
6740 if (package_info != (struct PackageInfo *) NULL)
6741 DestroyPackageInfo(package_info);
6742 InheritPerlException(exception,perl_exception);
6743 exception=DestroyExceptionInfo(exception);
6744 SvREFCNT_dec(perl_exception); /* throw away all errors */
6748 ###############################################################################
6756 ###############################################################################
6761 Image::Magick ref=NO_INIT
6765 OptimizeImageLayers = 3
6767 optimizeimagelayers = 5
6809 PERL_UNUSED_VAR(ref);
6810 PERL_UNUSED_VAR(ix);
6811 exception=AcquireExceptionInfo();
6812 perl_exception=newSVpv("",0);
6814 if (sv_isobject(ST(0)) == 0)
6816 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6820 reference=SvRV(ST(0));
6821 hv=SvSTASH(reference);
6823 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6825 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6826 if (image == (Image *) NULL)
6828 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6832 compose=image->compose;
6833 method=OptimizeLayer;
6834 for (i=2; i < items; i+=2)
6836 attribute=(char *) SvPV(ST(i-1),na);
6842 if (LocaleCompare(attribute,"compose") == 0)
6844 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6845 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6848 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6852 compose=(CompositeOperator) sp;
6855 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6862 if (LocaleCompare(attribute,"method") == 0)
6864 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6868 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6872 method=(LayerMethod) option;
6875 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6881 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6887 layers=(Image *) NULL;
6890 case CompareAnyLayer:
6891 case CompareClearLayer:
6892 case CompareOverlayLayer:
6895 layers=CompareImagesLayers(image,method,exception);
6902 layers=MergeImageLayers(image,method,exception);
6907 layers=DisposeImages(image,exception);
6910 case OptimizeImageLayer:
6912 layers=OptimizeImageLayers(image,exception);
6915 case OptimizePlusLayer:
6917 layers=OptimizePlusImageLayers(image,exception);
6920 case OptimizeTransLayer:
6922 OptimizeImageTransparency(image,exception);
6925 case RemoveDupsLayer:
6927 RemoveDuplicateLayers(&image,exception);
6930 case RemoveZeroLayer:
6932 RemoveZeroDelayLayers(&image,exception);
6941 General Purpose, GIF Animation Optimizer.
6943 layers=CoalesceImages(image,exception);
6944 if (layers == (Image *) NULL)
6947 layers=OptimizeImageLayers(image,exception);
6948 if (layers == (Image *) NULL)
6950 image=DestroyImageList(image);
6952 layers=(Image *) NULL;
6953 OptimizeImageTransparency(image,exception);
6954 quantize_info=AcquireQuantizeInfo(info->image_info);
6955 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6956 quantize_info=DestroyQuantizeInfo(quantize_info);
6959 case CompositeLayer:
6968 Split image sequence at the first 'NULL:' image.
6971 while (source != (Image *) NULL)
6973 source=GetNextImageInList(source);
6974 if ((source != (Image *) NULL) &&
6975 (LocaleCompare(source->magick,"NULL") == 0))
6978 if (source != (Image *) NULL)
6980 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6981 (GetNextImageInList(source) == (Image *) NULL))
6982 source=(Image *) NULL;
6986 Separate the two lists, junk the null: image.
6988 source=SplitImageList(source->previous);
6989 DeleteImageFromList(&source);
6992 if (source == (Image *) NULL)
6994 (void) ThrowMagickException(exception,GetMagickModule(),
6995 OptionError,"MissingNullSeparator","layers Composite");
6999 Adjust offset with gravity and virtual canvas.
7001 SetGeometry(image,&geometry);
7002 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7003 geometry.width=source->page.width != 0 ? source->page.width :
7005 geometry.height=source->page.height != 0 ? source->page.height :
7007 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7008 image->columns,image->page.height != 0 ? image->page.height :
7009 image->rows,image->gravity,&geometry);
7010 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7011 source=DestroyImageList(source);
7015 if (layers != (Image *) NULL)
7017 if (image == (Image *) NULL)
7019 for ( ; image; image=image->next)
7021 AddImageToRegistry(sv,image);
7023 av_push(av,sv_bless(rv,hv));
7026 exception=DestroyExceptionInfo(exception);
7028 SvREFCNT_dec(perl_exception);
7032 InheritPerlException(exception,perl_exception);
7033 exception=DestroyExceptionInfo(exception);
7034 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7035 SvPOK_on(perl_exception);
7036 ST(0)=sv_2mortal(perl_exception);
7041 ###############################################################################
7045 # M a g i c k T o M i m e #
7049 ###############################################################################
7053 MagickToMime(ref,name)
7054 Image::Magick ref=NO_INIT
7063 PERL_UNUSED_VAR(ref);
7064 PERL_UNUSED_VAR(ix);
7065 mime=MagickToMime(name);
7066 RETVAL=newSVpv(mime,0);
7067 mime=(char *) RelinquishMagickMemory(mime);
7073 ###############################################################################
7081 ###############################################################################
7086 Image::Magick ref=NO_INIT
7123 MedianConvolveImage = 36
7129 ReduceNoiseImage = 42
7155 ColorFloodfillImage= 68
7161 CycleColormapImage = 74
7171 MatteFloodfillImage= 84
7179 NumberColorsImage = 92
7189 SignatureImage = 102
7199 TransparentImage = 112
7201 ThresholdImage = 114
7215 DeconstructImage = 130
7217 GaussianBlurImage = 132
7223 UnsharpMaskImage = 138
7225 MotionBlurImage = 140
7227 OrderedDitherImage = 142
7234 AffineTransform = 149
7235 AffineTransformImage = 150
7237 DifferenceImage = 152
7238 AdaptiveThreshold = 153
7239 AdaptiveThresholdImage = 154
7244 BlackThreshold = 159
7245 BlackThresholdImage= 160
7246 WhiteThreshold = 161
7247 WhiteThresholdImage= 162
7249 RadialBlurImage = 164
7251 ThumbnailImage = 166
7261 PosterizeImage = 176
7267 SepiaToneImage = 182
7268 SigmoidalContrast = 183
7269 SigmoidalContrastImage = 184
7274 ContrastStretch = 189
7275 ContrastStretchImage = 190
7280 AdaptiveSharpen = 195
7281 AdaptiveSharpenImage = 196
7283 TransposeImage = 198
7285 TransverseImage = 200
7287 AutoOrientImage = 202
7289 AdaptiveBlurImage = 204
7293 UniqueColorsImage = 208
7294 AdaptiveResize = 209
7295 AdaptiveResizeImage= 210
7299 LinearStretchImage = 214
7301 ColorMatrixImage = 216
7306 FloodfillPaint = 221
7307 FloodfillPaintImage= 222
7313 LiquidRescaleImage = 228
7323 SparseColorImage = 238
7327 SelectiveBlurImage = 242
7331 BlueShiftImage = 246
7332 ForwardFourierTransform = 247
7333 ForwardFourierTransformImage = 248
7334 InverseFourierTransform = 249
7335 InverseFourierTransformImage = 250
7336 ColorDecisionList = 251
7337 ColorDecisionListImage = 252
7339 AutoGammaImage = 254
7341 AutoLevelImage = 256
7343 LevelImageColors = 258
7346 BrightnessContrast = 261
7347 BrightnessContrastImage = 262
7349 MorphologyImage = 264
7355 StatisticImage = 270
7364 attribute_flag[MaxArguments],
7365 message[MaxTextExtent];
7426 argument_list[MaxArguments];
7428 PERL_UNUSED_VAR(ref);
7429 PERL_UNUSED_VAR(ix);
7430 exception=AcquireExceptionInfo();
7431 perl_exception=newSVpv("",0);
7432 reference_vector=NULL;
7436 if (sv_isobject(ST(0)) == 0)
7438 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7442 reference=SvRV(ST(0));
7443 region_info.width=0;
7444 region_info.height=0;
7447 region_image=(Image *) NULL;
7448 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7449 if (ix && (ix != 666))
7452 Called as Method(...)
7455 rp=(&Methods[ix-1]);
7461 Called as Mogrify("Method",...)
7463 attribute=(char *) SvPV(ST(1),na);
7466 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7467 attribute=(char *) SvPV(ST(2),na);
7470 for (rp=Methods; ; rp++)
7472 if (rp >= EndOf(Methods))
7474 ThrowPerlException(exception,OptionError,
7475 "UnrecognizedPerlMagickMethod",attribute);
7478 if (strEQcase(attribute,rp->name))
7484 if (image == (Image *) NULL)
7486 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7489 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7490 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7491 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7508 pp=(Arguments *) NULL;
7516 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7518 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7520 if (strEQcase(attribute,qq->method) > ssize_test)
7523 ssize_test=strEQcase(attribute,qq->method);
7526 if (pp == (Arguments *) NULL)
7528 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7530 goto continue_outer_loop;
7532 al=(&argument_list[pp-rp->arguments]);
7535 case ArrayReference:
7537 if (SvTYPE(sv) != SVt_RV)
7539 (void) FormatLocaleString(message,MaxTextExtent,
7540 "invalid %.60s value",pp->method);
7541 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7542 goto continue_outer_loop;
7544 al->array_reference=SvRV(sv);
7549 al->real_reference=SvNV(sv);
7554 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7557 case ImageReference:
7559 if (!sv_isobject(sv) ||
7560 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7561 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7563 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7569 case IntegerReference:
7571 al->integer_reference=SvIV(sv);
7574 case StringReference:
7576 al->string_reference=(char *) SvPV(sv,al->length);
7577 if (sv_isobject(sv))
7578 al->image_reference=SetupList(aTHX_ SvRV(sv),
7579 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7585 Is a string; look up name.
7587 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7589 al->string_reference=(char *) SvPV(sv,al->length);
7590 al->integer_reference=(-1);
7593 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7594 MagickFalse,SvPV(sv,na));
7595 if (pp->type == MagickChannelOptions)
7596 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7597 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7599 (void) FormatLocaleString(message,MaxTextExtent,
7600 "invalid %.60s value",pp->method);
7601 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7602 goto continue_outer_loop;
7607 attribute_flag[pp-rp->arguments]++;
7608 continue_outer_loop: ;
7610 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7611 pv=reference_vector;
7612 SetGeometryInfo(&geometry_info);
7613 channel=DefaultChannels;
7614 for (next=image; next; next=next->next)
7617 SetGeometry(image,&geometry);
7618 if ((region_info.width*region_info.height) != 0)
7621 image=CropImage(image,®ion_info,exception);
7627 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7628 ThrowPerlException(exception,OptionError,
7629 "UnrecognizedPerlMagickMethod",message);
7632 case 1: /* Comment */
7634 if (attribute_flag[0] == 0)
7635 argument_list[0].string_reference=(char *) NULL;
7636 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7637 info ? info->image_info : (ImageInfo *) NULL,image,
7638 argument_list[0].string_reference,exception),exception);
7643 if (attribute_flag[0] == 0)
7644 argument_list[0].string_reference=(char *) NULL;
7645 (void) SetImageProperty(image,"label",InterpretImageProperties(
7646 info ? info->image_info : (ImageInfo *) NULL,image,
7647 argument_list[0].string_reference,exception),exception);
7650 case 3: /* AddNoise */
7655 if (attribute_flag[0] == 0)
7656 argument_list[0].integer_reference=UniformNoise;
7658 if (attribute_flag[1] != 0)
7659 attenuate=argument_list[1].real_reference;
7660 if (attribute_flag[2] != 0)
7661 channel=(ChannelType) argument_list[2].integer_reference;
7662 channel_mask=SetImageChannelMask(image,channel);
7663 image=AddNoiseImage(image,(NoiseType)
7664 argument_list[0].integer_reference,attenuate,exception);
7665 if (image != (Image *) NULL)
7666 (void) SetImageChannelMask(image,channel_mask);
7669 case 4: /* Colorize */
7674 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7675 0,0,&target,exception);
7676 if (attribute_flag[0] != 0)
7677 (void) QueryColorCompliance(argument_list[0].string_reference,
7678 AllCompliance,&target,exception);
7679 if (attribute_flag[1] == 0)
7680 argument_list[1].string_reference="100%";
7681 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7685 case 5: /* Border */
7692 if (attribute_flag[0] != 0)
7693 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7694 &geometry,exception);
7695 if (attribute_flag[1] != 0)
7696 geometry.width=argument_list[1].integer_reference;
7697 if (attribute_flag[2] != 0)
7698 geometry.height=argument_list[2].integer_reference;
7699 if (attribute_flag[3] != 0)
7700 QueryColorCompliance(argument_list[3].string_reference,
7701 AllCompliance,&image->border_color,exception);
7702 if (attribute_flag[4] != 0)
7703 QueryColorCompliance(argument_list[4].string_reference,
7704 AllCompliance,&image->border_color,exception);
7705 if (attribute_flag[5] != 0)
7706 QueryColorCompliance(argument_list[5].string_reference,
7707 AllCompliance,&image->border_color,exception);
7708 compose=image->compose;
7709 if (attribute_flag[6] != 0)
7710 compose=(CompositeOperator) argument_list[6].integer_reference;
7711 image=BorderImage(image,&geometry,compose,exception);
7716 if (attribute_flag[0] != 0)
7718 flags=ParseGeometry(argument_list[0].string_reference,
7720 if ((flags & SigmaValue) == 0)
7721 geometry_info.sigma=1.0;
7723 if (attribute_flag[1] != 0)
7724 geometry_info.rho=argument_list[1].real_reference;
7725 if (attribute_flag[2] != 0)
7726 geometry_info.sigma=argument_list[2].real_reference;
7727 if (attribute_flag[3] != 0)
7728 channel=(ChannelType) argument_list[3].integer_reference;
7729 channel_mask=SetImageChannelMask(image,channel);
7730 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7732 if (image != (Image *) NULL)
7733 (void) SetImageChannelMask(image,channel_mask);
7738 if (attribute_flag[0] != 0)
7739 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7740 &geometry,exception);
7741 if (attribute_flag[1] != 0)
7742 geometry.width=argument_list[1].integer_reference;
7743 if (attribute_flag[2] != 0)
7744 geometry.height=argument_list[2].integer_reference;
7745 if (attribute_flag[3] != 0)
7746 geometry.x=argument_list[3].integer_reference;
7747 if (attribute_flag[4] != 0)
7748 geometry.y=argument_list[4].integer_reference;
7749 image=ChopImage(image,&geometry,exception);
7754 if (attribute_flag[6] != 0)
7755 image->gravity=(GravityType) argument_list[6].integer_reference;
7756 if (attribute_flag[0] != 0)
7757 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7758 &geometry,exception);
7759 if (attribute_flag[1] != 0)
7760 geometry.width=argument_list[1].integer_reference;
7761 if (attribute_flag[2] != 0)
7762 geometry.height=argument_list[2].integer_reference;
7763 if (attribute_flag[3] != 0)
7764 geometry.x=argument_list[3].integer_reference;
7765 if (attribute_flag[4] != 0)
7766 geometry.y=argument_list[4].integer_reference;
7767 if (attribute_flag[5] != 0)
7768 image->fuzz=StringToDoubleInterval(
7769 argument_list[5].string_reference,(double) QuantumRange+1.0);
7770 image=CropImage(image,&geometry,exception);
7773 case 9: /* Despeckle */
7775 image=DespeckleImage(image,exception);
7780 if (attribute_flag[0] != 0)
7781 geometry_info.rho=argument_list[0].real_reference;
7782 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7786 case 11: /* Emboss */
7788 if (attribute_flag[0] != 0)
7790 flags=ParseGeometry(argument_list[0].string_reference,
7792 if ((flags & SigmaValue) == 0)
7793 geometry_info.sigma=1.0;
7795 if (attribute_flag[1] != 0)
7796 geometry_info.rho=argument_list[1].real_reference;
7797 if (attribute_flag[2] != 0)
7798 geometry_info.sigma=argument_list[2].real_reference;
7799 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7803 case 12: /* Enhance */
7805 image=EnhanceImage(image,exception);
7810 image=FlipImage(image,exception);
7815 image=FlopImage(image,exception);
7818 case 15: /* Frame */
7826 if (attribute_flag[0] != 0)
7828 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7829 &geometry,exception);
7830 frame_info.width=geometry.width;
7831 frame_info.height=geometry.height;
7832 frame_info.outer_bevel=geometry.x;
7833 frame_info.inner_bevel=geometry.y;
7835 if (attribute_flag[1] != 0)
7836 frame_info.width=argument_list[1].integer_reference;
7837 if (attribute_flag[2] != 0)
7838 frame_info.height=argument_list[2].integer_reference;
7839 if (attribute_flag[3] != 0)
7840 frame_info.inner_bevel=argument_list[3].integer_reference;
7841 if (attribute_flag[4] != 0)
7842 frame_info.outer_bevel=argument_list[4].integer_reference;
7843 if (attribute_flag[5] != 0)
7844 QueryColorCompliance(argument_list[5].string_reference,
7845 AllCompliance,&fill_color,exception);
7846 if (attribute_flag[6] != 0)
7847 QueryColorCompliance(argument_list[6].string_reference,
7848 AllCompliance,&fill_color,exception);
7849 frame_info.x=(ssize_t) frame_info.width;
7850 frame_info.y=(ssize_t) frame_info.height;
7851 frame_info.width=image->columns+2*frame_info.x;
7852 frame_info.height=image->rows+2*frame_info.y;
7853 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7854 image->matte_color=fill_color;
7855 compose=image->compose;
7856 if (attribute_flag[7] != 0)
7857 compose=(CompositeOperator) argument_list[7].integer_reference;
7858 image=FrameImage(image,&frame_info,compose,exception);
7861 case 16: /* Implode */
7863 PixelInterpolateMethod
7866 if (attribute_flag[0] == 0)
7867 argument_list[0].real_reference=0.5;
7868 method=UndefinedInterpolatePixel;
7869 if (attribute_flag[1] != 0)
7870 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7871 image=ImplodeImage(image,argument_list[0].real_reference,
7875 case 17: /* Magnify */
7877 image=MagnifyImage(image,exception);
7880 case 18: /* MedianFilter */
7882 if (attribute_flag[0] != 0)
7884 flags=ParseGeometry(argument_list[0].string_reference,
7886 if ((flags & SigmaValue) == 0)
7887 geometry_info.sigma=geometry_info.rho;
7889 if (attribute_flag[1] != 0)
7890 geometry_info.rho=argument_list[1].real_reference;
7891 if (attribute_flag[2] != 0)
7892 geometry_info.sigma=argument_list[2].real_reference;
7893 if (attribute_flag[3] != 0)
7894 channel=(ChannelType) argument_list[3].integer_reference;
7895 channel_mask=SetImageChannelMask(image,channel);
7896 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7897 (size_t) geometry_info.sigma,exception);
7898 if (image != (Image *) NULL)
7899 (void) SetImageChannelMask(image,channel_mask);
7902 case 19: /* Minify */
7904 image=MinifyImage(image,exception);
7907 case 20: /* OilPaint */
7909 if (attribute_flag[0] == 0)
7910 argument_list[0].real_reference=0.0;
7911 if (attribute_flag[1] == 0)
7912 argument_list[1].real_reference=1.0;
7913 image=OilPaintImage(image,argument_list[0].real_reference,
7914 argument_list[1].real_reference,exception);
7917 case 21: /* ReduceNoise */
7919 if (attribute_flag[0] != 0)
7921 flags=ParseGeometry(argument_list[0].string_reference,
7923 if ((flags & SigmaValue) == 0)
7924 geometry_info.sigma=1.0;
7926 if (attribute_flag[1] != 0)
7927 geometry_info.rho=argument_list[1].real_reference;
7928 if (attribute_flag[2] != 0)
7929 geometry_info.sigma=argument_list[2].real_reference;
7930 if (attribute_flag[3] != 0)
7931 channel=(ChannelType) argument_list[3].integer_reference;
7932 channel_mask=SetImageChannelMask(image,channel);
7933 image=StatisticImage(image,NonpeakStatistic,(size_t)
7934 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7935 if (image != (Image *) NULL)
7936 (void) SetImageChannelMask(image,channel_mask);
7941 if (attribute_flag[0] != 0)
7942 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7943 &geometry,exception);
7944 if (attribute_flag[1] != 0)
7945 geometry.x=argument_list[1].integer_reference;
7946 if (attribute_flag[2] != 0)
7947 geometry.y=argument_list[2].integer_reference;
7948 image=RollImage(image,geometry.x,geometry.y,exception);
7951 case 23: /* Rotate */
7953 if (attribute_flag[0] == 0)
7954 argument_list[0].real_reference=90.0;
7955 if (attribute_flag[1] != 0)
7957 QueryColorCompliance(argument_list[1].string_reference,
7958 AllCompliance,&image->background_color,exception);
7959 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
7960 (image->alpha_trait != BlendPixelTrait))
7961 (void) SetImageAlpha(image,OpaqueAlpha,exception);
7963 image=RotateImage(image,argument_list[0].real_reference,exception);
7966 case 24: /* Sample */
7968 if (attribute_flag[0] != 0)
7969 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7970 &geometry,exception);
7971 if (attribute_flag[1] != 0)
7972 geometry.width=argument_list[1].integer_reference;
7973 if (attribute_flag[2] != 0)
7974 geometry.height=argument_list[2].integer_reference;
7975 image=SampleImage(image,geometry.width,geometry.height,exception);
7978 case 25: /* Scale */
7980 if (attribute_flag[0] != 0)
7981 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7982 &geometry,exception);
7983 if (attribute_flag[1] != 0)
7984 geometry.width=argument_list[1].integer_reference;
7985 if (attribute_flag[2] != 0)
7986 geometry.height=argument_list[2].integer_reference;
7987 image=ScaleImage(image,geometry.width,geometry.height,exception);
7990 case 26: /* Shade */
7992 if (attribute_flag[0] != 0)
7994 flags=ParseGeometry(argument_list[0].string_reference,
7996 if ((flags & SigmaValue) == 0)
7997 geometry_info.sigma=0.0;
7999 if (attribute_flag[1] != 0)
8000 geometry_info.rho=argument_list[1].real_reference;
8001 if (attribute_flag[2] != 0)
8002 geometry_info.sigma=argument_list[2].real_reference;
8003 image=ShadeImage(image,
8004 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8005 geometry_info.rho,geometry_info.sigma,exception);
8008 case 27: /* Sharpen */
8010 if (attribute_flag[0] != 0)
8012 flags=ParseGeometry(argument_list[0].string_reference,
8014 if ((flags & SigmaValue) == 0)
8015 geometry_info.sigma=1.0;
8017 if (attribute_flag[1] != 0)
8018 geometry_info.rho=argument_list[1].real_reference;
8019 if (attribute_flag[2] != 0)
8020 geometry_info.sigma=argument_list[2].real_reference;
8021 if (attribute_flag[3] != 0)
8022 channel=(ChannelType) argument_list[3].integer_reference;
8023 channel_mask=SetImageChannelMask(image,channel);
8024 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8026 if (image != (Image *) NULL)
8027 (void) SetImageChannelMask(image,channel_mask);
8030 case 28: /* Shear */
8032 if (attribute_flag[0] != 0)
8034 flags=ParseGeometry(argument_list[0].string_reference,
8036 if ((flags & SigmaValue) == 0)
8037 geometry_info.sigma=geometry_info.rho;
8039 if (attribute_flag[1] != 0)
8040 geometry_info.rho=argument_list[1].real_reference;
8041 if (attribute_flag[2] != 0)
8042 geometry_info.sigma=argument_list[2].real_reference;
8043 if (attribute_flag[3] != 0)
8044 QueryColorCompliance(argument_list[3].string_reference,
8045 AllCompliance,&image->background_color,exception);
8046 if (attribute_flag[4] != 0)
8047 QueryColorCompliance(argument_list[4].string_reference,
8048 AllCompliance,&image->background_color,exception);
8049 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8053 case 29: /* Spread */
8055 PixelInterpolateMethod
8058 if (attribute_flag[0] == 0)
8059 argument_list[0].real_reference=1.0;
8060 method=UndefinedInterpolatePixel;
8061 if (attribute_flag[1] != 0)
8062 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8063 image=SpreadImage(image,argument_list[0].real_reference,method,
8067 case 30: /* Swirl */
8069 PixelInterpolateMethod
8072 if (attribute_flag[0] == 0)
8073 argument_list[0].real_reference=50.0;
8074 method=UndefinedInterpolatePixel;
8075 if (attribute_flag[1] != 0)
8076 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8077 image=SwirlImage(image,argument_list[0].real_reference,
8081 case 31: /* Resize */
8084 if (attribute_flag[0] != 0)
8085 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8086 &geometry,exception);
8087 if (attribute_flag[1] != 0)
8088 geometry.width=argument_list[1].integer_reference;
8089 if (attribute_flag[2] != 0)
8090 geometry.height=argument_list[2].integer_reference;
8091 if (attribute_flag[3] == 0)
8092 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8093 if (attribute_flag[4] != 0)
8094 SetImageArtifact(image,"filter:support",
8095 argument_list[4].string_reference);
8096 image=ResizeImage(image,geometry.width,geometry.height,
8097 (FilterTypes) argument_list[3].integer_reference,
8101 case 33: /* Annotate */
8106 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8108 if (attribute_flag[0] != 0)
8113 text=InterpretImageProperties(info ? info->image_info :
8114 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8116 (void) CloneString(&draw_info->text,text);
8117 text=DestroyString(text);
8119 if (attribute_flag[1] != 0)
8120 (void) CloneString(&draw_info->font,
8121 argument_list[1].string_reference);
8122 if (attribute_flag[2] != 0)
8123 draw_info->pointsize=argument_list[2].real_reference;
8124 if (attribute_flag[3] != 0)
8125 (void) CloneString(&draw_info->density,
8126 argument_list[3].string_reference);
8127 if (attribute_flag[4] != 0)
8128 (void) QueryColorCompliance(argument_list[4].string_reference,
8129 AllCompliance,&draw_info->undercolor,exception);
8130 if (attribute_flag[5] != 0)
8132 (void) QueryColorCompliance(argument_list[5].string_reference,
8133 AllCompliance,&draw_info->stroke,exception);
8134 if (argument_list[5].image_reference != (Image *) NULL)
8135 draw_info->stroke_pattern=CloneImage(
8136 argument_list[5].image_reference,0,0,MagickTrue,exception);
8138 if (attribute_flag[6] != 0)
8140 (void) QueryColorCompliance(argument_list[6].string_reference,
8141 AllCompliance,&draw_info->fill,exception);
8142 if (argument_list[6].image_reference != (Image *) NULL)
8143 draw_info->fill_pattern=CloneImage(
8144 argument_list[6].image_reference,0,0,MagickTrue,exception);
8146 if (attribute_flag[7] != 0)
8148 (void) CloneString(&draw_info->geometry,
8149 argument_list[7].string_reference);
8150 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8151 &geometry,exception);
8152 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8153 geometry_info.sigma=geometry_info.xi;
8155 if (attribute_flag[8] != 0)
8156 (void) QueryColorCompliance(argument_list[8].string_reference,
8157 AllCompliance,&draw_info->fill,exception);
8158 if (attribute_flag[11] != 0)
8159 draw_info->gravity=(GravityType)
8160 argument_list[11].integer_reference;
8161 if (attribute_flag[25] != 0)
8166 av=(AV *) argument_list[25].array_reference;
8167 if ((av_len(av) != 3) && (av_len(av) != 5))
8169 ThrowPerlException(exception,OptionError,
8170 "affine matrix must have 4 or 6 elements",PackageName);
8173 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8174 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8175 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8176 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8177 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8178 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8180 ThrowPerlException(exception,OptionError,
8181 "affine matrix is singular",PackageName);
8184 if (av_len(av) == 5)
8186 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8187 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8190 for (j=12; j < 17; j++)
8192 if (attribute_flag[j] == 0)
8194 value=argument_list[j].string_reference;
8195 angle=argument_list[j].real_reference;
8196 current=draw_info->affine;
8197 GetAffineMatrix(&affine);
8205 flags=ParseGeometry(value,&geometry_info);
8206 affine.tx=geometry_info.xi;
8207 affine.ty=geometry_info.psi;
8208 if ((flags & PsiValue) == 0)
8209 affine.ty=affine.tx;
8217 flags=ParseGeometry(value,&geometry_info);
8218 affine.sx=geometry_info.rho;
8219 affine.sy=geometry_info.sigma;
8220 if ((flags & SigmaValue) == 0)
8221 affine.sy=affine.sx;
8231 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8232 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8233 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8234 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8242 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8250 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8254 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8255 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8256 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8257 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8258 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8260 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8263 if (attribute_flag[9] == 0)
8264 argument_list[9].real_reference=0.0;
8265 if (attribute_flag[10] == 0)
8266 argument_list[10].real_reference=0.0;
8267 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8270 geometry[MaxTextExtent];
8272 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8273 (double) argument_list[9].real_reference+draw_info->affine.tx,
8274 (double) argument_list[10].real_reference+draw_info->affine.ty);
8275 (void) CloneString(&draw_info->geometry,geometry);
8277 if (attribute_flag[17] != 0)
8278 draw_info->stroke_width=argument_list[17].real_reference;
8279 if (attribute_flag[18] != 0)
8281 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8282 MagickTrue : MagickFalse;
8283 draw_info->stroke_antialias=draw_info->text_antialias;
8285 if (attribute_flag[19] != 0)
8286 (void) CloneString(&draw_info->family,
8287 argument_list[19].string_reference);
8288 if (attribute_flag[20] != 0)
8289 draw_info->style=(StyleType) argument_list[20].integer_reference;
8290 if (attribute_flag[21] != 0)
8291 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8292 if (attribute_flag[22] != 0)
8293 draw_info->weight=argument_list[22].integer_reference;
8294 if (attribute_flag[23] != 0)
8295 draw_info->align=(AlignType) argument_list[23].integer_reference;
8296 if (attribute_flag[24] != 0)
8297 (void) CloneString(&draw_info->encoding,
8298 argument_list[24].string_reference);
8299 if (attribute_flag[25] != 0)
8300 draw_info->fill_pattern=CloneImage(
8301 argument_list[25].image_reference,0,0,MagickTrue,exception);
8302 if (attribute_flag[26] != 0)
8303 draw_info->fill_pattern=CloneImage(
8304 argument_list[26].image_reference,0,0,MagickTrue,exception);
8305 if (attribute_flag[27] != 0)
8306 draw_info->stroke_pattern=CloneImage(
8307 argument_list[27].image_reference,0,0,MagickTrue,exception);
8308 if (attribute_flag[29] != 0)
8309 draw_info->kerning=argument_list[29].real_reference;
8310 if (attribute_flag[30] != 0)
8311 draw_info->interline_spacing=argument_list[30].real_reference;
8312 if (attribute_flag[31] != 0)
8313 draw_info->interword_spacing=argument_list[31].real_reference;
8314 if (attribute_flag[32] != 0)
8315 draw_info->direction=(DirectionType)
8316 argument_list[32].integer_reference;
8317 (void) AnnotateImage(image,draw_info,exception);
8318 draw_info=DestroyDrawInfo(draw_info);
8321 case 34: /* ColorFloodfill */
8332 draw_info=CloneDrawInfo(info ? info->image_info :
8333 (ImageInfo *) NULL,(DrawInfo *) NULL);
8334 if (attribute_flag[0] != 0)
8335 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8336 &geometry,exception);
8337 if (attribute_flag[1] != 0)
8338 geometry.x=argument_list[1].integer_reference;
8339 if (attribute_flag[2] != 0)
8340 geometry.y=argument_list[2].integer_reference;
8341 if (attribute_flag[3] != 0)
8342 (void) QueryColorCompliance(argument_list[3].string_reference,
8343 AllCompliance,&draw_info->fill,exception);
8344 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8345 geometry.x,geometry.y,&target,exception);
8347 if (attribute_flag[4] != 0)
8349 QueryColorCompliance(argument_list[4].string_reference,
8350 AllCompliance,&target,exception);
8353 if (attribute_flag[5] != 0)
8354 image->fuzz=StringToDoubleInterval(
8355 argument_list[5].string_reference,(double) QuantumRange+1.0);
8356 if (attribute_flag[6] != 0)
8357 invert=(MagickBooleanType) argument_list[6].integer_reference;
8358 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8359 geometry.y,invert,exception);
8360 draw_info=DestroyDrawInfo(draw_info);
8363 case 35: /* Composite */
8366 composite_geometry[MaxTextExtent];
8375 compose=OverCompositeOp;
8376 if (attribute_flag[0] != 0)
8377 composite_image=argument_list[0].image_reference;
8380 ThrowPerlException(exception,OptionError,
8381 "CompositeImageRequired",PackageName);
8385 Parameter Handling used for BOTH normal and tiled composition.
8387 if (attribute_flag[1] != 0) /* compose */
8388 compose=(CompositeOperator) argument_list[1].integer_reference;
8389 if (attribute_flag[6] != 0) /* opacity */
8391 if (compose != DissolveCompositeOp)
8392 (void) SetImageAlpha(composite_image,(Quantum)
8393 StringToDoubleInterval(argument_list[6].string_reference,
8394 (double) QuantumRange+1.0),exception);
8416 Handle dissolve composite operator (patch by
8419 (void) CloneString(&image->geometry,
8420 argument_list[6].string_reference);
8421 opacity=(Quantum) StringToDoubleInterval(
8422 argument_list[6].string_reference,(double) QuantumRange+
8424 if (composite_image->alpha_trait == BlendPixelTrait)
8425 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8426 composite_view=AcquireAuthenticCacheView(composite_image,
8428 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8430 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8431 composite_image->columns,1,exception);
8432 for (x=0; x < (ssize_t) composite_image->columns; x++)
8434 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8435 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8437 q+=GetPixelChannels(composite_image);
8439 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8440 if (sync == MagickFalse)
8443 composite_view=DestroyCacheView(composite_view);
8446 if (attribute_flag[9] != 0) /* "color=>" */
8447 QueryColorCompliance(argument_list[9].string_reference,
8448 AllCompliance,&composite_image->background_color,exception);
8449 if (attribute_flag[12] != 0) /* "interpolate=>" */
8450 image->interpolate=(PixelInterpolateMethod)
8451 argument_list[12].integer_reference;
8452 if (attribute_flag[13] != 0) /* "args=>" */
8453 (void) SetImageArtifact(composite_image,"compose:args",
8454 argument_list[13].string_reference);
8455 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8456 (void) SetImageArtifact(composite_image,"compose:args",
8457 argument_list[14].string_reference);
8458 clip_to_self=MagickTrue;
8459 if (attribute_flag[15] != 0)
8460 clip_to_self=(MagickBooleanType)
8461 argument_list[15].integer_reference;
8463 Tiling Composition (with orthogonal rotate).
8465 rotate_image=(Image *) NULL;
8466 if (attribute_flag[8] != 0) /* "rotate=>" */
8471 rotate_image=RotateImage(composite_image,
8472 argument_list[8].real_reference,exception);
8473 if (rotate_image == (Image *) NULL)
8476 if ((attribute_flag[7] != 0) &&
8477 (argument_list[7].integer_reference != 0)) /* tile */
8484 Tile the composite image.
8486 if (attribute_flag[8] != 0) /* "tile=>" */
8487 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8490 (void) SetImageArtifact(composite_image,
8491 "compose:outside-overlay","false");
8492 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8493 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8495 if (attribute_flag[8] != 0) /* rotate */
8496 (void) CompositeImage(image,rotate_image,compose,
8497 MagickTrue,x,y,exception);
8499 (void) CompositeImage(image,composite_image,compose,
8500 MagickTrue,x,y,exception);
8502 if (attribute_flag[8] != 0) /* rotate */
8503 rotate_image=DestroyImage(rotate_image);
8507 Parameter Handling used used ONLY for normal composition.
8509 if (attribute_flag[5] != 0) /* gravity */
8510 image->gravity=(GravityType) argument_list[5].integer_reference;
8511 if (attribute_flag[2] != 0) /* geometry offset */
8513 SetGeometry(image,&geometry);
8514 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8516 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8519 if (attribute_flag[3] != 0) /* x offset */
8520 geometry.x=argument_list[3].integer_reference;
8521 if (attribute_flag[4] != 0) /* y offset */
8522 geometry.y=argument_list[4].integer_reference;
8523 if (attribute_flag[10] != 0) /* mask */
8525 if ((image->compose == DisplaceCompositeOp) ||
8526 (image->compose == DistortCompositeOp))
8529 Merge Y displacement into X displacement image.
8531 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8533 (void) CompositeImage(composite_image,
8534 argument_list[10].image_reference,CopyGreenCompositeOp,
8535 MagickTrue,0,0,exception);
8543 Set a blending mask for the composition.
8545 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8546 MagickTrue,exception);
8547 (void) NegateImage(mask_image,MagickFalse,exception);
8548 (void) SetImageMask(composite_image,mask_image,exception);
8549 mask_image=DestroyImage(mask_image);
8552 if (attribute_flag[11] != 0) /* channel */
8553 channel=(ChannelType) argument_list[11].integer_reference;
8555 Composite two images (normal composition).
8557 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8558 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8559 (double) composite_image->rows,(double) geometry.x,(double)
8561 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8563 channel_mask=SetImageChannelMask(image,channel);
8564 if (attribute_flag[8] == 0) /* no rotate */
8565 CompositeImage(image,composite_image,compose,clip_to_self,
8566 geometry.x,geometry.y,exception);
8570 Position adjust rotated image then composite.
8572 geometry.x-=(ssize_t) (rotate_image->columns-
8573 composite_image->columns)/2;
8574 geometry.y-=(ssize_t) (rotate_image->rows-
8575 composite_image->rows)/2;
8576 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8577 geometry.y,exception);
8578 rotate_image=DestroyImage(rotate_image);
8580 if (attribute_flag[10] != 0) /* mask */
8582 if ((image->compose == DisplaceCompositeOp) ||
8583 (image->compose == DistortCompositeOp))
8584 composite_image=DestroyImage(composite_image);
8586 (void) SetImageMask(image,(Image *) NULL,exception);
8588 (void) SetImageChannelMask(image,channel_mask);
8591 case 36: /* Contrast */
8593 if (attribute_flag[0] == 0)
8594 argument_list[0].integer_reference=0;
8595 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8596 MagickTrue : MagickFalse,exception);
8599 case 37: /* CycleColormap */
8601 if (attribute_flag[0] == 0)
8602 argument_list[0].integer_reference=6;
8603 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8612 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8614 (void) CloneString(&draw_info->primitive,"point");
8615 if (attribute_flag[0] != 0)
8617 if (argument_list[0].integer_reference < 0)
8618 (void) CloneString(&draw_info->primitive,
8619 argument_list[0].string_reference);
8621 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8622 MagickPrimitiveOptions,argument_list[0].integer_reference));
8624 if (attribute_flag[1] != 0)
8626 if (LocaleCompare(draw_info->primitive,"path") == 0)
8628 (void) ConcatenateString(&draw_info->primitive," '");
8629 ConcatenateString(&draw_info->primitive,
8630 argument_list[1].string_reference);
8631 (void) ConcatenateString(&draw_info->primitive,"'");
8635 (void) ConcatenateString(&draw_info->primitive," ");
8636 ConcatenateString(&draw_info->primitive,
8637 argument_list[1].string_reference);
8640 if (attribute_flag[2] != 0)
8642 (void) ConcatenateString(&draw_info->primitive," ");
8643 (void) ConcatenateString(&draw_info->primitive,
8644 CommandOptionToMnemonic(MagickMethodOptions,
8645 argument_list[2].integer_reference));
8647 if (attribute_flag[3] != 0)
8649 (void) QueryColorCompliance(argument_list[3].string_reference,
8650 AllCompliance,&draw_info->stroke,exception);
8651 if (argument_list[3].image_reference != (Image *) NULL)
8652 draw_info->stroke_pattern=CloneImage(
8653 argument_list[3].image_reference,0,0,MagickTrue,exception);
8655 if (attribute_flag[4] != 0)
8657 (void) QueryColorCompliance(argument_list[4].string_reference,
8658 AllCompliance,&draw_info->fill,exception);
8659 if (argument_list[4].image_reference != (Image *) NULL)
8660 draw_info->fill_pattern=CloneImage(
8661 argument_list[4].image_reference,0,0,MagickTrue,exception);
8663 if (attribute_flag[5] != 0)
8664 draw_info->stroke_width=argument_list[5].real_reference;
8665 if (attribute_flag[6] != 0)
8666 (void) CloneString(&draw_info->font,
8667 argument_list[6].string_reference);
8668 if (attribute_flag[7] != 0)
8669 (void) QueryColorCompliance(argument_list[7].string_reference,
8670 AllCompliance,&draw_info->border_color,exception);
8671 if (attribute_flag[8] != 0)
8672 draw_info->affine.tx=argument_list[8].real_reference;
8673 if (attribute_flag[9] != 0)
8674 draw_info->affine.ty=argument_list[9].real_reference;
8675 if (attribute_flag[20] != 0)
8680 av=(AV *) argument_list[20].array_reference;
8681 if ((av_len(av) != 3) && (av_len(av) != 5))
8683 ThrowPerlException(exception,OptionError,
8684 "affine matrix must have 4 or 6 elements",PackageName);
8687 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8688 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8689 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8690 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8691 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8692 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8694 ThrowPerlException(exception,OptionError,
8695 "affine matrix is singular",PackageName);
8698 if (av_len(av) == 5)
8700 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8701 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8704 for (j=10; j < 15; j++)
8706 if (attribute_flag[j] == 0)
8708 value=argument_list[j].string_reference;
8709 angle=argument_list[j].real_reference;
8710 current=draw_info->affine;
8711 GetAffineMatrix(&affine);
8719 flags=ParseGeometry(value,&geometry_info);
8720 affine.tx=geometry_info.xi;
8721 affine.ty=geometry_info.psi;
8722 if ((flags & PsiValue) == 0)
8723 affine.ty=affine.tx;
8731 flags=ParseGeometry(value,&geometry_info);
8732 affine.sx=geometry_info.rho;
8733 affine.sy=geometry_info.sigma;
8734 if ((flags & SigmaValue) == 0)
8735 affine.sy=affine.sx;
8745 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8746 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8747 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8748 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8756 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8764 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8768 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8769 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8770 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8771 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8772 draw_info->affine.tx=
8773 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8774 draw_info->affine.ty=
8775 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8777 if (attribute_flag[15] != 0)
8778 draw_info->fill_pattern=CloneImage(
8779 argument_list[15].image_reference,0,0,MagickTrue,exception);
8780 if (attribute_flag[16] != 0)
8781 draw_info->pointsize=argument_list[16].real_reference;
8782 if (attribute_flag[17] != 0)
8784 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8785 ? MagickTrue : MagickFalse;
8786 draw_info->text_antialias=draw_info->stroke_antialias;
8788 if (attribute_flag[18] != 0)
8789 (void) CloneString(&draw_info->density,
8790 argument_list[18].string_reference);
8791 if (attribute_flag[19] != 0)
8792 draw_info->stroke_width=argument_list[19].real_reference;
8793 if (attribute_flag[21] != 0)
8794 draw_info->dash_offset=argument_list[21].real_reference;
8795 if (attribute_flag[22] != 0)
8800 av=(AV *) argument_list[22].array_reference;
8801 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8802 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8803 if (draw_info->dash_pattern != (double *) NULL)
8805 for (i=0; i <= av_len(av); i++)
8806 draw_info->dash_pattern[i]=(double)
8807 SvNV(*(av_fetch(av,i,0)));
8808 draw_info->dash_pattern[i]=0.0;
8811 if (attribute_flag[23] != 0)
8812 image->interpolate=(PixelInterpolateMethod)
8813 argument_list[23].integer_reference;
8814 if ((attribute_flag[24] != 0) &&
8815 (draw_info->fill_pattern != (Image *) NULL))
8816 flags=ParsePageGeometry(draw_info->fill_pattern,
8817 argument_list[24].string_reference,
8818 &draw_info->fill_pattern->tile_offset,exception);
8819 if (attribute_flag[25] != 0)
8821 (void) ConcatenateString(&draw_info->primitive," '");
8822 (void) ConcatenateString(&draw_info->primitive,
8823 argument_list[25].string_reference);
8824 (void) ConcatenateString(&draw_info->primitive,"'");
8826 if (attribute_flag[26] != 0)
8827 draw_info->fill_pattern=CloneImage(
8828 argument_list[26].image_reference,0,0,MagickTrue,exception);
8829 if (attribute_flag[27] != 0)
8830 draw_info->stroke_pattern=CloneImage(
8831 argument_list[27].image_reference,0,0,MagickTrue,exception);
8832 if (attribute_flag[28] != 0)
8833 (void) CloneString(&draw_info->primitive,
8834 argument_list[28].string_reference);
8835 if (attribute_flag[29] != 0)
8836 draw_info->kerning=argument_list[29].real_reference;
8837 if (attribute_flag[30] != 0)
8838 draw_info->interline_spacing=argument_list[30].real_reference;
8839 if (attribute_flag[31] != 0)
8840 draw_info->interword_spacing=argument_list[31].real_reference;
8841 if (attribute_flag[32] != 0)
8842 draw_info->direction=(DirectionType)
8843 argument_list[32].integer_reference;
8844 DrawImage(image,draw_info,exception);
8845 draw_info=DestroyDrawInfo(draw_info);
8848 case 39: /* Equalize */
8850 if (attribute_flag[0] != 0)
8851 channel=(ChannelType) argument_list[0].integer_reference;
8852 channel_mask=SetImageChannelMask(image,channel);
8853 EqualizeImage(image,exception);
8854 (void) SetImageChannelMask(image,channel_mask);
8857 case 40: /* Gamma */
8859 if (attribute_flag[1] != 0)
8860 channel=(ChannelType) argument_list[1].integer_reference;
8861 if (attribute_flag[2] == 0)
8862 argument_list[2].real_reference=1.0;
8863 if (attribute_flag[3] == 0)
8864 argument_list[3].real_reference=1.0;
8865 if (attribute_flag[4] == 0)
8866 argument_list[4].real_reference=1.0;
8867 if (attribute_flag[0] == 0)
8869 (void) FormatLocaleString(message,MaxTextExtent,
8870 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8871 (double) argument_list[3].real_reference,
8872 (double) argument_list[4].real_reference);
8873 argument_list[0].string_reference=message;
8875 (void) GammaImage(image,StringToDouble(
8876 argument_list[0].string_reference,(char **) NULL),exception);
8884 if (attribute_flag[0] == 0)
8886 ThrowPerlException(exception,OptionError,"MapImageRequired",
8890 quantize_info=AcquireQuantizeInfo(info->image_info);
8891 if (attribute_flag[1] != 0)
8892 quantize_info->dither_method=(DitherMethod)
8893 argument_list[1].integer_reference;
8894 (void) RemapImages(quantize_info,image,
8895 argument_list[0].image_reference,exception);
8896 quantize_info=DestroyQuantizeInfo(quantize_info);
8899 case 42: /* MatteFloodfill */
8910 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8912 if (attribute_flag[0] != 0)
8913 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8914 &geometry,exception);
8915 if (attribute_flag[1] != 0)
8916 geometry.x=argument_list[1].integer_reference;
8917 if (attribute_flag[2] != 0)
8918 geometry.y=argument_list[2].integer_reference;
8919 if (image->alpha_trait != BlendPixelTrait)
8920 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8921 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8922 geometry.x,geometry.y,&target,exception);
8923 if (attribute_flag[4] != 0)
8924 QueryColorCompliance(argument_list[4].string_reference,
8925 AllCompliance,&target,exception);
8926 if (attribute_flag[3] != 0)
8927 target.alpha=StringToDoubleInterval(
8928 argument_list[3].string_reference,(double) (double) QuantumRange+
8930 if (attribute_flag[5] != 0)
8931 image->fuzz=StringToDoubleInterval(
8932 argument_list[5].string_reference,(double) QuantumRange+1.0);
8934 if (attribute_flag[6] != 0)
8935 invert=(MagickBooleanType) argument_list[6].integer_reference;
8936 channel_mask=SetImageChannelMask(image,AlphaChannel);
8937 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8938 geometry.y,invert,exception);
8939 (void) SetImageChannelMask(image,channel_mask);
8940 draw_info=DestroyDrawInfo(draw_info);
8943 case 43: /* Modulate */
8946 modulate[MaxTextExtent];
8948 geometry_info.rho=100.0;
8949 geometry_info.sigma=100.0;
8950 geometry_info.xi=100.0;
8951 if (attribute_flag[0] != 0)
8952 (void)ParseGeometry(argument_list[0].string_reference,
8954 if (attribute_flag[1] != 0)
8955 geometry_info.xi=argument_list[1].real_reference;
8956 if (attribute_flag[2] != 0)
8957 geometry_info.sigma=argument_list[2].real_reference;
8958 if (attribute_flag[3] != 0)
8960 geometry_info.sigma=argument_list[3].real_reference;
8961 SetImageArtifact(image,"modulate:colorspace","HWB");
8963 if (attribute_flag[4] != 0)
8965 geometry_info.rho=argument_list[4].real_reference;
8966 SetImageArtifact(image,"modulate:colorspace","HSB");
8968 if (attribute_flag[5] != 0)
8970 geometry_info.sigma=argument_list[5].real_reference;
8971 SetImageArtifact(image,"modulate:colorspace","HSL");
8973 if (attribute_flag[6] != 0)
8975 geometry_info.rho=argument_list[6].real_reference;
8976 SetImageArtifact(image,"modulate:colorspace","HWB");
8978 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8979 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8980 (void) ModulateImage(image,modulate,exception);
8983 case 44: /* Negate */
8985 if (attribute_flag[0] == 0)
8986 argument_list[0].integer_reference=0;
8987 if (attribute_flag[1] != 0)
8988 channel=(ChannelType) argument_list[1].integer_reference;
8989 channel_mask=SetImageChannelMask(image,channel);
8990 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8991 MagickTrue : MagickFalse,exception);
8992 (void) SetImageChannelMask(image,channel_mask);
8995 case 45: /* Normalize */
8997 if (attribute_flag[0] != 0)
8998 channel=(ChannelType) argument_list[0].integer_reference;
8999 channel_mask=SetImageChannelMask(image,channel);
9000 NormalizeImage(image,exception);
9001 (void) SetImageChannelMask(image,channel_mask);
9004 case 46: /* NumberColors */
9006 case 47: /* Opaque */
9015 (void) QueryColorCompliance("none",AllCompliance,&target,
9017 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9019 if (attribute_flag[0] != 0)
9020 (void) QueryColorCompliance(argument_list[0].string_reference,
9021 AllCompliance,&target,exception);
9022 if (attribute_flag[1] != 0)
9023 (void) QueryColorCompliance(argument_list[1].string_reference,
9024 AllCompliance,&fill_color,exception);
9025 if (attribute_flag[2] != 0)
9026 image->fuzz=StringToDoubleInterval(
9027 argument_list[2].string_reference,(double) QuantumRange+1.0);
9028 if (attribute_flag[3] != 0)
9029 channel=(ChannelType) argument_list[3].integer_reference;
9031 if (attribute_flag[4] != 0)
9032 invert=(MagickBooleanType) argument_list[4].integer_reference;
9033 channel_mask=SetImageChannelMask(image,channel);
9034 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9035 (void) SetImageChannelMask(image,channel_mask);
9038 case 48: /* Quantize */
9043 quantize_info=AcquireQuantizeInfo(info->image_info);
9044 if (attribute_flag[0] != 0)
9045 quantize_info->number_colors=(size_t)
9046 argument_list[0].integer_reference;
9047 if (attribute_flag[1] != 0)
9048 quantize_info->tree_depth=(size_t)
9049 argument_list[1].integer_reference;
9050 if (attribute_flag[2] != 0)
9051 quantize_info->colorspace=(ColorspaceType)
9052 argument_list[2].integer_reference;
9053 if (attribute_flag[3] != 0)
9054 quantize_info->dither_method=(DitherMethod)
9055 argument_list[3].integer_reference;
9056 if (attribute_flag[4] != 0)
9057 quantize_info->measure_error=argument_list[4].integer_reference !=
9058 0 ? MagickTrue : MagickFalse;
9059 if (attribute_flag[5] != 0)
9060 (void) QueryColorCompliance(argument_list[5].string_reference,
9061 AllCompliance,&image->transparent_color,exception);
9062 if (attribute_flag[5] && argument_list[5].integer_reference)
9064 (void) QuantizeImages(quantize_info,image,exception);
9067 if (attribute_flag[6] != 0)
9068 quantize_info->dither_method=(DitherMethod)
9069 argument_list[6].integer_reference;
9070 if ((image->storage_class == DirectClass) ||
9071 (image->colors > quantize_info->number_colors) ||
9072 (quantize_info->colorspace == GRAYColorspace))
9073 (void) QuantizeImage(quantize_info,image,exception);
9075 CompressImageColormap(image,exception);
9076 quantize_info=DestroyQuantizeInfo(quantize_info);
9079 case 49: /* Raise */
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.width=argument_list[1].integer_reference;
9086 if (attribute_flag[2] != 0)
9087 geometry.height=argument_list[2].integer_reference;
9088 if (attribute_flag[3] == 0)
9089 argument_list[3].integer_reference=1;
9090 (void) RaiseImage(image,&geometry,
9091 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9095 case 50: /* Segment */
9102 smoothing_threshold;
9107 cluster_threshold=1.0;
9108 smoothing_threshold=1.5;
9109 colorspace=sRGBColorspace;
9110 verbose=MagickFalse;
9111 if (attribute_flag[0] != 0)
9113 flags=ParseGeometry(argument_list[0].string_reference,
9115 cluster_threshold=geometry_info.rho;
9116 if (flags & SigmaValue)
9117 smoothing_threshold=geometry_info.sigma;
9119 if (attribute_flag[1] != 0)
9120 cluster_threshold=argument_list[1].real_reference;
9121 if (attribute_flag[2] != 0)
9122 smoothing_threshold=argument_list[2].real_reference;
9123 if (attribute_flag[3] != 0)
9124 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9125 if (attribute_flag[4] != 0)
9126 verbose=argument_list[4].integer_reference != 0 ?
9127 MagickTrue : MagickFalse;
9128 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9129 smoothing_threshold,exception);
9132 case 51: /* Signature */
9134 (void) SignatureImage(image,exception);
9137 case 52: /* Solarize */
9139 geometry_info.rho=QuantumRange/2.0;
9140 if (attribute_flag[0] != 0)
9141 flags=ParseGeometry(argument_list[0].string_reference,
9143 if (attribute_flag[1] != 0)
9144 geometry_info.rho=StringToDoubleInterval(
9145 argument_list[1].string_reference,(double) QuantumRange+1.0);
9146 (void) SolarizeImage(image,geometry_info.rho,exception);
9151 (void) SyncImage(image,exception);
9154 case 54: /* Texture */
9156 if (attribute_flag[0] == 0)
9158 TextureImage(image,argument_list[0].image_reference,exception);
9161 case 55: /* Evalute */
9163 MagickEvaluateOperator
9166 op=SetEvaluateOperator;
9167 if (attribute_flag[0] == MagickFalse)
9168 argument_list[0].real_reference=0.0;
9169 if (attribute_flag[1] != MagickFalse)
9170 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9171 if (attribute_flag[2] != MagickFalse)
9172 channel=(ChannelType) argument_list[2].integer_reference;
9173 channel_mask=SetImageChannelMask(image,channel);
9174 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9176 (void) SetImageChannelMask(image,channel_mask);
9179 case 56: /* Transparent */
9190 (void) QueryColorCompliance("none",AllCompliance,&target,
9192 if (attribute_flag[0] != 0)
9193 (void) QueryColorCompliance(argument_list[0].string_reference,
9194 AllCompliance,&target,exception);
9195 opacity=TransparentAlpha;
9196 if (attribute_flag[1] != 0)
9197 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9198 (double) QuantumRange+1.0);
9199 if (attribute_flag[2] != 0)
9200 image->fuzz=StringToDoubleInterval(
9201 argument_list[2].string_reference,(double) QuantumRange+1.0);
9202 if (attribute_flag[3] == 0)
9203 argument_list[3].integer_reference=0;
9205 if (attribute_flag[3] != 0)
9206 invert=(MagickBooleanType) argument_list[3].integer_reference;
9207 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9211 case 57: /* Threshold */
9216 if (attribute_flag[0] == 0)
9217 argument_list[0].string_reference="50%";
9218 if (attribute_flag[1] != 0)
9219 channel=(ChannelType) argument_list[1].integer_reference;
9220 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9221 (double) QuantumRange+1.0);
9222 channel_mask=SetImageChannelMask(image,channel);
9223 (void) BilevelImage(image,threshold,exception);
9224 (void) SetImageChannelMask(image,channel_mask);
9227 case 58: /* Charcoal */
9229 if (attribute_flag[0] != 0)
9231 flags=ParseGeometry(argument_list[0].string_reference,
9233 if ((flags & SigmaValue) == 0)
9234 geometry_info.sigma=1.0;
9236 if (attribute_flag[1] != 0)
9237 geometry_info.rho=argument_list[1].real_reference;
9238 if (attribute_flag[2] != 0)
9239 geometry_info.sigma=argument_list[2].real_reference;
9240 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9246 if (attribute_flag[0] != 0)
9247 image->fuzz=StringToDoubleInterval(
9248 argument_list[0].string_reference,(double) QuantumRange+1.0);
9249 image=TrimImage(image,exception);
9254 PixelInterpolateMethod
9257 if (attribute_flag[0] != 0)
9259 flags=ParseGeometry(argument_list[0].string_reference,
9261 if ((flags & SigmaValue) == 0)
9262 geometry_info.sigma=1.0;
9264 if (attribute_flag[1] != 0)
9265 geometry_info.rho=argument_list[1].real_reference;
9266 if (attribute_flag[2] != 0)
9267 geometry_info.sigma=argument_list[2].real_reference;
9268 method=UndefinedInterpolatePixel;
9269 if (attribute_flag[3] != 0)
9270 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9271 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9275 case 61: /* Separate */
9277 if (attribute_flag[0] != 0)
9278 channel=(ChannelType) argument_list[0].integer_reference;
9279 image=SeparateImage(image,channel,exception);
9282 case 63: /* Stereo */
9284 if (attribute_flag[0] == 0)
9286 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9290 if (attribute_flag[1] != 0)
9291 geometry.x=argument_list[1].integer_reference;
9292 if (attribute_flag[2] != 0)
9293 geometry.y=argument_list[2].integer_reference;
9294 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9295 geometry.x,geometry.y,exception);
9298 case 64: /* Stegano */
9300 if (attribute_flag[0] == 0)
9302 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9306 if (attribute_flag[1] == 0)
9307 argument_list[1].integer_reference=0;
9308 image->offset=argument_list[1].integer_reference;
9309 image=SteganoImage(image,argument_list[0].image_reference,exception);
9312 case 65: /* Deconstruct */
9314 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9317 case 66: /* GaussianBlur */
9319 if (attribute_flag[0] != 0)
9321 flags=ParseGeometry(argument_list[0].string_reference,
9323 if ((flags & SigmaValue) == 0)
9324 geometry_info.sigma=1.0;
9326 if (attribute_flag[1] != 0)
9327 geometry_info.rho=argument_list[1].real_reference;
9328 if (attribute_flag[2] != 0)
9329 geometry_info.sigma=argument_list[2].real_reference;
9330 if (attribute_flag[3] != 0)
9331 channel=(ChannelType) argument_list[3].integer_reference;
9332 channel_mask=SetImageChannelMask(image,channel);
9333 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9335 if (image != (Image *) NULL)
9336 (void) SetImageChannelMask(image,channel_mask);
9339 case 67: /* Convolve */
9344 kernel=(KernelInfo *) NULL;
9345 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9347 if (attribute_flag[0] != 0)
9355 kernel=AcquireKernelInfo((const char *) NULL);
9356 if (kernel == (KernelInfo *) NULL)
9358 av=(AV *) argument_list[0].array_reference;
9359 order=(size_t) sqrt(av_len(av)+1);
9360 kernel->width=order;
9361 kernel->height=order;
9362 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9363 order*sizeof(*kernel->values));
9364 if (kernel->values == (MagickRealType *) NULL)
9366 kernel=DestroyKernelInfo(kernel);
9367 ThrowPerlException(exception,ResourceLimitFatalError,
9368 "MemoryAllocationFailed",PackageName);
9371 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9372 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9373 for ( ; j < (ssize_t) (order*order); j++)
9374 kernel->values[j]=0.0;
9376 if (attribute_flag[1] != 0)
9377 channel=(ChannelType) argument_list[1].integer_reference;
9378 if (attribute_flag[2] != 0)
9379 SetImageArtifact(image,"filter:blur",
9380 argument_list[2].string_reference);
9381 if (attribute_flag[3] != 0)
9383 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9384 if (kernel == (KernelInfo *) NULL)
9387 channel_mask=SetImageChannelMask(image,channel);
9388 image=ConvolveImage(image,kernel,exception);
9389 if (image != (Image *) NULL)
9390 (void) SetImageChannelMask(image,channel_mask);
9391 kernel=DestroyKernelInfo(kernel);
9394 case 68: /* Profile */
9409 if (attribute_flag[0] != 0)
9410 name=argument_list[0].string_reference;
9411 if (attribute_flag[2] != 0)
9412 image->rendering_intent=(RenderingIntent)
9413 argument_list[2].integer_reference;
9414 if (attribute_flag[3] != 0)
9415 image->black_point_compensation=
9416 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9417 if (attribute_flag[1] != 0)
9419 if (argument_list[1].length == 0)
9422 Remove a profile from the image.
9424 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9429 Associate user supplied profile with the image.
9431 profile=AcquireStringInfo(argument_list[1].length);
9432 SetStringInfoDatum(profile,(const unsigned char *)
9433 argument_list[1].string_reference);
9434 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9435 (size_t) GetStringInfoLength(profile),exception);
9436 profile=DestroyStringInfo(profile);
9440 Associate a profile with the image.
9442 profile_info=CloneImageInfo(info ? info->image_info :
9443 (ImageInfo *) NULL);
9444 profile_image=ReadImages(profile_info,name,exception);
9445 if (profile_image == (Image *) NULL)
9447 ResetImageProfileIterator(profile_image);
9448 name=GetNextImageProfile(profile_image);
9449 while (name != (const char *) NULL)
9454 profile=GetImageProfile(profile_image,name);
9455 if (profile != (const StringInfo *) NULL)
9456 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9457 (size_t) GetStringInfoLength(profile),exception);
9458 name=GetNextImageProfile(profile_image);
9460 profile_image=DestroyImage(profile_image);
9461 profile_info=DestroyImageInfo(profile_info);
9464 case 69: /* UnsharpMask */
9466 if (attribute_flag[0] != 0)
9468 flags=ParseGeometry(argument_list[0].string_reference,
9470 if ((flags & SigmaValue) == 0)
9471 geometry_info.sigma=1.0;
9472 if ((flags & XiValue) == 0)
9473 geometry_info.xi=1.0;
9474 if ((flags & PsiValue) == 0)
9475 geometry_info.psi=0.5;
9477 if (attribute_flag[1] != 0)
9478 geometry_info.rho=argument_list[1].real_reference;
9479 if (attribute_flag[2] != 0)
9480 geometry_info.sigma=argument_list[2].real_reference;
9481 if (attribute_flag[3] != 0)
9482 geometry_info.xi=argument_list[3].real_reference;
9483 if (attribute_flag[4] != 0)
9484 geometry_info.psi=argument_list[4].real_reference;
9485 if (attribute_flag[5] != 0)
9486 channel=(ChannelType) argument_list[5].integer_reference;
9487 channel_mask=SetImageChannelMask(image,channel);
9488 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9489 geometry_info.xi,geometry_info.psi,exception);
9490 if (image != (Image *) NULL)
9491 (void) SetImageChannelMask(image,channel_mask);
9494 case 70: /* MotionBlur */
9496 if (attribute_flag[0] != 0)
9498 flags=ParseGeometry(argument_list[0].string_reference,
9500 if ((flags & SigmaValue) == 0)
9501 geometry_info.sigma=1.0;
9502 if ((flags & XiValue) == 0)
9503 geometry_info.xi=1.0;
9505 if (attribute_flag[1] != 0)
9506 geometry_info.rho=argument_list[1].real_reference;
9507 if (attribute_flag[2] != 0)
9508 geometry_info.sigma=argument_list[2].real_reference;
9509 if (attribute_flag[3] != 0)
9510 geometry_info.xi=argument_list[3].real_reference;
9511 if (attribute_flag[4] != 0)
9512 channel=(ChannelType) argument_list[4].integer_reference;
9513 channel_mask=SetImageChannelMask(image,channel);
9514 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9515 geometry_info.xi,exception);
9516 if (image != (Image *) NULL)
9517 (void) SetImageChannelMask(image,channel_mask);
9520 case 71: /* OrderedDither */
9522 if (attribute_flag[0] == 0)
9523 argument_list[0].string_reference="o8x8";
9524 if (attribute_flag[1] != 0)
9525 channel=(ChannelType) argument_list[1].integer_reference;
9526 channel_mask=SetImageChannelMask(image,channel);
9527 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9529 (void) SetImageChannelMask(image,channel_mask);
9532 case 72: /* Shave */
9534 if (attribute_flag[0] != 0)
9535 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9536 &geometry,exception);
9537 if (attribute_flag[1] != 0)
9538 geometry.width=argument_list[1].integer_reference;
9539 if (attribute_flag[2] != 0)
9540 geometry.height=argument_list[2].integer_reference;
9541 image=ShaveImage(image,&geometry,exception);
9544 case 73: /* Level */
9552 white_point=(double) image->columns*image->rows;
9554 if (attribute_flag[0] != 0)
9556 flags=ParseGeometry(argument_list[0].string_reference,
9558 black_point=geometry_info.rho;
9559 if ((flags & SigmaValue) != 0)
9560 white_point=geometry_info.sigma;
9561 if ((flags & XiValue) != 0)
9562 gamma=geometry_info.xi;
9563 if ((flags & PercentValue) != 0)
9565 black_point*=(double) (QuantumRange/100.0);
9566 white_point*=(double) (QuantumRange/100.0);
9568 if ((flags & SigmaValue) == 0)
9569 white_point=(double) QuantumRange-black_point;
9571 if (attribute_flag[1] != 0)
9572 black_point=argument_list[1].real_reference;
9573 if (attribute_flag[2] != 0)
9574 white_point=argument_list[2].real_reference;
9575 if (attribute_flag[3] != 0)
9576 gamma=argument_list[3].real_reference;
9577 if (attribute_flag[4] != 0)
9578 channel=(ChannelType) argument_list[4].integer_reference;
9579 if (attribute_flag[5] != 0)
9581 argument_list[0].real_reference=argument_list[5].real_reference;
9582 attribute_flag[0]=attribute_flag[5];
9584 channel_mask=SetImageChannelMask(image,channel);
9585 (void) LevelImage(image,black_point,white_point,gamma,exception);
9586 (void) SetImageChannelMask(image,channel_mask);
9591 if (attribute_flag[0] == 0)
9592 argument_list[0].string_reference="#1";
9593 if (attribute_flag[1] == 0)
9594 argument_list[1].integer_reference=MagickTrue;
9595 (void) ClipImagePath(image,argument_list[0].string_reference,
9596 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9600 case 75: /* AffineTransform */
9605 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9607 if (attribute_flag[0] != 0)
9612 av=(AV *) argument_list[0].array_reference;
9613 if ((av_len(av) != 3) && (av_len(av) != 5))
9615 ThrowPerlException(exception,OptionError,
9616 "affine matrix must have 4 or 6 elements",PackageName);
9619 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9620 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9621 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9622 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9623 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9624 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9626 ThrowPerlException(exception,OptionError,
9627 "affine matrix is singular",PackageName);
9630 if (av_len(av) == 5)
9632 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9633 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9636 for (j=1; j < 6; j++)
9638 if (attribute_flag[j] == 0)
9640 value=argument_list[j].string_reference;
9641 angle=argument_list[j].real_reference;
9642 current=draw_info->affine;
9643 GetAffineMatrix(&affine);
9651 flags=ParseGeometry(value,&geometry_info);
9652 affine.tx=geometry_info.xi;
9653 affine.ty=geometry_info.psi;
9654 if ((flags & PsiValue) == 0)
9655 affine.ty=affine.tx;
9663 flags=ParseGeometry(value,&geometry_info);
9664 affine.sx=geometry_info.rho;
9665 affine.sy=geometry_info.sigma;
9666 if ((flags & SigmaValue) == 0)
9667 affine.sy=affine.sx;
9677 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9678 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9679 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9680 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9688 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9696 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9700 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9701 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9702 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9703 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9704 draw_info->affine.tx=
9705 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9706 draw_info->affine.ty=
9707 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9709 if (attribute_flag[6] != 0)
9710 image->interpolate=(PixelInterpolateMethod)
9711 argument_list[6].integer_reference;
9712 if (attribute_flag[7] != 0)
9713 QueryColorCompliance(argument_list[7].string_reference,
9714 AllCompliance,&image->background_color,exception);
9715 image=AffineTransformImage(image,&draw_info->affine,exception);
9716 draw_info=DestroyDrawInfo(draw_info);
9719 case 76: /* Difference */
9721 if (attribute_flag[0] == 0)
9723 ThrowPerlException(exception,OptionError,
9724 "ReferenceImageRequired",PackageName);
9727 if (attribute_flag[1] != 0)
9728 image->fuzz=StringToDoubleInterval(
9729 argument_list[1].string_reference,(double) QuantumRange+1.0);
9730 (void) IsImagesEqual(image,argument_list[0].image_reference,
9734 case 77: /* AdaptiveThreshold */
9736 if (attribute_flag[0] != 0)
9738 flags=ParseGeometry(argument_list[0].string_reference,
9740 if ((flags & PercentValue) != 0)
9741 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9743 if (attribute_flag[1] != 0)
9744 geometry_info.rho=argument_list[1].integer_reference;
9745 if (attribute_flag[2] != 0)
9746 geometry_info.sigma=argument_list[2].integer_reference;
9747 if (attribute_flag[3] != 0)
9748 geometry_info.xi=argument_list[3].integer_reference;;
9749 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9750 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9753 case 78: /* Resample */
9759 if (attribute_flag[0] != 0)
9761 flags=ParseGeometry(argument_list[0].string_reference,
9763 if ((flags & SigmaValue) == 0)
9764 geometry_info.sigma=geometry_info.rho;
9766 if (attribute_flag[1] != 0)
9767 geometry_info.rho=argument_list[1].real_reference;
9768 if (attribute_flag[2] != 0)
9769 geometry_info.sigma=argument_list[2].real_reference;
9770 if (attribute_flag[3] == 0)
9771 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9772 if (attribute_flag[4] == 0)
9773 SetImageArtifact(image,"filter:support",
9774 argument_list[4].string_reference);
9775 width=(size_t) (geometry_info.rho*image->columns/
9776 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9777 height=(size_t) (geometry_info.sigma*image->rows/
9778 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9779 image=ResizeImage(image,width,height,(FilterTypes)
9780 argument_list[3].integer_reference,exception);
9781 if (image != (Image *) NULL)
9783 image->resolution.x=geometry_info.rho;
9784 image->resolution.y=geometry_info.sigma;
9788 case 79: /* Describe */
9790 if (attribute_flag[0] == 0)
9791 argument_list[0].file_reference=(FILE *) NULL;
9792 if (attribute_flag[1] != 0)
9793 (void) SetImageArtifact(image,"identify:features",
9794 argument_list[1].string_reference);
9795 (void) IdentifyImage(image,argument_list[0].file_reference,
9796 MagickTrue,exception);
9799 case 80: /* BlackThreshold */
9801 if (attribute_flag[0] == 0)
9802 argument_list[0].string_reference="50%";
9803 if (attribute_flag[2] != 0)
9804 channel=(ChannelType) argument_list[2].integer_reference;
9805 channel_mask=SetImageChannelMask(image,channel);
9806 BlackThresholdImage(image,argument_list[0].string_reference,
9808 (void) SetImageChannelMask(image,channel_mask);
9811 case 81: /* WhiteThreshold */
9813 if (attribute_flag[0] == 0)
9814 argument_list[0].string_reference="50%";
9815 if (attribute_flag[2] != 0)
9816 channel=(ChannelType) argument_list[2].integer_reference;
9817 channel_mask=SetImageChannelMask(image,channel);
9818 WhiteThresholdImage(image,argument_list[0].string_reference,
9820 (void) SetImageChannelMask(image,channel_mask);
9823 case 82: /* RadialBlur */
9825 if (attribute_flag[0] != 0)
9827 flags=ParseGeometry(argument_list[0].string_reference,
9830 if (attribute_flag[1] != 0)
9831 geometry_info.rho=argument_list[1].real_reference;
9832 if (attribute_flag[2] != 0)
9833 channel=(ChannelType) argument_list[2].integer_reference;
9834 channel_mask=SetImageChannelMask(image,channel);
9835 image=RadialBlurImage(image,geometry_info.rho,exception);
9836 if (image != (Image *) NULL)
9837 (void) SetImageChannelMask(image,channel_mask);
9840 case 83: /* Thumbnail */
9842 if (attribute_flag[0] != 0)
9843 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9844 &geometry,exception);
9845 if (attribute_flag[1] != 0)
9846 geometry.width=argument_list[1].integer_reference;
9847 if (attribute_flag[2] != 0)
9848 geometry.height=argument_list[2].integer_reference;
9849 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9852 case 84: /* Strip */
9854 (void) StripImage(image,exception);
9862 GetPixelInfo(image,&tint);
9863 if (attribute_flag[0] != 0)
9864 (void) QueryColorCompliance(argument_list[0].string_reference,
9865 AllCompliance,&tint,exception);
9866 if (attribute_flag[1] == 0)
9867 argument_list[1].string_reference="100";
9868 image=TintImage(image,argument_list[1].string_reference,&tint,
9872 case 86: /* Channel */
9874 if (attribute_flag[0] != 0)
9875 channel=(ChannelType) argument_list[0].integer_reference;
9876 image=SeparateImage(image,channel,exception);
9879 case 87: /* Splice */
9881 if (attribute_flag[0] != 0)
9882 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9883 &geometry,exception);
9884 if (attribute_flag[1] != 0)
9885 geometry.width=argument_list[1].integer_reference;
9886 if (attribute_flag[2] != 0)
9887 geometry.height=argument_list[2].integer_reference;
9888 if (attribute_flag[3] != 0)
9889 geometry.x=argument_list[3].integer_reference;
9890 if (attribute_flag[4] != 0)
9891 geometry.y=argument_list[4].integer_reference;
9892 if (attribute_flag[5] != 0)
9893 image->fuzz=StringToDoubleInterval(
9894 argument_list[5].string_reference,(double) QuantumRange+1.0);
9895 if (attribute_flag[6] != 0)
9896 (void) QueryColorCompliance(argument_list[6].string_reference,
9897 AllCompliance,&image->background_color,exception);
9898 if (attribute_flag[7] != 0)
9899 image->gravity=(GravityType) argument_list[7].integer_reference;
9900 image=SpliceImage(image,&geometry,exception);
9903 case 88: /* Posterize */
9905 if (attribute_flag[0] == 0)
9906 argument_list[0].integer_reference=3;
9907 if (attribute_flag[1] == 0)
9908 argument_list[1].integer_reference=0;
9909 (void) PosterizeImage(image,argument_list[0].integer_reference,
9910 argument_list[1].integer_reference ? RiemersmaDitherMethod :
9911 NoDitherMethod,exception);
9914 case 89: /* Shadow */
9916 if (attribute_flag[0] != 0)
9918 flags=ParseGeometry(argument_list[0].string_reference,
9920 if ((flags & SigmaValue) == 0)
9921 geometry_info.sigma=1.0;
9922 if ((flags & XiValue) == 0)
9923 geometry_info.xi=4.0;
9924 if ((flags & PsiValue) == 0)
9925 geometry_info.psi=4.0;
9927 if (attribute_flag[1] != 0)
9928 geometry_info.rho=argument_list[1].real_reference;
9929 if (attribute_flag[2] != 0)
9930 geometry_info.sigma=argument_list[2].real_reference;
9931 if (attribute_flag[3] != 0)
9932 geometry_info.xi=argument_list[3].integer_reference;
9933 if (attribute_flag[4] != 0)
9934 geometry_info.psi=argument_list[4].integer_reference;
9935 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9936 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
9937 ceil(geometry_info.psi-0.5),exception);
9940 case 90: /* Identify */
9942 if (attribute_flag[0] == 0)
9943 argument_list[0].file_reference=(FILE *) NULL;
9944 if (attribute_flag[1] != 0)
9945 (void) SetImageArtifact(image,"identify:features",
9946 argument_list[1].string_reference);
9947 if ((attribute_flag[2] != 0) &&
9948 (argument_list[2].integer_reference != 0))
9949 (void) SetImageArtifact(image,"identify:unique","true");
9950 (void) IdentifyImage(image,argument_list[0].file_reference,
9951 MagickTrue,exception);
9954 case 91: /* SepiaTone */
9956 if (attribute_flag[0] == 0)
9957 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9958 image=SepiaToneImage(image,argument_list[0].real_reference,
9962 case 92: /* SigmoidalContrast */
9967 if (attribute_flag[0] != 0)
9969 flags=ParseGeometry(argument_list[0].string_reference,
9971 if ((flags & SigmaValue) == 0)
9972 geometry_info.sigma=QuantumRange/2.0;
9973 if ((flags & PercentValue) != 0)
9974 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9976 if (attribute_flag[1] != 0)
9977 geometry_info.rho=argument_list[1].real_reference;
9978 if (attribute_flag[2] != 0)
9979 geometry_info.sigma=argument_list[2].real_reference;
9980 if (attribute_flag[3] != 0)
9981 channel=(ChannelType) argument_list[3].integer_reference;
9983 if (attribute_flag[4] != 0)
9984 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9986 channel_mask=SetImageChannelMask(image,channel);
9987 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9988 geometry_info.sigma,exception);
9989 (void) SetImageChannelMask(image,channel_mask);
9992 case 93: /* Extent */
9994 if (attribute_flag[7] != 0)
9995 image->gravity=(GravityType) argument_list[7].integer_reference;
9996 if (attribute_flag[0] != 0)
10001 flags=ParseGravityGeometry(image,
10002 argument_list[0].string_reference,&geometry,exception);
10004 if (geometry.width == 0)
10005 geometry.width=image->columns;
10006 if (geometry.height == 0)
10007 geometry.height=image->rows;
10009 if (attribute_flag[1] != 0)
10010 geometry.width=argument_list[1].integer_reference;
10011 if (attribute_flag[2] != 0)
10012 geometry.height=argument_list[2].integer_reference;
10013 if (attribute_flag[3] != 0)
10014 geometry.x=argument_list[3].integer_reference;
10015 if (attribute_flag[4] != 0)
10016 geometry.y=argument_list[4].integer_reference;
10017 if (attribute_flag[5] != 0)
10018 image->fuzz=StringToDoubleInterval(
10019 argument_list[5].string_reference,(double) QuantumRange+1.0);
10020 if (attribute_flag[6] != 0)
10021 (void) QueryColorCompliance(argument_list[6].string_reference,
10022 AllCompliance,&image->background_color,exception);
10023 image=ExtentImage(image,&geometry,exception);
10026 case 94: /* Vignette */
10028 if (attribute_flag[0] != 0)
10030 flags=ParseGeometry(argument_list[0].string_reference,
10032 if ((flags & SigmaValue) == 0)
10033 geometry_info.sigma=1.0;
10034 if ((flags & XiValue) == 0)
10035 geometry_info.xi=0.1*image->columns;
10036 if ((flags & PsiValue) == 0)
10037 geometry_info.psi=0.1*image->rows;
10039 if (attribute_flag[1] != 0)
10040 geometry_info.rho=argument_list[1].real_reference;
10041 if (attribute_flag[2] != 0)
10042 geometry_info.sigma=argument_list[2].real_reference;
10043 if (attribute_flag[3] != 0)
10044 geometry_info.xi=argument_list[3].integer_reference;
10045 if (attribute_flag[4] != 0)
10046 geometry_info.psi=argument_list[4].integer_reference;
10047 if (attribute_flag[5] != 0)
10048 (void) QueryColorCompliance(argument_list[5].string_reference,
10049 AllCompliance,&image->background_color,exception);
10050 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10051 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10052 ceil(geometry_info.psi-0.5),exception);
10055 case 95: /* ContrastStretch */
10062 white_point=(double) image->columns*image->rows;
10063 if (attribute_flag[0] != 0)
10065 flags=ParseGeometry(argument_list[0].string_reference,
10067 black_point=geometry_info.rho;
10068 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10070 if ((flags & PercentValue) != 0)
10072 black_point*=(double) image->columns*image->rows/100.0;
10073 white_point*=(double) image->columns*image->rows/100.0;
10075 white_point=(double) image->columns*image->rows-
10078 if (attribute_flag[1] != 0)
10079 black_point=argument_list[1].real_reference;
10080 if (attribute_flag[2] != 0)
10081 white_point=argument_list[2].real_reference;
10082 if (attribute_flag[4] != 0)
10083 channel=(ChannelType) argument_list[4].integer_reference;
10084 channel_mask=SetImageChannelMask(image,channel);
10085 (void) ContrastStretchImage(image,black_point,white_point,exception);
10086 (void) SetImageChannelMask(image,channel_mask);
10089 case 96: /* Sans0 */
10093 case 97: /* Sans1 */
10097 case 98: /* AdaptiveSharpen */
10099 if (attribute_flag[0] != 0)
10101 flags=ParseGeometry(argument_list[0].string_reference,
10103 if ((flags & SigmaValue) == 0)
10104 geometry_info.sigma=1.0;
10105 if ((flags & XiValue) == 0)
10106 geometry_info.xi=0.0;
10108 if (attribute_flag[1] != 0)
10109 geometry_info.rho=argument_list[1].real_reference;
10110 if (attribute_flag[2] != 0)
10111 geometry_info.sigma=argument_list[2].real_reference;
10112 if (attribute_flag[3] != 0)
10113 geometry_info.xi=argument_list[3].real_reference;
10114 if (attribute_flag[4] != 0)
10115 channel=(ChannelType) argument_list[4].integer_reference;
10116 channel_mask=SetImageChannelMask(image,channel);
10117 image=AdaptiveSharpenImage(image,geometry_info.rho,
10118 geometry_info.sigma,exception);
10119 if (image != (Image *) NULL)
10120 (void) SetImageChannelMask(image,channel_mask);
10123 case 99: /* Transpose */
10125 image=TransposeImage(image,exception);
10128 case 100: /* Tranverse */
10130 image=TransverseImage(image,exception);
10133 case 101: /* AutoOrient */
10135 switch (image->orientation)
10137 case TopRightOrientation:
10139 image=FlopImage(image,exception);
10142 case BottomRightOrientation:
10144 image=RotateImage(image,180.0,exception);
10147 case BottomLeftOrientation:
10149 image=FlipImage(image,exception);
10152 case LeftTopOrientation:
10154 image=TransposeImage(image,exception);
10157 case RightTopOrientation:
10159 image=RotateImage(image,90.0,exception);
10162 case RightBottomOrientation:
10164 image=TransverseImage(image,exception);
10167 case LeftBottomOrientation:
10169 image=RotateImage(image,270.0,exception);
10177 case 102: /* AdaptiveBlur */
10179 if (attribute_flag[0] != 0)
10181 flags=ParseGeometry(argument_list[0].string_reference,
10183 if ((flags & SigmaValue) == 0)
10184 geometry_info.sigma=1.0;
10185 if ((flags & XiValue) == 0)
10186 geometry_info.xi=0.0;
10188 if (attribute_flag[1] != 0)
10189 geometry_info.rho=argument_list[1].real_reference;
10190 if (attribute_flag[2] != 0)
10191 geometry_info.sigma=argument_list[2].real_reference;
10192 if (attribute_flag[3] != 0)
10193 channel=(ChannelType) argument_list[3].integer_reference;
10194 channel_mask=SetImageChannelMask(image,channel);
10195 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10197 if (image != (Image *) NULL)
10198 (void) SetImageChannelMask(image,channel_mask);
10201 case 103: /* Sketch */
10203 if (attribute_flag[0] != 0)
10205 flags=ParseGeometry(argument_list[0].string_reference,
10207 if ((flags & SigmaValue) == 0)
10208 geometry_info.sigma=1.0;
10209 if ((flags & XiValue) == 0)
10210 geometry_info.xi=1.0;
10212 if (attribute_flag[1] != 0)
10213 geometry_info.rho=argument_list[1].real_reference;
10214 if (attribute_flag[2] != 0)
10215 geometry_info.sigma=argument_list[2].real_reference;
10216 if (attribute_flag[3] != 0)
10217 geometry_info.xi=argument_list[3].real_reference;
10218 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10219 geometry_info.xi,exception);
10222 case 104: /* UniqueColors */
10224 image=UniqueImageColors(image,exception);
10227 case 105: /* AdaptiveResize */
10229 if (attribute_flag[0] != 0)
10230 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10231 &geometry,exception);
10232 if (attribute_flag[1] != 0)
10233 geometry.width=argument_list[1].integer_reference;
10234 if (attribute_flag[2] != 0)
10235 geometry.height=argument_list[2].integer_reference;
10236 if (attribute_flag[3] != 0)
10237 image->filter=(FilterTypes) argument_list[4].integer_reference;
10238 if (attribute_flag[4] != 0)
10239 SetImageArtifact(image,"filter:support",
10240 argument_list[4].string_reference);
10241 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10245 case 106: /* ClipMask */
10250 if (attribute_flag[0] == 0)
10252 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10254 goto PerlException;
10256 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10258 (void) NegateImage(mask_image,MagickFalse,exception);
10259 (void) SetImageMask(image,mask_image,exception);
10260 mask_image=DestroyImage(mask_image);
10263 case 107: /* LinearStretch */
10270 white_point=(double) image->columns*image->rows;
10271 if (attribute_flag[0] != 0)
10273 flags=ParseGeometry(argument_list[0].string_reference,
10275 if ((flags & SigmaValue) != 0)
10276 white_point=geometry_info.sigma;
10277 if ((flags & PercentValue) != 0)
10279 black_point*=(double) image->columns*image->rows/100.0;
10280 white_point*=(double) image->columns*image->rows/100.0;
10282 if ((flags & SigmaValue) == 0)
10283 white_point=(double) image->columns*image->rows-black_point;
10285 if (attribute_flag[1] != 0)
10286 black_point=argument_list[1].real_reference;
10287 if (attribute_flag[2] != 0)
10288 white_point=argument_list[2].real_reference;
10289 (void) LinearStretchImage(image,black_point,white_point,exception);
10292 case 108: /* ColorMatrix */
10306 if (attribute_flag[0] == 0)
10308 av=(AV *) argument_list[0].array_reference;
10309 order=(size_t) sqrt(av_len(av)+1);
10310 color_matrix=(double *) AcquireQuantumMemory(order,order*
10311 sizeof(*color_matrix));
10312 if (color_matrix == (double *) NULL)
10314 ThrowPerlException(exception,ResourceLimitFatalError,
10315 "MemoryAllocationFailed",PackageName);
10316 goto PerlException;
10318 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10319 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10320 for ( ; j < (ssize_t) (order*order); j++)
10321 color_matrix[j]=0.0;
10322 kernel_info=AcquireKernelInfo((const char *) NULL);
10323 if (kernel_info == (KernelInfo *) NULL)
10325 kernel_info->width=order;
10326 kernel_info->height=order;
10327 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10328 order*sizeof(*kernel_info->values));
10329 if (kernel_info->values != (MagickRealType *) NULL)
10331 for (i=0; i < (ssize_t) (order*order); i++)
10332 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10333 image=ColorMatrixImage(image,kernel_info,exception);
10335 kernel_info=DestroyKernelInfo(kernel_info);
10336 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10339 case 109: /* Mask */
10344 if (attribute_flag[0] == 0)
10346 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10348 goto PerlException;
10350 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10351 MagickTrue,exception);
10352 (void) NegateImage(mask_image,MagickFalse,exception);
10353 (void) SetImageMask(image,mask_image,exception);
10354 mask_image=DestroyImage(mask_image);
10357 case 110: /* Polaroid */
10368 PixelInterpolateMethod
10371 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10372 (DrawInfo *) NULL);
10373 caption=(char *) NULL;
10374 if (attribute_flag[0] != 0)
10375 caption=InterpretImageProperties(info ? info->image_info :
10376 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10379 if (attribute_flag[1] != 0)
10380 angle=argument_list[1].real_reference;
10381 if (attribute_flag[2] != 0)
10382 (void) CloneString(&draw_info->font,
10383 argument_list[2].string_reference);
10384 if (attribute_flag[3] != 0)
10385 (void) QueryColorCompliance(argument_list[3].string_reference,
10386 AllCompliance,&draw_info->stroke,exception);
10387 if (attribute_flag[4] != 0)
10388 (void) QueryColorCompliance(argument_list[4].string_reference,
10389 AllCompliance,&draw_info->fill,exception);
10390 if (attribute_flag[5] != 0)
10391 draw_info->stroke_width=argument_list[5].real_reference;
10392 if (attribute_flag[6] != 0)
10393 draw_info->pointsize=argument_list[6].real_reference;
10394 if (attribute_flag[7] != 0)
10395 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10396 if (attribute_flag[8] != 0)
10397 (void) QueryColorCompliance(argument_list[8].string_reference,
10398 AllCompliance,&image->background_color,exception);
10399 method=UndefinedInterpolatePixel;
10400 if (attribute_flag[9] != 0)
10401 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10402 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10403 draw_info=DestroyDrawInfo(draw_info);
10404 if (caption != (char *) NULL)
10405 caption=DestroyString(caption);
10408 case 111: /* FloodfillPaint */
10419 draw_info=CloneDrawInfo(info ? info->image_info :
10420 (ImageInfo *) NULL,(DrawInfo *) NULL);
10421 if (attribute_flag[0] != 0)
10422 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10423 &geometry,exception);
10424 if (attribute_flag[1] != 0)
10425 geometry.x=argument_list[1].integer_reference;
10426 if (attribute_flag[2] != 0)
10427 geometry.y=argument_list[2].integer_reference;
10428 if (attribute_flag[3] != 0)
10429 (void) QueryColorCompliance(argument_list[3].string_reference,
10430 AllCompliance,&draw_info->fill,exception);
10431 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10432 geometry.x,geometry.y,&target,exception);
10433 if (attribute_flag[4] != 0)
10434 QueryColorCompliance(argument_list[4].string_reference,
10435 AllCompliance,&target,exception);
10436 if (attribute_flag[5] != 0)
10437 image->fuzz=StringToDoubleInterval(
10438 argument_list[5].string_reference,(double) QuantumRange+1.0);
10439 if (attribute_flag[6] != 0)
10440 channel=(ChannelType) argument_list[6].integer_reference;
10441 invert=MagickFalse;
10442 if (attribute_flag[7] != 0)
10443 invert=(MagickBooleanType) argument_list[7].integer_reference;
10444 channel_mask=SetImageChannelMask(image,channel);
10445 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10446 geometry.y,invert,exception);
10447 (void) SetImageChannelMask(image,channel_mask);
10448 draw_info=DestroyDrawInfo(draw_info);
10451 case 112: /* Distort */
10463 number_coordinates;
10468 if (attribute_flag[0] == 0)
10470 method=UndefinedDistortion;
10471 if (attribute_flag[1] != 0)
10472 method=(DistortImageMethod) argument_list[1].integer_reference;
10473 av=(AV *) argument_list[0].array_reference;
10474 number_coordinates=(size_t) av_len(av)+1;
10475 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10476 sizeof(*coordinates));
10477 if (coordinates == (double *) NULL)
10479 ThrowPerlException(exception,ResourceLimitFatalError,
10480 "MemoryAllocationFailed",PackageName);
10481 goto PerlException;
10483 for (j=0; j < (ssize_t) number_coordinates; j++)
10484 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10485 virtual_pixel=UndefinedVirtualPixelMethod;
10486 if (attribute_flag[2] != 0)
10487 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10488 argument_list[2].integer_reference,exception);
10489 image=DistortImage(image,method,number_coordinates,coordinates,
10490 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10492 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10493 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10495 coordinates=(double *) RelinquishMagickMemory(coordinates);
10498 case 113: /* Clut */
10500 PixelInterpolateMethod
10503 if (attribute_flag[0] == 0)
10505 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10507 goto PerlException;
10509 method=UndefinedInterpolatePixel;
10510 if (attribute_flag[1] != 0)
10511 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10512 if (attribute_flag[2] != 0)
10513 channel=(ChannelType) argument_list[2].integer_reference;
10514 channel_mask=SetImageChannelMask(image,channel);
10515 (void) ClutImage(image,argument_list[0].image_reference,method,
10517 (void) SetImageChannelMask(image,channel_mask);
10520 case 114: /* LiquidRescale */
10522 if (attribute_flag[0] != 0)
10523 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10524 &geometry,exception);
10525 if (attribute_flag[1] != 0)
10526 geometry.width=argument_list[1].integer_reference;
10527 if (attribute_flag[2] != 0)
10528 geometry.height=argument_list[2].integer_reference;
10529 if (attribute_flag[3] == 0)
10530 argument_list[3].real_reference=1.0;
10531 if (attribute_flag[4] == 0)
10532 argument_list[4].real_reference=0.0;
10533 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10534 argument_list[3].real_reference,argument_list[4].real_reference,
10538 case 115: /* EncipherImage */
10540 (void) EncipherImage(image,argument_list[0].string_reference,
10544 case 116: /* DecipherImage */
10546 (void) DecipherImage(image,argument_list[0].string_reference,
10550 case 117: /* Deskew */
10552 geometry_info.rho=QuantumRange/2.0;
10553 if (attribute_flag[0] != 0)
10554 flags=ParseGeometry(argument_list[0].string_reference,
10556 if (attribute_flag[1] != 0)
10557 geometry_info.rho=StringToDoubleInterval(
10558 argument_list[1].string_reference,(double) QuantumRange+1.0);
10559 image=DeskewImage(image,geometry_info.rho,exception);
10562 case 118: /* Remap */
10567 if (attribute_flag[0] == 0)
10569 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10571 goto PerlException;
10573 quantize_info=AcquireQuantizeInfo(info->image_info);
10574 if (attribute_flag[1] != 0)
10575 quantize_info->dither_method=(DitherMethod)
10576 argument_list[1].integer_reference;
10577 (void) RemapImages(quantize_info,image,
10578 argument_list[0].image_reference,exception);
10579 quantize_info=DestroyQuantizeInfo(quantize_info);
10582 case 119: /* SparseColor */
10594 number_coordinates;
10599 if (attribute_flag[0] == 0)
10601 method=UndefinedColorInterpolate;
10602 if (attribute_flag[1] != 0)
10603 method=(SparseColorMethod) argument_list[1].integer_reference;
10604 av=(AV *) argument_list[0].array_reference;
10605 number_coordinates=(size_t) av_len(av)+1;
10606 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10607 sizeof(*coordinates));
10608 if (coordinates == (double *) NULL)
10610 ThrowPerlException(exception,ResourceLimitFatalError,
10611 "MemoryAllocationFailed",PackageName);
10612 goto PerlException;
10614 for (j=0; j < (ssize_t) number_coordinates; j++)
10615 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10616 virtual_pixel=UndefinedVirtualPixelMethod;
10617 if (attribute_flag[2] != 0)
10618 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10619 argument_list[2].integer_reference,exception);
10620 if (attribute_flag[3] != 0)
10621 channel=(ChannelType) argument_list[3].integer_reference;
10622 channel_mask=SetImageChannelMask(image,channel);
10623 image=SparseColorImage(image,method,number_coordinates,coordinates,
10625 if (image != (Image *) NULL)
10626 (void) SetImageChannelMask(image,channel_mask);
10627 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10628 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10630 coordinates=(double *) RelinquishMagickMemory(coordinates);
10633 case 120: /* Function */
10650 if (attribute_flag[0] == 0)
10652 function=UndefinedFunction;
10653 if (attribute_flag[1] != 0)
10654 function=(MagickFunction) argument_list[1].integer_reference;
10655 av=(AV *) argument_list[0].array_reference;
10656 number_parameters=(size_t) av_len(av)+1;
10657 parameters=(double *) AcquireQuantumMemory(number_parameters,
10658 sizeof(*parameters));
10659 if (parameters == (double *) NULL)
10661 ThrowPerlException(exception,ResourceLimitFatalError,
10662 "MemoryAllocationFailed",PackageName);
10663 goto PerlException;
10665 for (j=0; j < (ssize_t) number_parameters; j++)
10666 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10667 virtual_pixel=UndefinedVirtualPixelMethod;
10668 if (attribute_flag[2] != 0)
10669 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10670 argument_list[2].integer_reference,exception);
10671 (void) FunctionImage(image,function,number_parameters,parameters,
10673 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10674 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10676 parameters=(double *) RelinquishMagickMemory(parameters);
10679 case 121: /* SelectiveBlur */
10681 if (attribute_flag[0] != 0)
10683 flags=ParseGeometry(argument_list[0].string_reference,
10685 if ((flags & SigmaValue) == 0)
10686 geometry_info.sigma=1.0;
10687 if ((flags & PercentValue) != 0)
10688 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10690 if (attribute_flag[1] != 0)
10691 geometry_info.rho=argument_list[1].real_reference;
10692 if (attribute_flag[2] != 0)
10693 geometry_info.sigma=argument_list[2].real_reference;
10694 if (attribute_flag[3] != 0)
10695 geometry_info.xi=argument_list[3].integer_reference;;
10696 if (attribute_flag[5] != 0)
10697 channel=(ChannelType) argument_list[5].integer_reference;
10698 channel_mask=SetImageChannelMask(image,channel);
10699 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10700 geometry_info.xi,exception);
10701 if (image != (Image *) NULL)
10702 (void) SetImageChannelMask(image,channel_mask);
10705 case 122: /* HaldClut */
10707 if (attribute_flag[0] == 0)
10709 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10711 goto PerlException;
10713 if (attribute_flag[1] != 0)
10714 channel=(ChannelType) argument_list[1].integer_reference;
10715 channel_mask=SetImageChannelMask(image,channel);
10716 (void) HaldClutImage(image,argument_list[0].image_reference,
10718 (void) SetImageChannelMask(image,channel_mask);
10721 case 123: /* BlueShift */
10723 if (attribute_flag[0] != 0)
10724 (void) ParseGeometry(argument_list[0].string_reference,
10726 image=BlueShiftImage(image,geometry_info.rho,exception);
10729 case 124: /* ForwardFourierTransformImage */
10731 image=ForwardFourierTransformImage(image,
10732 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10736 case 125: /* InverseFourierTransformImage */
10738 image=InverseFourierTransformImage(image,image->next,
10739 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10743 case 126: /* ColorDecisionList */
10745 if (attribute_flag[0] == 0)
10746 argument_list[0].string_reference=(char *) NULL;
10747 (void) ColorDecisionListImage(image,
10748 argument_list[0].string_reference,exception);
10751 case 127: /* AutoGamma */
10753 if (attribute_flag[0] != 0)
10754 channel=(ChannelType) argument_list[0].integer_reference;
10755 channel_mask=SetImageChannelMask(image,channel);
10756 (void) AutoGammaImage(image,exception);
10757 (void) SetImageChannelMask(image,channel_mask);
10760 case 128: /* AutoLevel */
10762 if (attribute_flag[0] != 0)
10763 channel=(ChannelType) argument_list[0].integer_reference;
10764 channel_mask=SetImageChannelMask(image,channel);
10765 (void) AutoLevelImage(image,exception);
10766 (void) SetImageChannelMask(image,channel_mask);
10769 case 129: /* LevelColors */
10775 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10777 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10779 if (attribute_flag[1] != 0)
10780 (void) QueryColorCompliance(
10781 argument_list[1].string_reference,AllCompliance,&black_point,
10783 if (attribute_flag[2] != 0)
10784 (void) QueryColorCompliance(
10785 argument_list[2].string_reference,AllCompliance,&white_point,
10787 if (attribute_flag[3] != 0)
10788 channel=(ChannelType) argument_list[3].integer_reference;
10789 channel_mask=SetImageChannelMask(image,channel);
10790 (void) LevelImageColors(image,&black_point,&white_point,
10791 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10793 (void) SetImageChannelMask(image,channel_mask);
10796 case 130: /* Clamp */
10798 if (attribute_flag[0] != 0)
10799 channel=(ChannelType) argument_list[0].integer_reference;
10800 channel_mask=SetImageChannelMask(image,channel);
10801 (void) ClampImage(image,exception);
10802 (void) SetImageChannelMask(image,channel_mask);
10805 case 131: /* BrightnessContrast */
10813 if (attribute_flag[0] != 0)
10815 flags=ParseGeometry(argument_list[0].string_reference,
10817 brightness=geometry_info.rho;
10818 if ((flags & SigmaValue) == 0)
10819 contrast=geometry_info.sigma;
10821 if (attribute_flag[1] != 0)
10822 brightness=argument_list[1].real_reference;
10823 if (attribute_flag[2] != 0)
10824 contrast=argument_list[2].real_reference;
10825 if (attribute_flag[4] != 0)
10826 channel=(ChannelType) argument_list[4].integer_reference;
10827 channel_mask=SetImageChannelMask(image,channel);
10828 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10829 (void) SetImageChannelMask(image,channel_mask);
10832 case 132: /* Morphology */
10843 if (attribute_flag[0] == 0)
10845 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10846 if (kernel == (KernelInfo *) NULL)
10848 if (attribute_flag[1] != 0)
10849 channel=(ChannelType) argument_list[1].integer_reference;
10850 method=UndefinedMorphology;
10851 if (attribute_flag[2] != 0)
10852 method=argument_list[2].integer_reference;
10854 if (attribute_flag[3] != 0)
10855 iterations=argument_list[3].integer_reference;
10856 channel_mask=SetImageChannelMask(image,channel);
10857 image=MorphologyImage(image,method,iterations,kernel,exception);
10858 if (image != (Image *) NULL)
10859 (void) SetImageChannelMask(image,channel_mask);
10860 kernel=DestroyKernelInfo(kernel);
10863 case 133: /* Mode */
10865 if (attribute_flag[0] != 0)
10867 flags=ParseGeometry(argument_list[0].string_reference,
10869 if ((flags & SigmaValue) == 0)
10870 geometry_info.sigma=1.0;
10872 if (attribute_flag[1] != 0)
10873 geometry_info.rho=argument_list[1].real_reference;
10874 if (attribute_flag[2] != 0)
10875 geometry_info.sigma=argument_list[2].real_reference;
10876 if (attribute_flag[3] != 0)
10877 channel=(ChannelType) argument_list[3].integer_reference;
10878 channel_mask=SetImageChannelMask(image,channel);
10879 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10880 (size_t) geometry_info.sigma,exception);
10881 if (image != (Image *) NULL)
10882 (void) SetImageChannelMask(image,channel_mask);
10885 case 134: /* Statistic */
10890 statistic=UndefinedStatistic;
10891 if (attribute_flag[0] != 0)
10893 flags=ParseGeometry(argument_list[0].string_reference,
10895 if ((flags & SigmaValue) == 0)
10896 geometry_info.sigma=1.0;
10898 if (attribute_flag[1] != 0)
10899 geometry_info.rho=argument_list[1].real_reference;
10900 if (attribute_flag[2] != 0)
10901 geometry_info.sigma=argument_list[2].real_reference;
10902 if (attribute_flag[3] != 0)
10903 channel=(ChannelType) argument_list[3].integer_reference;
10904 if (attribute_flag[4] != 0)
10905 statistic=(StatisticType) argument_list[4].integer_reference;
10906 channel_mask=SetImageChannelMask(image,channel);
10907 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10908 (size_t) geometry_info.sigma,exception);
10909 if (image != (Image *) NULL)
10910 (void) SetImageChannelMask(image,channel_mask);
10914 if (next != (Image *) NULL)
10915 (void) CatchImageException(next);
10916 if (region_image != (Image *) NULL)
10921 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
10922 region_info.x,region_info.y,exception);
10924 (void) CatchImageException(region_image);
10925 image=DestroyImage(image);
10926 image=region_image;
10928 if (image != (Image *) NULL)
10931 if (next && (next != image))
10933 image->next=next->next;
10934 if (image->next != (Image *) NULL)
10935 image->next->previous=image;
10936 DeleteImageFromRegistry(*pv,next);
10938 sv_setiv(*pv,PTR2IV(image));
10946 if (reference_vector)
10947 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10948 InheritPerlException(exception,perl_exception);
10949 exception=DestroyExceptionInfo(exception);
10950 sv_setiv(perl_exception,(IV) number_images);
10951 SvPOK_on(perl_exception);
10952 ST(0)=sv_2mortal(perl_exception);
10957 ###############################################################################
10965 ###############################################################################
10970 Image::Magick ref=NO_INIT
11015 PERL_UNUSED_VAR(ref);
11016 PERL_UNUSED_VAR(ix);
11017 exception=AcquireExceptionInfo();
11018 perl_exception=newSVpv("",0);
11021 if (sv_isobject(ST(0)) == 0)
11023 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11025 goto PerlException;
11027 reference=SvRV(ST(0));
11028 hv=SvSTASH(reference);
11030 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11032 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11033 if (image == (Image *) NULL)
11035 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11037 goto PerlException;
11042 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11043 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11044 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11046 for (i=2; i < items; i+=2)
11048 attribute=(char *) SvPV(ST(i-1),na);
11049 switch (*attribute)
11054 if (LocaleCompare(attribute,"background") == 0)
11056 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11057 &montage_info->background_color,exception);
11058 for (next=image; next; next=next->next)
11059 next->background_color=montage_info->background_color;
11062 if (LocaleCompare(attribute,"border") == 0)
11064 montage_info->border_width=SvIV(ST(i));
11067 if (LocaleCompare(attribute,"bordercolor") == 0)
11069 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11070 &montage_info->border_color,exception);
11071 for (next=image; next; next=next->next)
11072 next->border_color=montage_info->border_color;
11075 if (LocaleCompare(attribute,"borderwidth") == 0)
11077 montage_info->border_width=SvIV(ST(i));
11080 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11087 if (LocaleCompare(attribute,"compose") == 0)
11089 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11090 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11093 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11097 for (next=image; next; next=next->next)
11098 next->compose=(CompositeOperator) sp;
11101 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11108 if (LocaleCompare(attribute,"fill") == 0)
11110 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11111 &montage_info->fill,exception);
11114 if (LocaleCompare(attribute,"font") == 0)
11116 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11119 if (LocaleCompare(attribute,"frame") == 0)
11125 if (IsGeometry(p) == MagickFalse)
11127 ThrowPerlException(exception,OptionError,"MissingGeometry",
11131 (void) CloneString(&montage_info->frame,p);
11133 montage_info->frame=(char *) NULL;
11136 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11143 if (LocaleCompare(attribute,"geometry") == 0)
11149 if (IsGeometry(p) == MagickFalse)
11151 ThrowPerlException(exception,OptionError,"MissingGeometry",
11155 (void) CloneString(&montage_info->geometry,p);
11157 montage_info->geometry=(char *) NULL;
11160 if (LocaleCompare(attribute,"gravity") == 0)
11165 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11166 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11169 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11173 montage_info->gravity=(GravityType) in;
11174 for (next=image; next; next=next->next)
11175 next->gravity=(GravityType) in;
11178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11185 if (LocaleCompare(attribute,"label") == 0)
11187 for (next=image; next; next=next->next)
11188 (void) SetImageProperty(next,"label",InterpretImageProperties(
11189 info ? info->image_info : (ImageInfo *) NULL,next,
11190 SvPV(ST(i),na),exception),exception);
11193 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11200 if (LocaleCompare(attribute,"mattecolor") == 0)
11202 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11203 &montage_info->matte_color,exception);
11204 for (next=image; next; next=next->next)
11205 next->matte_color=montage_info->matte_color;
11208 if (LocaleCompare(attribute,"mode") == 0)
11213 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11214 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11219 ThrowPerlException(exception,OptionError,
11220 "UnrecognizedModeType",SvPV(ST(i),na));
11225 (void) CloneString(&montage_info->frame,"15x15+3+3");
11226 montage_info->shadow=MagickTrue;
11231 montage_info->frame=(char *) NULL;
11232 montage_info->shadow=MagickFalse;
11233 montage_info->border_width=0;
11236 case ConcatenateMode:
11238 montage_info->frame=(char *) NULL;
11239 montage_info->shadow=MagickFalse;
11240 (void) CloneString(&montage_info->geometry,"+0+0");
11241 montage_info->border_width=0;
11246 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11253 if (LocaleCompare(attribute,"pointsize") == 0)
11255 montage_info->pointsize=SvIV(ST(i));
11258 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11265 if (LocaleCompare(attribute,"shadow") == 0)
11267 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11268 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11271 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11275 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11278 if (LocaleCompare(attribute,"stroke") == 0)
11280 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11281 &montage_info->stroke,exception);
11284 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11291 if (LocaleCompare(attribute,"texture") == 0)
11293 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11296 if (LocaleCompare(attribute,"tile") == 0)
11298 char *p=SvPV(ST(i),na);
11299 if (IsGeometry(p) == MagickFalse)
11301 ThrowPerlException(exception,OptionError,"MissingGeometry",
11305 (void) CloneString(&montage_info->tile,p);
11307 montage_info->tile=(char *) NULL;
11310 if (LocaleCompare(attribute,"title") == 0)
11312 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11315 if (LocaleCompare(attribute,"transparent") == 0)
11320 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11321 &transparent_color,exception);
11322 for (next=image; next; next=next->next)
11323 (void) TransparentPaintImage(next,&transparent_color,
11324 TransparentAlpha,MagickFalse,exception);
11327 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11333 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11339 image=MontageImageList(info->image_info,montage_info,image,exception);
11340 montage_info=DestroyMontageInfo(montage_info);
11341 if (image == (Image *) NULL)
11342 goto PerlException;
11343 if (transparent_color.alpha != TransparentAlpha)
11344 for (next=image; next; next=next->next)
11345 (void) TransparentPaintImage(next,&transparent_color,
11346 TransparentAlpha,MagickFalse,exception);
11347 for ( ; image; image=image->next)
11349 AddImageToRegistry(sv,image);
11351 av_push(av,sv_bless(rv,hv));
11354 exception=DestroyExceptionInfo(exception);
11355 ST(0)=av_reference;
11356 SvREFCNT_dec(perl_exception);
11360 InheritPerlException(exception,perl_exception);
11361 exception=DestroyExceptionInfo(exception);
11362 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11363 SvPOK_on(perl_exception);
11364 ST(0)=sv_2mortal(perl_exception);
11369 ###############################################################################
11377 ###############################################################################
11382 Image::Magick ref=NO_INIT
11420 PERL_UNUSED_VAR(ref);
11421 PERL_UNUSED_VAR(ix);
11422 exception=AcquireExceptionInfo();
11423 perl_exception=newSVpv("",0);
11427 if (sv_isobject(ST(0)) == 0)
11429 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11431 goto PerlException;
11433 reference=SvRV(ST(0));
11434 hv=SvSTASH(reference);
11436 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11438 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11439 if (image == (Image *) NULL)
11441 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11443 goto PerlException;
11445 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11450 for (i=2; i < items; i+=2)
11452 attribute=(char *) SvPV(ST(i-1),na);
11453 switch (*attribute)
11458 if (LocaleCompare(attribute,"frames") == 0)
11460 number_frames=SvIV(ST(i));
11463 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11469 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11475 image=MorphImages(image,number_frames,exception);
11476 if (image == (Image *) NULL)
11477 goto PerlException;
11478 for ( ; image; image=image->next)
11480 AddImageToRegistry(sv,image);
11482 av_push(av,sv_bless(rv,hv));
11485 exception=DestroyExceptionInfo(exception);
11486 ST(0)=av_reference;
11487 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11491 InheritPerlException(exception,perl_exception);
11492 exception=DestroyExceptionInfo(exception);
11493 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11494 SvPOK_on(perl_exception);
11495 ST(0)=sv_2mortal(perl_exception);
11500 ###############################################################################
11508 ###############################################################################
11513 Image::Magick ref=NO_INIT
11541 PERL_UNUSED_VAR(ref);
11542 PERL_UNUSED_VAR(ix);
11543 exception=AcquireExceptionInfo();
11544 perl_exception=newSVpv("",0);
11546 if (sv_isobject(ST(0)) == 0)
11548 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11550 goto PerlException;
11552 reference=SvRV(ST(0));
11553 hv=SvSTASH(reference);
11554 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11555 if (image == (Image *) NULL)
11557 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11559 goto PerlException;
11561 image=MergeImageLayers(image,MosaicLayer,exception);
11563 Create blessed Perl array for the returned image.
11566 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11568 AddImageToRegistry(sv,image);
11570 av_push(av,sv_bless(rv,hv));
11572 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11573 (void) CopyMagickString(info->image_info->filename,image->filename,
11575 SetImageInfo(info->image_info,0,exception);
11576 exception=DestroyExceptionInfo(exception);
11577 SvREFCNT_dec(perl_exception);
11581 InheritPerlException(exception,perl_exception);
11582 exception=DestroyExceptionInfo(exception);
11583 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11584 SvPOK_on(perl_exception); /* return messages in string context */
11585 ST(0)=sv_2mortal(perl_exception);
11590 ###############################################################################
11598 ###############################################################################
11603 Image::Magick ref=NO_INIT
11653 PERL_UNUSED_VAR(ref);
11654 PERL_UNUSED_VAR(ix);
11655 exception=AcquireExceptionInfo();
11656 perl_exception=newSVpv("",0);
11657 package_info=(struct PackageInfo *) NULL;
11658 ac=(items < 2) ? 1 : items-1;
11659 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11661 length=(STRLEN *) NULL;
11662 if (list == (char **) NULL)
11664 ThrowPerlException(exception,ResourceLimitError,
11665 "MemoryAllocationFailed",PackageName);
11666 goto PerlException;
11669 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11670 if (length == (STRLEN *) NULL)
11672 ThrowPerlException(exception,ResourceLimitError,
11673 "MemoryAllocationFailed",PackageName);
11674 goto PerlException;
11676 if (sv_isobject(ST(0)) == 0)
11678 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11680 goto PerlException;
11682 reference=SvRV(ST(0));
11683 if (SvTYPE(reference) != SVt_PVAV)
11685 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11687 goto PerlException;
11689 av=(AV *) reference;
11690 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11692 package_info=ClonePackageInfo(info,exception);
11695 *list=(char *) (*package_info->image_info->filename ?
11696 package_info->image_info->filename : "XC:black");
11698 for (n=0, i=0; i < ac; i++)
11700 list[n]=(char *) SvPV(ST(i+1),length[n]);
11701 if ((items >= 3) && strEQcase(list[n],"blob"))
11707 blob=(void *) (SvPV(ST(i+1),length[n]));
11708 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11710 if ((items >= 3) && strEQcase(list[n],"filename"))
11712 if ((items >= 3) && strEQcase(list[n],"file"))
11721 io_info=IoIFP(sv_2io(ST(i+1)));
11722 if (io_info == (PerlIO *) NULL)
11724 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11728 file=PerlIO_findFILE(io_info);
11729 if (file == (FILE *) NULL)
11731 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11735 SetImageInfoFile(package_info->image_info,file);
11737 if ((items >= 3) && strEQcase(list[n],"magick"))
11741 list[n]=(char *) NULL;
11743 status=ExpandFilenames(&n,&list);
11744 if (status == MagickFalse)
11746 ThrowPerlException(exception,ResourceLimitError,
11747 "MemoryAllocationFailed",PackageName);
11748 goto PerlException;
11751 for (i=0; i < n; i++)
11753 (void) CopyMagickString(package_info->image_info->filename,list[i],
11755 image=PingImage(package_info->image_info,exception);
11756 if (image == (Image *) NULL)
11758 if ((package_info->image_info->file != (FILE *) NULL) ||
11759 (package_info->image_info->blob != (void *) NULL))
11760 DisassociateImageStream(image);
11761 count+=GetImageListLength(image);
11762 EXTEND(sp,4*count);
11763 for (next=image; next; next=next->next)
11765 PUSHs(sv_2mortal(newSViv(next->columns)));
11766 PUSHs(sv_2mortal(newSViv(next->rows)));
11767 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11768 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11770 image=DestroyImageList(image);
11775 for (i=0; i < n; i++)
11776 if (list[i] != (char *) NULL)
11777 for (p=keep; list[i] != *p++; )
11780 list[i]=(char *) RelinquishMagickMemory(list[i]);
11785 if (package_info != (struct PackageInfo *) NULL)
11786 DestroyPackageInfo(package_info);
11787 if (list && (list != keep))
11788 list=(char **) RelinquishMagickMemory(list);
11790 keep=(char **) RelinquishMagickMemory(keep);
11792 length=(STRLEN *) RelinquishMagickMemory(length);
11793 InheritPerlException(exception,perl_exception);
11794 exception=DestroyExceptionInfo(exception);
11795 SvREFCNT_dec(perl_exception); /* throw away all errors */
11799 ###############################################################################
11807 ###############################################################################
11812 Image::Magick ref=NO_INIT
11845 PERL_UNUSED_VAR(ref);
11846 PERL_UNUSED_VAR(ix);
11847 exception=AcquireExceptionInfo();
11848 perl_exception=newSVpv("",0);
11851 if (sv_isobject(ST(0)) == 0)
11853 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11855 goto PerlException;
11857 reference=SvRV(ST(0));
11858 hv=SvSTASH(reference);
11860 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11862 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11863 if (image == (Image *) NULL)
11865 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11867 goto PerlException;
11869 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11870 preview_type=GammaPreview;
11872 preview_type=(PreviewType)
11873 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11874 for ( ; image; image=image->next)
11876 preview_image=PreviewImage(image,preview_type,exception);
11877 if (preview_image == (Image *) NULL)
11878 goto PerlException;
11879 AddImageToRegistry(sv,preview_image);
11881 av_push(av,sv_bless(rv,hv));
11884 exception=DestroyExceptionInfo(exception);
11885 ST(0)=av_reference;
11886 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11890 InheritPerlException(exception,perl_exception);
11891 exception=DestroyExceptionInfo(exception);
11892 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11893 SvPOK_on(perl_exception);
11894 ST(0)=sv_2mortal(perl_exception);
11899 ###############################################################################
11903 # Q u e r y C o l o r #
11907 ###############################################################################
11911 QueryColor(ref,...)
11912 Image::Magick ref=NO_INIT
11932 PERL_UNUSED_VAR(ref);
11933 PERL_UNUSED_VAR(ix);
11934 exception=AcquireExceptionInfo();
11935 perl_exception=newSVpv("",0);
11944 colorlist=GetColorInfoList("*",&colors,exception);
11946 for (i=0; i < (ssize_t) colors; i++)
11948 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11950 colorlist=(const ColorInfo **)
11951 RelinquishMagickMemory((ColorInfo **) colorlist);
11952 goto PerlException;
11954 EXTEND(sp,5*items);
11955 for (i=1; i < items; i++)
11957 name=(char *) SvPV(ST(i),na);
11958 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11963 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11964 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11965 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11966 if (color.colorspace == CMYKColorspace)
11967 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11968 if (color.alpha_trait == BlendPixelTrait)
11969 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11973 InheritPerlException(exception,perl_exception);
11974 exception=DestroyExceptionInfo(exception);
11975 SvREFCNT_dec(perl_exception);
11979 ###############################################################################
11983 # Q u e r y C o l o r N a m e #
11987 ###############################################################################
11991 QueryColorname(ref,...)
11992 Image::Magick ref=NO_INIT
12001 message[MaxTextExtent];
12020 *reference; /* reference is the SV* of ref=SvIV(reference) */
12022 PERL_UNUSED_VAR(ref);
12023 PERL_UNUSED_VAR(ix);
12024 exception=AcquireExceptionInfo();
12025 perl_exception=newSVpv("",0);
12026 reference=SvRV(ST(0));
12027 av=(AV *) reference;
12028 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12030 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12031 if (image == (Image *) NULL)
12033 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12035 goto PerlException;
12038 for (i=1; i < items; i++)
12040 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12042 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12044 PUSHs(sv_2mortal(newSVpv(message,0)));
12048 InheritPerlException(exception,perl_exception);
12049 exception=DestroyExceptionInfo(exception);
12050 SvREFCNT_dec(perl_exception);
12054 ###############################################################################
12058 # Q u e r y F o n t #
12062 ###############################################################################
12067 Image::Magick ref=NO_INIT
12074 message[MaxTextExtent];
12085 volatile const TypeInfo
12088 PERL_UNUSED_VAR(ref);
12089 PERL_UNUSED_VAR(ix);
12090 exception=AcquireExceptionInfo();
12091 perl_exception=newSVpv("",0);
12100 typelist=GetTypeInfoList("*",&types,exception);
12102 for (i=0; i < (ssize_t) types; i++)
12104 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12106 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12108 goto PerlException;
12110 EXTEND(sp,10*items);
12111 for (i=1; i < items; i++)
12113 name=(char *) SvPV(ST(i),na);
12114 type_info=GetTypeInfo(name,exception);
12115 if (type_info == (TypeInfo *) NULL)
12120 if (type_info->name == (char *) NULL)
12123 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12124 if (type_info->description == (char *) NULL)
12127 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12128 if (type_info->family == (char *) NULL)
12131 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12132 if (type_info->style == UndefinedStyle)
12135 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12136 type_info->style),0)));
12137 if (type_info->stretch == UndefinedStretch)
12140 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12141 type_info->stretch),0)));
12142 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12143 type_info->weight);
12144 PUSHs(sv_2mortal(newSVpv(message,0)));
12145 if (type_info->encoding == (char *) NULL)
12148 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12149 if (type_info->foundry == (char *) NULL)
12152 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12153 if (type_info->format == (char *) NULL)
12156 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12157 if (type_info->metrics == (char *) NULL)
12160 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12161 if (type_info->glyphs == (char *) NULL)
12164 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12168 InheritPerlException(exception,perl_exception);
12169 exception=DestroyExceptionInfo(exception);
12170 SvREFCNT_dec(perl_exception);
12174 ###############################################################################
12178 # Q u e r y F o n t M e t r i c s #
12182 ###############################################################################
12186 QueryFontMetrics(ref,...)
12187 Image::Magick ref=NO_INIT
12189 queryfontmetrics = 1
12236 *reference; /* reference is the SV* of ref=SvIV(reference) */
12241 PERL_UNUSED_VAR(ref);
12242 PERL_UNUSED_VAR(ix);
12243 exception=AcquireExceptionInfo();
12244 package_info=(struct PackageInfo *) NULL;
12245 perl_exception=newSVpv("",0);
12246 reference=SvRV(ST(0));
12247 av=(AV *) reference;
12248 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12250 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12251 if (image == (Image *) NULL)
12253 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12255 goto PerlException;
12257 package_info=ClonePackageInfo(info,exception);
12258 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12259 CloneString(&draw_info->text,"");
12260 current=draw_info->affine;
12261 GetAffineMatrix(&affine);
12264 EXTEND(sp,7*items);
12265 for (i=2; i < items; i+=2)
12267 attribute=(char *) SvPV(ST(i-1),na);
12268 switch (*attribute)
12273 if (LocaleCompare(attribute,"antialias") == 0)
12275 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12279 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12283 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12286 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12293 if (LocaleCompare(attribute,"density") == 0)
12295 CloneString(&draw_info->density,SvPV(ST(i),na));
12298 if (LocaleCompare(attribute,"direction") == 0)
12300 draw_info->direction=(DirectionType) ParseCommandOption(
12301 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12304 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12311 if (LocaleCompare(attribute,"encoding") == 0)
12313 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12316 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12323 if (LocaleCompare(attribute,"family") == 0)
12325 CloneString(&draw_info->family,SvPV(ST(i),na));
12328 if (LocaleCompare(attribute,"fill") == 0)
12331 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12332 &draw_info->fill,exception);
12335 if (LocaleCompare(attribute,"font") == 0)
12337 CloneString(&draw_info->font,SvPV(ST(i),na));
12340 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12347 if (LocaleCompare(attribute,"geometry") == 0)
12349 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12352 if (LocaleCompare(attribute,"gravity") == 0)
12354 draw_info->gravity=(GravityType) ParseCommandOption(
12355 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12358 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12365 if (LocaleCompare(attribute,"interline-spacing") == 0)
12367 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12368 draw_info->interline_spacing=geometry_info.rho;
12371 if (LocaleCompare(attribute,"interword-spacing") == 0)
12373 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12374 draw_info->interword_spacing=geometry_info.rho;
12377 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12384 if (LocaleCompare(attribute,"kerning") == 0)
12386 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12387 draw_info->kerning=geometry_info.rho;
12390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12397 if (LocaleCompare(attribute,"pointsize") == 0)
12399 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12400 draw_info->pointsize=geometry_info.rho;
12403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12410 if (LocaleCompare(attribute,"rotate") == 0)
12412 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12413 affine.rx=geometry_info.rho;
12414 affine.ry=geometry_info.sigma;
12415 if ((flags & SigmaValue) == 0)
12416 affine.ry=affine.rx;
12419 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12426 if (LocaleCompare(attribute,"scale") == 0)
12428 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12429 affine.sx=geometry_info.rho;
12430 affine.sy=geometry_info.sigma;
12431 if ((flags & SigmaValue) == 0)
12432 affine.sy=affine.sx;
12435 if (LocaleCompare(attribute,"skew") == 0)
12441 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12442 x_angle=geometry_info.rho;
12443 y_angle=geometry_info.sigma;
12444 if ((flags & SigmaValue) == 0)
12446 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12447 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12450 if (LocaleCompare(attribute,"stroke") == 0)
12453 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12454 &draw_info->stroke,exception);
12457 if (LocaleCompare(attribute,"style") == 0)
12459 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12463 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12467 draw_info->style=(StyleType) type;
12470 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12477 if (LocaleCompare(attribute,"text") == 0)
12479 CloneString(&draw_info->text,SvPV(ST(i),na));
12482 if (LocaleCompare(attribute,"translate") == 0)
12484 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12485 affine.tx=geometry_info.rho;
12486 affine.ty=geometry_info.sigma;
12487 if ((flags & SigmaValue) == 0)
12488 affine.ty=affine.tx;
12491 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12498 if (LocaleCompare(attribute,"weight") == 0)
12500 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12501 draw_info->weight=(size_t) geometry_info.rho;
12504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12511 if (LocaleCompare(attribute,"x") == 0)
12513 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12514 x=geometry_info.rho;
12517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12524 if (LocaleCompare(attribute,"y") == 0)
12526 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12527 y=geometry_info.rho;
12530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12536 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12542 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12543 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12544 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12545 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12546 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12547 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12548 if (draw_info->geometry == (char *) NULL)
12550 draw_info->geometry=AcquireString((char *) NULL);
12551 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12552 "%.15g,%.15g",x,y);
12554 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12555 (void) CatchImageException(image);
12556 if (status == MagickFalse)
12560 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12561 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12562 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12563 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12564 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12565 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12566 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12567 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12568 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12569 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12570 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12571 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12572 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12574 draw_info=DestroyDrawInfo(draw_info);
12577 if (package_info != (struct PackageInfo *) NULL)
12578 DestroyPackageInfo(package_info);
12579 InheritPerlException(exception,perl_exception);
12580 exception=DestroyExceptionInfo(exception);
12581 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12585 ###############################################################################
12589 # 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 #
12593 ###############################################################################
12597 QueryMultilineFontMetrics(ref,...)
12598 Image::Magick ref=NO_INIT
12600 querymultilinefontmetrics = 1
12647 *reference; /* reference is the SV* of ref=SvIV(reference) */
12652 PERL_UNUSED_VAR(ref);
12653 PERL_UNUSED_VAR(ix);
12654 exception=AcquireExceptionInfo();
12655 package_info=(struct PackageInfo *) NULL;
12656 perl_exception=newSVpv("",0);
12657 reference=SvRV(ST(0));
12658 av=(AV *) reference;
12659 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12661 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12662 if (image == (Image *) NULL)
12664 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12666 goto PerlException;
12668 package_info=ClonePackageInfo(info,exception);
12669 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12670 CloneString(&draw_info->text,"");
12671 current=draw_info->affine;
12672 GetAffineMatrix(&affine);
12675 EXTEND(sp,7*items);
12676 for (i=2; i < items; i+=2)
12678 attribute=(char *) SvPV(ST(i-1),na);
12679 switch (*attribute)
12684 if (LocaleCompare(attribute,"antialias") == 0)
12686 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12690 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12694 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12704 if (LocaleCompare(attribute,"density") == 0)
12706 CloneString(&draw_info->density,SvPV(ST(i),na));
12709 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12716 if (LocaleCompare(attribute,"encoding") == 0)
12718 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12721 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12728 if (LocaleCompare(attribute,"family") == 0)
12730 CloneString(&draw_info->family,SvPV(ST(i),na));
12733 if (LocaleCompare(attribute,"fill") == 0)
12736 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12737 &draw_info->fill,exception);
12740 if (LocaleCompare(attribute,"font") == 0)
12742 CloneString(&draw_info->font,SvPV(ST(i),na));
12745 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12752 if (LocaleCompare(attribute,"geometry") == 0)
12754 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12757 if (LocaleCompare(attribute,"gravity") == 0)
12759 draw_info->gravity=(GravityType) ParseCommandOption(
12760 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12763 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12770 if (LocaleCompare(attribute,"pointsize") == 0)
12772 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12773 draw_info->pointsize=geometry_info.rho;
12776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12783 if (LocaleCompare(attribute,"rotate") == 0)
12785 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12786 affine.rx=geometry_info.rho;
12787 affine.ry=geometry_info.sigma;
12788 if ((flags & SigmaValue) == 0)
12789 affine.ry=affine.rx;
12792 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12799 if (LocaleCompare(attribute,"scale") == 0)
12801 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12802 affine.sx=geometry_info.rho;
12803 affine.sy=geometry_info.sigma;
12804 if ((flags & SigmaValue) == 0)
12805 affine.sy=affine.sx;
12808 if (LocaleCompare(attribute,"skew") == 0)
12814 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12815 x_angle=geometry_info.rho;
12816 y_angle=geometry_info.sigma;
12817 if ((flags & SigmaValue) == 0)
12819 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12820 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12823 if (LocaleCompare(attribute,"stroke") == 0)
12826 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12827 &draw_info->stroke,exception);
12830 if (LocaleCompare(attribute,"style") == 0)
12832 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12836 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12840 draw_info->style=(StyleType) type;
12843 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12850 if (LocaleCompare(attribute,"text") == 0)
12852 CloneString(&draw_info->text,SvPV(ST(i),na));
12855 if (LocaleCompare(attribute,"translate") == 0)
12857 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12858 affine.tx=geometry_info.rho;
12859 affine.ty=geometry_info.sigma;
12860 if ((flags & SigmaValue) == 0)
12861 affine.ty=affine.tx;
12864 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12871 if (LocaleCompare(attribute,"weight") == 0)
12873 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12874 draw_info->weight=(size_t) geometry_info.rho;
12877 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12884 if (LocaleCompare(attribute,"x") == 0)
12886 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12887 x=geometry_info.rho;
12890 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12897 if (LocaleCompare(attribute,"y") == 0)
12899 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12900 y=geometry_info.rho;
12903 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12909 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12915 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12916 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12917 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12918 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12919 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12920 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12921 if (draw_info->geometry == (char *) NULL)
12923 draw_info->geometry=AcquireString((char *) NULL);
12924 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12925 "%.15g,%.15g",x,y);
12927 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12928 (void) CatchException(exception);
12929 if (status == MagickFalse)
12933 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12934 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12935 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12936 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12937 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12938 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12939 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12940 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12941 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12942 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12943 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12944 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12945 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12947 draw_info=DestroyDrawInfo(draw_info);
12950 if (package_info != (struct PackageInfo *) NULL)
12951 DestroyPackageInfo(package_info);
12952 InheritPerlException(exception,perl_exception);
12953 exception=DestroyExceptionInfo(exception);
12954 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12958 ###############################################################################
12962 # Q u e r y F o r m a t #
12966 ###############################################################################
12970 QueryFormat(ref,...)
12971 Image::Magick ref=NO_INIT
12988 volatile const MagickInfo
12991 PERL_UNUSED_VAR(ref);
12992 PERL_UNUSED_VAR(ix);
12993 exception=AcquireExceptionInfo();
12994 perl_exception=newSVpv("",0);
12998 format[MaxTextExtent];
13006 format_list=GetMagickInfoList("*",&types,exception);
13008 for (i=0; i < (ssize_t) types; i++)
13010 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13011 LocaleLower(format);
13012 PUSHs(sv_2mortal(newSVpv(format,0)));
13014 format_list=(const MagickInfo **)
13015 RelinquishMagickMemory((MagickInfo *) format_list);
13016 goto PerlException;
13018 EXTEND(sp,8*items);
13019 for (i=1; i < items; i++)
13021 name=(char *) SvPV(ST(i),na);
13022 magick_info=GetMagickInfo(name,exception);
13023 if (magick_info == (const MagickInfo *) NULL)
13028 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13029 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13030 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13031 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13032 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13033 if (magick_info->description == (char *) NULL)
13036 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13037 if (magick_info->module == (char *) NULL)
13040 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13044 InheritPerlException(exception,perl_exception);
13045 exception=DestroyExceptionInfo(exception);
13046 SvREFCNT_dec(perl_exception);
13050 ###############################################################################
13054 # Q u e r y O p t i o n #
13058 ###############################################################################
13062 QueryOption(ref,...)
13063 Image::Magick ref=NO_INIT
13084 PERL_UNUSED_VAR(ref);
13085 PERL_UNUSED_VAR(ix);
13086 exception=AcquireExceptionInfo();
13087 perl_exception=newSVpv("",0);
13088 EXTEND(sp,8*items);
13089 for (i=1; i < items; i++)
13091 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13093 options=GetCommandOptions((CommandOption) option);
13094 if (options == (char **) NULL)
13098 for (j=0; options[j] != (char *) NULL; j++)
13099 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13100 options=DestroyStringList(options);
13104 InheritPerlException(exception,perl_exception);
13105 exception=DestroyExceptionInfo(exception);
13106 SvREFCNT_dec(perl_exception);
13110 ###############################################################################
13118 ###############################################################################
13123 Image::Magick ref=NO_INIT
13170 *perl_exception, /* Perl variable for storing messages */
13175 PERL_UNUSED_VAR(ref);
13176 PERL_UNUSED_VAR(ix);
13177 exception=AcquireExceptionInfo();
13178 perl_exception=newSVpv("",0);
13180 package_info=(struct PackageInfo *) NULL;
13182 ac=(items < 2) ? 1 : items-1;
13183 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13185 length=(STRLEN *) NULL;
13186 if (list == (char **) NULL)
13188 ThrowPerlException(exception,ResourceLimitError,
13189 "MemoryAllocationFailed",PackageName);
13190 goto PerlException;
13192 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13193 if (length == (STRLEN *) NULL)
13195 ThrowPerlException(exception,ResourceLimitError,
13196 "MemoryAllocationFailed",PackageName);
13197 goto PerlException;
13199 if (sv_isobject(ST(0)) == 0)
13201 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13203 goto PerlException;
13205 reference=SvRV(ST(0));
13206 hv=SvSTASH(reference);
13207 if (SvTYPE(reference) != SVt_PVAV)
13209 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13211 goto PerlException;
13213 av=(AV *) reference;
13214 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13216 package_info=ClonePackageInfo(info,exception);
13219 *list=(char *) (*package_info->image_info->filename ?
13220 package_info->image_info->filename : "XC:black");
13222 for (n=0, i=0; i < ac; i++)
13224 list[n]=(char *) SvPV(ST(i+1),length[n]);
13225 if ((items >= 3) && strEQcase(list[n],"blob"))
13231 blob=(void *) (SvPV(ST(i+1),length[n]));
13232 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13234 if ((items >= 3) && strEQcase(list[n],"filename"))
13236 if ((items >= 3) && strEQcase(list[n],"file"))
13245 io_info=IoIFP(sv_2io(ST(i+1)));
13246 if (io_info == (PerlIO *) NULL)
13248 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13252 file=PerlIO_findFILE(io_info);
13253 if (file == (FILE *) NULL)
13255 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13259 SetImageInfoFile(package_info->image_info,file);
13261 if ((items >= 3) && strEQcase(list[n],"magick"))
13265 list[n]=(char *) NULL;
13267 status=ExpandFilenames(&n,&list);
13268 if (status == MagickFalse)
13270 ThrowPerlException(exception,ResourceLimitError,
13271 "MemoryAllocationFailed",PackageName);
13272 goto PerlException;
13275 for (i=0; i < n; i++)
13277 if ((package_info->image_info->file == (FILE *) NULL) &&
13278 (package_info->image_info->blob == (void *) NULL))
13279 image=ReadImages(package_info->image_info,list[i],exception);
13282 image=ReadImages(package_info->image_info,
13283 package_info->image_info->filename,exception);
13284 if (image != (Image *) NULL)
13285 DisassociateImageStream(image);
13287 if (image == (Image *) NULL)
13289 for ( ; image; image=image->next)
13291 AddImageToRegistry(sv,image);
13293 av_push(av,sv_bless(rv,hv));
13301 for (i=0; i < n; i++)
13302 if (list[i] != (char *) NULL)
13303 for (p=keep; list[i] != *p++; )
13304 if (*p == (char *) NULL)
13306 list[i]=(char *) RelinquishMagickMemory(list[i]);
13311 if (package_info != (struct PackageInfo *) NULL)
13312 DestroyPackageInfo(package_info);
13313 if (list && (list != keep))
13314 list=(char **) RelinquishMagickMemory(list);
13316 keep=(char **) RelinquishMagickMemory(keep);
13318 length=(STRLEN *) RelinquishMagickMemory(length);
13319 InheritPerlException(exception,perl_exception);
13320 exception=DestroyExceptionInfo(exception);
13321 sv_setiv(perl_exception,(IV) number_images);
13322 SvPOK_on(perl_exception);
13323 ST(0)=sv_2mortal(perl_exception);
13328 ###############################################################################
13336 ###############################################################################
13341 Image::Magick ref=NO_INIT
13364 PERL_UNUSED_VAR(ref);
13365 PERL_UNUSED_VAR(ix);
13366 exception=AcquireExceptionInfo();
13367 perl_exception=newSVpv("",0);
13368 reference=SvRV(ST(0));
13369 av=(AV *) reference;
13370 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13372 for (i=1; i < items; i++)
13373 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13374 SvPV(ST(i),na),exception);
13375 InheritPerlException(exception,perl_exception);
13376 exception=DestroyExceptionInfo(exception);
13377 SvREFCNT_dec(perl_exception); /* throw away all errors */
13381 ###############################################################################
13389 ###############################################################################
13394 Image::Magick ref=NO_INIT
13417 *reference; /* reference is the SV* of ref=SvIV(reference) */
13419 PERL_UNUSED_VAR(ref);
13420 PERL_UNUSED_VAR(ix);
13421 exception=AcquireExceptionInfo();
13422 perl_exception=newSVpv("",0);
13423 if (sv_isobject(ST(0)) == 0)
13425 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13427 goto PerlException;
13429 reference=SvRV(ST(0));
13430 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13432 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13434 for (i=2; i < items; i+=2)
13435 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13438 InheritPerlException(exception,perl_exception);
13439 exception=DestroyExceptionInfo(exception);
13440 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13441 SvPOK_on(perl_exception);
13442 ST(0)=sv_2mortal(perl_exception);
13447 ###############################################################################
13451 # S e t P i x e l #
13455 ###############################################################################
13460 Image::Magick ref=NO_INIT
13502 *reference; /* reference is the SV* of ref=SvIV(reference) */
13504 PERL_UNUSED_VAR(ref);
13505 PERL_UNUSED_VAR(ix);
13506 exception=AcquireExceptionInfo();
13507 perl_exception=newSVpv("",0);
13508 reference=SvRV(ST(0));
13509 av=(AV *) reference;
13510 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13513 if (image == (Image *) NULL)
13515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13517 goto PerlException;
13520 normalize=MagickTrue;
13523 region.width=image->columns;
13526 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13527 channel=DefaultChannels;
13528 for (i=2; i < items; i+=2)
13530 attribute=(char *) SvPV(ST(i-1),na);
13531 switch (*attribute)
13536 if (LocaleCompare(attribute,"channel") == 0)
13541 option=ParseChannelOption(SvPV(ST(i),na));
13544 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13548 channel=(ChannelType) option;
13551 if (LocaleCompare(attribute,"color") == 0)
13553 if (SvTYPE(ST(i)) != SVt_RV)
13556 message[MaxTextExtent];
13558 (void) FormatLocaleString(message,MaxTextExtent,
13559 "invalid %.60s value",attribute);
13560 ThrowPerlException(exception,OptionError,message,
13563 av=(AV *) SvRV(ST(i));
13566 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13573 if (LocaleCompare(attribute,"geometry") == 0)
13575 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13578 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13585 if (LocaleCompare(attribute,"normalize") == 0)
13587 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13591 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13595 normalize=option != 0 ? MagickTrue : MagickFalse;
13598 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13605 if (LocaleCompare(attribute,"x") == 0)
13607 region.x=SvIV(ST(i));
13610 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13617 if (LocaleCompare(attribute,"y") == 0)
13619 region.y=SvIV(ST(i));
13622 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13628 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13634 (void) SetImageStorageClass(image,DirectClass,exception);
13635 channel_mask=SetImageChannelMask(image,channel);
13636 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13637 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13638 (SvTYPE(av) != SVt_PVAV))
13650 if (normalize != MagickFalse)
13651 scale=QuantumRange;
13652 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13655 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13656 av_fetch(av,i,0)))),q);
13659 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13662 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13663 av_fetch(av,i,0)))),q);
13666 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13669 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13670 av_fetch(av,i,0)))),q);
13673 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13674 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13676 SetPixelBlack(image,ClampToQuantum(scale*
13677 SvNV(*(av_fetch(av,i,0)))),q);
13680 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13683 SetPixelAlpha(image,ClampToQuantum(scale*
13684 SvNV(*(av_fetch(av,i,0)))),q);
13687 (void) SyncAuthenticPixels(image,exception);
13689 (void) SetImageChannelMask(image,channel_mask);
13692 InheritPerlException(exception,perl_exception);
13693 exception=DestroyExceptionInfo(exception);
13694 SvREFCNT_dec(perl_exception);
13698 ###############################################################################
13706 ###############################################################################
13711 Image::Magick ref=NO_INIT
13750 PERL_UNUSED_VAR(ref);
13751 PERL_UNUSED_VAR(ix);
13752 exception=AcquireExceptionInfo();
13753 perl_exception=newSVpv("",0);
13757 if (sv_isobject(ST(0)) == 0)
13759 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13761 goto PerlException;
13763 reference=SvRV(ST(0));
13764 hv=SvSTASH(reference);
13766 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13768 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13769 if (image == (Image *) NULL)
13771 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13773 goto PerlException;
13775 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13781 for (i=2; i < items; i+=2)
13783 attribute=(char *) SvPV(ST(i-1),na);
13784 switch (*attribute)
13789 if (LocaleCompare(attribute,"offset") == 0)
13791 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13794 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13801 if (LocaleCompare(attribute,"stack") == 0)
13803 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13807 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13813 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13819 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13825 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13827 if (image == (Image *) NULL)
13828 goto PerlException;
13829 for ( ; image; image=image->next)
13831 AddImageToRegistry(sv,image);
13833 av_push(av,sv_bless(rv,hv));
13836 exception=DestroyExceptionInfo(exception);
13837 ST(0)=av_reference;
13838 SvREFCNT_dec(perl_exception);
13842 InheritPerlException(exception,perl_exception);
13843 exception=DestroyExceptionInfo(exception);
13844 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13845 SvPOK_on(perl_exception);
13846 ST(0)=sv_2mortal(perl_exception);
13851 ###############################################################################
13855 # S t a t i s t i c s #
13859 ###############################################################################
13863 Statistics(ref,...)
13864 Image::Magick ref=NO_INIT
13866 StatisticsImage = 1
13868 statisticsimage = 3
13871 #define ChannelStatistics(channel) \
13873 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13874 (double) channel_statistics[channel].depth); \
13875 PUSHs(sv_2mortal(newSVpv(message,0))); \
13876 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13877 channel_statistics[channel].minima/scale); \
13878 PUSHs(sv_2mortal(newSVpv(message,0))); \
13879 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13880 channel_statistics[channel].maxima/scale); \
13881 PUSHs(sv_2mortal(newSVpv(message,0))); \
13882 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13883 channel_statistics[channel].mean/scale); \
13884 PUSHs(sv_2mortal(newSVpv(message,0))); \
13885 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13886 channel_statistics[channel].standard_deviation/scale); \
13887 PUSHs(sv_2mortal(newSVpv(message,0))); \
13888 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13889 channel_statistics[channel].kurtosis); \
13890 PUSHs(sv_2mortal(newSVpv(message,0))); \
13891 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13892 channel_statistics[channel].skewness); \
13893 PUSHs(sv_2mortal(newSVpv(message,0))); \
13900 message[MaxTextExtent];
13903 *channel_statistics;
13924 PERL_UNUSED_VAR(ref);
13925 PERL_UNUSED_VAR(ix);
13926 exception=AcquireExceptionInfo();
13927 perl_exception=newSVpv("",0);
13929 if (sv_isobject(ST(0)) == 0)
13931 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13933 goto PerlException;
13935 reference=SvRV(ST(0));
13938 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13939 if (image == (Image *) NULL)
13941 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13943 goto PerlException;
13945 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13947 for ( ; image; image=image->next)
13949 channel_statistics=GetImageStatistics(image,exception);
13950 if (channel_statistics == (ChannelStatistics *) NULL)
13953 EXTEND(sp,35*count);
13954 scale=(double) QuantumRange;
13955 ChannelStatistics(RedChannel);
13956 ChannelStatistics(GreenChannel);
13957 ChannelStatistics(BlueChannel);
13958 if (image->colorspace == CMYKColorspace)
13959 ChannelStatistics(BlackChannel);
13960 if (image->alpha_trait == BlendPixelTrait)
13961 ChannelStatistics(AlphaChannel);
13962 channel_statistics=(ChannelStatistics *)
13963 RelinquishMagickMemory(channel_statistics);
13967 InheritPerlException(exception,perl_exception);
13968 exception=DestroyExceptionInfo(exception);
13969 SvREFCNT_dec(perl_exception);
13973 ###############################################################################
13977 # S y n c A u t h e n t i c P i x e l s #
13981 ###############################################################################
13985 SyncAuthenticPixels(ref,...)
13986 Image::Magick ref = NO_INIT
13988 Syncauthenticpixels = 1
13989 SyncImagePixels = 2
13990 syncimagepixels = 3
14009 PERL_UNUSED_VAR(ref);
14010 PERL_UNUSED_VAR(ix);
14011 exception=AcquireExceptionInfo();
14012 perl_exception=newSVpv("",0);
14013 if (sv_isobject(ST(0)) == 0)
14015 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14017 goto PerlException;
14020 reference=SvRV(ST(0));
14021 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14022 if (image == (Image *) NULL)
14024 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14026 goto PerlException;
14029 status=SyncAuthenticPixels(image,exception);
14030 if (status != MagickFalse)
14034 InheritPerlException(exception,perl_exception);
14035 exception=DestroyExceptionInfo(exception);
14036 SvREFCNT_dec(perl_exception); /* throw away all errors */
14040 ###############################################################################
14044 # T r a n s f o r m #
14048 ###############################################################################
14053 Image::Magick ref=NO_INIT
14091 PERL_UNUSED_VAR(ref);
14092 PERL_UNUSED_VAR(ix);
14093 exception=AcquireExceptionInfo();
14094 perl_exception=newSVpv("",0);
14098 if (sv_isobject(ST(0)) == 0)
14100 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14102 goto PerlException;
14104 reference=SvRV(ST(0));
14105 hv=SvSTASH(reference);
14107 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14109 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14110 if (image == (Image *) NULL)
14112 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14114 goto PerlException;
14116 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14120 crop_geometry=(char *) NULL;
14121 geometry=(char *) NULL;
14122 for (i=2; i < items; i+=2)
14124 attribute=(char *) SvPV(ST(i-1),na);
14125 switch (*attribute)
14130 if (LocaleCompare(attribute,"crop") == 0)
14132 crop_geometry=SvPV(ST(i),na);
14135 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14142 if (LocaleCompare(attribute,"geometry") == 0)
14144 geometry=SvPV(ST(i),na);
14147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14159 for ( ; image; image=image->next)
14161 clone=CloneImage(image,0,0,MagickTrue,exception);
14162 if (clone == (Image *) NULL)
14163 goto PerlException;
14164 TransformImage(&clone,crop_geometry,geometry,exception);
14165 for ( ; clone; clone=clone->next)
14167 AddImageToRegistry(sv,clone);
14169 av_push(av,sv_bless(rv,hv));
14173 exception=DestroyExceptionInfo(exception);
14174 ST(0)=av_reference;
14175 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14179 InheritPerlException(exception,perl_exception);
14180 exception=DestroyExceptionInfo(exception);
14181 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14182 SvPOK_on(perl_exception);
14183 ST(0)=sv_2mortal(perl_exception);
14188 ###############################################################################
14196 ###############################################################################
14201 Image::Magick ref=NO_INIT
14209 filename[MaxTextExtent];
14233 PERL_UNUSED_VAR(ref);
14234 PERL_UNUSED_VAR(ix);
14235 exception=AcquireExceptionInfo();
14236 perl_exception=newSVpv("",0);
14238 package_info=(struct PackageInfo *) NULL;
14239 if (sv_isobject(ST(0)) == 0)
14241 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14243 goto PerlException;
14245 reference=SvRV(ST(0));
14246 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14247 if (image == (Image *) NULL)
14249 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14251 goto PerlException;
14253 package_info=ClonePackageInfo(info,exception);
14255 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14258 for (i=2; i < items; i+=2)
14259 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14261 (void) CopyMagickString(filename,package_info->image_info->filename,
14264 for (next=image; next; next=next->next)
14266 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14267 next->scene=scene++;
14269 SetImageInfo(package_info->image_info,(unsigned int)
14270 GetImageListLength(image),exception);
14271 for (next=image; next; next=next->next)
14273 (void) WriteImage(package_info->image_info,next,exception);
14275 if (package_info->image_info->adjoin)
14280 if (package_info != (struct PackageInfo *) NULL)
14281 DestroyPackageInfo(package_info);
14282 InheritPerlException(exception,perl_exception);
14283 exception=DestroyExceptionInfo(exception);
14284 sv_setiv(perl_exception,(IV) number_images);
14285 SvPOK_on(perl_exception);
14286 ST(0)=sv_2mortal(perl_exception);