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-2011 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((IV) 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},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"opacity", 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}, {"bias", RealReference},
218 {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
251 {"color", StringReference}, {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"bias", RealReference},
260 {"channel", MagickChannelOptions} } },
261 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
262 {"y", RealReference}, { "fill", StringReference},
263 {"color", StringReference} } },
264 { "Spread", { {"radius", RealReference} } },
265 { "Swirl", { {"degrees", RealReference},
266 {"interpolate", MagickInterpolateOptions} } },
267 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
268 {"height", IntegerReference}, {"filter", MagickFilterOptions},
269 {"support", StringReference }, {"blur", RealReference } } },
270 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", RealReference }, {"blur", RealReference } } },
273 { "Annotate", { {"text", StringReference}, {"font", StringReference},
274 {"pointsize", RealReference}, {"density", StringReference},
275 {"undercolor", StringReference}, {"stroke", StringReference},
276 {"fill", StringReference}, {"geometry", StringReference},
277 {"pen", StringReference}, {"x", RealReference},
278 {"y", RealReference}, {"gravity", MagickGravityOptions},
279 {"translate", StringReference}, {"scale", StringReference},
280 {"rotate", RealReference}, {"skewX", RealReference},
281 {"skewY", RealReference}, {"strokewidth", RealReference},
282 {"antialias", MagickBooleanOptions}, {"family", StringReference},
283 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
284 {"weight", IntegerReference}, {"align", MagickAlignOptions},
285 {"encoding", StringReference}, {"affine", ArrayReference},
286 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
287 {"tile", ImageReference}, {"kerning", RealReference},
288 {"interline-spacing", RealReference},
289 {"interword-spacing", RealReference},
290 {"direction", MagickDirectionOptions} } },
291 { "ColorFloodfill", { {"geometry", StringReference},
292 {"x", IntegerReference}, {"y", IntegerReference},
293 {"fill", StringReference}, {"bordercolor", StringReference},
294 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
295 { "Composite", { {"image", ImageReference},
296 {"compose", MagickComposeOptions}, {"geometry", StringReference},
297 {"x", IntegerReference}, {"y", IntegerReference},
298 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
299 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
300 {"color", StringReference}, {"mask", ImageReference},
301 {"channel", MagickChannelOptions},
302 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
303 {"blend", StringReference} } },
304 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
305 { "CycleColormap", { {"display", IntegerReference} } },
306 { "Draw", { {"primitive", MagickPrimitiveOptions},
307 {"points", StringReference}, {"method", MagickMethodOptions},
308 {"stroke", StringReference}, {"fill", StringReference},
309 {"strokewidth", RealReference}, {"font", StringReference},
310 {"bordercolor", StringReference}, {"x", RealReference},
311 {"y", RealReference}, {"translate", StringReference},
312 {"scale", StringReference}, {"rotate", RealReference},
313 {"skewX", RealReference}, {"skewY", RealReference},
314 {"tile", ImageReference}, {"pointsize", RealReference},
315 {"antialias", MagickBooleanOptions}, {"density", StringReference},
316 {"linewidth", RealReference}, {"affine", ArrayReference},
317 {"stroke-dashoffset", RealReference},
318 {"stroke-dasharray", ArrayReference},
319 {"interpolate", MagickInterpolateOptions},
320 {"origin", StringReference}, {"text", StringReference},
321 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
322 {"vector-graphics", StringReference}, {"kerning", RealReference},
323 {"interline-spacing", RealReference},
324 {"interword-spacing", RealReference},
325 {"direction", MagickDirectionOptions} } },
326 { "Equalize", { {"channel", MagickChannelOptions} } },
327 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
328 {"red", RealReference}, {"green", RealReference},
329 {"blue", RealReference} } },
330 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
331 {"dither-method", MagickDitherOptions} } },
332 { "MatteFloodfill", { {"geometry", StringReference},
333 {"x", IntegerReference}, {"y", IntegerReference},
334 {"opacity", StringReference}, {"bordercolor", StringReference},
335 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
336 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
337 {"saturation", RealReference}, {"whiteness", RealReference},
338 {"brightness", RealReference}, {"lightness", RealReference},
339 {"blackness", RealReference} } },
340 { "Negate", { {"gray", MagickBooleanOptions},
341 {"channel", MagickChannelOptions} } },
342 { "Normalize", { {"channel", MagickChannelOptions} } },
344 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
345 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
346 {"invert", MagickBooleanOptions} } },
347 { "Quantize", { {"colors", IntegerReference},
348 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
349 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
350 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
351 {"dither-method", MagickDitherOptions} } },
352 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
353 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
354 { "Segment", { {"geometry", StringReference},
355 {"cluster-threshold", RealReference},
356 {"smoothing-threshold", RealReference},
357 {"colorspace", MagickColorspaceOptions},
358 {"verbose", MagickBooleanOptions} } },
360 { "Solarize", { {"geometry", StringReference},
361 {"threshold", StringReference} } },
363 { "Texture", { {"texture", ImageReference} } },
364 { "Evaluate", { {"value", RealReference},
365 {"operator", MagickEvaluateOptions},
366 {"channel", MagickChannelOptions} } },
367 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
368 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
369 { "Threshold", { {"threshold", StringReference},
370 {"channel", MagickChannelOptions} } },
371 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
372 {"sigma", RealReference}, {"biabias", RealReference} } },
373 { "Trim", { {"fuzz", StringReference} } },
374 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
375 {"wavelength", RealReference},
376 {"interpolate", MagickInterpolateOptions} } },
377 { "Separate", { {"channel", MagickChannelOptions} } },
379 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
380 {"y", IntegerReference} } },
381 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
383 { "GaussianBlur", { {"geometry", StringReference},
384 {"radius", RealReference}, {"sigma", RealReference},
385 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
386 { "Convolve", { {"coefficients", ArrayReference},
387 {"channel", MagickChannelOptions}, {"bias", StringReference},
388 {"kernel", StringReference} } },
389 { "Profile", { {"name", StringReference}, {"profile", StringReference},
390 { "rendering-intent", MagickIntentOptions},
391 { "black-point-compensation", MagickBooleanOptions} } },
392 { "UnsharpMask", { {"geometry", StringReference},
393 {"radius", RealReference}, {"sigma", RealReference},
394 {"amount", RealReference}, {"threshold", RealReference},
395 {"channel", MagickChannelOptions} } },
396 { "MotionBlur", { {"geometry", StringReference},
397 {"radius", RealReference}, {"sigma", RealReference},
398 {"angle", RealReference}, {"bias", RealReference},
399 {"channel", MagickChannelOptions} } },
400 { "OrderedDither", { {"threshold", StringReference},
401 {"channel", MagickChannelOptions} } },
402 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
403 {"height", IntegerReference} } },
404 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
405 {"white-point", RealReference}, {"gamma", RealReference},
406 {"channel", MagickChannelOptions}, {"level", StringReference} } },
407 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
408 { "AffineTransform", { {"affine", ArrayReference},
409 {"translate", StringReference}, {"scale", StringReference},
410 {"rotate", RealReference}, {"skewX", RealReference},
411 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
412 {"background", StringReference} } },
413 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
414 { "AdaptiveThreshold", { {"geometry", StringReference},
415 {"width", IntegerReference}, {"height", IntegerReference},
416 {"bias", RealReference} } },
417 { "Resample", { {"density", StringReference}, {"x", RealReference},
418 {"y", RealReference}, {"filter", MagickFilterOptions},
419 {"support", RealReference }, {"blur", RealReference } } },
420 { "Describe", { {"file", FileReference} } },
421 { "BlackThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "WhiteThreshold", { {"threshold", StringReference},
424 {"channel", MagickChannelOptions} } },
425 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
426 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
427 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
428 {"height", IntegerReference} } },
430 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
431 { "Channel", { {"channel", MagickChannelOptions} } },
432 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
433 {"height", IntegerReference}, {"x", IntegerReference},
434 {"y", IntegerReference}, {"fuzz", StringReference},
435 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
436 { "Posterize", { {"levels", IntegerReference},
437 {"dither", MagickBooleanOptions} } },
438 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
439 {"sigma", RealReference}, {"x", IntegerReference},
440 {"y", IntegerReference} } },
441 { "Identify", { {"file", FileReference}, {"features", StringReference},
442 {"unique", MagickBooleanOptions} } },
443 { "SepiaTone", { {"threshold", RealReference} } },
444 { "SigmoidalContrast", { {"geometry", StringReference},
445 {"contrast", RealReference}, {"mid-point", RealReference},
446 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
447 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
448 {"height", IntegerReference}, {"x", IntegerReference},
449 {"y", IntegerReference}, {"fuzz", StringReference},
450 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
451 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
452 {"sigma", RealReference}, {"x", IntegerReference},
453 {"y", IntegerReference}, {"background", StringReference} } },
454 { "ContrastStretch", { {"levels", StringReference},
455 {"black-point", RealReference},{"white-point", RealReference},
456 {"channel", MagickChannelOptions} } },
459 { "AdaptiveSharpen", { {"geometry", StringReference},
460 {"radius", RealReference}, {"sigma", RealReference},
461 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
465 { "AdaptiveBlur", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
468 { "Sketch", { {"geometry", StringReference},
469 {"radius", RealReference}, {"sigma", RealReference},
470 {"angle", RealReference}, {"bias", RealReference} } },
472 { "AdaptiveResize", { {"geometry", StringReference},
473 {"width", IntegerReference}, {"height", IntegerReference},
474 {"filter", MagickFilterOptions}, {"support", StringReference },
475 {"blur", RealReference } } },
476 { "ClipMask", { {"mask", ImageReference} } },
477 { "LinearStretch", { {"levels", StringReference},
478 {"black-point", RealReference},{"white-point", RealReference} } },
479 { "Recolor", { {"matrix", ArrayReference} } },
480 { "Mask", { {"mask", ImageReference} } },
481 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
482 {"font", StringReference}, {"stroke", StringReference},
483 {"fill", StringReference}, {"strokewidth", RealReference},
484 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
485 {"background", StringReference} } },
486 { "FloodfillPaint", { {"geometry", StringReference},
487 {"x", IntegerReference}, {"y", IntegerReference},
488 {"fill", StringReference}, {"bordercolor", StringReference},
489 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
490 {"invert", MagickBooleanOptions} } },
491 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
492 {"virtual-pixel", MagickVirtualPixelOptions},
493 {"best-fit", MagickBooleanOptions} } },
494 { "Clut", { {"image", ImageReference},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"bias", RealReference},
515 {"channel", MagickChannelOptions} } },
516 { "HaldClut", { {"image", ImageReference},
517 {"channel", MagickChannelOptions} } },
518 { "BlueShift", { {"factor", StringReference} } },
519 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
521 { "ColorDecisionList", {
522 {"color-correction-collection", StringReference} } },
523 { "AutoGamma", { {"channel", MagickChannelOptions} } },
524 { "AutoLevel", { {"channel", MagickChannelOptions} } },
525 { "LevelColors", { {"invert", MagickBooleanOptions},
526 {"black-point", StringReference}, {"white-point", StringReference},
527 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
528 { "Clamp", { {"channel", MagickChannelOptions} } },
529 { "BrightnessContrast", { {"levels", StringReference},
530 {"brightness", RealReference},{"contrast", RealReference},
531 {"channel", MagickChannelOptions} } },
532 { "Morphology", { {"kernel", StringReference},
533 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
534 {"iterations", IntegerReference} } },
535 { "ColorMatrix", { {"matrix", ArrayReference} } },
536 { "Color", { {"color", StringReference} } },
537 { "Mode", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions} } },
540 { "Statistic", { {"geometry", StringReference},
541 {"width", IntegerReference},{"height", IntegerReference},
542 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
546 *magick_registry = (SplayTreeInfo *) NULL;
549 Forward declarations.
552 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
555 strEQcase(const char *,const char *);
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 % C l o n e P a c k a g e I n f o %
566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
571 % The format of the ClonePackageInfo routine is:
573 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
576 % A description of each parameter follows:
578 % o info: a structure of type info.
580 % o exception: Return any errors or warnings in this structure.
583 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
584 ExceptionInfo *exception)
589 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
590 if (clone_info == (struct PackageInfo *) NULL)
592 ThrowPerlException(exception,ResourceLimitError,
593 "UnableToClonePackageInfo",PackageName);
594 return((struct PackageInfo *) NULL);
596 if (info == (struct PackageInfo *) NULL)
598 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
602 clone_info->image_info=CloneImageInfo(info->image_info);
607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 % constant() returns a double value for the specified name.
619 % The format of the constant routine is:
621 % double constant(char *name,ssize_t sans)
623 % A description of each parameter follows:
625 % o value: Method constant returns a double value for the specified name.
627 % o name: The name of the constant.
629 % o sans: This integer value is not used.
632 static double constant(char *name,ssize_t sans)
640 if (strEQ(name,"BlobError"))
642 if (strEQ(name,"BlobWarning"))
648 if (strEQ(name,"CacheError"))
650 if (strEQ(name,"CacheWarning"))
651 return(CacheWarning);
652 if (strEQ(name,"CoderError"))
654 if (strEQ(name,"CoderWarning"))
655 return(CoderWarning);
656 if (strEQ(name,"ConfigureError"))
657 return(ConfigureError);
658 if (strEQ(name,"ConfigureWarning"))
659 return(ConfigureWarning);
660 if (strEQ(name,"CorruptImageError"))
661 return(CorruptImageError);
662 if (strEQ(name,"CorruptImageWarning"))
663 return(CorruptImageWarning);
668 if (strEQ(name,"DelegateError"))
669 return(DelegateError);
670 if (strEQ(name,"DelegateWarning"))
671 return(DelegateWarning);
672 if (strEQ(name,"DrawError"))
674 if (strEQ(name,"DrawWarning"))
680 if (strEQ(name,"ErrorException"))
681 return(ErrorException);
682 if (strEQ(name,"ExceptionError"))
684 if (strEQ(name,"ExceptionWarning"))
685 return(CoderWarning);
690 if (strEQ(name,"FatalErrorException"))
691 return(FatalErrorException);
692 if (strEQ(name,"FileOpenError"))
693 return(FileOpenError);
694 if (strEQ(name,"FileOpenWarning"))
695 return(FileOpenWarning);
700 if (strEQ(name,"ImageError"))
702 if (strEQ(name,"ImageWarning"))
703 return(ImageWarning);
708 if (strEQ(name,"MaxRGB"))
709 return(QuantumRange);
710 if (strEQ(name,"MissingDelegateError"))
711 return(MissingDelegateError);
712 if (strEQ(name,"MissingDelegateWarning"))
713 return(MissingDelegateWarning);
714 if (strEQ(name,"ModuleError"))
716 if (strEQ(name,"ModuleWarning"))
717 return(ModuleWarning);
722 if (strEQ(name,"Opaque"))
724 if (strEQ(name,"OptionError"))
726 if (strEQ(name,"OptionWarning"))
727 return(OptionWarning);
732 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
733 return(MAGICKCORE_QUANTUM_DEPTH);
734 if (strEQ(name,"QuantumDepth"))
735 return(MAGICKCORE_QUANTUM_DEPTH);
736 if (strEQ(name,"QuantumRange"))
737 return(QuantumRange);
742 if (strEQ(name,"ResourceLimitError"))
743 return(ResourceLimitError);
744 if (strEQ(name,"ResourceLimitWarning"))
745 return(ResourceLimitWarning);
746 if (strEQ(name,"RegistryError"))
747 return(RegistryError);
748 if (strEQ(name,"RegistryWarning"))
749 return(RegistryWarning);
754 if (strEQ(name,"StreamError"))
756 if (strEQ(name,"StreamWarning"))
757 return(StreamWarning);
758 if (strEQ(name,"Success"))
764 if (strEQ(name,"Transparent"))
765 return(TransparentAlpha);
766 if (strEQ(name,"TypeError"))
768 if (strEQ(name,"TypeWarning"))
774 if (strEQ(name,"WarningException"))
775 return(WarningException);
780 if (strEQ(name,"XServerError"))
781 return(XServerError);
782 if (strEQ(name,"XServerWarning"))
783 return(XServerWarning);
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796 % D e s t r o y P a c k a g e I n f o %
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802 % Method DestroyPackageInfo frees a previously created info structure.
804 % The format of the DestroyPackageInfo routine is:
806 % DestroyPackageInfo(struct PackageInfo *info)
808 % A description of each parameter follows:
810 % o info: a structure of type info.
813 static void DestroyPackageInfo(struct PackageInfo *info)
815 info->image_info=DestroyImageInfo(info->image_info);
816 info=(struct PackageInfo *) RelinquishMagickMemory(info);
820 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 % Method GetList is recursively called by SetupList to traverse the
831 % Image__Magick reference. If building an reference_vector (see SetupList),
832 % *current is the current position in *reference_vector and *last is the final
833 % entry in *reference_vector.
835 % The format of the GetList routine is:
839 % A description of each parameter follows:
841 % o info: a structure of type info.
844 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
845 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
850 if (reference == (SV *) NULL)
852 switch (SvTYPE(reference))
872 previous=(Image *) NULL;
876 for (i=0; i <= n; i++)
882 if (rv && *rv && sv_isobject(*rv))
884 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
886 if (image == (Image *) NULL)
888 if (image == previous)
890 image=CloneImage(image,0,0,MagickTrue,exception);
891 if (image == (Image *) NULL)
894 image->previous=previous;
895 *(previous ? &previous->next : &head)=image;
896 for (previous=image; previous->next; previous=previous->next) ;
904 Blessed scalar, one image.
906 image=(Image *) SvIV(reference);
907 if (image == (Image *) NULL)
909 image->previous=(Image *) NULL;
910 image->next=(Image *) NULL;
911 if (reference_vector)
913 if (*current == *last)
916 if (*reference_vector == (SV **) NULL)
917 *reference_vector=(SV **) AcquireQuantumMemory(*last,
918 sizeof(*reference_vector));
920 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
921 *last,sizeof(*reference_vector));
923 if (*reference_vector == (SV **) NULL)
925 ThrowPerlException(exception,ResourceLimitError,
926 "MemoryAllocationFailed",PackageName);
927 return((Image *) NULL);
929 (*reference_vector)[*current]=reference;
930 (*reference_vector)[++(*current)]=NULL;
937 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
938 (double) SvTYPE(reference));
939 return((Image *) NULL);
943 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
947 % G e t P a c k a g e I n f o %
951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953 % Method GetPackageInfo looks up or creates an info structure for the given
954 % Image__Magick reference. If it does create a new one, the information in
955 % package_info is used to initialize it.
957 % The format of the GetPackageInfo routine is:
959 % struct PackageInfo *GetPackageInfo(void *reference,
960 % struct PackageInfo *package_info,ExceptionInfo *exception)
962 % A description of each parameter follows:
964 % o info: a structure of type info.
966 % o exception: Return any errors or warnings in this structure.
969 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
970 struct PackageInfo *package_info,ExceptionInfo *exception)
973 message[MaxTextExtent];
981 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
982 PackageName,XS_VERSION,reference);
983 sv=perl_get_sv(message,(TRUE | 0x02));
984 if (sv == (SV *) NULL)
986 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
988 return(package_info);
990 if (SvREFCNT(sv) == 0)
991 (void) SvREFCNT_inc(sv);
992 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
994 clone_info=ClonePackageInfo(package_info,exception);
995 sv_setiv(sv,(IV) clone_info);
1000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 % S e t A t t r i b u t e %
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 % SetAttribute() sets the attribute to the value in sval. This can change
1011 % either or both of image or info.
1013 % The format of the SetAttribute routine is:
1015 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1016 % SV *sval,ExceptionInfo *exception)
1018 % A description of each parameter follows:
1020 % o list: a list of strings.
1022 % o string: a character string.
1026 static double SiPrefixToDouble(const char *string,const double interval)
1035 value=InterpretLocaleValue(string,&q);
1037 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1039 switch (tolower((int) ((unsigned char) *q)))
1041 case '%': value*=pow(scale,0)*interval/100.0; break;
1042 case 'k': value*=pow(scale,1); break;
1043 case 'm': value*=pow(scale,2); break;
1044 case 'g': value*=pow(scale,3); break;
1045 case 't': value*=pow(scale,4); break;
1046 case 'p': value*=pow(scale,5); break;
1047 case 'e': value*=pow(scale,6); break;
1048 case 'z': value*=pow(scale,7); break;
1049 case 'y': value*=pow(scale,8); break;
1055 static inline ssize_t StringToLong(const char *value)
1057 return(strtol(value,(char **) NULL,10));
1060 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1061 const char *attribute,SV *sval,ExceptionInfo *exception)
1088 if (LocaleCompare(attribute,"adjoin") == 0)
1090 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1091 SvPV(sval,na)) : SvIV(sval);
1094 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1099 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1102 if (LocaleCompare(attribute,"alpha") == 0)
1104 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1105 SvPV(sval,na)) : SvIV(sval);
1108 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1112 for ( ; image; image=image->next)
1113 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1116 if (LocaleCompare(attribute,"antialias") == 0)
1118 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1119 SvPV(sval,na)) : SvIV(sval);
1122 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1127 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1130 if (LocaleCompare(attribute,"area-limit") == 0)
1135 limit=MagickResourceInfinity;
1136 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1137 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1138 (void) SetMagickResourceLimit(AreaResource,limit);
1141 if (LocaleCompare(attribute,"attenuate") == 0)
1144 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1147 if (LocaleCompare(attribute,"authenticate") == 0)
1150 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1154 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1155 for ( ; image; image=image->next)
1156 SetImageProperty(image,attribute,SvPV(sval,na));
1162 if (LocaleCompare(attribute,"background") == 0)
1164 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1166 info->image_info->background_color=target_color;
1167 for ( ; image; image=image->next)
1168 image->background_color=target_color;
1171 if (LocaleCompare(attribute,"bias") == 0)
1173 for ( ; image; image=image->next)
1174 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1177 if (LocaleCompare(attribute,"blue-primary") == 0)
1179 for ( ; image; image=image->next)
1181 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1182 image->chromaticity.blue_primary.x=geometry_info.rho;
1183 image->chromaticity.blue_primary.y=geometry_info.sigma;
1184 if ((flags & SigmaValue) == 0)
1185 image->chromaticity.blue_primary.y=
1186 image->chromaticity.blue_primary.x;
1190 if (LocaleCompare(attribute,"bordercolor") == 0)
1192 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1194 info->image_info->border_color=target_color;
1195 for ( ; image; image=image->next)
1196 image->border_color=target_color;
1200 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1201 for ( ; image; image=image->next)
1202 SetImageProperty(image,attribute,SvPV(sval,na));
1208 if (LocaleCompare(attribute,"cache-threshold") == 0)
1210 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1211 SiPrefixToDouble(SvPV(sval,na),100.0));
1212 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1213 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1216 if (LocaleCompare(attribute,"clip-mask") == 0)
1221 clip_mask=(Image *) NULL;
1223 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1224 for ( ; image; image=image->next)
1225 SetImageClipMask(image,clip_mask,exception);
1228 if (LocaleNCompare(attribute,"colormap",8) == 0)
1230 for ( ; image; image=image->next)
1238 if (image->storage_class == DirectClass)
1241 items=sscanf(attribute,"%*[^[][%ld",&i);
1243 if (i > (ssize_t) image->colors)
1245 if ((strchr(SvPV(sval,na),',') == 0) ||
1246 (strchr(SvPV(sval,na),')') != 0))
1247 QueryColorDatabase(SvPV(sval,na),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);
1279 if (LocaleCompare(attribute,"comment") == 0)
1281 for ( ; image; image=image->next)
1282 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1283 info ? info->image_info : (ImageInfo *) NULL,image,
1284 SvPV(sval,na),exception));
1287 if (LocaleCompare(attribute,"compression") == 0)
1289 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1290 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1293 ThrowPerlException(exception,OptionError,
1294 "UnrecognizedImageCompression",SvPV(sval,na));
1298 info->image_info->compression=(CompressionType) sp;
1299 for ( ; image; image=image->next)
1300 image->compression=(CompressionType) sp;
1304 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1305 for ( ; image; image=image->next)
1306 SetImageProperty(image,attribute,SvPV(sval,na));
1312 if (LocaleCompare(attribute,"debug") == 0)
1314 SetLogEventMask(SvPV(sval,na));
1317 if (LocaleCompare(attribute,"delay") == 0)
1319 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1320 for ( ; image; image=image->next)
1322 image->delay=(size_t) floor(geometry_info.rho+0.5);
1323 if ((flags & SigmaValue) != 0)
1324 image->ticks_per_second=(ssize_t)
1325 floor(geometry_info.sigma+0.5);
1329 if (LocaleCompare(attribute,"disk-limit") == 0)
1334 limit=MagickResourceInfinity;
1335 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1336 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1337 (void) SetMagickResourceLimit(DiskResource,limit);
1340 if (LocaleCompare(attribute,"density") == 0)
1342 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1344 ThrowPerlException(exception,OptionError,"MissingGeometry",
1349 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1350 for ( ; image; image=image->next)
1352 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1353 image->x_resolution=geometry_info.rho;
1354 image->y_resolution=geometry_info.sigma;
1355 if ((flags & SigmaValue) == 0)
1356 image->y_resolution=image->x_resolution;
1360 if (LocaleCompare(attribute,"depth") == 0)
1363 info->image_info->depth=SvIV(sval);
1364 for ( ; image; image=image->next)
1365 (void) SetImageDepth(image,SvIV(sval));
1368 if (LocaleCompare(attribute,"dispose") == 0)
1370 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1371 SvPV(sval,na)) : SvIV(sval);
1374 ThrowPerlException(exception,OptionError,
1375 "UnrecognizedDisposeMethod",SvPV(sval,na));
1378 for ( ; image; image=image->next)
1379 image->dispose=(DisposeType) sp;
1382 if (LocaleCompare(attribute,"dither") == 0)
1386 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1387 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1390 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1394 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1398 if (LocaleCompare(attribute,"display") == 0)
1402 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1406 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1407 for ( ; image; image=image->next)
1408 SetImageProperty(image,attribute,SvPV(sval,na));
1414 if (LocaleCompare(attribute,"endian") == 0)
1416 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1417 SvPV(sval,na)) : SvIV(sval);
1420 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1425 info->image_info->endian=(EndianType) sp;
1426 for ( ; image; image=image->next)
1427 image->endian=(EndianType) sp;
1430 if (LocaleCompare(attribute,"extract") == 0)
1433 Set image extract geometry.
1435 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1439 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1440 for ( ; image; image=image->next)
1441 SetImageProperty(image,attribute,SvPV(sval,na));
1447 if (LocaleCompare(attribute,"filename") == 0)
1450 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1452 for ( ; image; image=image->next)
1453 (void) CopyMagickString(image->filename,SvPV(sval,na),
1457 if (LocaleCompare(attribute,"file") == 0)
1465 if (info == (struct PackageInfo *) NULL)
1467 io_info=IoIFP(sv_2io(sval));
1468 if (io_info == (PerlIO *) NULL)
1470 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1474 file=PerlIO_findFILE(io_info);
1475 if (file == (FILE *) NULL)
1477 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1481 SetImageInfoFile(info->image_info,file);
1484 if (LocaleCompare(attribute,"fill") == 0)
1487 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1490 if (LocaleCompare(attribute,"font") == 0)
1493 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1496 if (LocaleCompare(attribute,"foreground") == 0)
1498 if (LocaleCompare(attribute,"fuzz") == 0)
1501 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1502 for ( ; image; image=image->next)
1503 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1507 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1508 for ( ; image; image=image->next)
1509 SetImageProperty(image,attribute,SvPV(sval,na));
1515 if (LocaleCompare(attribute,"gamma") == 0)
1517 for ( ; image; image=image->next)
1518 image->gamma=SvNV(sval);
1521 if (LocaleCompare(attribute,"gravity") == 0)
1523 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1524 SvPV(sval,na)) : SvIV(sval);
1527 ThrowPerlException(exception,OptionError,
1528 "UnrecognizedGravityType",SvPV(sval,na));
1532 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1533 for ( ; image; image=image->next)
1534 image->gravity=(GravityType) sp;
1537 if (LocaleCompare(attribute,"green-primary") == 0)
1539 for ( ; image; image=image->next)
1541 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1542 image->chromaticity.green_primary.x=geometry_info.rho;
1543 image->chromaticity.green_primary.y=geometry_info.sigma;
1544 if ((flags & SigmaValue) == 0)
1545 image->chromaticity.green_primary.y=
1546 image->chromaticity.green_primary.x;
1551 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1552 for ( ; image; image=image->next)
1553 SetImageProperty(image,attribute,SvPV(sval,na));
1559 if (LocaleNCompare(attribute,"index",5) == 0)
1573 for ( ; image; image=image->next)
1575 if (image->storage_class != PseudoClass)
1579 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1581 image_view=AcquireCacheView(image);
1582 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1583 if (q != (Quantum *) NULL)
1585 items=sscanf(SvPV(sval,na),"%ld",&index);
1586 if ((index >= 0) && (index < (ssize_t) image->colors))
1587 SetPixelIndex(image,index,q);
1588 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1590 image_view=DestroyCacheView(image_view);
1594 if (LocaleCompare(attribute,"iterations") == 0)
1597 for ( ; image; image=image->next)
1598 image->iterations=SvIV(sval);
1601 if (LocaleCompare(attribute,"interlace") == 0)
1603 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1604 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1607 ThrowPerlException(exception,OptionError,
1608 "UnrecognizedInterlaceType",SvPV(sval,na));
1612 info->image_info->interlace=(InterlaceType) sp;
1613 for ( ; image; image=image->next)
1614 image->interlace=(InterlaceType) sp;
1618 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1619 for ( ; image; image=image->next)
1620 SetImageProperty(image,attribute,SvPV(sval,na));
1626 if (LocaleCompare(attribute,"label") == 0)
1628 for ( ; image; image=image->next)
1629 (void) SetImageProperty(image,"label",InterpretImageProperties(
1630 info ? info->image_info : (ImageInfo *) NULL,image,
1631 SvPV(sval,na),exception));
1634 if (LocaleCompare(attribute,"loop") == 0)
1637 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1638 for ( ; image; image=image->next)
1639 SetImageProperty(image,attribute,SvPV(sval,na));
1645 if (LocaleCompare(attribute,"magick") == 0)
1648 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1649 "%s:",SvPV(sval,na));
1650 for ( ; image; image=image->next)
1651 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1654 if (LocaleCompare(attribute,"map-limit") == 0)
1659 limit=MagickResourceInfinity;
1660 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1661 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1662 (void) SetMagickResourceLimit(MapResource,limit);
1665 if (LocaleCompare(attribute,"mask") == 0)
1670 mask=(Image *) NULL;
1672 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1673 for ( ; image; image=image->next)
1674 SetImageMask(image,mask,exception);
1677 if (LocaleCompare(attribute,"mattecolor") == 0)
1679 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1681 info->image_info->matte_color=target_color;
1682 for ( ; image; image=image->next)
1683 image->matte_color=target_color;
1686 if (LocaleCompare(attribute,"matte") == 0)
1688 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1689 SvPV(sval,na)) : SvIV(sval);
1692 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1696 for ( ; image; image=image->next)
1697 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1700 if (LocaleCompare(attribute,"memory-limit") == 0)
1705 limit=MagickResourceInfinity;
1706 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1707 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1708 (void) SetMagickResourceLimit(MemoryResource,limit);
1711 if (LocaleCompare(attribute,"monochrome") == 0)
1713 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1714 SvPV(sval,na)) : SvIV(sval);
1717 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1722 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1723 for ( ; image; image=image->next)
1724 (void) SetImageType(image,BilevelType,exception);
1728 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1729 for ( ; image; image=image->next)
1730 SetImageProperty(image,attribute,SvPV(sval,na));
1736 if (LocaleCompare(attribute,"option") == 0)
1739 DefineImageOption(info->image_info,SvPV(sval,na));
1742 if (LocaleCompare(attribute,"orientation") == 0)
1744 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1745 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1748 ThrowPerlException(exception,OptionError,
1749 "UnrecognizedOrientationType",SvPV(sval,na));
1753 info->image_info->orientation=(OrientationType) sp;
1754 for ( ; image; image=image->next)
1755 image->orientation=(OrientationType) sp;
1759 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1760 for ( ; image; image=image->next)
1761 SetImageProperty(image,attribute,SvPV(sval,na));
1767 if (LocaleCompare(attribute,"page") == 0)
1772 geometry=GetPageGeometry(SvPV(sval,na));
1774 (void) CloneString(&info->image_info->page,geometry);
1775 for ( ; image; image=image->next)
1776 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1777 geometry=(char *) RelinquishMagickMemory(geometry);
1780 if (LocaleCompare(attribute,"pen") == 0)
1783 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1786 if (LocaleNCompare(attribute,"pixel",5) == 0)
1800 for ( ; image; image=image->next)
1802 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1806 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1808 image_view=AcquireCacheView(image);
1809 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1810 if (q != (Quantum *) NULL)
1812 if ((strchr(SvPV(sval,na),',') == 0) ||
1813 (strchr(SvPV(sval,na),')') != 0))
1814 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1817 GetPixelInfo(image,&pixel);
1818 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1819 pixel.red=geometry_info.rho;
1820 if ((flags & SigmaValue) != 0)
1821 pixel.green=geometry_info.sigma;
1822 if ((flags & XiValue) != 0)
1823 pixel.blue=geometry_info.xi;
1824 if ((flags & PsiValue) != 0)
1825 pixel.alpha=geometry_info.psi;
1826 if ((flags & ChiValue) != 0)
1827 pixel.black=geometry_info.chi;
1829 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1830 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1831 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1832 if (image->colorspace == CMYKColorspace)
1833 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1834 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1835 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1837 image_view=DestroyCacheView(image_view);
1841 if (LocaleCompare(attribute,"pointsize") == 0)
1845 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1846 info->image_info->pointsize=geometry_info.rho;
1850 if (LocaleCompare(attribute,"preview") == 0)
1852 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1853 SvPV(sval,na)) : SvIV(sval);
1856 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1861 info->image_info->preview_type=(PreviewType) sp;
1865 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1866 for ( ; image; image=image->next)
1867 SetImageProperty(image,attribute,SvPV(sval,na));
1873 if (LocaleCompare(attribute,"quality") == 0)
1876 info->image_info->quality=SvIV(sval);
1877 for ( ; image; image=image->next)
1878 image->quality=SvIV(sval);
1882 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1883 for ( ; image; image=image->next)
1884 SetImageProperty(image,attribute,SvPV(sval,na));
1890 if (LocaleCompare(attribute,"red-primary") == 0)
1892 for ( ; image; image=image->next)
1894 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1895 image->chromaticity.red_primary.x=geometry_info.rho;
1896 image->chromaticity.red_primary.y=geometry_info.sigma;
1897 if ((flags & SigmaValue) == 0)
1898 image->chromaticity.red_primary.y=
1899 image->chromaticity.red_primary.x;
1903 if (LocaleCompare(attribute,"render") == 0)
1905 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1906 SvPV(sval,na)) : SvIV(sval);
1909 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1913 for ( ; image; image=image->next)
1914 image->rendering_intent=(RenderingIntent) sp;
1917 if (LocaleCompare(attribute,"repage") == 0)
1922 for ( ; image; image=image->next)
1924 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1925 if ((flags & WidthValue) != 0)
1927 if ((flags & HeightValue) == 0)
1928 geometry.height=geometry.width;
1929 image->page.width=geometry.width;
1930 image->page.height=geometry.height;
1932 if ((flags & AspectValue) != 0)
1934 if ((flags & XValue) != 0)
1935 image->page.x+=geometry.x;
1936 if ((flags & YValue) != 0)
1937 image->page.y+=geometry.y;
1941 if ((flags & XValue) != 0)
1943 image->page.x=geometry.x;
1944 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1945 image->page.width=image->columns+geometry.x;
1947 if ((flags & YValue) != 0)
1949 image->page.y=geometry.y;
1950 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1951 image->page.height=image->rows+geometry.y;
1958 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1959 for ( ; image; image=image->next)
1960 SetImageProperty(image,attribute,SvPV(sval,na));
1966 if (LocaleCompare(attribute,"sampling-factor") == 0)
1968 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1970 ThrowPerlException(exception,OptionError,"MissingGeometry",
1975 (void) CloneString(&info->image_info->sampling_factor,
1979 if (LocaleCompare(attribute,"scene") == 0)
1981 for ( ; image; image=image->next)
1982 image->scene=SvIV(sval);
1985 if (LocaleCompare(attribute,"server") == 0)
1987 if (LocaleCompare(attribute,"size") == 0)
1991 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1993 ThrowPerlException(exception,OptionError,"MissingGeometry",
1997 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2001 if (LocaleCompare(attribute,"stroke") == 0)
2004 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2008 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2009 for ( ; image; image=image->next)
2010 SetImageProperty(image,attribute,SvPV(sval,na));
2016 if (LocaleCompare(attribute,"texture") == 0)
2019 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2022 if (LocaleCompare(attribute,"thread-limit") == 0)
2027 limit=MagickResourceInfinity;
2028 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2029 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2030 (void) SetMagickResourceLimit(ThreadResource,limit);
2033 if (LocaleCompare(attribute,"tile-offset") == 0)
2038 geometry=GetPageGeometry(SvPV(sval,na));
2040 (void) CloneString(&info->image_info->page,geometry);
2041 for ( ; image; image=image->next)
2042 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2044 geometry=(char *) RelinquishMagickMemory(geometry);
2047 if (LocaleCompare(attribute,"time-limit") == 0)
2052 limit=MagickResourceInfinity;
2053 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2054 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2055 (void) SetMagickResourceLimit(TimeResource,limit);
2058 if (LocaleCompare(attribute,"transparent-color") == 0)
2060 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2062 info->image_info->transparent_color=target_color;
2063 for ( ; image; image=image->next)
2064 image->transparent_color=target_color;
2067 if (LocaleCompare(attribute,"type") == 0)
2069 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2070 SvPV(sval,na)) : SvIV(sval);
2073 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2078 info->image_info->type=(ImageType) sp;
2079 for ( ; image; image=image->next)
2080 SetImageType(image,(ImageType) sp,exception);
2084 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2085 for ( ; image; image=image->next)
2086 SetImageProperty(image,attribute,SvPV(sval,na));
2092 if (LocaleCompare(attribute,"units") == 0)
2094 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2095 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2098 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2103 info->image_info->units=(ResolutionType) sp;
2104 for ( ; image; image=image->next)
2109 units=(ResolutionType) sp;
2110 if (image->units != units)
2111 switch (image->units)
2113 case UndefinedResolution:
2114 case PixelsPerInchResolution:
2116 if (units == PixelsPerCentimeterResolution)
2118 image->x_resolution*=2.54;
2119 image->y_resolution*=2.54;
2123 case PixelsPerCentimeterResolution:
2125 if (units == PixelsPerInchResolution)
2127 image->x_resolution/=2.54;
2128 image->y_resolution/=2.54;
2138 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2139 for ( ; image; image=image->next)
2140 SetImageProperty(image,attribute,SvPV(sval,na));
2146 if (LocaleCompare(attribute,"verbose") == 0)
2148 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2149 SvPV(sval,na)) : SvIV(sval);
2152 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2157 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2160 if (LocaleCompare(attribute,"view") == 0)
2163 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2166 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2168 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2169 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2172 ThrowPerlException(exception,OptionError,
2173 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2177 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2178 for ( ; image; image=image->next)
2179 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2183 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2184 for ( ; image; image=image->next)
2185 SetImageProperty(image,attribute,SvPV(sval,na));
2191 if (LocaleCompare(attribute,"white-point") == 0)
2193 for ( ; image; image=image->next)
2195 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2196 image->chromaticity.white_point.x=geometry_info.rho;
2197 image->chromaticity.white_point.y=geometry_info.sigma;
2198 if ((flags & SigmaValue) == 0)
2199 image->chromaticity.white_point.y=
2200 image->chromaticity.white_point.x;
2205 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2206 for ( ; image; image=image->next)
2207 SetImageProperty(image,attribute,SvPV(sval,na));
2213 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2214 for ( ; image; image=image->next)
2215 SetImageProperty(image,attribute,SvPV(sval,na));
2222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2226 % S e t u p L i s t %
2230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2232 % Method SetupList returns the list of all the images linked by their
2233 % image->next and image->previous link lists for use with ImageMagick. If
2234 % info is non-NULL, an info structure is returned in *info. If
2235 % reference_vector is non-NULL,an array of SV* are returned in
2236 % *reference_vector. Reference_vector is used when the images are going to be
2237 % replaced with new Image*'s.
2239 % The format of the SetupList routine is:
2241 % Image *SetupList(SV *reference,struct PackageInfo **info,
2242 % SV ***reference_vector,ExceptionInfo *exception)
2244 % A description of each parameter follows:
2246 % o list: a list of strings.
2248 % o string: a character string.
2250 % o exception: Return any errors or warnings in this structure.
2253 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2254 SV ***reference_vector,ExceptionInfo *exception)
2263 if (reference_vector)
2264 *reference_vector=NULL;
2269 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2270 if (info && (SvTYPE(reference) == SVt_PVAV))
2271 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2281 % s t r E Q c a s e %
2285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2287 % strEQcase() compares two strings and returns 0 if they are the
2288 % same or if the second string runs out first. The comparison is case
2291 % The format of the strEQcase routine is:
2293 % ssize_t strEQcase(const char *p,const char *q)
2295 % A description of each parameter follows:
2297 % o p: a character string.
2299 % o q: a character string.
2303 static ssize_t strEQcase(const char *p,const char *q)
2311 for (i=0 ; (c=(*q)) != 0; i++)
2313 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2314 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2319 return(((*q == 0) && (*p == 0)) ? i : 0);
2323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2327 % I m a g e : : M a g i c k %
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 MODULE = Image::Magick PACKAGE = Image::Magick
2340 MagickCoreGenesis("PerlMagick",MagickFalse);
2341 SetWarningHandler(NULL);
2342 SetErrorHandler(NULL);
2343 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2344 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2350 if (magick_registry != (SplayTreeInfo *) NULL)
2351 magick_registry=DestroySplayTree(magick_registry);
2352 MagickCoreTerminus();
2356 constant(name,argument)
2361 ###############################################################################
2369 ###############################################################################
2374 Image::Magick ref=NO_INIT
2398 PERL_UNUSED_VAR(ref);
2399 PERL_UNUSED_VAR(ix);
2400 exception=AcquireExceptionInfo();
2401 perl_exception=newSVpv("",0);
2402 package_info=(struct PackageInfo *) NULL;
2403 if (sv_isobject(ST(0)) == 0)
2405 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2409 reference=SvRV(ST(0));
2410 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2411 if (image == (Image *) NULL)
2413 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2417 package_info=ClonePackageInfo(info,exception);
2419 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2422 for (i=2; i < items; i+=2)
2423 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2425 (void) AnimateImages(package_info->image_info,image,exception);
2426 (void) CatchImageException(image);
2429 if (package_info != (struct PackageInfo *) NULL)
2430 DestroyPackageInfo(package_info);
2431 InheritPerlException(exception,perl_exception);
2432 exception=DestroyExceptionInfo(exception);
2433 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2434 SvPOK_on(perl_exception);
2435 ST(0)=sv_2mortal(perl_exception);
2440 ###############################################################################
2448 ###############################################################################
2453 Image::Magick ref=NO_INIT
2491 PERL_UNUSED_VAR(ref);
2492 PERL_UNUSED_VAR(ix);
2493 exception=AcquireExceptionInfo();
2494 perl_exception=newSVpv("",0);
2498 if (sv_isobject(ST(0)) == 0)
2500 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2504 reference=SvRV(ST(0));
2505 hv=SvSTASH(reference);
2507 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2509 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2510 if (image == (Image *) NULL)
2512 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2516 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2521 for (i=2; i < items; i+=2)
2523 attribute=(char *) SvPV(ST(i-1),na);
2529 if (LocaleCompare(attribute,"stack") == 0)
2531 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2535 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2553 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2554 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2556 for ( ; image; image=image->next)
2558 AddImageToRegistry(sv,image);
2560 av_push(av,sv_bless(rv,hv));
2563 exception=DestroyExceptionInfo(exception);
2565 SvREFCNT_dec(perl_exception);
2569 InheritPerlException(exception,perl_exception);
2570 exception=DestroyExceptionInfo(exception);
2571 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2572 SvPOK_on(perl_exception);
2573 ST(0)=sv_2mortal(perl_exception);
2578 ###############################################################################
2586 ###############################################################################
2591 Image::Magick ref=NO_INIT
2622 PERL_UNUSED_VAR(ref);
2623 PERL_UNUSED_VAR(ix);
2624 exception=AcquireExceptionInfo();
2625 perl_exception=newSVpv("",0);
2627 if (sv_isobject(ST(0)) == 0)
2629 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2633 reference=SvRV(ST(0));
2634 hv=SvSTASH(reference);
2635 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2636 if (image == (Image *) NULL)
2638 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2642 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2643 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2646 Create blessed Perl array for the returned image.
2649 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2651 AddImageToRegistry(sv,image);
2653 av_push(av,sv_bless(rv,hv));
2655 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2656 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2657 "average-%.*s",(int) (MaxTextExtent-9),
2658 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2659 (void) CopyMagickString(image->filename,info->image_info->filename,
2661 SetImageInfo(info->image_info,0,exception);
2662 exception=DestroyExceptionInfo(exception);
2663 SvREFCNT_dec(perl_exception);
2667 InheritPerlException(exception,perl_exception);
2668 exception=DestroyExceptionInfo(exception);
2669 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2670 SvPOK_on(perl_exception);
2671 ST(0)=sv_2mortal(perl_exception);
2676 ###############################################################################
2680 # B l o b T o I m a g e #
2684 ###############################################################################
2688 BlobToImage(ref,...)
2689 Image::Magick ref=NO_INIT
2735 PERL_UNUSED_VAR(ref);
2736 PERL_UNUSED_VAR(ix);
2737 exception=AcquireExceptionInfo();
2738 perl_exception=newSVpv("",0);
2741 ac=(items < 2) ? 1 : items-1;
2742 length=(STRLEN *) NULL;
2743 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2744 if (list == (char **) NULL)
2746 ThrowPerlException(exception,ResourceLimitError,
2747 "MemoryAllocationFailed",PackageName);
2750 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2751 if (length == (STRLEN *) NULL)
2753 ThrowPerlException(exception,ResourceLimitError,
2754 "MemoryAllocationFailed",PackageName);
2757 if (sv_isobject(ST(0)) == 0)
2759 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2763 reference=SvRV(ST(0));
2764 hv=SvSTASH(reference);
2765 if (SvTYPE(reference) != SVt_PVAV)
2767 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2771 av=(AV *) reference;
2772 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2777 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2780 for (n=0, i=0; i < ac; i++)
2782 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2783 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2785 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2790 list[n]=(char *) NULL;
2792 for (i=number_images=0; i < n; i++)
2794 image=BlobToImage(info->image_info,list[i],length[i],exception);
2795 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2797 for ( ; image; image=image->next)
2799 AddImageToRegistry(sv,image);
2801 av_push(av,sv_bless(rv,hv));
2809 for (i=0; i < n; i++)
2810 if (list[i] != (char *) NULL)
2811 for (p=keep; list[i] != *p++; )
2812 if (*p == (char *) NULL)
2814 list[i]=(char *) RelinquishMagickMemory(list[i]);
2820 list=(char **) RelinquishMagickMemory(list);
2822 length=(STRLEN *) RelinquishMagickMemory(length);
2823 InheritPerlException(exception,perl_exception);
2824 exception=DestroyExceptionInfo(exception);
2825 sv_setiv(perl_exception,(IV) number_images);
2826 SvPOK_on(perl_exception);
2827 ST(0)=sv_2mortal(perl_exception);
2832 ###############################################################################
2840 ###############################################################################
2845 Image::Magick ref=NO_INIT
2878 PERL_UNUSED_VAR(ref);
2879 PERL_UNUSED_VAR(ix);
2880 exception=AcquireExceptionInfo();
2881 perl_exception=newSVpv("",0);
2883 if (sv_isobject(ST(0)) == 0)
2885 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2889 reference=SvRV(ST(0));
2890 hv=SvSTASH(reference);
2891 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2892 if (image == (Image *) NULL)
2894 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2899 Create blessed Perl array for the returned image.
2902 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2904 for ( ; image; image=image->next)
2906 clone=CloneImage(image,0,0,MagickTrue,exception);
2907 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2909 AddImageToRegistry(sv,clone);
2911 av_push(av,sv_bless(rv,hv));
2914 exception=DestroyExceptionInfo(exception);
2915 SvREFCNT_dec(perl_exception);
2919 InheritPerlException(exception,perl_exception);
2920 exception=DestroyExceptionInfo(exception);
2921 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2922 SvPOK_on(perl_exception);
2923 ST(0)=sv_2mortal(perl_exception);
2928 ###############################################################################
2936 ###############################################################################
2944 PERL_UNUSED_VAR(ref);
2945 if (magick_registry != (SplayTreeInfo *) NULL)
2950 ResetSplayTreeIterator(magick_registry);
2951 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2952 while (p != (Image *) NULL)
2955 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2961 ###############################################################################
2969 ###############################################################################
2974 Image::Magick ref=NO_INIT
3003 PERL_UNUSED_VAR(ref);
3004 PERL_UNUSED_VAR(ix);
3005 exception=AcquireExceptionInfo();
3006 perl_exception=newSVpv("",0);
3008 if (sv_isobject(ST(0)) == 0)
3010 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3014 reference=SvRV(ST(0));
3015 hv=SvSTASH(reference);
3017 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3019 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3020 if (image == (Image *) NULL)
3022 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3026 image=CoalesceImages(image,exception);
3027 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3029 for ( ; image; image=image->next)
3031 AddImageToRegistry(sv,image);
3033 av_push(av,sv_bless(rv,hv));
3036 exception=DestroyExceptionInfo(exception);
3038 SvREFCNT_dec(perl_exception);
3042 InheritPerlException(exception,perl_exception);
3043 exception=DestroyExceptionInfo(exception);
3044 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3045 SvPOK_on(perl_exception);
3046 ST(0)=sv_2mortal(perl_exception);
3051 ###############################################################################
3059 ###############################################################################
3064 Image::Magick ref=NO_INIT
3110 PERL_UNUSED_VAR(ref);
3111 PERL_UNUSED_VAR(ix);
3112 exception=AcquireExceptionInfo();
3113 perl_exception=newSVpv("",0);
3117 if (sv_isobject(ST(0)) == 0)
3119 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3123 reference=SvRV(ST(0));
3124 hv=SvSTASH(reference);
3126 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3128 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3129 if (image == (Image *) NULL)
3131 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3135 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3139 reconstruct_image=image;
3140 metric=RootMeanSquaredErrorMetric;
3141 for (i=2; i < items; i+=2)
3143 attribute=(char *) SvPV(ST(i-1),na);
3149 if (LocaleCompare(attribute,"channel") == 0)
3154 option=ParseChannelOption(SvPV(ST(i),na));
3157 ThrowPerlException(exception,OptionError,
3158 "UnrecognizedType",SvPV(ST(i),na));
3161 SetPixelChannelMap(image,(ChannelType) option);
3164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3171 if (LocaleCompare(attribute,"fuzz") == 0)
3173 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3176 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3183 if (LocaleCompare(attribute,"image") == 0)
3185 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3186 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3196 if (LocaleCompare(attribute,"metric") == 0)
3198 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3202 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3206 metric=(MetricType) option;
3209 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3221 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3223 if (difference_image != (Image *) NULL)
3225 difference_image->error.mean_error_per_pixel=distortion;
3226 AddImageToRegistry(sv,difference_image);
3228 av_push(av,sv_bless(rv,hv));
3231 exception=DestroyExceptionInfo(exception);
3233 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3237 InheritPerlException(exception,perl_exception);
3238 exception=DestroyExceptionInfo(exception);
3239 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3240 SvPOK_on(perl_exception);
3241 ST(0)=sv_2mortal(perl_exception);
3246 ###############################################################################
3250 # C o m p a r e L a y e r s #
3254 ###############################################################################
3259 Image::Magick ref=NO_INIT
3261 CompareImagesLayers = 1
3263 compareimagelayers = 3
3300 PERL_UNUSED_VAR(ref);
3301 PERL_UNUSED_VAR(ix);
3302 exception=AcquireExceptionInfo();
3303 perl_exception=newSVpv("",0);
3305 if (sv_isobject(ST(0)) == 0)
3307 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3311 reference=SvRV(ST(0));
3312 hv=SvSTASH(reference);
3314 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3316 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3317 if (image == (Image *) NULL)
3319 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3323 method=CompareAnyLayer;
3324 for (i=2; i < items; i+=2)
3326 attribute=(char *) SvPV(ST(i-1),na);
3332 if (LocaleCompare(attribute,"method") == 0)
3334 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3338 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3342 method=(ImageLayerMethod) option;
3345 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3351 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3357 image=CompareImagesLayers(image,method,exception);
3358 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3360 for ( ; image; image=image->next)
3362 AddImageToRegistry(sv,image);
3364 av_push(av,sv_bless(rv,hv));
3367 exception=DestroyExceptionInfo(exception);
3369 SvREFCNT_dec(perl_exception);
3373 InheritPerlException(exception,perl_exception);
3374 exception=DestroyExceptionInfo(exception);
3375 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3376 SvPOK_on(perl_exception);
3377 ST(0)=sv_2mortal(perl_exception);
3382 ###############################################################################
3390 ###############################################################################
3395 Image::Magick ref=NO_INIT
3401 PERL_UNUSED_VAR(ref);
3402 if (sv_isobject(ST(0)) == 0)
3403 croak("ReferenceIsNotMyType");
3404 reference=SvRV(ST(0));
3405 switch (SvTYPE(reference))
3410 message[MaxTextExtent];
3428 Array (AV *) reference
3430 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3431 XS_VERSION,reference);
3432 hv=gv_stashpv(PackageName, FALSE);
3435 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3439 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3441 info=(struct PackageInfo *) SvIV(sv);
3442 DestroyPackageInfo(info);
3444 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3454 Blessed scalar = (Image *) SvIV(reference)
3456 image=(Image *) SvIV(reference);
3457 if (image != (Image *) NULL)
3458 DeleteImageFromRegistry(reference,image);
3467 ###############################################################################
3475 ###############################################################################
3480 Image::Magick ref=NO_INIT
3504 PERL_UNUSED_VAR(ref);
3505 PERL_UNUSED_VAR(ix);
3506 exception=AcquireExceptionInfo();
3507 perl_exception=newSVpv("",0);
3508 package_info=(struct PackageInfo *) NULL;
3509 if (sv_isobject(ST(0)) == 0)
3511 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3515 reference=SvRV(ST(0));
3516 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3517 if (image == (Image *) NULL)
3519 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3523 package_info=ClonePackageInfo(info,exception);
3525 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3528 for (i=2; i < items; i+=2)
3529 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3531 (void) DisplayImages(package_info->image_info,image,exception);
3532 (void) CatchImageException(image);
3535 if (package_info != (struct PackageInfo *) NULL)
3536 DestroyPackageInfo(package_info);
3537 InheritPerlException(exception,perl_exception);
3538 exception=DestroyExceptionInfo(exception);
3539 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3540 SvPOK_on(perl_exception);
3541 ST(0)=sv_2mortal(perl_exception);
3546 ###############################################################################
3550 # E v a l u a t e I m a g e s #
3554 ###############################################################################
3559 Image::Magick ref=NO_INIT
3581 MagickEvaluateOperator
3596 PERL_UNUSED_VAR(ref);
3597 PERL_UNUSED_VAR(ix);
3598 exception=AcquireExceptionInfo();
3599 perl_exception=newSVpv("",0);
3601 if (sv_isobject(ST(0)) == 0)
3603 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3607 reference=SvRV(ST(0));
3608 hv=SvSTASH(reference);
3609 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3610 if (image == (Image *) NULL)
3612 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3616 op=MeanEvaluateOperator;
3622 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3626 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3630 op=(MagickEvaluateOperator) in;
3633 for (i=2; i < items; i+=2)
3635 attribute=(char *) SvPV(ST(i-1),na);
3641 if (LocaleCompare(attribute,"operator") == 0)
3646 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3647 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3650 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3654 op=(MagickEvaluateOperator) in;
3657 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3663 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3669 image=EvaluateImages(image,op,exception);
3670 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3673 Create blessed Perl array for the returned image.
3676 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3678 AddImageToRegistry(sv,image);
3680 av_push(av,sv_bless(rv,hv));
3682 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3683 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3684 "evaluate-%.*s",(int) (MaxTextExtent-9),
3685 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3686 (void) CopyMagickString(image->filename,info->image_info->filename,
3688 SetImageInfo(info->image_info,0,exception);
3689 exception=DestroyExceptionInfo(exception);
3690 SvREFCNT_dec(perl_exception);
3694 InheritPerlException(exception,perl_exception);
3695 exception=DestroyExceptionInfo(exception);
3696 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3697 SvPOK_on(perl_exception);
3698 ST(0)=sv_2mortal(perl_exception);
3703 ###############################################################################
3711 ###############################################################################
3716 Image::Magick ref=NO_INIT
3723 #define ChannelFeatures(channel,direction) \
3725 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3726 channel_features[channel].angular_second_moment[direction]); \
3727 PUSHs(sv_2mortal(newSVpv(message,0))); \
3728 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3729 channel_features[channel].contrast[direction]); \
3730 PUSHs(sv_2mortal(newSVpv(message,0))); \
3731 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3732 channel_features[channel].contrast[direction]); \
3733 PUSHs(sv_2mortal(newSVpv(message,0))); \
3734 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3735 channel_features[channel].variance_sum_of_squares[direction]); \
3736 PUSHs(sv_2mortal(newSVpv(message,0))); \
3737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3738 channel_features[channel].inverse_difference_moment[direction]); \
3739 PUSHs(sv_2mortal(newSVpv(message,0))); \
3740 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3741 channel_features[channel].sum_average[direction]); \
3742 PUSHs(sv_2mortal(newSVpv(message,0))); \
3743 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3744 channel_features[channel].sum_variance[direction]); \
3745 PUSHs(sv_2mortal(newSVpv(message,0))); \
3746 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3747 channel_features[channel].sum_entropy[direction]); \
3748 PUSHs(sv_2mortal(newSVpv(message,0))); \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].entropy[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].difference_variance[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].difference_entropy[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].measure_of_correlation_1[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].measure_of_correlation_2[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].maximum_correlation_coefficient[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3774 message[MaxTextExtent];
3801 PERL_UNUSED_VAR(ref);
3802 PERL_UNUSED_VAR(ix);
3803 exception=AcquireExceptionInfo();
3804 perl_exception=newSVpv("",0);
3806 if (sv_isobject(ST(0)) == 0)
3808 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3812 reference=SvRV(ST(0));
3815 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3816 if (image == (Image *) NULL)
3818 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3822 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3824 for (i=2; i < items; i+=2)
3826 attribute=(char *) SvPV(ST(i-1),na);
3832 if (LocaleCompare(attribute,"distance") == 0)
3834 distance=StringToLong((char *) SvPV(ST(1),na));
3837 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3843 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3850 for ( ; image; image=image->next)
3852 channel_features=GetImageFeatures(image,distance,
3854 if (channel_features == (ChannelFeatures *) NULL)
3857 EXTEND(sp,75*count);
3858 for (i=0; i < 4; i++)
3860 ChannelFeatures(RedChannel,i);
3861 ChannelFeatures(GreenChannel,i);
3862 ChannelFeatures(BlueChannel,i);
3863 if (image->colorspace == CMYKColorspace)
3864 ChannelFeatures(BlackChannel,i);
3865 if (image->matte != MagickFalse)
3866 ChannelFeatures(AlphaChannel,i);
3868 channel_features=(ChannelFeatures *)
3869 RelinquishMagickMemory(channel_features);
3873 InheritPerlException(exception,perl_exception);
3874 exception=DestroyExceptionInfo(exception);
3875 SvREFCNT_dec(perl_exception);
3879 ###############################################################################
3887 ###############################################################################
3892 Image::Magick ref=NO_INIT
3930 PERL_UNUSED_VAR(ref);
3931 PERL_UNUSED_VAR(ix);
3932 exception=AcquireExceptionInfo();
3933 perl_exception=newSVpv("",0);
3935 if (sv_isobject(ST(0)) == 0)
3937 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3941 reference=SvRV(ST(0));
3942 hv=SvSTASH(reference);
3943 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3944 if (image == (Image *) NULL)
3946 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3950 background_color=image->background_color;
3952 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3955 for (i=2; i < items; i+=2)
3957 attribute=(char *) SvPV(ST(i-1),na);
3963 if (LocaleCompare(attribute,"background") == 0)
3965 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3966 &background_color,exception);
3969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3975 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3981 image->background_color=background_color;
3982 image=MergeImageLayers(image,FlattenLayer,exception);
3983 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3986 Create blessed Perl array for the returned image.
3989 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3991 AddImageToRegistry(sv,image);
3993 av_push(av,sv_bless(rv,hv));
3995 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3996 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3997 "flatten-%.*s",(int) (MaxTextExtent-9),
3998 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3999 (void) CopyMagickString(image->filename,info->image_info->filename,
4001 SetImageInfo(info->image_info,0,exception);
4002 exception=DestroyExceptionInfo(exception);
4003 SvREFCNT_dec(perl_exception);
4007 InheritPerlException(exception,perl_exception);
4008 exception=DestroyExceptionInfo(exception);
4009 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4010 SvPOK_on(perl_exception); /* return messages in string context */
4011 ST(0)=sv_2mortal(perl_exception);
4016 ###############################################################################
4024 ###############################################################################
4029 Image::Magick ref=NO_INIT
4041 expression[MaxTextExtent];
4069 PERL_UNUSED_VAR(ref);
4070 PERL_UNUSED_VAR(ix);
4071 exception=AcquireExceptionInfo();
4072 perl_exception=newSVpv("",0);
4076 if (sv_isobject(ST(0)) == 0)
4078 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4082 reference=SvRV(ST(0));
4083 hv=SvSTASH(reference);
4085 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4087 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4088 if (image == (Image *) NULL)
4090 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4094 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4098 channel=DefaultChannels;
4099 (void) CopyMagickString(expression,"u",MaxTextExtent);
4101 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4103 for (i=2; i < items; i+=2)
4105 attribute=(char *) SvPV(ST(i-1),na);
4111 if (LocaleCompare(attribute,"channel") == 0)
4116 option=ParseChannelOption(SvPV(ST(i),na));
4119 ThrowPerlException(exception,OptionError,
4120 "UnrecognizedType",SvPV(ST(i),na));
4123 channel=(ChannelType) option;
4126 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4133 if (LocaleCompare(attribute,"expression") == 0)
4135 (void) CopyMagickString(expression,SvPV(ST(i),na),
4139 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4145 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4151 channel_mask=SetPixelChannelMask(image,channel);
4152 image=FxImage(image,expression,exception);
4153 if (image != (Image *) NULL)
4154 (void) SetPixelChannelMask(image,channel_mask);
4155 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4157 for ( ; image; image=image->next)
4159 AddImageToRegistry(sv,image);
4161 av_push(av,sv_bless(rv,hv));
4164 exception=DestroyExceptionInfo(exception);
4166 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4170 InheritPerlException(exception,perl_exception);
4171 exception=DestroyExceptionInfo(exception);
4172 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4173 SvPOK_on(perl_exception);
4174 ST(0)=sv_2mortal(perl_exception);
4179 ###############################################################################
4187 ###############################################################################
4192 Image::Magick ref=NO_INIT
4203 color[MaxTextExtent];
4228 PERL_UNUSED_VAR(ref);
4229 PERL_UNUSED_VAR(ix);
4230 exception=AcquireExceptionInfo();
4231 perl_exception=newSVpv("",0);
4232 if (sv_isobject(ST(0)) == 0)
4234 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4238 reference=SvRV(ST(0));
4239 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4240 if (image == (Image *) NULL && !info)
4243 for (i=1; i < items; i++)
4245 attribute=(char *) SvPV(ST(i),na);
4252 if (LocaleCompare(attribute,"adjoin") == 0)
4255 s=newSViv((ssize_t) info->image_info->adjoin);
4256 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4259 if (LocaleCompare(attribute,"antialias") == 0)
4262 s=newSViv((ssize_t) info->image_info->antialias);
4263 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4266 if (LocaleCompare(attribute,"area") == 0)
4268 s=newSViv(GetMagickResource(AreaResource));
4269 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4272 if (LocaleCompare(attribute,"attenuate") == 0)
4277 value=GetImageProperty(image,attribute);
4278 if (value != (const char *) NULL)
4280 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4283 if (LocaleCompare(attribute,"authenticate") == 0)
4286 s=newSVpv(info->image_info->authenticate,0);
4287 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4290 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4297 if (LocaleCompare(attribute,"background") == 0)
4299 if (image == (Image *) NULL)
4301 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4302 QuantumFormat "," QuantumFormat "," QuantumFormat,
4303 image->background_color.red,image->background_color.green,
4304 image->background_color.blue,image->background_color.alpha);
4306 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4309 if (LocaleCompare(attribute,"base-columns") == 0)
4311 if (image != (Image *) NULL)
4312 s=newSViv((ssize_t) image->magick_columns);
4313 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4316 if (LocaleCompare(attribute,"base-filename") == 0)
4318 if (image != (Image *) NULL)
4319 s=newSVpv(image->magick_filename,0);
4320 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4323 if (LocaleCompare(attribute,"base-height") == 0)
4325 if (image != (Image *) NULL)
4326 s=newSViv((ssize_t) image->magick_rows);
4327 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4330 if (LocaleCompare(attribute,"base-rows") == 0)
4332 if (image != (Image *) NULL)
4333 s=newSViv((ssize_t) image->magick_rows);
4334 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4337 if (LocaleCompare(attribute,"base-width") == 0)
4339 if (image != (Image *) NULL)
4340 s=newSViv((ssize_t) image->magick_columns);
4341 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4344 if (LocaleCompare(attribute,"bias") == 0)
4346 if (image != (Image *) NULL)
4347 s=newSVnv(image->bias);
4348 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4351 if (LocaleCompare(attribute,"blue-primary") == 0)
4353 if (image == (Image *) NULL)
4355 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4356 image->chromaticity.blue_primary.x,
4357 image->chromaticity.blue_primary.y);
4359 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4362 if (LocaleCompare(attribute,"bordercolor") == 0)
4364 if (image == (Image *) NULL)
4366 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4367 QuantumFormat "," QuantumFormat "," QuantumFormat,
4368 image->border_color.red,image->border_color.green,
4369 image->border_color.blue,image->border_color.alpha);
4371 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4374 if (LocaleCompare(attribute,"bounding-box") == 0)
4377 geometry[MaxTextExtent];
4382 if (image == (Image *) NULL)
4384 page=GetImageBoundingBox(image,&image->exception);
4385 (void) FormatLocaleString(geometry,MaxTextExtent,
4386 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4387 page.height,(double) page.x,(double) page.y);
4388 s=newSVpv(geometry,0);
4389 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4392 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4399 if (LocaleCompare(attribute,"class") == 0)
4401 if (image == (Image *) NULL)
4403 s=newSViv(image->storage_class);
4404 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4405 image->storage_class));
4407 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4410 if (LocaleCompare(attribute,"clip-mask") == 0)
4412 if (image != (Image *) NULL)
4418 if (image->mask == (Image *) NULL)
4419 ClipImage(image,exception);
4420 if (image->mask != (Image *) NULL)
4422 AddImageToRegistry(sv,image->mask);
4423 s=sv_bless(newRV(sv),SvSTASH(reference));
4426 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4429 if (LocaleCompare(attribute,"clip-path") == 0)
4431 if (image != (Image *) NULL)
4437 if (image->clip_mask == (Image *) NULL)
4438 ClipImage(image,exception);
4439 if (image->clip_mask != (Image *) NULL)
4441 AddImageToRegistry(sv,image->clip_mask);
4442 s=sv_bless(newRV(sv),SvSTASH(reference));
4445 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4448 if (LocaleCompare(attribute,"compression") == 0)
4450 j=info ? info->image_info->compression : image ?
4451 image->compression : UndefinedCompression;
4453 if (info->image_info->compression == UndefinedCompression)
4454 j=image->compression;
4456 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4459 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4462 if (LocaleCompare(attribute,"colorspace") == 0)
4464 j=image ? image->colorspace : RGBColorspace;
4466 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4469 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4472 if (LocaleCompare(attribute,"colors") == 0)
4474 if (image != (Image *) NULL)
4475 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4476 &image->exception));
4477 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4480 if (LocaleNCompare(attribute,"colormap",8) == 0)
4485 if (image == (Image *) NULL || !image->colormap)
4488 items=sscanf(attribute,"%*[^[][%ld",&j);
4490 if (j > (ssize_t) image->colors)
4492 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4493 QuantumFormat "," QuantumFormat "," QuantumFormat,
4494 image->colormap[j].red,image->colormap[j].green,
4495 image->colormap[j].blue,image->colormap[j].alpha);
4497 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4500 if (LocaleCompare(attribute,"columns") == 0)
4502 if (image != (Image *) NULL)
4503 s=newSViv((ssize_t) image->columns);
4504 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4507 if (LocaleCompare(attribute,"comment") == 0)
4512 value=GetImageProperty(image,attribute);
4513 if (value != (const char *) NULL)
4515 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4518 if (LocaleCompare(attribute,"copyright") == 0)
4520 s=newSVpv(GetMagickCopyright(),0);
4521 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4524 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4531 if (LocaleCompare(attribute,"density") == 0)
4534 geometry[MaxTextExtent];
4536 if (image == (Image *) NULL)
4538 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4539 image->x_resolution,image->y_resolution);
4540 s=newSVpv(geometry,0);
4541 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4544 if (LocaleCompare(attribute,"delay") == 0)
4546 if (image != (Image *) NULL)
4547 s=newSViv((ssize_t) image->delay);
4548 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4551 if (LocaleCompare(attribute,"depth") == 0)
4553 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4554 if (image != (Image *) NULL)
4555 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4556 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4559 if (LocaleCompare(attribute,"directory") == 0)
4561 if (image && image->directory)
4562 s=newSVpv(image->directory,0);
4563 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4566 if (LocaleCompare(attribute,"dispose") == 0)
4568 if (image == (Image *) NULL)
4571 s=newSViv(image->dispose);
4573 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4575 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4578 if (LocaleCompare(attribute,"disk") == 0)
4580 s=newSViv(GetMagickResource(DiskResource));
4581 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4584 if (LocaleCompare(attribute,"dither") == 0)
4587 s=newSViv((ssize_t) info->image_info->dither);
4588 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4591 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4593 if (info && info->image_info->server_name)
4594 s=newSVpv(info->image_info->server_name,0);
4595 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4598 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4605 if (LocaleCompare(attribute,"elapsed-time") == 0)
4607 if (image != (Image *) NULL)
4608 s=newSVnv(GetElapsedTime(&image->timer));
4609 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4612 if (LocaleCompare(attribute,"endian") == 0)
4614 j=info ? info->image_info->endian : image ? image->endian :
4617 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4619 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4622 if (LocaleCompare(attribute,"error") == 0)
4624 if (image != (Image *) NULL)
4625 s=newSVnv(image->error.mean_error_per_pixel);
4626 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4629 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4636 if (LocaleCompare(attribute,"filesize") == 0)
4638 if (image != (Image *) NULL)
4639 s=newSViv((ssize_t) GetBlobSize(image));
4640 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4643 if (LocaleCompare(attribute,"filename") == 0)
4645 if (info && info->image_info->filename &&
4646 *info->image_info->filename)
4647 s=newSVpv(info->image_info->filename,0);
4648 if (image != (Image *) NULL)
4649 s=newSVpv(image->filename,0);
4650 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4653 if (LocaleCompare(attribute,"filter") == 0)
4655 s=image ? newSViv(image->filter) : newSViv(0);
4656 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4659 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4662 if (LocaleCompare(attribute,"font") == 0)
4664 if (info && info->image_info->font)
4665 s=newSVpv(info->image_info->font,0);
4666 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4669 if (LocaleCompare(attribute,"foreground") == 0)
4671 if (LocaleCompare(attribute,"format") == 0)
4676 magick_info=(const MagickInfo *) NULL;
4677 if (info && (*info->image_info->magick != '\0'))
4678 magick_info=GetMagickInfo(info->image_info->magick,exception);
4679 if (image != (Image *) NULL)
4680 magick_info=GetMagickInfo(image->magick,&image->exception);
4681 if ((magick_info != (const MagickInfo *) NULL) &&
4682 (*magick_info->description != '\0'))
4683 s=newSVpv((char *) magick_info->description,0);
4684 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4687 if (LocaleCompare(attribute,"fuzz") == 0)
4690 s=newSVnv(info->image_info->fuzz);
4691 if (image != (Image *) NULL)
4692 s=newSVnv(image->fuzz);
4693 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4696 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4703 if (LocaleCompare(attribute,"gamma") == 0)
4705 if (image != (Image *) NULL)
4706 s=newSVnv(image->gamma);
4707 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4710 if (LocaleCompare(attribute,"geometry") == 0)
4712 if (image && image->geometry)
4713 s=newSVpv(image->geometry,0);
4714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4717 if (LocaleCompare(attribute,"gravity") == 0)
4719 s=image ? newSViv(image->gravity) : newSViv(0);
4720 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4723 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4726 if (LocaleCompare(attribute,"green-primary") == 0)
4728 if (image == (Image *) NULL)
4730 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4731 image->chromaticity.green_primary.x,
4732 image->chromaticity.green_primary.y);
4734 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4737 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4744 if (LocaleCompare(attribute,"height") == 0)
4746 if (image != (Image *) NULL)
4747 s=newSViv((ssize_t) image->rows);
4748 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4751 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4758 if (LocaleCompare(attribute,"icc") == 0)
4760 if (image != (Image *) NULL)
4765 profile=GetImageProfile(image,"icc");
4766 if (profile != (StringInfo *) NULL)
4767 s=newSVpv((const char *) GetStringInfoDatum(profile),
4768 GetStringInfoLength(profile));
4770 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4773 if (LocaleCompare(attribute,"icm") == 0)
4775 if (image != (Image *) NULL)
4780 profile=GetImageProfile(image,"icm");
4781 if (profile != (const StringInfo *) NULL)
4782 s=newSVpv((const char *) GetStringInfoDatum(profile),
4783 GetStringInfoLength(profile));
4785 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4788 if (LocaleCompare(attribute,"id") == 0)
4790 if (image != (Image *) NULL)
4801 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4803 status=SetImageRegistry(ImageRegistryType,key,image,
4808 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4811 if (LocaleNCompare(attribute,"index",5) == 0)
4814 name[MaxTextExtent];
4823 register const Quantum
4829 if (image == (Image *) NULL)
4831 if (image->storage_class != PseudoClass)
4835 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4837 image_view=AcquireCacheView(image);
4838 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4839 if (p != (const Quantum *) NULL)
4841 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4842 GetPixelIndex(image,p));
4844 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4846 image_view=DestroyCacheView(image_view);
4849 if (LocaleCompare(attribute,"iptc") == 0)
4851 if (image != (Image *) NULL)
4856 profile=GetImageProfile(image,"iptc");
4857 if (profile != (const StringInfo *) NULL)
4858 s=newSVpv((const char *) GetStringInfoDatum(profile),
4859 GetStringInfoLength(profile));
4861 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4864 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4866 if (image != (Image *) NULL)
4867 s=newSViv((ssize_t) image->iterations);
4868 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4871 if (LocaleCompare(attribute,"interlace") == 0)
4873 j=info ? info->image_info->interlace : image ? image->interlace :
4876 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4879 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4882 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4889 if (LocaleCompare(attribute,"label") == 0)
4894 if (image == (Image *) NULL)
4896 value=GetImageProperty(image,"Label");
4897 if (value != (const char *) NULL)
4899 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4902 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4904 if (image != (Image *) NULL)
4905 s=newSViv((ssize_t) image->iterations);
4906 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4909 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4916 if (LocaleCompare(attribute,"magick") == 0)
4918 if (info && *info->image_info->magick)
4919 s=newSVpv(info->image_info->magick,0);
4920 if (image != (Image *) NULL)
4921 s=newSVpv(image->magick,0);
4922 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4925 if (LocaleCompare(attribute,"map") == 0)
4927 s=newSViv(GetMagickResource(MapResource));
4928 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4931 if (LocaleCompare(attribute,"maximum-error") == 0)
4933 if (image != (Image *) NULL)
4934 s=newSVnv(image->error.normalized_maximum_error);
4935 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4938 if (LocaleCompare(attribute,"memory") == 0)
4940 s=newSViv(GetMagickResource(MemoryResource));
4941 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4944 if (LocaleCompare(attribute,"mean-error") == 0)
4946 if (image != (Image *) NULL)
4947 s=newSVnv(image->error.normalized_mean_error);
4948 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4951 if (LocaleCompare(attribute,"mime") == 0)
4953 if (info && *info->image_info->magick)
4954 s=newSVpv(MagickToMime(info->image_info->magick),0);
4955 if (image != (Image *) NULL)
4956 s=newSVpv(MagickToMime(image->magick),0);
4957 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4960 if (LocaleCompare(attribute,"mattecolor") == 0)
4962 if (image == (Image *) NULL)
4964 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4965 QuantumFormat "," QuantumFormat "," QuantumFormat,
4966 image->matte_color.red,image->matte_color.green,
4967 image->matte_color.blue,image->matte_color.alpha);
4969 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4972 if (LocaleCompare(attribute,"matte") == 0)
4974 if (image != (Image *) NULL)
4975 s=newSViv((ssize_t) image->matte);
4976 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4979 if (LocaleCompare(attribute,"mime") == 0)
4985 if (info && *info->image_info->magick)
4986 magick=info->image_info->magick;
4987 if (image != (Image *) NULL)
4988 magick=image->magick;
4994 mime=MagickToMime(magick);
4996 mime=(char *) RelinquishMagickMemory(mime);
4998 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5001 if (LocaleCompare(attribute,"monochrome") == 0)
5003 if (image == (Image *) NULL)
5005 j=info ? info->image_info->monochrome :
5006 IsImageMonochrome(image,&image->exception);
5008 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5011 if (LocaleCompare(attribute,"montage") == 0)
5013 if (image && image->montage)
5014 s=newSVpv(image->montage,0);
5015 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5018 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5025 if (LocaleCompare(attribute,"orientation") == 0)
5027 j=info ? info->image_info->orientation : image ?
5028 image->orientation : UndefinedOrientation;
5030 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5033 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5036 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5043 if (LocaleCompare(attribute,"page") == 0)
5045 if (info && info->image_info->page)
5046 s=newSVpv(info->image_info->page,0);
5047 if (image != (Image *) NULL)
5050 geometry[MaxTextExtent];
5052 (void) FormatLocaleString(geometry,MaxTextExtent,
5053 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5054 (double) image->page.height,(double) image->page.x,(double)
5056 s=newSVpv(geometry,0);
5058 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5061 if (LocaleCompare(attribute,"page.x") == 0)
5063 if (image != (Image *) NULL)
5064 s=newSViv((ssize_t) image->page.x);
5065 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5068 if (LocaleCompare(attribute,"page.y") == 0)
5070 if (image != (Image *) NULL)
5071 s=newSViv((ssize_t) image->page.y);
5072 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5075 if (LocaleNCompare(attribute,"pixel",5) == 0)
5078 tuple[MaxTextExtent];
5087 register const Quantum
5090 if (image == (Image *) NULL)
5094 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5096 p=GetVirtualPixels(image,x,y,1,1,exception);
5097 if (image->colorspace != CMYKColorspace)
5098 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5099 QuantumFormat "," QuantumFormat "," QuantumFormat,
5100 GetPixelRed(image,p),GetPixelGreen(image,p),
5101 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5103 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5104 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5105 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5106 GetPixelBlue(image,p),GetPixelBlack(image,p),
5107 GetPixelAlpha(image,p));
5109 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5112 if (LocaleCompare(attribute,"pointsize") == 0)
5115 s=newSViv((ssize_t) info->image_info->pointsize);
5116 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5119 if (LocaleCompare(attribute,"preview") == 0)
5121 s=newSViv(info->image_info->preview_type);
5122 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5123 info->image_info->preview_type));
5125 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5128 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5135 if (LocaleCompare(attribute,"quality") == 0)
5138 s=newSViv((ssize_t) info->image_info->quality);
5139 if (image != (Image *) NULL)
5140 s=newSViv((ssize_t) image->quality);
5141 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5144 if (LocaleCompare(attribute,"quantum") == 0)
5147 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5148 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5158 if (LocaleCompare(attribute,"rendering-intent") == 0)
5160 s=newSViv(image->rendering_intent);
5161 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5162 image->rendering_intent));
5164 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5167 if (LocaleCompare(attribute,"red-primary") == 0)
5169 if (image == (Image *) NULL)
5171 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5172 image->chromaticity.red_primary.x,
5173 image->chromaticity.red_primary.y);
5175 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5178 if (LocaleCompare(attribute,"rows") == 0)
5180 if (image != (Image *) NULL)
5181 s=newSViv((ssize_t) image->rows);
5182 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5192 if (LocaleCompare(attribute,"sampling-factor") == 0)
5194 if (info && info->image_info->sampling_factor)
5195 s=newSVpv(info->image_info->sampling_factor,0);
5196 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5199 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5201 if (info && info->image_info->server_name)
5202 s=newSVpv(info->image_info->server_name,0);
5203 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5206 if (LocaleCompare(attribute,"size") == 0)
5208 if (info && info->image_info->size)
5209 s=newSVpv(info->image_info->size,0);
5210 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5213 if (LocaleCompare(attribute,"scene") == 0)
5215 if (image != (Image *) NULL)
5216 s=newSViv((ssize_t) image->scene);
5217 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5220 if (LocaleCompare(attribute,"scenes") == 0)
5222 if (image != (Image *) NULL)
5223 s=newSViv((ssize_t) info->image_info->number_scenes);
5224 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5227 if (LocaleCompare(attribute,"signature") == 0)
5232 if (image == (Image *) NULL)
5234 (void) SignatureImage(image,exception);
5235 value=GetImageProperty(image,"Signature");
5236 if (value != (const char *) NULL)
5238 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5241 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5248 if (LocaleCompare(attribute,"taint") == 0)
5250 if (image != (Image *) NULL)
5251 s=newSViv((ssize_t) IsTaintImage(image));
5252 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5255 if (LocaleCompare(attribute,"texture") == 0)
5257 if (info && info->image_info->texture)
5258 s=newSVpv(info->image_info->texture,0);
5259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5262 if (LocaleCompare(attribute,"total-ink-density") == 0)
5264 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5265 if (image != (Image *) NULL)
5266 s=newSVnv(GetImageTotalInkDensity(image));
5267 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5270 if (LocaleCompare(attribute,"transparent-color") == 0)
5272 if (image == (Image *) NULL)
5274 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5275 QuantumFormat "," QuantumFormat "," QuantumFormat,
5276 image->transparent_color.red,image->transparent_color.green,
5277 image->transparent_color.blue,image->transparent_color.alpha);
5279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5282 if (LocaleCompare(attribute,"type") == 0)
5284 if (image == (Image *) NULL)
5286 j=(ssize_t) GetImageType(image,&image->exception);
5288 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5290 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5293 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5300 if (LocaleCompare(attribute,"units") == 0)
5302 j=info ? info->image_info->units : image ? image->units :
5303 UndefinedResolution;
5304 if (info && (info->image_info->units == UndefinedResolution))
5307 if (j == UndefinedResolution)
5308 s=newSVpv("undefined units",0);
5310 if (j == PixelsPerInchResolution)
5311 s=newSVpv("pixels / inch",0);
5313 s=newSVpv("pixels / centimeter",0);
5314 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5317 if (LocaleCompare(attribute,"user-time") == 0)
5319 if (image != (Image *) NULL)
5320 s=newSVnv(GetUserTime(&image->timer));
5321 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5324 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5331 if (LocaleCompare(attribute,"verbose") == 0)
5334 s=newSViv((ssize_t) info->image_info->verbose);
5335 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5338 if (LocaleCompare(attribute,"version") == 0)
5340 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5341 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5344 if (LocaleCompare(attribute,"view") == 0)
5346 if (info && info->image_info->view)
5347 s=newSVpv(info->image_info->view,0);
5348 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5351 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5353 if (image == (Image *) NULL)
5355 j=(ssize_t) GetImageVirtualPixelMethod(image);
5357 (void) sv_setpv(s,CommandOptionToMnemonic(
5358 MagickVirtualPixelOptions,j));
5360 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5363 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5370 if (LocaleCompare(attribute,"white-point") == 0)
5372 if (image == (Image *) NULL)
5374 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5375 image->chromaticity.white_point.x,
5376 image->chromaticity.white_point.y);
5378 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5381 if (LocaleCompare(attribute,"width") == 0)
5383 if (image != (Image *) NULL)
5384 s=newSViv((ssize_t) image->columns);
5385 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5395 if (LocaleCompare(attribute,"x-resolution") == 0)
5397 if (image != (Image *) NULL)
5398 s=newSVnv(image->x_resolution);
5399 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5402 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5409 if (LocaleCompare(attribute,"y-resolution") == 0)
5411 if (image != (Image *) NULL)
5412 s=newSVnv(image->y_resolution);
5413 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5416 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5423 if (image == (Image *) NULL)
5424 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5428 value=GetImageProperty(image,attribute);
5429 if (value != (const char *) NULL)
5432 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5435 if (*attribute != '%')
5436 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5443 meta=InterpretImageProperties(info ? info->image_info :
5444 (ImageInfo *) NULL,image,attribute,exception);
5446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5447 meta=(char *) RelinquishMagickMemory(meta);
5451 exception=DestroyExceptionInfo(exception);
5452 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5456 ###############################################################################
5460 # G e t A u t h e n t i c P i x e l s #
5464 ###############################################################################
5468 GetAuthenticPixels(ref,...)
5469 Image::Magick ref = NO_INIT
5471 getauthenticpixels = 1
5501 PERL_UNUSED_VAR(ref);
5502 PERL_UNUSED_VAR(ix);
5503 exception=AcquireExceptionInfo();
5504 perl_exception=newSVpv("",0);
5505 if (sv_isobject(ST(0)) == 0)
5507 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5511 reference=SvRV(ST(0));
5513 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5514 if (image == (Image *) NULL)
5516 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5523 region.width=image->columns;
5526 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5527 for (i=2; i < items; i+=2)
5529 attribute=(char *) SvPV(ST(i-1),na);
5535 if (LocaleCompare(attribute,"geometry") == 0)
5537 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5547 if (LocaleCompare(attribute,"height") == 0)
5549 region.height=SvIV(ST(i));
5552 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5559 if (LocaleCompare(attribute,"x") == 0)
5561 region.x=SvIV(ST(i));
5564 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5571 if (LocaleCompare(attribute,"y") == 0)
5573 region.y=SvIV(ST(i));
5576 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5583 if (LocaleCompare(attribute,"width") == 0)
5585 region.width=SvIV(ST(i));
5588 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5594 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5595 region.height,exception);
5596 if (blob != (void *) NULL)
5600 InheritPerlException(exception,perl_exception);
5601 exception=DestroyExceptionInfo(exception);
5602 SvREFCNT_dec(perl_exception); /* throw away all errors */
5611 ###############################################################################
5615 # G e t V i r t u a l P i x e l s #
5619 ###############################################################################
5623 GetVirtualPixels(ref,...)
5624 Image::Magick ref = NO_INIT
5626 getvirtualpixels = 1
5627 AcquireImagePixels = 2
5628 acquireimagepixels = 3
5656 PERL_UNUSED_VAR(ref);
5657 PERL_UNUSED_VAR(ix);
5658 exception=AcquireExceptionInfo();
5659 perl_exception=newSVpv("",0);
5660 if (sv_isobject(ST(0)) == 0)
5662 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5666 reference=SvRV(ST(0));
5668 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5669 if (image == (Image *) NULL)
5671 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5678 region.width=image->columns;
5681 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5682 for (i=2; i < items; i+=2)
5684 attribute=(char *) SvPV(ST(i-1),na);
5690 if (LocaleCompare(attribute,"geometry") == 0)
5692 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5695 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5702 if (LocaleCompare(attribute,"height") == 0)
5704 region.height=SvIV(ST(i));
5707 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5714 if (LocaleCompare(attribute,"x") == 0)
5716 region.x=SvIV(ST(i));
5719 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5726 if (LocaleCompare(attribute,"y") == 0)
5728 region.y=SvIV(ST(i));
5731 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5738 if (LocaleCompare(attribute,"width") == 0)
5740 region.width=SvIV(ST(i));
5743 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5749 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5750 region.height,exception);
5751 if (blob != (void *) NULL)
5755 InheritPerlException(exception,perl_exception);
5756 exception=DestroyExceptionInfo(exception);
5757 SvREFCNT_dec(perl_exception); /* throw away all errors */
5760 RETVAL = (void *) blob;
5766 ###############################################################################
5770 # G e t A u t h e n t i c M e t a c o n t e n t #
5774 ###############################################################################
5778 GetAuthenticMetacontent(ref,...)
5779 Image::Magick ref = NO_INIT
5781 getauthenticmetacontent = 1
5802 PERL_UNUSED_VAR(ref);
5803 PERL_UNUSED_VAR(ix);
5804 exception=AcquireExceptionInfo();
5805 perl_exception=newSVpv("",0);
5806 if (sv_isobject(ST(0)) == 0)
5808 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5812 reference=SvRV(ST(0));
5814 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5815 if (image == (Image *) NULL)
5817 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5822 blob=(void *) GetAuthenticMetacontent(image);
5823 if (blob != (void *) NULL)
5827 InheritPerlException(exception,perl_exception);
5828 exception=DestroyExceptionInfo(exception);
5829 SvREFCNT_dec(perl_exception); /* throw away all errors */
5838 ###############################################################################
5842 # G e t V i r t u a l M e t a c o n t e n t #
5846 ###############################################################################
5850 GetVirtualMetacontent(ref,...)
5851 Image::Magick ref = NO_INIT
5853 getvirtualmetacontent = 1
5872 PERL_UNUSED_VAR(ref);
5873 PERL_UNUSED_VAR(ix);
5874 exception=AcquireExceptionInfo();
5875 perl_exception=newSVpv("",0);
5876 if (sv_isobject(ST(0)) == 0)
5878 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5882 reference=SvRV(ST(0));
5884 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5885 if (image == (Image *) NULL)
5887 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5892 blob=(void *) GetVirtualMetacontent(image);
5893 if (blob != (void *) NULL)
5897 InheritPerlException(exception,perl_exception);
5898 exception=DestroyExceptionInfo(exception);
5899 SvREFCNT_dec(perl_exception); /* throw away all errors */
5908 ###############################################################################
5912 # H i s t o g r a m #
5916 ###############################################################################
5921 Image::Magick ref=NO_INIT
5932 message[MaxTextExtent];
5959 PERL_UNUSED_VAR(ref);
5960 PERL_UNUSED_VAR(ix);
5961 exception=AcquireExceptionInfo();
5962 perl_exception=newSVpv("",0);
5964 if (sv_isobject(ST(0)) == 0)
5966 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5970 reference=SvRV(ST(0));
5973 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5974 if (image == (Image *) NULL)
5976 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5980 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5982 for ( ; image; image=image->next)
5984 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5985 if (histogram == (PixelPacket *) NULL)
5987 count+=(ssize_t) number_colors;
5989 for (i=0; i < (ssize_t) number_colors; i++)
5991 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5993 PUSHs(sv_2mortal(newSVpv(message,0)));
5994 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5995 histogram[i].green);
5996 PUSHs(sv_2mortal(newSVpv(message,0)));
5997 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5999 PUSHs(sv_2mortal(newSVpv(message,0)));
6000 if (image->colorspace == CMYKColorspace)
6002 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6003 histogram[i].black);
6004 PUSHs(sv_2mortal(newSVpv(message,0)));
6006 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6007 histogram[i].alpha);
6008 PUSHs(sv_2mortal(newSVpv(message,0)));
6009 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6010 histogram[i].count);
6011 PUSHs(sv_2mortal(newSVpv(message,0)));
6013 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6017 InheritPerlException(exception,perl_exception);
6018 exception=DestroyExceptionInfo(exception);
6019 SvREFCNT_dec(perl_exception);
6023 ###############################################################################
6031 ###############################################################################
6036 Image::Magick ref=NO_INIT
6060 register const Quantum
6074 *reference; /* reference is the SV* of ref=SvIV(reference) */
6076 PERL_UNUSED_VAR(ref);
6077 PERL_UNUSED_VAR(ix);
6078 exception=AcquireExceptionInfo();
6079 perl_exception=newSVpv("",0);
6080 reference=SvRV(ST(0));
6081 av=(AV *) reference;
6082 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6084 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6085 if (image == (Image *) NULL)
6087 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6091 normalize=MagickTrue;
6094 region.width=image->columns;
6097 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6098 for (i=2; i < items; i+=2)
6100 attribute=(char *) SvPV(ST(i-1),na);
6106 if (LocaleCompare(attribute,"channel") == 0)
6111 option=ParseChannelOption(SvPV(ST(i),na));
6114 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6118 SetPixelChannelMap(image,(ChannelType) option);
6121 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6128 if (LocaleCompare(attribute,"geometry") == 0)
6130 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6133 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6140 if (LocaleCompare(attribute,"normalize") == 0)
6142 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6146 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6150 normalize=option != 0 ? MagickTrue : MagickFalse;
6153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6160 if (LocaleCompare(attribute,"x") == 0)
6162 region.x=SvIV(ST(i));
6165 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6172 if (LocaleCompare(attribute,"y") == 0)
6174 region.y=SvIV(ST(i));
6177 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6183 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6189 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6190 if (p == (const Quantum *) NULL)
6198 if (normalize != MagickFalse)
6199 scale=1.0/QuantumRange;
6200 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6201 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6202 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6203 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6204 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6205 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6206 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6207 (image->colorspace == CMYKColorspace))
6208 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6209 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6210 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6214 InheritPerlException(exception,perl_exception);
6215 exception=DestroyExceptionInfo(exception);
6216 SvREFCNT_dec(perl_exception);
6220 ###############################################################################
6224 # G e t P i x e l s #
6228 ###############################################################################
6233 Image::Magick ref=NO_INIT
6272 *reference; /* reference is the SV* of ref=SvIV(reference) */
6274 PERL_UNUSED_VAR(ref);
6275 PERL_UNUSED_VAR(ix);
6276 exception=AcquireExceptionInfo();
6277 perl_exception=newSVpv("",0);
6278 reference=SvRV(ST(0));
6279 av=(AV *) reference;
6280 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6282 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6283 if (image == (Image *) NULL)
6285 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6290 if (image->matte != MagickFalse)
6292 if (image->colorspace == CMYKColorspace)
6295 if (image->matte != MagickFalse)
6298 normalize=MagickFalse;
6301 region.width=image->columns;
6304 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6305 for (i=2; i < items; i+=2)
6307 attribute=(char *) SvPV(ST(i-1),na);
6313 if (LocaleCompare(attribute,"geometry") == 0)
6315 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6318 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6325 if (LocaleCompare(attribute,"height") == 0)
6327 region.height=SvIV(ST(i));
6330 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6337 if (LocaleCompare(attribute,"map") == 0)
6342 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6349 if (LocaleCompare(attribute,"normalize") == 0)
6351 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6355 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6359 normalize=option != 0 ? MagickTrue : MagickFalse;
6362 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6369 if (LocaleCompare(attribute,"width") == 0)
6371 region.width=SvIV(ST(i));
6374 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6381 if (LocaleCompare(attribute,"x") == 0)
6383 region.x=SvIV(ST(i));
6386 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6393 if (LocaleCompare(attribute,"y") == 0)
6395 region.y=SvIV(ST(i));
6398 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6410 if (normalize != MagickFalse)
6415 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6416 region.height*sizeof(*pixels));
6417 if (pixels == (float *) NULL)
6419 ThrowPerlException(exception,ResourceLimitError,
6420 "MemoryAllocationFailed",PackageName);
6423 status=ExportImagePixels(image,region.x,region.y,region.width,
6424 region.height,map,FloatPixel,pixels,exception);
6425 if (status == MagickFalse)
6429 EXTEND(sp,strlen(map)*region.width*region.height);
6430 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6431 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6433 pixels=(float *) RelinquishMagickMemory(pixels);
6440 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6441 region.height*sizeof(*pixels));
6442 if (pixels == (Quantum *) NULL)
6444 ThrowPerlException(exception,ResourceLimitError,
6445 "MemoryAllocationFailed",PackageName);
6448 status=ExportImagePixels(image,region.x,region.y,region.width,
6449 region.height,map,QuantumPixel,pixels,exception);
6450 if (status == MagickFalse)
6454 EXTEND(sp,strlen(map)*region.width*region.height);
6455 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6456 PUSHs(sv_2mortal(newSViv(pixels[i])));
6458 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6462 InheritPerlException(exception,perl_exception);
6463 exception=DestroyExceptionInfo(exception);
6464 SvREFCNT_dec(perl_exception);
6468 ###############################################################################
6472 # I m a g e T o B l o b #
6476 ###############################################################################
6480 ImageToBlob(ref,...)
6481 Image::Magick ref=NO_INIT
6490 filename[MaxTextExtent];
6519 PERL_UNUSED_VAR(ref);
6520 PERL_UNUSED_VAR(ix);
6521 exception=AcquireExceptionInfo();
6522 perl_exception=newSVpv("",0);
6523 package_info=(struct PackageInfo *) NULL;
6524 if (sv_isobject(ST(0)) == 0)
6526 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6530 reference=SvRV(ST(0));
6531 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6532 if (image == (Image *) NULL)
6534 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6538 package_info=ClonePackageInfo(info,exception);
6539 for (i=2; i < items; i+=2)
6540 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6541 (void) CopyMagickString(filename,package_info->image_info->filename,
6544 for (next=image; next; next=next->next)
6546 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6547 next->scene=scene++;
6549 SetImageInfo(package_info->image_info,(unsigned int)
6550 GetImageListLength(image),&image->exception);
6551 EXTEND(sp,(ssize_t) GetImageListLength(image));
6552 for ( ; image; image=image->next)
6555 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6556 if (blob != (char *) NULL)
6558 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6559 blob=(unsigned char *) RelinquishMagickMemory(blob);
6561 if (package_info->image_info->adjoin)
6566 if (package_info != (struct PackageInfo *) NULL)
6567 DestroyPackageInfo(package_info);
6568 InheritPerlException(exception,perl_exception);
6569 exception=DestroyExceptionInfo(exception);
6570 SvREFCNT_dec(perl_exception); /* throw away all errors */
6574 ###############################################################################
6582 ###############################################################################
6587 Image::Magick ref=NO_INIT
6591 OptimizeImageLayers = 3
6593 optimizeimagelayers = 5
6635 PERL_UNUSED_VAR(ref);
6636 PERL_UNUSED_VAR(ix);
6637 exception=AcquireExceptionInfo();
6638 perl_exception=newSVpv("",0);
6640 if (sv_isobject(ST(0)) == 0)
6642 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6646 reference=SvRV(ST(0));
6647 hv=SvSTASH(reference);
6649 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6651 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6652 if (image == (Image *) NULL)
6654 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6658 compose=image->compose;
6659 method=OptimizeLayer;
6660 for (i=2; i < items; i+=2)
6662 attribute=(char *) SvPV(ST(i-1),na);
6668 if (LocaleCompare(attribute,"compose") == 0)
6670 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6671 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6674 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6678 compose=(CompositeOperator) sp;
6681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6688 if (LocaleCompare(attribute,"method") == 0)
6690 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6694 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6698 method=(ImageLayerMethod) option;
6701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6707 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6713 layers=(Image *) NULL;
6716 case CompareAnyLayer:
6717 case CompareClearLayer:
6718 case CompareOverlayLayer:
6721 layers=CompareImagesLayers(image,method,exception);
6728 layers=MergeImageLayers(image,method,exception);
6733 layers=DisposeImages(image,exception);
6736 case OptimizeImageLayer:
6738 layers=OptimizeImageLayers(image,exception);
6741 case OptimizePlusLayer:
6743 layers=OptimizePlusImageLayers(image,exception);
6746 case OptimizeTransLayer:
6748 OptimizeImageTransparency(image,exception);
6749 InheritException(&(image->exception),exception);
6752 case RemoveDupsLayer:
6754 RemoveDuplicateLayers(&image,exception);
6755 InheritException(&(image->exception),exception);
6758 case RemoveZeroLayer:
6760 RemoveZeroDelayLayers(&image,exception);
6761 InheritException(&(image->exception),exception);
6770 General Purpose, GIF Animation Optimizer.
6772 layers=CoalesceImages(image,exception);
6773 if (layers == (Image *) NULL)
6775 InheritException(&(layers->exception),exception);
6777 layers=OptimizeImageLayers(image,exception);
6778 if (layers == (Image *) NULL)
6780 InheritException(&(layers->exception),exception);
6781 image=DestroyImageList(image);
6783 layers=(Image *) NULL;
6784 OptimizeImageTransparency(image,exception);
6785 InheritException(&(image->exception),exception);
6786 quantize_info=AcquireQuantizeInfo(info->image_info);
6787 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6788 quantize_info=DestroyQuantizeInfo(quantize_info);
6791 case CompositeLayer:
6800 Split image sequence at the first 'NULL:' image.
6803 while (source != (Image *) NULL)
6805 source=GetNextImageInList(source);
6806 if ((source != (Image *) NULL) &&
6807 (LocaleCompare(source->magick,"NULL") == 0))
6810 if (source != (Image *) NULL)
6812 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6813 (GetNextImageInList(source) == (Image *) NULL))
6814 source=(Image *) NULL;
6818 Separate the two lists, junk the null: image.
6820 source=SplitImageList(source->previous);
6821 DeleteImageFromList(&source);
6824 if (source == (Image *) NULL)
6826 (void) ThrowMagickException(exception,GetMagickModule(),
6827 OptionError,"MissingNullSeparator","layers Composite");
6831 Adjust offset with gravity and virtual canvas.
6833 SetGeometry(image,&geometry);
6834 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6835 geometry.width=source->page.width != 0 ? source->page.width :
6837 geometry.height=source->page.height != 0 ? source->page.height :
6839 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6840 image->columns,image->page.height != 0 ? image->page.height :
6841 image->rows,image->gravity,&geometry);
6842 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6843 source=DestroyImageList(source);
6844 InheritException(&(image->exception),exception);
6848 if (layers != (Image *) NULL)
6850 InheritException(&(layers->exception),exception);
6853 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6855 for ( ; image; image=image->next)
6857 AddImageToRegistry(sv,image);
6859 av_push(av,sv_bless(rv,hv));
6862 exception=DestroyExceptionInfo(exception);
6864 SvREFCNT_dec(perl_exception);
6868 InheritPerlException(exception,perl_exception);
6869 exception=DestroyExceptionInfo(exception);
6870 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6871 SvPOK_on(perl_exception);
6872 ST(0)=sv_2mortal(perl_exception);
6877 ###############################################################################
6881 # M a g i c k T o M i m e #
6885 ###############################################################################
6889 MagickToMime(ref,name)
6890 Image::Magick ref=NO_INIT
6899 PERL_UNUSED_VAR(ref);
6900 PERL_UNUSED_VAR(ix);
6901 mime=MagickToMime(name);
6902 RETVAL=newSVpv(mime,0);
6903 mime=(char *) RelinquishMagickMemory(mime);
6909 ###############################################################################
6917 ###############################################################################
6922 Image::Magick ref=NO_INIT
6959 MedianConvolveImage = 36
6965 ReduceNoiseImage = 42
6991 ColorFloodfillImage= 68
6997 CycleColormapImage = 74
7007 MatteFloodfillImage= 84
7015 NumberColorsImage = 92
7025 SignatureImage = 102
7035 TransparentImage = 112
7037 ThresholdImage = 114
7051 DeconstructImage = 130
7053 GaussianBlurImage = 132
7059 UnsharpMaskImage = 138
7061 MotionBlurImage = 140
7063 OrderedDitherImage = 142
7070 AffineTransform = 149
7071 AffineTransformImage = 150
7073 DifferenceImage = 152
7074 AdaptiveThreshold = 153
7075 AdaptiveThresholdImage = 154
7080 BlackThreshold = 159
7081 BlackThresholdImage= 160
7082 WhiteThreshold = 161
7083 WhiteThresholdImage= 162
7085 RadialBlurImage = 164
7087 ThumbnailImage = 166
7097 PosterizeImage = 176
7103 SepiaToneImage = 182
7104 SigmoidalContrast = 183
7105 SigmoidalContrastImage = 184
7110 ContrastStretch = 189
7111 ContrastStretchImage = 190
7116 AdaptiveSharpen = 195
7117 AdaptiveSharpenImage = 196
7119 TransposeImage = 198
7121 TransverseImage = 200
7123 AutoOrientImage = 202
7125 AdaptiveBlurImage = 204
7129 UniqueColorsImage = 208
7130 AdaptiveResize = 209
7131 AdaptiveResizeImage= 210
7135 LinearStretchImage = 214
7142 FloodfillPaint = 221
7143 FloodfillPaintImage= 222
7149 LiquidRescaleImage = 228
7159 SparseColorImage = 238
7163 SelectiveBlurImage = 242
7167 BlueShiftImage = 246
7168 ForwardFourierTransform = 247
7169 ForwardFourierTransformImage = 248
7170 InverseFourierTransform = 249
7171 InverseFourierTransformImage = 250
7172 ColorDecisionList = 251
7173 ColorDecisionListImage = 252
7175 AutoGammaImage = 254
7177 AutoLevelImage = 256
7179 LevelImageColors = 258
7182 BrightnessContrast = 263
7183 BrightnessContrastImage = 264
7185 MorphologyImage = 266
7187 ColorMatrixImage = 268
7193 StatisticImage = 274
7202 attribute_flag[MaxArguments],
7203 message[MaxTextExtent];
7264 argument_list[MaxArguments];
7266 PERL_UNUSED_VAR(ref);
7267 PERL_UNUSED_VAR(ix);
7268 exception=AcquireExceptionInfo();
7269 perl_exception=newSVpv("",0);
7270 reference_vector=NULL;
7274 if (sv_isobject(ST(0)) == 0)
7276 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7280 reference=SvRV(ST(0));
7281 region_info.width=0;
7282 region_info.height=0;
7285 region_image=(Image *) NULL;
7286 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7287 if (ix && (ix != 666))
7290 Called as Method(...)
7293 rp=(&Methods[ix-1]);
7299 Called as Mogrify("Method",...)
7301 attribute=(char *) SvPV(ST(1),na);
7304 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7305 attribute=(char *) SvPV(ST(2),na);
7308 for (rp=Methods; ; rp++)
7310 if (rp >= EndOf(Methods))
7312 ThrowPerlException(exception,OptionError,
7313 "UnrecognizedPerlMagickMethod",attribute);
7316 if (strEQcase(attribute,rp->name))
7322 if (image == (Image *) NULL)
7324 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7327 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7328 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7329 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7346 pp=(Arguments *) NULL;
7354 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7356 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7358 if (strEQcase(attribute,qq->method) > ssize_test)
7361 ssize_test=strEQcase(attribute,qq->method);
7364 if (pp == (Arguments *) NULL)
7366 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7368 goto continue_outer_loop;
7370 al=(&argument_list[pp-rp->arguments]);
7373 case ArrayReference:
7375 if (SvTYPE(sv) != SVt_RV)
7377 (void) FormatLocaleString(message,MaxTextExtent,
7378 "invalid %.60s value",pp->method);
7379 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7380 goto continue_outer_loop;
7382 al->array_reference=SvRV(sv);
7387 al->real_reference=SvNV(sv);
7392 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7395 case ImageReference:
7397 if (!sv_isobject(sv) ||
7398 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7399 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7401 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7407 case IntegerReference:
7409 al->integer_reference=SvIV(sv);
7412 case StringReference:
7414 al->string_reference=(char *) SvPV(sv,al->length);
7415 if (sv_isobject(sv))
7416 al->image_reference=SetupList(aTHX_ SvRV(sv),
7417 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7423 Is a string; look up name.
7425 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7427 al->string_reference=(char *) SvPV(sv,al->length);
7428 al->integer_reference=(-1);
7431 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7432 MagickFalse,SvPV(sv,na));
7433 if (pp->type == MagickChannelOptions)
7434 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7435 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7437 (void) FormatLocaleString(message,MaxTextExtent,
7438 "invalid %.60s value",pp->method);
7439 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7440 goto continue_outer_loop;
7445 attribute_flag[pp-rp->arguments]++;
7446 continue_outer_loop: ;
7448 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7449 pv=reference_vector;
7450 SetGeometryInfo(&geometry_info);
7451 channel=DefaultChannels;
7452 for (next=image; next; next=next->next)
7455 SetGeometry(image,&geometry);
7456 if ((region_info.width*region_info.height) != 0)
7459 image=CropImage(image,®ion_info,exception);
7465 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7466 ThrowPerlException(exception,OptionError,
7467 "UnrecognizedPerlMagickMethod",message);
7470 case 1: /* Comment */
7472 if (attribute_flag[0] == 0)
7473 argument_list[0].string_reference=(char *) NULL;
7474 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7475 info ? info->image_info : (ImageInfo *) NULL,image,
7476 argument_list[0].string_reference,exception));
7481 if (attribute_flag[0] == 0)
7482 argument_list[0].string_reference=(char *) NULL;
7483 (void) SetImageProperty(image,"label",InterpretImageProperties(
7484 info ? info->image_info : (ImageInfo *) NULL,image,
7485 argument_list[0].string_reference,exception));
7488 case 3: /* AddNoise */
7490 if (attribute_flag[0] == 0)
7491 argument_list[0].integer_reference=UniformNoise;
7492 if (attribute_flag[1] != 0)
7493 channel=(ChannelType) argument_list[1].integer_reference;
7494 channel_mask=SetPixelChannelMask(image,channel);
7495 image=AddNoiseImage(image,(NoiseType)
7496 argument_list[0].integer_reference,exception);
7497 if (image != (Image *) NULL)
7498 (void) SetPixelChannelMask(image,channel_mask);
7501 case 4: /* Colorize */
7506 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7507 if (attribute_flag[0] != 0)
7508 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7510 if (attribute_flag[1] == 0)
7511 argument_list[1].string_reference="100%";
7512 image=ColorizeImage(image,argument_list[1].string_reference,target,
7516 case 5: /* Border */
7520 if (attribute_flag[0] != 0)
7522 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7523 &geometry,exception);
7524 if ((flags & HeightValue) == 0)
7525 geometry.height=geometry.width;
7527 if (attribute_flag[1] != 0)
7528 geometry.width=argument_list[1].integer_reference;
7529 if (attribute_flag[2] != 0)
7530 geometry.height=argument_list[2].integer_reference;
7531 if (attribute_flag[3] != 0)
7532 QueryColorDatabase(argument_list[3].string_reference,
7533 &image->border_color,exception);
7534 if (attribute_flag[4] != 0)
7535 QueryColorDatabase(argument_list[4].string_reference,
7536 &image->border_color,exception);
7537 if (attribute_flag[5] != 0)
7538 QueryColorDatabase(argument_list[5].string_reference,
7539 &image->border_color,exception);
7540 if (attribute_flag[6] != 0)
7541 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7542 image=BorderImage(image,&geometry,exception);
7547 if (attribute_flag[0] != 0)
7549 flags=ParseGeometry(argument_list[0].string_reference,
7551 if ((flags & SigmaValue) == 0)
7552 geometry_info.sigma=1.0;
7554 if (attribute_flag[1] != 0)
7555 geometry_info.rho=argument_list[1].real_reference;
7556 if (attribute_flag[2] != 0)
7557 geometry_info.sigma=argument_list[2].real_reference;
7558 if (attribute_flag[3] != 0)
7559 geometry_info.xi=argument_list[3].real_reference;
7560 if (attribute_flag[4] != 0)
7561 channel=(ChannelType) argument_list[4].integer_reference;
7562 channel_mask=SetPixelChannelMask(image,channel);
7563 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7564 geometry_info.xi,exception);
7565 if (image != (Image *) NULL)
7566 (void) SetPixelChannelMask(image,channel_mask);
7571 if (attribute_flag[0] != 0)
7572 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7573 &geometry,exception);
7574 if (attribute_flag[1] != 0)
7575 geometry.width=argument_list[1].integer_reference;
7576 if (attribute_flag[2] != 0)
7577 geometry.height=argument_list[2].integer_reference;
7578 if (attribute_flag[3] != 0)
7579 geometry.x=argument_list[3].integer_reference;
7580 if (attribute_flag[4] != 0)
7581 geometry.y=argument_list[4].integer_reference;
7582 image=ChopImage(image,&geometry,exception);
7587 if (attribute_flag[6] != 0)
7588 image->gravity=(GravityType) argument_list[6].integer_reference;
7589 if (attribute_flag[0] != 0)
7590 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7591 &geometry,exception);
7592 if (attribute_flag[1] != 0)
7593 geometry.width=argument_list[1].integer_reference;
7594 if (attribute_flag[2] != 0)
7595 geometry.height=argument_list[2].integer_reference;
7596 if (attribute_flag[3] != 0)
7597 geometry.x=argument_list[3].integer_reference;
7598 if (attribute_flag[4] != 0)
7599 geometry.y=argument_list[4].integer_reference;
7600 if (attribute_flag[5] != 0)
7602 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7603 image=CropImage(image,&geometry,exception);
7606 case 9: /* Despeckle */
7608 image=DespeckleImage(image,exception);
7613 if (attribute_flag[0] != 0)
7614 geometry_info.rho=argument_list[0].real_reference;
7615 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7619 case 11: /* Emboss */
7621 if (attribute_flag[0] != 0)
7623 flags=ParseGeometry(argument_list[0].string_reference,
7625 if ((flags & SigmaValue) == 0)
7626 geometry_info.sigma=1.0;
7628 if (attribute_flag[1] != 0)
7629 geometry_info.rho=argument_list[1].real_reference;
7630 if (attribute_flag[2] != 0)
7631 geometry_info.sigma=argument_list[2].real_reference;
7632 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7636 case 12: /* Enhance */
7638 image=EnhanceImage(image,exception);
7643 image=FlipImage(image,exception);
7648 image=FlopImage(image,exception);
7651 case 15: /* Frame */
7656 if (attribute_flag[0] != 0)
7658 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7659 &geometry,exception);
7660 if ((flags & HeightValue) == 0)
7661 geometry.height=geometry.width;
7662 frame_info.width=geometry.width;
7663 frame_info.height=geometry.height;
7664 frame_info.outer_bevel=geometry.x;
7665 frame_info.inner_bevel=geometry.y;
7667 if (attribute_flag[1] != 0)
7668 frame_info.width=argument_list[1].integer_reference;
7669 if (attribute_flag[2] != 0)
7670 frame_info.height=argument_list[2].integer_reference;
7671 if (attribute_flag[3] != 0)
7672 frame_info.inner_bevel=argument_list[3].integer_reference;
7673 if (attribute_flag[4] != 0)
7674 frame_info.outer_bevel=argument_list[4].integer_reference;
7675 if (attribute_flag[5] != 0)
7676 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7678 if (attribute_flag[6] != 0)
7679 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7681 frame_info.x=(ssize_t) frame_info.width;
7682 frame_info.y=(ssize_t) frame_info.height;
7683 frame_info.width=image->columns+2*frame_info.x;
7684 frame_info.height=image->rows+2*frame_info.y;
7685 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7686 image->matte_color=fill_color;
7687 if (attribute_flag[7] != 0)
7688 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7689 image=FrameImage(image,&frame_info,exception);
7692 case 16: /* Implode */
7694 if (attribute_flag[0] == 0)
7695 argument_list[0].real_reference=0.5;
7696 if (attribute_flag[1] != 0)
7697 image->interpolate=(InterpolatePixelMethod)
7698 argument_list[1].integer_reference;
7699 image=ImplodeImage(image,argument_list[0].real_reference,
7703 case 17: /* Magnify */
7705 image=MagnifyImage(image,exception);
7708 case 18: /* MedianFilter */
7710 if (attribute_flag[0] != 0)
7712 flags=ParseGeometry(argument_list[0].string_reference,
7714 if ((flags & SigmaValue) == 0)
7715 geometry_info.sigma=geometry_info.rho;
7717 if (attribute_flag[1] != 0)
7718 geometry_info.rho=argument_list[1].real_reference;
7719 if (attribute_flag[2] != 0)
7720 geometry_info.sigma=argument_list[2].real_reference;
7721 if (attribute_flag[3] != 0)
7722 channel=(ChannelType) argument_list[3].integer_reference;
7723 channel_mask=SetPixelChannelMask(image,channel);
7724 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7725 (size_t) geometry_info.sigma,exception);
7726 if (image != (Image *) NULL)
7727 (void) SetPixelChannelMask(image,channel_mask);
7730 case 19: /* Minify */
7732 image=MinifyImage(image,exception);
7735 case 20: /* OilPaint */
7737 if (attribute_flag[0] == 0)
7738 argument_list[0].real_reference=0.0;
7739 if (attribute_flag[1] == 0)
7740 argument_list[1].real_reference=1.0;
7741 image=OilPaintImage(image,argument_list[0].real_reference,
7742 argument_list[1].real_reference,exception);
7745 case 21: /* ReduceNoise */
7747 if (attribute_flag[0] != 0)
7749 flags=ParseGeometry(argument_list[0].string_reference,
7751 if ((flags & SigmaValue) == 0)
7752 geometry_info.sigma=1.0;
7754 if (attribute_flag[1] != 0)
7755 geometry_info.rho=argument_list[1].real_reference;
7756 if (attribute_flag[2] != 0)
7757 geometry_info.sigma=argument_list[2].real_reference;
7758 if (attribute_flag[3] != 0)
7759 channel=(ChannelType) argument_list[3].integer_reference;
7760 channel_mask=SetPixelChannelMask(image,channel);
7761 image=StatisticImage(image,NonpeakStatistic,(size_t)
7762 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7763 if (image != (Image *) NULL)
7764 (void) SetPixelChannelMask(image,channel_mask);
7769 if (attribute_flag[0] != 0)
7770 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7771 &geometry,exception);
7772 if (attribute_flag[1] != 0)
7773 geometry.x=argument_list[1].integer_reference;
7774 if (attribute_flag[2] != 0)
7775 geometry.y=argument_list[2].integer_reference;
7776 image=RollImage(image,geometry.x,geometry.y,exception);
7779 case 23: /* Rotate */
7781 if (attribute_flag[0] == 0)
7782 argument_list[0].real_reference=90.0;
7783 if (attribute_flag[1] != 0)
7784 QueryColorDatabase(argument_list[1].string_reference,
7785 &image->background_color,exception);
7786 if (attribute_flag[2] != 0)
7787 QueryColorDatabase(argument_list[2].string_reference,
7788 &image->background_color,exception);
7789 if (attribute_flag[3] != 0)
7790 QueryColorDatabase(argument_list[3].string_reference,
7791 &image->background_color,exception);
7792 image=RotateImage(image,argument_list[0].real_reference,exception);
7795 case 24: /* Sample */
7797 if (attribute_flag[0] != 0)
7798 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7799 &geometry,exception);
7800 if (attribute_flag[1] != 0)
7801 geometry.width=argument_list[1].integer_reference;
7802 if (attribute_flag[2] != 0)
7803 geometry.height=argument_list[2].integer_reference;
7804 image=SampleImage(image,geometry.width,geometry.height,exception);
7807 case 25: /* Scale */
7809 if (attribute_flag[0] != 0)
7810 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7811 &geometry,exception);
7812 if (attribute_flag[1] != 0)
7813 geometry.width=argument_list[1].integer_reference;
7814 if (attribute_flag[2] != 0)
7815 geometry.height=argument_list[2].integer_reference;
7816 image=ScaleImage(image,geometry.width,geometry.height,exception);
7819 case 26: /* Shade */
7821 if (attribute_flag[0] != 0)
7823 flags=ParseGeometry(argument_list[0].string_reference,
7825 if ((flags & SigmaValue) == 0)
7826 geometry_info.sigma=0.0;
7828 if (attribute_flag[1] != 0)
7829 geometry_info.rho=argument_list[1].real_reference;
7830 if (attribute_flag[2] != 0)
7831 geometry_info.sigma=argument_list[2].real_reference;
7832 image=ShadeImage(image,
7833 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7834 geometry_info.rho,geometry_info.sigma,exception);
7837 case 27: /* Sharpen */
7839 if (attribute_flag[0] != 0)
7841 flags=ParseGeometry(argument_list[0].string_reference,
7843 if ((flags & SigmaValue) == 0)
7844 geometry_info.sigma=1.0;
7846 if (attribute_flag[1] != 0)
7847 geometry_info.rho=argument_list[1].real_reference;
7848 if (attribute_flag[2] != 0)
7849 geometry_info.sigma=argument_list[2].real_reference;
7850 if (attribute_flag[3] != 0)
7851 geometry_info.xi=argument_list[3].real_reference;
7852 if (attribute_flag[4] != 0)
7853 channel=(ChannelType) argument_list[4].integer_reference;
7854 channel_mask=SetPixelChannelMask(image,channel);
7855 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7856 geometry_info.xi,exception);
7857 if (image != (Image *) NULL)
7858 (void) SetPixelChannelMask(image,channel_mask);
7861 case 28: /* Shear */
7863 if (attribute_flag[0] != 0)
7865 flags=ParseGeometry(argument_list[0].string_reference,
7867 if ((flags & SigmaValue) == 0)
7868 geometry_info.sigma=geometry_info.rho;
7870 if (attribute_flag[1] != 0)
7871 geometry_info.rho=argument_list[1].real_reference;
7872 if (attribute_flag[2] != 0)
7873 geometry_info.sigma=argument_list[2].real_reference;
7874 if (attribute_flag[3] != 0)
7875 QueryColorDatabase(argument_list[3].string_reference,
7876 &image->background_color,exception);
7877 if (attribute_flag[4] != 0)
7878 QueryColorDatabase(argument_list[4].string_reference,
7879 &image->background_color,exception);
7880 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7884 case 29: /* Spread */
7886 if (attribute_flag[0] == 0)
7887 argument_list[0].real_reference=1.0;
7888 image=SpreadImage(image,argument_list[0].real_reference,exception);
7891 case 30: /* Swirl */
7893 if (attribute_flag[0] == 0)
7894 argument_list[0].real_reference=50.0;
7895 if (attribute_flag[1] != 0)
7896 image->interpolate=(InterpolatePixelMethod)
7897 argument_list[1].integer_reference;
7898 image=SwirlImage(image,argument_list[0].real_reference,exception);
7901 case 31: /* Resize */
7904 if (attribute_flag[0] != 0)
7905 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7906 &geometry,exception);
7907 if (attribute_flag[1] != 0)
7908 geometry.width=argument_list[1].integer_reference;
7909 if (attribute_flag[2] != 0)
7910 geometry.height=argument_list[2].integer_reference;
7911 if (attribute_flag[3] == 0)
7912 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7913 if (attribute_flag[4] != 0)
7914 SetImageArtifact(image,"filter:support",
7915 argument_list[4].string_reference);
7916 if (attribute_flag[5] == 0)
7917 argument_list[5].real_reference=1.0;
7918 image=ResizeImage(image,geometry.width,geometry.height,
7919 (FilterTypes) argument_list[3].integer_reference,
7920 argument_list[5].real_reference,exception);
7923 case 33: /* Annotate */
7928 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7930 if (attribute_flag[0] != 0)
7935 text=InterpretImageProperties(info ? info->image_info :
7936 (ImageInfo *) NULL,image,argument_list[0].string_reference,
7938 (void) CloneString(&draw_info->text,text);
7939 text=DestroyString(text);
7941 if (attribute_flag[1] != 0)
7942 (void) CloneString(&draw_info->font,
7943 argument_list[1].string_reference);
7944 if (attribute_flag[2] != 0)
7945 draw_info->pointsize=argument_list[2].real_reference;
7946 if (attribute_flag[3] != 0)
7947 (void) CloneString(&draw_info->density,
7948 argument_list[3].string_reference);
7949 if (attribute_flag[4] != 0)
7950 (void) QueryColorDatabase(argument_list[4].string_reference,
7951 &draw_info->undercolor,exception);
7952 if (attribute_flag[5] != 0)
7954 (void) QueryColorDatabase(argument_list[5].string_reference,
7955 &draw_info->stroke,exception);
7956 if (argument_list[5].image_reference != (Image *) NULL)
7957 draw_info->stroke_pattern=CloneImage(
7958 argument_list[5].image_reference,0,0,MagickTrue,exception);
7960 if (attribute_flag[6] != 0)
7962 (void) QueryColorDatabase(argument_list[6].string_reference,
7963 &draw_info->fill,exception);
7964 if (argument_list[6].image_reference != (Image *) NULL)
7965 draw_info->fill_pattern=CloneImage(
7966 argument_list[6].image_reference,0,0,MagickTrue,exception);
7968 if (attribute_flag[7] != 0)
7970 (void) CloneString(&draw_info->geometry,
7971 argument_list[7].string_reference);
7972 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7973 &geometry,exception);
7974 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7975 geometry_info.sigma=geometry_info.xi;
7977 if (attribute_flag[8] != 0)
7978 (void) QueryColorDatabase(argument_list[8].string_reference,
7979 &draw_info->fill,exception);
7980 if (attribute_flag[11] != 0)
7981 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7982 if (attribute_flag[25] != 0)
7987 av=(AV *) argument_list[25].array_reference;
7988 if ((av_len(av) != 3) && (av_len(av) != 5))
7990 ThrowPerlException(exception,OptionError,
7991 "affine matrix must have 4 or 6 elements",PackageName);
7994 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7995 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7996 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7997 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7998 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7999 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8001 ThrowPerlException(exception,OptionError,
8002 "affine matrix is singular",PackageName);
8005 if (av_len(av) == 5)
8007 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8008 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8011 for (j=12; j < 17; j++)
8013 if (attribute_flag[j] == 0)
8015 value=argument_list[j].string_reference;
8016 angle=argument_list[j].real_reference;
8017 current=draw_info->affine;
8018 GetAffineMatrix(&affine);
8026 flags=ParseGeometry(value,&geometry_info);
8027 affine.tx=geometry_info.xi;
8028 affine.ty=geometry_info.psi;
8029 if ((flags & PsiValue) == 0)
8030 affine.ty=affine.tx;
8038 flags=ParseGeometry(value,&geometry_info);
8039 affine.sx=geometry_info.rho;
8040 affine.sy=geometry_info.sigma;
8041 if ((flags & SigmaValue) == 0)
8042 affine.sy=affine.sx;
8052 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8053 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8054 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8055 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8063 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8071 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8075 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8076 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8077 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8078 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8079 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8081 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8084 if (attribute_flag[9] == 0)
8085 argument_list[9].real_reference=0.0;
8086 if (attribute_flag[10] == 0)
8087 argument_list[10].real_reference=0.0;
8088 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8091 geometry[MaxTextExtent];
8093 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8094 (double) argument_list[9].real_reference+draw_info->affine.tx,
8095 (double) argument_list[10].real_reference+draw_info->affine.ty);
8096 (void) CloneString(&draw_info->geometry,geometry);
8098 if (attribute_flag[17] != 0)
8099 draw_info->stroke_width=argument_list[17].real_reference;
8100 if (attribute_flag[18] != 0)
8102 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8103 MagickTrue : MagickFalse;
8104 draw_info->stroke_antialias=draw_info->text_antialias;
8106 if (attribute_flag[19] != 0)
8107 (void) CloneString(&draw_info->family,
8108 argument_list[19].string_reference);
8109 if (attribute_flag[20] != 0)
8110 draw_info->style=(StyleType) argument_list[20].integer_reference;
8111 if (attribute_flag[21] != 0)
8112 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8113 if (attribute_flag[22] != 0)
8114 draw_info->weight=argument_list[22].integer_reference;
8115 if (attribute_flag[23] != 0)
8116 draw_info->align=(AlignType) argument_list[23].integer_reference;
8117 if (attribute_flag[24] != 0)
8118 (void) CloneString(&draw_info->encoding,
8119 argument_list[24].string_reference);
8120 if (attribute_flag[25] != 0)
8121 draw_info->fill_pattern=CloneImage(
8122 argument_list[25].image_reference,0,0,MagickTrue,exception);
8123 if (attribute_flag[26] != 0)
8124 draw_info->fill_pattern=CloneImage(
8125 argument_list[26].image_reference,0,0,MagickTrue,exception);
8126 if (attribute_flag[27] != 0)
8127 draw_info->stroke_pattern=CloneImage(
8128 argument_list[27].image_reference,0,0,MagickTrue,exception);
8129 if (attribute_flag[29] != 0)
8130 draw_info->kerning=argument_list[29].real_reference;
8131 if (attribute_flag[30] != 0)
8132 draw_info->interline_spacing=argument_list[30].real_reference;
8133 if (attribute_flag[31] != 0)
8134 draw_info->interword_spacing=argument_list[31].real_reference;
8135 if (attribute_flag[32] != 0)
8136 draw_info->direction=(DirectionType)
8137 argument_list[32].integer_reference;
8138 (void) AnnotateImage(image,draw_info,exception);
8139 draw_info=DestroyDrawInfo(draw_info);
8142 case 34: /* ColorFloodfill */
8153 draw_info=CloneDrawInfo(info ? info->image_info :
8154 (ImageInfo *) NULL,(DrawInfo *) NULL);
8155 if (attribute_flag[0] != 0)
8156 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8157 &geometry,exception);
8158 if (attribute_flag[1] != 0)
8159 geometry.x=argument_list[1].integer_reference;
8160 if (attribute_flag[2] != 0)
8161 geometry.y=argument_list[2].integer_reference;
8162 if (attribute_flag[3] != 0)
8163 (void) QueryColorDatabase(argument_list[3].string_reference,
8164 &draw_info->fill,exception);
8165 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8168 if (attribute_flag[4] != 0)
8170 QueryMagickColor(argument_list[4].string_reference,&target,
8174 if (attribute_flag[5] != 0)
8175 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8177 if (attribute_flag[6] != 0)
8178 invert=(MagickBooleanType) argument_list[6].integer_reference;
8179 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8180 geometry.y,invert,exception);
8181 draw_info=DestroyDrawInfo(draw_info);
8184 case 35: /* Composite */
8187 composite_geometry[MaxTextExtent];
8193 compose=OverCompositeOp;
8194 if (attribute_flag[0] != 0)
8195 composite_image=argument_list[0].image_reference;
8198 ThrowPerlException(exception,OptionError,
8199 "CompositeImageRequired",PackageName);
8203 Parameter Handling used for BOTH normal and tiled composition.
8205 if (attribute_flag[1] != 0) /* compose */
8206 compose=(CompositeOperator) argument_list[1].integer_reference;
8207 if (attribute_flag[6] != 0) /* opacity */
8209 if (compose != DissolveCompositeOp)
8210 (void) SetImageOpacity(composite_image,(Quantum)
8211 SiPrefixToDouble(argument_list[6].string_reference,
8234 Handle dissolve composite operator (patch by
8237 (void) CloneString(&image->geometry,
8238 argument_list[6].string_reference);
8239 opacity=(Quantum) SiPrefixToDouble(
8240 argument_list[6].string_reference,QuantumRange);
8241 if (composite_image->matte != MagickTrue)
8242 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8243 composite_view=AcquireCacheView(composite_image);
8244 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8246 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8247 composite_image->columns,1,exception);
8248 for (x=0; x < (ssize_t) composite_image->columns; x++)
8250 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8251 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8252 q+=GetPixelChannels(composite_image);
8254 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8255 if (sync == MagickFalse)
8258 composite_view=DestroyCacheView(composite_view);
8261 if (attribute_flag[9] != 0) /* "color=>" */
8262 QueryColorDatabase(argument_list[9].string_reference,
8263 &composite_image->background_color,exception);
8264 if (attribute_flag[12] != 0) /* "interpolate=>" */
8265 image->interpolate=(InterpolatePixelMethod)
8266 argument_list[12].integer_reference;
8267 if (attribute_flag[13] != 0) /* "args=>" */
8268 (void) SetImageArtifact(composite_image,"compose:args",
8269 argument_list[13].string_reference);
8270 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8271 (void) SetImageArtifact(composite_image,"compose:args",
8272 argument_list[14].string_reference);
8274 Tiling Composition (with orthogonal rotate).
8276 rotate_image=(Image *) NULL;
8277 if (attribute_flag[8] != 0) /* "rotate=>" */
8282 rotate_image=RotateImage(composite_image,
8283 argument_list[8].real_reference,exception);
8284 if (rotate_image == (Image *) NULL)
8287 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8294 Tile the composite image.
8296 if (attribute_flag[8] != 0) /* "tile=>" */
8297 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8300 (void) SetImageArtifact(composite_image,
8301 "compose:outside-overlay","false");
8302 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8303 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8305 if (attribute_flag[8] != 0) /* rotate */
8306 (void) CompositeImage(image,compose,rotate_image,x,y);
8308 (void) CompositeImage(image,compose,composite_image,x,y);
8310 if (attribute_flag[8] != 0) /* rotate */
8311 rotate_image=DestroyImage(rotate_image);
8315 Parameter Handling used used ONLY for normal composition.
8317 if (attribute_flag[5] != 0) /* gravity */
8318 image->gravity=(GravityType) argument_list[5].integer_reference;
8319 if (attribute_flag[2] != 0) /* geometry offset */
8321 SetGeometry(image,&geometry);
8322 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8324 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8327 if (attribute_flag[3] != 0) /* x offset */
8328 geometry.x=argument_list[3].integer_reference;
8329 if (attribute_flag[4] != 0) /* y offset */
8330 geometry.y=argument_list[4].integer_reference;
8331 if (attribute_flag[10] != 0) /* mask */
8333 if ((image->compose == DisplaceCompositeOp) ||
8334 (image->compose == DistortCompositeOp))
8337 Merge Y displacement into X displacement image.
8339 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8341 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8342 argument_list[10].image_reference,0,0);
8347 Set a blending mask for the composition.
8349 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8350 MagickTrue,&image->exception);
8351 (void) NegateImage(image->mask,MagickFalse,exception);
8354 if (attribute_flag[11] != 0) /* channel */
8355 channel=(ChannelType) argument_list[11].integer_reference;
8357 Composite two images (normal composition).
8359 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8360 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8361 (double) composite_image->rows,(double) geometry.x,(double)
8363 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8365 channel_mask=SetPixelChannelMask(image,channel);
8366 if (attribute_flag[8] == 0) /* no rotate */
8367 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8371 Position adjust rotated image then composite.
8373 geometry.x-=(ssize_t) (rotate_image->columns-
8374 composite_image->columns)/2;
8375 geometry.y-=(ssize_t) (rotate_image->rows-
8376 composite_image->rows)/2;
8377 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8378 rotate_image=DestroyImage(rotate_image);
8380 if (attribute_flag[10] != 0) /* mask */
8382 if ((image->compose == DisplaceCompositeOp) ||
8383 (image->compose == DistortCompositeOp))
8384 composite_image=DestroyImage(composite_image);
8386 image->mask=DestroyImage(image->mask);
8388 (void) SetPixelChannelMask(image,channel_mask);
8391 case 36: /* Contrast */
8393 if (attribute_flag[0] == 0)
8394 argument_list[0].integer_reference=0;
8395 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8396 MagickTrue : MagickFalse,exception);
8399 case 37: /* CycleColormap */
8401 if (attribute_flag[0] == 0)
8402 argument_list[0].integer_reference=6;
8403 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8412 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8414 (void) CloneString(&draw_info->primitive,"point");
8415 if (attribute_flag[0] != 0)
8417 if (argument_list[0].integer_reference < 0)
8418 (void) CloneString(&draw_info->primitive,
8419 argument_list[0].string_reference);
8421 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8422 MagickPrimitiveOptions,argument_list[0].integer_reference));
8424 if (attribute_flag[1] != 0)
8426 if (LocaleCompare(draw_info->primitive,"path") == 0)
8428 (void) ConcatenateString(&draw_info->primitive," '");
8429 ConcatenateString(&draw_info->primitive,
8430 argument_list[1].string_reference);
8431 (void) ConcatenateString(&draw_info->primitive,"'");
8435 (void) ConcatenateString(&draw_info->primitive," ");
8436 ConcatenateString(&draw_info->primitive,
8437 argument_list[1].string_reference);
8440 if (attribute_flag[2] != 0)
8442 (void) ConcatenateString(&draw_info->primitive," ");
8443 (void) ConcatenateString(&draw_info->primitive,
8444 CommandOptionToMnemonic(MagickMethodOptions,
8445 argument_list[2].integer_reference));
8447 if (attribute_flag[3] != 0)
8449 (void) QueryColorDatabase(argument_list[3].string_reference,
8450 &draw_info->stroke,exception);
8451 if (argument_list[3].image_reference != (Image *) NULL)
8452 draw_info->stroke_pattern=CloneImage(
8453 argument_list[3].image_reference,0,0,MagickTrue,exception);
8455 if (attribute_flag[4] != 0)
8457 (void) QueryColorDatabase(argument_list[4].string_reference,
8458 &draw_info->fill,exception);
8459 if (argument_list[4].image_reference != (Image *) NULL)
8460 draw_info->fill_pattern=CloneImage(
8461 argument_list[4].image_reference,0,0,MagickTrue,exception);
8463 if (attribute_flag[5] != 0)
8464 draw_info->stroke_width=argument_list[5].real_reference;
8465 if (attribute_flag[6] != 0)
8466 (void) CloneString(&draw_info->font,
8467 argument_list[6].string_reference);
8468 if (attribute_flag[7] != 0)
8469 (void) QueryColorDatabase(argument_list[7].string_reference,
8470 &draw_info->border_color,exception);
8471 if (attribute_flag[8] != 0)
8472 draw_info->affine.tx=argument_list[8].real_reference;
8473 if (attribute_flag[9] != 0)
8474 draw_info->affine.ty=argument_list[9].real_reference;
8475 if (attribute_flag[20] != 0)
8480 av=(AV *) argument_list[20].array_reference;
8481 if ((av_len(av) != 3) && (av_len(av) != 5))
8483 ThrowPerlException(exception,OptionError,
8484 "affine matrix must have 4 or 6 elements",PackageName);
8487 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8488 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8489 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8490 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8491 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8492 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8494 ThrowPerlException(exception,OptionError,
8495 "affine matrix is singular",PackageName);
8498 if (av_len(av) == 5)
8500 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8501 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8504 for (j=10; j < 15; j++)
8506 if (attribute_flag[j] == 0)
8508 value=argument_list[j].string_reference;
8509 angle=argument_list[j].real_reference;
8510 current=draw_info->affine;
8511 GetAffineMatrix(&affine);
8519 flags=ParseGeometry(value,&geometry_info);
8520 affine.tx=geometry_info.xi;
8521 affine.ty=geometry_info.psi;
8522 if ((flags & PsiValue) == 0)
8523 affine.ty=affine.tx;
8531 flags=ParseGeometry(value,&geometry_info);
8532 affine.sx=geometry_info.rho;
8533 affine.sy=geometry_info.sigma;
8534 if ((flags & SigmaValue) == 0)
8535 affine.sy=affine.sx;
8545 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8546 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8547 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8548 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8556 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8564 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8568 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8569 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8570 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8571 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8572 draw_info->affine.tx=
8573 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8574 draw_info->affine.ty=
8575 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8577 if (attribute_flag[15] != 0)
8578 draw_info->fill_pattern=CloneImage(
8579 argument_list[15].image_reference,0,0,MagickTrue,exception);
8580 if (attribute_flag[16] != 0)
8581 draw_info->pointsize=argument_list[16].real_reference;
8582 if (attribute_flag[17] != 0)
8584 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8585 ? MagickTrue : MagickFalse;
8586 draw_info->text_antialias=draw_info->stroke_antialias;
8588 if (attribute_flag[18] != 0)
8589 (void) CloneString(&draw_info->density,
8590 argument_list[18].string_reference);
8591 if (attribute_flag[19] != 0)
8592 draw_info->stroke_width=argument_list[19].real_reference;
8593 if (attribute_flag[21] != 0)
8594 draw_info->dash_offset=argument_list[21].real_reference;
8595 if (attribute_flag[22] != 0)
8600 av=(AV *) argument_list[22].array_reference;
8601 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8602 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8603 if (draw_info->dash_pattern != (double *) NULL)
8605 for (i=0; i <= av_len(av); i++)
8606 draw_info->dash_pattern[i]=(double)
8607 SvNV(*(av_fetch(av,i,0)));
8608 draw_info->dash_pattern[i]=0.0;
8611 if (attribute_flag[23] != 0)
8612 image->interpolate=(InterpolatePixelMethod)
8613 argument_list[23].integer_reference;
8614 if ((attribute_flag[24] != 0) &&
8615 (draw_info->fill_pattern != (Image *) NULL))
8616 flags=ParsePageGeometry(draw_info->fill_pattern,
8617 argument_list[24].string_reference,
8618 &draw_info->fill_pattern->tile_offset,exception);
8619 if (attribute_flag[25] != 0)
8621 (void) ConcatenateString(&draw_info->primitive," '");
8622 (void) ConcatenateString(&draw_info->primitive,
8623 argument_list[25].string_reference);
8624 (void) ConcatenateString(&draw_info->primitive,"'");
8626 if (attribute_flag[26] != 0)
8627 draw_info->fill_pattern=CloneImage(
8628 argument_list[26].image_reference,0,0,MagickTrue,exception);
8629 if (attribute_flag[27] != 0)
8630 draw_info->stroke_pattern=CloneImage(
8631 argument_list[27].image_reference,0,0,MagickTrue,exception);
8632 if (attribute_flag[28] != 0)
8633 (void) CloneString(&draw_info->primitive,
8634 argument_list[28].string_reference);
8635 if (attribute_flag[29] != 0)
8636 draw_info->kerning=argument_list[29].real_reference;
8637 if (attribute_flag[30] != 0)
8638 draw_info->interline_spacing=argument_list[30].real_reference;
8639 if (attribute_flag[31] != 0)
8640 draw_info->interword_spacing=argument_list[31].real_reference;
8641 if (attribute_flag[32] != 0)
8642 draw_info->direction=(DirectionType)
8643 argument_list[32].integer_reference;
8644 DrawImage(image,draw_info,exception);
8645 draw_info=DestroyDrawInfo(draw_info);
8648 case 39: /* Equalize */
8650 if (attribute_flag[0] != 0)
8651 channel=(ChannelType) argument_list[0].integer_reference;
8652 channel_mask=SetPixelChannelMask(image,channel);
8653 EqualizeImage(image,exception);
8654 (void) SetPixelChannelMask(image,channel_mask);
8657 case 40: /* Gamma */
8659 if (attribute_flag[1] != 0)
8660 channel=(ChannelType) argument_list[1].integer_reference;
8661 if (attribute_flag[2] == 0)
8662 argument_list[2].real_reference=1.0;
8663 if (attribute_flag[3] == 0)
8664 argument_list[3].real_reference=1.0;
8665 if (attribute_flag[4] == 0)
8666 argument_list[4].real_reference=1.0;
8667 if (attribute_flag[0] == 0)
8669 (void) FormatLocaleString(message,MaxTextExtent,
8670 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8671 (double) argument_list[3].real_reference,
8672 (double) argument_list[4].real_reference);
8673 argument_list[0].string_reference=message;
8675 (void) GammaImage(image,InterpretLocaleValue(
8676 argument_list[0].string_reference,(char **) NULL),exception);
8684 if (attribute_flag[0] == 0)
8686 ThrowPerlException(exception,OptionError,"MapImageRequired",
8690 quantize_info=AcquireQuantizeInfo(info->image_info);
8691 if (attribute_flag[1] != 0)
8692 quantize_info->dither=(MagickBooleanType)
8693 argument_list[1].integer_reference;
8694 if (attribute_flag[2] != 0)
8695 quantize_info->dither_method=(DitherMethod)
8696 argument_list[2].integer_reference;
8697 (void) RemapImages(quantize_info,image,
8698 argument_list[0].image_reference,exception);
8699 quantize_info=DestroyQuantizeInfo(quantize_info);
8702 case 42: /* MatteFloodfill */
8713 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8715 if (attribute_flag[0] != 0)
8716 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8717 &geometry,exception);
8718 if (attribute_flag[1] != 0)
8719 geometry.x=argument_list[1].integer_reference;
8720 if (attribute_flag[2] != 0)
8721 geometry.y=argument_list[2].integer_reference;
8722 if (image->matte == MagickFalse)
8723 (void) SetImageOpacity(image,OpaqueAlpha);
8724 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8726 if (attribute_flag[4] != 0)
8727 QueryMagickColor(argument_list[4].string_reference,&target,
8729 if (attribute_flag[3] != 0)
8730 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8732 if (attribute_flag[5] != 0)
8733 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8736 if (attribute_flag[6] != 0)
8737 invert=(MagickBooleanType) argument_list[6].integer_reference;
8738 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8739 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8740 geometry.y,invert,exception);
8741 (void) SetPixelChannelMask(image,channel_mask);
8742 draw_info=DestroyDrawInfo(draw_info);
8745 case 43: /* Modulate */
8748 modulate[MaxTextExtent];
8750 geometry_info.rho=100.0;
8751 geometry_info.sigma=100.0;
8752 geometry_info.xi=100.0;
8753 if (attribute_flag[0] != 0)
8754 (void)ParseGeometry(argument_list[0].string_reference,
8756 if (attribute_flag[1] != 0)
8757 geometry_info.xi=argument_list[1].real_reference;
8758 if (attribute_flag[2] != 0)
8759 geometry_info.sigma=argument_list[2].real_reference;
8760 if (attribute_flag[3] != 0)
8762 geometry_info.sigma=argument_list[3].real_reference;
8763 SetImageArtifact(image,"modulate:colorspace","HWB");
8765 if (attribute_flag[4] != 0)
8767 geometry_info.rho=argument_list[4].real_reference;
8768 SetImageArtifact(image,"modulate:colorspace","HSB");
8770 if (attribute_flag[5] != 0)
8772 geometry_info.sigma=argument_list[5].real_reference;
8773 SetImageArtifact(image,"modulate:colorspace","HSL");
8775 if (attribute_flag[6] != 0)
8777 geometry_info.rho=argument_list[6].real_reference;
8778 SetImageArtifact(image,"modulate:colorspace","HWB");
8780 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8781 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8782 (void) ModulateImage(image,modulate,exception);
8785 case 44: /* Negate */
8787 if (attribute_flag[0] == 0)
8788 argument_list[0].integer_reference=0;
8789 if (attribute_flag[1] != 0)
8790 channel=(ChannelType) argument_list[1].integer_reference;
8791 channel_mask=SetPixelChannelMask(image,channel);
8792 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8793 MagickTrue : MagickFalse,exception);
8794 (void) SetPixelChannelMask(image,channel_mask);
8797 case 45: /* Normalize */
8799 if (attribute_flag[0] != 0)
8800 channel=(ChannelType) argument_list[0].integer_reference;
8801 channel_mask=SetPixelChannelMask(image,channel);
8802 NormalizeImage(image,exception);
8803 (void) SetPixelChannelMask(image,channel_mask);
8806 case 46: /* NumberColors */
8808 case 47: /* Opaque */
8817 (void) QueryMagickColor("none",&target,exception);
8818 (void) QueryMagickColor("none",&fill_color,exception);
8819 if (attribute_flag[0] != 0)
8820 (void) QueryMagickColor(argument_list[0].string_reference,
8822 if (attribute_flag[1] != 0)
8823 (void) QueryMagickColor(argument_list[1].string_reference,
8824 &fill_color,exception);
8825 if (attribute_flag[2] != 0)
8826 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8828 if (attribute_flag[3] != 0)
8829 channel=(ChannelType) argument_list[3].integer_reference;
8831 if (attribute_flag[4] != 0)
8832 invert=(MagickBooleanType) argument_list[4].integer_reference;
8833 channel_mask=SetPixelChannelMask(image,channel);
8834 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8835 (void) SetPixelChannelMask(image,channel_mask);
8838 case 48: /* Quantize */
8843 quantize_info=AcquireQuantizeInfo(info->image_info);
8844 if (attribute_flag[0] != 0)
8845 quantize_info->number_colors=(size_t)
8846 argument_list[0].integer_reference;
8847 if (attribute_flag[1] != 0)
8848 quantize_info->tree_depth=(size_t)
8849 argument_list[1].integer_reference;
8850 if (attribute_flag[2] != 0)
8851 quantize_info->colorspace=(ColorspaceType)
8852 argument_list[2].integer_reference;
8853 if (attribute_flag[3] != 0)
8854 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8855 MagickTrue : MagickFalse;
8856 if (attribute_flag[4] != 0)
8857 quantize_info->measure_error=
8858 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8859 if (attribute_flag[5] != 0)
8860 (void) QueryColorDatabase(argument_list[5].string_reference,
8861 &image->transparent_color,exception);
8862 if (attribute_flag[5] && argument_list[5].integer_reference)
8864 (void) QuantizeImages(quantize_info,image,exception);
8867 if (attribute_flag[6] != 0)
8868 quantize_info->dither_method=(DitherMethod)
8869 argument_list[6].integer_reference;
8870 if ((image->storage_class == DirectClass) ||
8871 (image->colors > quantize_info->number_colors) ||
8872 (quantize_info->colorspace == GRAYColorspace))
8873 (void) QuantizeImage(quantize_info,image,exception);
8875 CompressImageColormap(image,exception);
8876 quantize_info=DestroyQuantizeInfo(quantize_info);
8879 case 49: /* Raise */
8881 if (attribute_flag[0] != 0)
8882 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8883 &geometry,exception);
8884 if (attribute_flag[1] != 0)
8885 geometry.width=argument_list[1].integer_reference;
8886 if (attribute_flag[2] != 0)
8887 geometry.height=argument_list[2].integer_reference;
8888 if (attribute_flag[3] == 0)
8889 argument_list[3].integer_reference=1;
8890 (void) RaiseImage(image,&geometry,
8891 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8895 case 50: /* Segment */
8902 smoothing_threshold;
8907 cluster_threshold=1.0;
8908 smoothing_threshold=1.5;
8909 colorspace=RGBColorspace;
8910 verbose=MagickFalse;
8911 if (attribute_flag[0] != 0)
8913 flags=ParseGeometry(argument_list[0].string_reference,
8915 cluster_threshold=geometry_info.rho;
8916 if (flags & SigmaValue)
8917 smoothing_threshold=geometry_info.sigma;
8919 if (attribute_flag[1] != 0)
8920 cluster_threshold=argument_list[1].real_reference;
8921 if (attribute_flag[2] != 0)
8922 smoothing_threshold=argument_list[2].real_reference;
8923 if (attribute_flag[3] != 0)
8924 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8925 if (attribute_flag[4] != 0)
8926 verbose=argument_list[4].integer_reference != 0 ?
8927 MagickTrue : MagickFalse;
8928 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8929 smoothing_threshold,exception);
8932 case 51: /* Signature */
8934 (void) SignatureImage(image,exception);
8937 case 52: /* Solarize */
8939 geometry_info.rho=QuantumRange/2.0;
8940 if (attribute_flag[0] != 0)
8941 flags=ParseGeometry(argument_list[0].string_reference,
8943 if (attribute_flag[1] != 0)
8944 geometry_info.rho=SiPrefixToDouble(
8945 argument_list[1].string_reference,QuantumRange);
8946 (void) SolarizeImage(image,geometry_info.rho,exception);
8951 (void) SyncImage(image);
8954 case 54: /* Texture */
8956 if (attribute_flag[0] == 0)
8958 TextureImage(image,argument_list[0].image_reference);
8961 case 55: /* Evalute */
8963 MagickEvaluateOperator
8966 op=SetEvaluateOperator;
8967 if (attribute_flag[0] == MagickFalse)
8968 argument_list[0].real_reference=0.0;
8969 if (attribute_flag[1] != MagickFalse)
8970 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8971 if (attribute_flag[2] != MagickFalse)
8972 channel=(ChannelType) argument_list[2].integer_reference;
8973 channel_mask=SetPixelChannelMask(image,channel);
8974 (void) EvaluateImage(image,op,argument_list[0].real_reference,
8976 (void) SetPixelChannelMask(image,channel_mask);
8979 case 56: /* Transparent */
8990 (void) QueryMagickColor("none",&target,exception);
8991 if (attribute_flag[0] != 0)
8992 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8994 opacity=TransparentAlpha;
8995 if (attribute_flag[1] != 0)
8996 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8998 if (attribute_flag[2] != 0)
8999 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
9001 if (attribute_flag[3] == 0)
9002 argument_list[3].integer_reference=0;
9004 if (attribute_flag[3] != 0)
9005 invert=(MagickBooleanType) argument_list[3].integer_reference;
9006 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9010 case 57: /* Threshold */
9015 if (attribute_flag[0] == 0)
9016 argument_list[0].string_reference="50%";
9017 if (attribute_flag[1] != 0)
9018 channel=(ChannelType) argument_list[1].integer_reference;
9019 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9021 channel_mask=SetPixelChannelMask(image,channel);
9022 (void) BilevelImage(image,threshold);
9023 (void) SetPixelChannelMask(image,channel_mask);
9026 case 58: /* Charcoal */
9028 if (attribute_flag[0] != 0)
9030 flags=ParseGeometry(argument_list[0].string_reference,
9032 if ((flags & SigmaValue) == 0)
9033 geometry_info.sigma=1.0;
9035 if (attribute_flag[1] != 0)
9036 geometry_info.rho=argument_list[1].real_reference;
9037 if (attribute_flag[2] != 0)
9038 geometry_info.sigma=argument_list[2].real_reference;
9039 if (attribute_flag[3] != 0)
9040 geometry_info.xi=argument_list[3].real_reference;
9041 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9042 geometry_info.xi,exception);
9047 if (attribute_flag[0] != 0)
9048 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9050 image=TrimImage(image,exception);
9055 if (attribute_flag[0] != 0)
9057 flags=ParseGeometry(argument_list[0].string_reference,
9059 if ((flags & SigmaValue) == 0)
9060 geometry_info.sigma=1.0;
9062 if (attribute_flag[1] != 0)
9063 geometry_info.rho=argument_list[1].real_reference;
9064 if (attribute_flag[2] != 0)
9065 geometry_info.sigma=argument_list[2].real_reference;
9066 if (attribute_flag[3] != 0)
9067 image->interpolate=(InterpolatePixelMethod)
9068 argument_list[3].integer_reference;
9069 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9073 case 61: /* Separate */
9075 if (attribute_flag[0] != 0)
9076 channel=(ChannelType) argument_list[0].integer_reference;
9077 channel_mask=SetPixelChannelMask(image,channel);
9078 (void) SeparateImage(image);
9079 (void) SetPixelChannelMask(image,channel_mask);
9082 case 63: /* Stereo */
9084 if (attribute_flag[0] == 0)
9086 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9090 if (attribute_flag[1] != 0)
9091 geometry.x=argument_list[1].integer_reference;
9092 if (attribute_flag[2] != 0)
9093 geometry.y=argument_list[2].integer_reference;
9094 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9095 geometry.x,geometry.y,exception);
9098 case 64: /* Stegano */
9100 if (attribute_flag[0] == 0)
9102 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9106 if (attribute_flag[1] == 0)
9107 argument_list[1].integer_reference=0;
9108 image->offset=argument_list[1].integer_reference;
9109 image=SteganoImage(image,argument_list[0].image_reference,exception);
9112 case 65: /* Deconstruct */
9114 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9117 case 66: /* GaussianBlur */
9119 if (attribute_flag[0] != 0)
9121 flags=ParseGeometry(argument_list[0].string_reference,
9123 if ((flags & SigmaValue) == 0)
9124 geometry_info.sigma=1.0;
9126 if (attribute_flag[1] != 0)
9127 geometry_info.rho=argument_list[1].real_reference;
9128 if (attribute_flag[2] != 0)
9129 geometry_info.sigma=argument_list[2].real_reference;
9130 if (attribute_flag[3] != 0)
9131 geometry_info.xi=argument_list[3].real_reference;
9132 if (attribute_flag[4] != 0)
9133 channel=(ChannelType) argument_list[4].integer_reference;
9134 channel_mask=SetPixelChannelMask(image,channel);
9135 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9136 geometry_info.xi,exception);
9137 if (image != (Image *) NULL)
9138 (void) SetPixelChannelMask(image,channel_mask);
9141 case 67: /* Convolve */
9146 kernel=(KernelInfo *) NULL;
9147 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9149 if (attribute_flag[0] != 0)
9157 kernel=AcquireKernelInfo((const char *) NULL);
9158 if (kernel == (KernelInfo *) NULL)
9160 av=(AV *) argument_list[0].array_reference;
9161 order=(size_t) sqrt(av_len(av)+1);
9162 kernel->width=order;
9163 kernel->height=order;
9164 kernel->values=(double *) AcquireQuantumMemory(order,order*
9165 sizeof(*kernel->values));
9166 if (kernel->values == (double *) NULL)
9168 kernel=DestroyKernelInfo(kernel);
9169 ThrowPerlException(exception,ResourceLimitFatalError,
9170 "MemoryAllocationFailed",PackageName);
9173 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9174 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9175 for ( ; j < (ssize_t) (order*order); j++)
9176 kernel->values[j]=0.0;
9178 if (attribute_flag[1] != 0)
9179 channel=(ChannelType) argument_list[1].integer_reference;
9180 if (attribute_flag[2] != 0)
9181 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9183 if (attribute_flag[3] != 0)
9185 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9186 if (kernel == (KernelInfo *) NULL)
9189 channel_mask=SetPixelChannelMask(image,channel);
9190 kernel->bias=image->bias;
9191 image=ConvolveImage(image,kernel,exception);
9192 if (image != (Image *) NULL)
9193 (void) SetPixelChannelMask(image,channel_mask);
9194 kernel=DestroyKernelInfo(kernel);
9197 case 68: /* Profile */
9212 if (attribute_flag[0] != 0)
9213 name=argument_list[0].string_reference;
9214 if (attribute_flag[2] != 0)
9215 image->rendering_intent=(RenderingIntent)
9216 argument_list[2].integer_reference;
9217 if (attribute_flag[3] != 0)
9218 image->black_point_compensation=
9219 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9220 if (attribute_flag[1] != 0)
9222 if (argument_list[1].length == 0)
9225 Remove a profile from the image.
9227 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9232 Associate user supplied profile with the image.
9234 profile=AcquireStringInfo(argument_list[1].length);
9235 SetStringInfoDatum(profile,(const unsigned char *)
9236 argument_list[1].string_reference);
9237 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9238 (size_t) GetStringInfoLength(profile),MagickFalse);
9239 profile=DestroyStringInfo(profile);
9243 Associate a profile with the image.
9246 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9247 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9248 profile_image=ReadImages(profile_info,&image->exception);
9249 if (profile_image == (Image *) NULL)
9251 ResetImageProfileIterator(profile_image);
9252 name=GetNextImageProfile(profile_image);
9253 while (name != (const char *) NULL)
9258 profile=GetImageProfile(profile_image,name);
9259 if (profile != (const StringInfo *) NULL)
9260 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9261 (size_t) GetStringInfoLength(profile),MagickFalse);
9262 name=GetNextImageProfile(profile_image);
9264 profile_image=DestroyImage(profile_image);
9265 profile_info=DestroyImageInfo(profile_info);
9268 case 69: /* UnsharpMask */
9270 if (attribute_flag[0] != 0)
9272 flags=ParseGeometry(argument_list[0].string_reference,
9274 if ((flags & SigmaValue) == 0)
9275 geometry_info.sigma=1.0;
9276 if ((flags & XiValue) == 0)
9277 geometry_info.xi=1.0;
9278 if ((flags & PsiValue) == 0)
9279 geometry_info.psi=0.5;
9281 if (attribute_flag[1] != 0)
9282 geometry_info.rho=argument_list[1].real_reference;
9283 if (attribute_flag[2] != 0)
9284 geometry_info.sigma=argument_list[2].real_reference;
9285 if (attribute_flag[3] != 0)
9286 geometry_info.xi=argument_list[3].real_reference;
9287 if (attribute_flag[4] != 0)
9288 geometry_info.psi=argument_list[4].real_reference;
9289 if (attribute_flag[5] != 0)
9290 channel=(ChannelType) argument_list[5].integer_reference;
9291 channel_mask=SetPixelChannelMask(image,channel);
9292 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9293 geometry_info.xi,geometry_info.psi,exception);
9294 if (image != (Image *) NULL)
9295 (void) SetPixelChannelMask(image,channel_mask);
9298 case 70: /* MotionBlur */
9300 if (attribute_flag[0] != 0)
9302 flags=ParseGeometry(argument_list[0].string_reference,
9304 if ((flags & SigmaValue) == 0)
9305 geometry_info.sigma=1.0;
9306 if ((flags & XiValue) == 0)
9307 geometry_info.xi=1.0;
9309 if (attribute_flag[1] != 0)
9310 geometry_info.rho=argument_list[1].real_reference;
9311 if (attribute_flag[2] != 0)
9312 geometry_info.sigma=argument_list[2].real_reference;
9313 if (attribute_flag[3] != 0)
9314 geometry_info.xi=argument_list[3].real_reference;
9315 if (attribute_flag[4] != 0)
9316 geometry_info.psi=argument_list[4].real_reference;
9317 if (attribute_flag[5] != 0)
9318 channel=(ChannelType) argument_list[5].integer_reference;
9319 channel_mask=SetPixelChannelMask(image,channel);
9320 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9321 geometry_info.xi,geometry_info.psi,exception);
9322 if (image != (Image *) NULL)
9323 (void) SetPixelChannelMask(image,channel_mask);
9326 case 71: /* OrderedDither */
9328 if (attribute_flag[0] == 0)
9329 argument_list[0].string_reference="o8x8";
9330 if (attribute_flag[1] != 0)
9331 channel=(ChannelType) argument_list[1].integer_reference;
9332 channel_mask=SetPixelChannelMask(image,channel);
9333 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9335 (void) SetPixelChannelMask(image,channel_mask);
9338 case 72: /* Shave */
9340 if (attribute_flag[0] != 0)
9341 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9342 &geometry,exception);
9343 if (attribute_flag[1] != 0)
9344 geometry.width=argument_list[1].integer_reference;
9345 if (attribute_flag[2] != 0)
9346 geometry.height=argument_list[2].integer_reference;
9347 image=ShaveImage(image,&geometry,exception);
9350 case 73: /* Level */
9358 white_point=(MagickRealType) image->columns*image->rows;
9360 if (attribute_flag[0] != 0)
9362 flags=ParseGeometry(argument_list[0].string_reference,
9364 black_point=geometry_info.rho;
9365 if ((flags & SigmaValue) != 0)
9366 white_point=geometry_info.sigma;
9367 if ((flags & XiValue) != 0)
9368 gamma=geometry_info.xi;
9369 if ((flags & PercentValue) != 0)
9371 black_point*=(double) (QuantumRange/100.0);
9372 white_point*=(double) (QuantumRange/100.0);
9374 if ((flags & SigmaValue) == 0)
9375 white_point=(double) QuantumRange-black_point;
9377 if (attribute_flag[1] != 0)
9378 black_point=argument_list[1].real_reference;
9379 if (attribute_flag[2] != 0)
9380 white_point=argument_list[2].real_reference;
9381 if (attribute_flag[3] != 0)
9382 gamma=argument_list[3].real_reference;
9383 if (attribute_flag[4] != 0)
9384 channel=(ChannelType) argument_list[4].integer_reference;
9385 if (attribute_flag[5] != 0)
9387 argument_list[0].real_reference=argument_list[5].real_reference;
9388 attribute_flag[0]=attribute_flag[5];
9390 channel_mask=SetPixelChannelMask(image,channel);
9391 (void) LevelImage(image,black_point,white_point,gamma,exception);
9392 (void) SetPixelChannelMask(image,channel_mask);
9397 if (attribute_flag[0] == 0)
9398 argument_list[0].string_reference="#1";
9399 if (attribute_flag[1] == 0)
9400 argument_list[1].integer_reference=MagickTrue;
9401 (void) ClipImagePath(image,argument_list[0].string_reference,
9402 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9406 case 75: /* AffineTransform */
9411 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9413 if (attribute_flag[0] != 0)
9418 av=(AV *) argument_list[0].array_reference;
9419 if ((av_len(av) != 3) && (av_len(av) != 5))
9421 ThrowPerlException(exception,OptionError,
9422 "affine matrix must have 4 or 6 elements",PackageName);
9425 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9426 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9427 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9428 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9429 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9430 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9432 ThrowPerlException(exception,OptionError,
9433 "affine matrix is singular",PackageName);
9436 if (av_len(av) == 5)
9438 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9439 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9442 for (j=1; j < 6; j++)
9444 if (attribute_flag[j] == 0)
9446 value=argument_list[j].string_reference;
9447 angle=argument_list[j].real_reference;
9448 current=draw_info->affine;
9449 GetAffineMatrix(&affine);
9457 flags=ParseGeometry(value,&geometry_info);
9458 affine.tx=geometry_info.xi;
9459 affine.ty=geometry_info.psi;
9460 if ((flags & PsiValue) == 0)
9461 affine.ty=affine.tx;
9469 flags=ParseGeometry(value,&geometry_info);
9470 affine.sx=geometry_info.rho;
9471 affine.sy=geometry_info.sigma;
9472 if ((flags & SigmaValue) == 0)
9473 affine.sy=affine.sx;
9483 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9484 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9485 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9486 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9494 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9502 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9506 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9507 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9508 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9509 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9510 draw_info->affine.tx=
9511 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9512 draw_info->affine.ty=
9513 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9515 if (attribute_flag[6] != 0)
9516 image->interpolate=(InterpolatePixelMethod)
9517 argument_list[6].integer_reference;
9518 if (attribute_flag[7] != 0)
9519 QueryColorDatabase(argument_list[7].string_reference,
9520 &image->background_color,exception);
9521 image=AffineTransformImage(image,&draw_info->affine,exception);
9522 draw_info=DestroyDrawInfo(draw_info);
9525 case 76: /* Difference */
9527 if (attribute_flag[0] == 0)
9529 ThrowPerlException(exception,OptionError,
9530 "ReferenceImageRequired",PackageName);
9533 if (attribute_flag[1] != 0)
9534 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9536 (void) IsImagesEqual(image,argument_list[0].image_reference,
9540 case 77: /* AdaptiveThreshold */
9542 if (attribute_flag[0] != 0)
9544 flags=ParseGeometry(argument_list[0].string_reference,
9546 if ((flags & PercentValue) != 0)
9547 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9549 if (attribute_flag[1] != 0)
9550 geometry_info.rho=argument_list[1].integer_reference;
9551 if (attribute_flag[2] != 0)
9552 geometry_info.sigma=argument_list[2].integer_reference;
9553 if (attribute_flag[3] != 0)
9554 geometry_info.xi=argument_list[3].integer_reference;;
9555 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9556 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9559 case 78: /* Resample */
9565 if (attribute_flag[0] != 0)
9567 flags=ParseGeometry(argument_list[0].string_reference,
9569 if ((flags & SigmaValue) == 0)
9570 geometry_info.sigma=geometry_info.rho;
9572 if (attribute_flag[1] != 0)
9573 geometry_info.rho=argument_list[1].real_reference;
9574 if (attribute_flag[2] != 0)
9575 geometry_info.sigma=argument_list[2].real_reference;
9576 if (attribute_flag[3] == 0)
9577 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9578 if (attribute_flag[4] == 0)
9579 SetImageArtifact(image,"filter:support",
9580 argument_list[4].string_reference);
9581 if (attribute_flag[5] != 0)
9582 argument_list[5].real_reference=1.0;
9583 width=(size_t) (geometry_info.rho*image->columns/
9584 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9585 height=(size_t) (geometry_info.sigma*image->rows/
9586 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9587 image=ResizeImage(image,width,height,(FilterTypes)
9588 argument_list[3].integer_reference,argument_list[5].real_reference,
9590 if (image != (Image *) NULL)
9592 image->x_resolution=geometry_info.rho;
9593 image->y_resolution=geometry_info.sigma;
9597 case 79: /* Describe */
9599 if (attribute_flag[0] == 0)
9600 argument_list[0].file_reference=(FILE *) NULL;
9601 if (attribute_flag[1] != 0)
9602 (void) SetImageArtifact(image,"identify:features",
9603 argument_list[1].string_reference);
9604 (void) IdentifyImage(image,argument_list[0].file_reference,
9605 MagickTrue,exception);
9608 case 80: /* BlackThreshold */
9610 if (attribute_flag[0] == 0)
9611 argument_list[0].string_reference="50%";
9612 if (attribute_flag[2] != 0)
9613 channel=(ChannelType) argument_list[2].integer_reference;
9614 channel_mask=SetPixelChannelMask(image,channel);
9615 BlackThresholdImage(image,argument_list[0].string_reference,
9617 (void) SetPixelChannelMask(image,channel_mask);
9620 case 81: /* WhiteThreshold */
9622 if (attribute_flag[0] == 0)
9623 argument_list[0].string_reference="50%";
9624 if (attribute_flag[2] != 0)
9625 channel=(ChannelType) argument_list[2].integer_reference;
9626 channel_mask=SetPixelChannelMask(image,channel);
9627 WhiteThresholdImage(image,argument_list[0].string_reference,
9629 (void) SetPixelChannelMask(image,channel_mask);
9632 case 82: /* RadialBlur */
9634 if (attribute_flag[0] != 0)
9636 flags=ParseGeometry(argument_list[0].string_reference,
9639 if (attribute_flag[1] != 0)
9640 geometry_info.rho=argument_list[1].real_reference;
9641 if (attribute_flag[2] != 0)
9642 geometry_info.sigma=argument_list[2].real_reference;
9643 if (attribute_flag[3] != 0)
9644 channel=(ChannelType) argument_list[3].integer_reference;
9645 channel_mask=SetPixelChannelMask(image,channel);
9646 image=RadialBlurImage(image,geometry_info.rho,geometry_info.sigma,
9648 if (image != (Image *) NULL)
9649 (void) SetPixelChannelMask(image,channel_mask);
9652 case 83: /* Thumbnail */
9654 if (attribute_flag[0] != 0)
9655 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9656 &geometry,exception);
9657 if (attribute_flag[1] != 0)
9658 geometry.width=argument_list[1].integer_reference;
9659 if (attribute_flag[2] != 0)
9660 geometry.height=argument_list[2].integer_reference;
9661 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9664 case 84: /* Strip */
9666 (void) StripImage(image);
9674 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9675 if (attribute_flag[0] != 0)
9676 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9678 if (attribute_flag[1] == 0)
9679 argument_list[1].string_reference="100";
9680 image=TintImage(image,argument_list[1].string_reference,target,
9684 case 86: /* Channel */
9686 if (attribute_flag[0] != 0)
9687 channel=(ChannelType) argument_list[0].integer_reference;
9688 channel_mask=SetPixelChannelMask(image,channel);
9689 (void) SeparateImage(image);
9690 (void) SetPixelChannelMask(image,channel_mask);
9693 case 87: /* Splice */
9695 if (attribute_flag[0] != 0)
9696 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9697 &geometry,exception);
9698 if (attribute_flag[1] != 0)
9699 geometry.width=argument_list[1].integer_reference;
9700 if (attribute_flag[2] != 0)
9701 geometry.height=argument_list[2].integer_reference;
9702 if (attribute_flag[3] != 0)
9703 geometry.x=argument_list[3].integer_reference;
9704 if (attribute_flag[4] != 0)
9705 geometry.y=argument_list[4].integer_reference;
9706 if (attribute_flag[5] != 0)
9707 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9709 if (attribute_flag[6] != 0)
9710 (void) QueryColorDatabase(argument_list[6].string_reference,
9711 &image->background_color,exception);
9712 if (attribute_flag[7] != 0)
9713 image->gravity=(GravityType) argument_list[7].integer_reference;
9714 image=SpliceImage(image,&geometry,exception);
9717 case 88: /* Posterize */
9719 if (attribute_flag[0] == 0)
9720 argument_list[0].integer_reference=3;
9721 if (attribute_flag[1] == 0)
9722 argument_list[1].integer_reference=0;
9723 (void) PosterizeImage(image,argument_list[0].integer_reference,
9724 argument_list[1].integer_reference ? MagickTrue : MagickFalse,
9728 case 89: /* Shadow */
9730 if (attribute_flag[0] != 0)
9732 flags=ParseGeometry(argument_list[0].string_reference,
9734 if ((flags & SigmaValue) == 0)
9735 geometry_info.sigma=1.0;
9736 if ((flags & XiValue) == 0)
9737 geometry_info.xi=4.0;
9738 if ((flags & PsiValue) == 0)
9739 geometry_info.psi=4.0;
9741 if (attribute_flag[1] != 0)
9742 geometry_info.rho=argument_list[1].real_reference;
9743 if (attribute_flag[2] != 0)
9744 geometry_info.sigma=argument_list[2].real_reference;
9745 if (attribute_flag[3] != 0)
9746 geometry_info.xi=argument_list[3].integer_reference;
9747 if (attribute_flag[4] != 0)
9748 geometry_info.psi=argument_list[4].integer_reference;
9749 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9750 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9754 case 90: /* Identify */
9756 if (attribute_flag[0] == 0)
9757 argument_list[0].file_reference=(FILE *) NULL;
9758 if (attribute_flag[1] != 0)
9759 (void) SetImageArtifact(image,"identify:features",
9760 argument_list[1].string_reference);
9761 if ((attribute_flag[2] != 0) &&
9762 (argument_list[2].integer_reference != 0))
9763 (void) SetImageArtifact(image,"identify:unique","true");
9764 (void) IdentifyImage(image,argument_list[0].file_reference,
9765 MagickTrue,exception);
9768 case 91: /* SepiaTone */
9770 if (attribute_flag[0] == 0)
9771 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9772 image=SepiaToneImage(image,argument_list[0].real_reference,
9776 case 92: /* SigmoidalContrast */
9781 if (attribute_flag[0] != 0)
9783 flags=ParseGeometry(argument_list[0].string_reference,
9785 if ((flags & SigmaValue) == 0)
9786 geometry_info.sigma=QuantumRange/2.0;
9787 if ((flags & PercentValue) != 0)
9788 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9790 if (attribute_flag[1] != 0)
9791 geometry_info.rho=argument_list[1].real_reference;
9792 if (attribute_flag[2] != 0)
9793 geometry_info.sigma=argument_list[2].real_reference;
9794 if (attribute_flag[3] != 0)
9795 channel=(ChannelType) argument_list[3].integer_reference;
9797 if (attribute_flag[4] != 0)
9798 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9800 channel_mask=SetPixelChannelMask(image,channel);
9801 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9802 geometry_info.sigma,exception);
9803 (void) SetPixelChannelMask(image,channel_mask);
9806 case 93: /* Extent */
9808 if (attribute_flag[7] != 0)
9809 image->gravity=(GravityType) argument_list[7].integer_reference;
9810 if (attribute_flag[0] != 0)
9815 flags=ParseGravityGeometry(image,
9816 argument_list[0].string_reference,&geometry,exception);
9818 if (geometry.width == 0)
9819 geometry.width=image->columns;
9820 if (geometry.height == 0)
9821 geometry.height=image->rows;
9823 if (attribute_flag[1] != 0)
9824 geometry.width=argument_list[1].integer_reference;
9825 if (attribute_flag[2] != 0)
9826 geometry.height=argument_list[2].integer_reference;
9827 if (attribute_flag[3] != 0)
9828 geometry.x=argument_list[3].integer_reference;
9829 if (attribute_flag[4] != 0)
9830 geometry.y=argument_list[4].integer_reference;
9831 if (attribute_flag[5] != 0)
9832 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9834 if (attribute_flag[6] != 0)
9835 (void) QueryColorDatabase(argument_list[6].string_reference,
9836 &image->background_color,exception);
9837 image=ExtentImage(image,&geometry,exception);
9840 case 94: /* Vignette */
9842 if (attribute_flag[0] != 0)
9844 flags=ParseGeometry(argument_list[0].string_reference,
9846 if ((flags & SigmaValue) == 0)
9847 geometry_info.sigma=1.0;
9848 if ((flags & XiValue) == 0)
9849 geometry_info.xi=0.1*image->columns;
9850 if ((flags & PsiValue) == 0)
9851 geometry_info.psi=0.1*image->rows;
9853 if (attribute_flag[1] != 0)
9854 geometry_info.rho=argument_list[1].real_reference;
9855 if (attribute_flag[2] != 0)
9856 geometry_info.sigma=argument_list[2].real_reference;
9857 if (attribute_flag[3] != 0)
9858 geometry_info.xi=argument_list[3].integer_reference;
9859 if (attribute_flag[4] != 0)
9860 geometry_info.psi=argument_list[4].integer_reference;
9861 if (attribute_flag[5] != 0)
9862 (void) QueryColorDatabase(argument_list[5].string_reference,
9863 &image->background_color,exception);
9864 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9865 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9869 case 95: /* ContrastStretch */
9876 white_point=(MagickRealType) image->columns*image->rows;
9877 if (attribute_flag[0] != 0)
9879 flags=ParseGeometry(argument_list[0].string_reference,
9881 black_point=geometry_info.rho;
9882 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9884 if ((flags & PercentValue) != 0)
9886 black_point*=(double) image->columns*image->rows/100.0;
9887 white_point*=(double) image->columns*image->rows/100.0;
9889 white_point=(MagickRealType) image->columns*image->rows-
9892 if (attribute_flag[1] != 0)
9893 black_point=argument_list[1].real_reference;
9894 if (attribute_flag[2] != 0)
9895 white_point=argument_list[2].real_reference;
9896 if (attribute_flag[4] != 0)
9897 channel=(ChannelType) argument_list[4].integer_reference;
9898 channel_mask=SetPixelChannelMask(image,channel);
9899 (void) ContrastStretchImage(image,black_point,white_point,exception);
9900 (void) SetPixelChannelMask(image,channel_mask);
9903 case 96: /* Sans0 */
9907 case 97: /* Sans1 */
9911 case 98: /* AdaptiveSharpen */
9913 if (attribute_flag[0] != 0)
9915 flags=ParseGeometry(argument_list[0].string_reference,
9917 if ((flags & SigmaValue) == 0)
9918 geometry_info.sigma=1.0;
9919 if ((flags & XiValue) == 0)
9920 geometry_info.xi=0.0;
9922 if (attribute_flag[1] != 0)
9923 geometry_info.rho=argument_list[1].real_reference;
9924 if (attribute_flag[2] != 0)
9925 geometry_info.sigma=argument_list[2].real_reference;
9926 if (attribute_flag[3] != 0)
9927 geometry_info.xi=argument_list[3].real_reference;
9928 if (attribute_flag[4] != 0)
9929 channel=(ChannelType) argument_list[4].integer_reference;
9930 channel_mask=SetPixelChannelMask(image,channel);
9931 image=AdaptiveSharpenImage(image,geometry_info.rho,
9932 geometry_info.sigma,geometry_info.xi,exception);
9933 if (image != (Image *) NULL)
9934 (void) SetPixelChannelMask(image,channel_mask);
9937 case 99: /* Transpose */
9939 image=TransposeImage(image,exception);
9942 case 100: /* Tranverse */
9944 image=TransverseImage(image,exception);
9947 case 101: /* AutoOrient */
9949 switch (image->orientation)
9951 case TopRightOrientation:
9953 image=FlopImage(image,exception);
9956 case BottomRightOrientation:
9958 image=RotateImage(image,180.0,exception);
9961 case BottomLeftOrientation:
9963 image=FlipImage(image,exception);
9966 case LeftTopOrientation:
9968 image=TransposeImage(image,exception);
9971 case RightTopOrientation:
9973 image=RotateImage(image,90.0,exception);
9976 case RightBottomOrientation:
9978 image=TransverseImage(image,exception);
9981 case LeftBottomOrientation:
9983 image=RotateImage(image,270.0,exception);
9991 case 102: /* AdaptiveBlur */
9993 if (attribute_flag[0] != 0)
9995 flags=ParseGeometry(argument_list[0].string_reference,
9997 if ((flags & SigmaValue) == 0)
9998 geometry_info.sigma=1.0;
9999 if ((flags & XiValue) == 0)
10000 geometry_info.xi=0.0;
10002 if (attribute_flag[1] != 0)
10003 geometry_info.rho=argument_list[1].real_reference;
10004 if (attribute_flag[2] != 0)
10005 geometry_info.sigma=argument_list[2].real_reference;
10006 if (attribute_flag[3] != 0)
10007 geometry_info.xi=argument_list[3].real_reference;
10008 if (attribute_flag[4] != 0)
10009 channel=(ChannelType) argument_list[4].integer_reference;
10010 channel_mask=SetPixelChannelMask(image,channel);
10011 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10012 geometry_info.xi,exception);
10013 if (image != (Image *) NULL)
10014 (void) SetPixelChannelMask(image,channel_mask);
10017 case 103: /* Sketch */
10019 if (attribute_flag[0] != 0)
10021 flags=ParseGeometry(argument_list[0].string_reference,
10023 if ((flags & SigmaValue) == 0)
10024 geometry_info.sigma=1.0;
10025 if ((flags & XiValue) == 0)
10026 geometry_info.xi=1.0;
10028 if (attribute_flag[1] != 0)
10029 geometry_info.rho=argument_list[1].real_reference;
10030 if (attribute_flag[2] != 0)
10031 geometry_info.sigma=argument_list[2].real_reference;
10032 if (attribute_flag[3] != 0)
10033 geometry_info.xi=argument_list[3].real_reference;
10034 if (attribute_flag[4] != 0)
10035 geometry_info.psi=argument_list[4].real_reference;
10036 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10037 geometry_info.xi,geometry_info.psi,exception);
10040 case 104: /* UniqueColors */
10042 image=UniqueImageColors(image,exception);
10045 case 105: /* AdaptiveResize */
10047 if (attribute_flag[0] != 0)
10048 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10049 &geometry,exception);
10050 if (attribute_flag[1] != 0)
10051 geometry.width=argument_list[1].integer_reference;
10052 if (attribute_flag[2] != 0)
10053 geometry.height=argument_list[2].integer_reference;
10054 if (attribute_flag[3] != 0)
10055 image->filter=(FilterTypes) argument_list[4].integer_reference;
10056 if (attribute_flag[4] != 0)
10057 SetImageArtifact(image,"filter:support",
10058 argument_list[4].string_reference);
10059 if (attribute_flag[5] != 0)
10060 image->blur=argument_list[5].real_reference;
10061 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10065 case 106: /* ClipMask */
10067 if (attribute_flag[0] == 0)
10069 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10071 goto PerlException;
10073 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10074 MagickTrue,exception);
10075 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10078 case 107: /* LinearStretch */
10085 white_point=(MagickRealType) image->columns*image->rows;
10086 if (attribute_flag[0] != 0)
10088 flags=ParseGeometry(argument_list[0].string_reference,
10090 if ((flags & SigmaValue) != 0)
10091 white_point=geometry_info.sigma;
10092 if ((flags & PercentValue) != 0)
10094 black_point*=(double) image->columns*image->rows/100.0;
10095 white_point*=(double) image->columns*image->rows/100.0;
10097 if ((flags & SigmaValue) == 0)
10098 white_point=(double) image->columns*image->rows-black_point;
10100 if (attribute_flag[1] != 0)
10101 black_point=argument_list[1].real_reference;
10102 if (attribute_flag[2] != 0)
10103 white_point=argument_list[2].real_reference;
10104 (void) LinearStretchImage(image,black_point,white_point,exception);
10107 case 109: /* Mask */
10109 if (attribute_flag[0] == 0)
10111 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10113 goto PerlException;
10115 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10116 MagickTrue,exception);
10117 (void) NegateImage(image->mask,MagickFalse,exception);
10120 case 110: /* Polaroid */
10128 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10129 (DrawInfo *) NULL);
10130 if (attribute_flag[0] != 0)
10131 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10132 info ? info->image_info : (ImageInfo *) NULL,image,
10133 argument_list[0].string_reference,exception));
10135 if (attribute_flag[1] != 0)
10136 angle=argument_list[1].real_reference;
10137 if (attribute_flag[2] != 0)
10138 (void) CloneString(&draw_info->font,
10139 argument_list[2].string_reference);
10140 if (attribute_flag[3] != 0)
10141 (void) QueryColorDatabase(argument_list[3].string_reference,
10142 &draw_info->stroke,exception);
10143 if (attribute_flag[4] != 0)
10144 (void) QueryColorDatabase(argument_list[4].string_reference,
10145 &draw_info->fill,exception);
10146 if (attribute_flag[5] != 0)
10147 draw_info->stroke_width=argument_list[5].real_reference;
10148 if (attribute_flag[6] != 0)
10149 draw_info->pointsize=argument_list[6].real_reference;
10150 if (attribute_flag[7] != 0)
10151 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10152 if (attribute_flag[8] != 0)
10153 (void) QueryColorDatabase(argument_list[8].string_reference,
10154 &image->background_color,exception);
10155 image=PolaroidImage(image,draw_info,angle,exception);
10156 draw_info=DestroyDrawInfo(draw_info);
10159 case 111: /* FloodfillPaint */
10170 draw_info=CloneDrawInfo(info ? info->image_info :
10171 (ImageInfo *) NULL,(DrawInfo *) NULL);
10172 if (attribute_flag[0] != 0)
10173 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10174 &geometry,exception);
10175 if (attribute_flag[1] != 0)
10176 geometry.x=argument_list[1].integer_reference;
10177 if (attribute_flag[2] != 0)
10178 geometry.y=argument_list[2].integer_reference;
10179 if (attribute_flag[3] != 0)
10180 (void) QueryColorDatabase(argument_list[3].string_reference,
10181 &draw_info->fill,exception);
10182 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10184 if (attribute_flag[4] != 0)
10185 QueryMagickColor(argument_list[4].string_reference,&target,
10187 if (attribute_flag[5] != 0)
10188 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10190 if (attribute_flag[6] != 0)
10191 channel=(ChannelType) argument_list[6].integer_reference;
10192 invert=MagickFalse;
10193 if (attribute_flag[7] != 0)
10194 invert=(MagickBooleanType) argument_list[7].integer_reference;
10195 channel_mask=SetPixelChannelMask(image,channel);
10196 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10197 geometry.y,invert,exception);
10198 (void) SetPixelChannelMask(image,channel_mask);
10199 draw_info=DestroyDrawInfo(draw_info);
10202 case 112: /* Distort */
10214 number_coordinates;
10219 if (attribute_flag[0] == 0)
10221 method=UndefinedDistortion;
10222 if (attribute_flag[1] != 0)
10223 method=(DistortImageMethod) argument_list[1].integer_reference;
10224 av=(AV *) argument_list[0].array_reference;
10225 number_coordinates=(size_t) av_len(av)+1;
10226 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10227 sizeof(*coordinates));
10228 if (coordinates == (double *) NULL)
10230 ThrowPerlException(exception,ResourceLimitFatalError,
10231 "MemoryAllocationFailed",PackageName);
10232 goto PerlException;
10234 for (j=0; j < (ssize_t) number_coordinates; j++)
10235 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10236 virtual_pixel=UndefinedVirtualPixelMethod;
10237 if (attribute_flag[2] != 0)
10238 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10239 argument_list[2].integer_reference);
10240 image=DistortImage(image,method,number_coordinates,coordinates,
10241 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10243 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10244 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10245 coordinates=(double *) RelinquishMagickMemory(coordinates);
10248 case 113: /* Clut */
10250 if (attribute_flag[0] == 0)
10252 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10254 goto PerlException;
10256 if (attribute_flag[1] != 0)
10257 channel=(ChannelType) argument_list[1].integer_reference;
10258 channel_mask=SetPixelChannelMask(image,channel);
10259 (void) ClutImage(image,argument_list[0].image_reference,exception);
10260 (void) SetPixelChannelMask(image,channel_mask);
10263 case 114: /* LiquidRescale */
10265 if (attribute_flag[0] != 0)
10266 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10267 &geometry,exception);
10268 if (attribute_flag[1] != 0)
10269 geometry.width=argument_list[1].integer_reference;
10270 if (attribute_flag[2] != 0)
10271 geometry.height=argument_list[2].integer_reference;
10272 if (attribute_flag[3] == 0)
10273 argument_list[3].real_reference=1.0;
10274 if (attribute_flag[4] == 0)
10275 argument_list[4].real_reference=0.0;
10276 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10277 argument_list[3].real_reference,argument_list[4].real_reference,
10281 case 115: /* EncipherImage */
10283 (void) EncipherImage(image,argument_list[0].string_reference,
10287 case 116: /* DecipherImage */
10289 (void) DecipherImage(image,argument_list[0].string_reference,
10293 case 117: /* Deskew */
10295 geometry_info.rho=QuantumRange/2.0;
10296 if (attribute_flag[0] != 0)
10297 flags=ParseGeometry(argument_list[0].string_reference,
10299 if (attribute_flag[1] != 0)
10300 geometry_info.rho=SiPrefixToDouble(
10301 argument_list[1].string_reference,QuantumRange);
10302 image=DeskewImage(image,geometry_info.rho,exception);
10305 case 118: /* Remap */
10310 if (attribute_flag[0] == 0)
10312 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10314 goto PerlException;
10316 quantize_info=AcquireQuantizeInfo(info->image_info);
10317 if (attribute_flag[1] != 0)
10318 quantize_info->dither=(MagickBooleanType)
10319 argument_list[1].integer_reference;
10320 if (attribute_flag[2] != 0)
10321 quantize_info->dither_method=(DitherMethod)
10322 argument_list[2].integer_reference;
10323 (void) RemapImages(quantize_info,image,
10324 argument_list[0].image_reference,exception);
10325 quantize_info=DestroyQuantizeInfo(quantize_info);
10328 case 119: /* SparseColor */
10340 number_coordinates;
10345 if (attribute_flag[0] == 0)
10347 method=UndefinedColorInterpolate;
10348 if (attribute_flag[1] != 0)
10349 method=(SparseColorMethod) argument_list[1].integer_reference;
10350 av=(AV *) argument_list[0].array_reference;
10351 number_coordinates=(size_t) av_len(av)+1;
10352 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10353 sizeof(*coordinates));
10354 if (coordinates == (double *) NULL)
10356 ThrowPerlException(exception,ResourceLimitFatalError,
10357 "MemoryAllocationFailed",PackageName);
10358 goto PerlException;
10360 for (j=0; j < (ssize_t) number_coordinates; j++)
10361 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10362 virtual_pixel=UndefinedVirtualPixelMethod;
10363 if (attribute_flag[2] != 0)
10364 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10365 argument_list[2].integer_reference);
10366 if (attribute_flag[3] != 0)
10367 channel=(ChannelType) argument_list[3].integer_reference;
10368 channel_mask=SetPixelChannelMask(image,channel);
10369 image=SparseColorImage(image,method,number_coordinates,coordinates,
10371 if (image != (Image *) NULL)
10372 (void) SetPixelChannelMask(image,channel_mask);
10373 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10374 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10375 coordinates=(double *) RelinquishMagickMemory(coordinates);
10378 case 120: /* Function */
10395 if (attribute_flag[0] == 0)
10397 function=UndefinedFunction;
10398 if (attribute_flag[1] != 0)
10399 function=(MagickFunction) argument_list[1].integer_reference;
10400 av=(AV *) argument_list[0].array_reference;
10401 number_parameters=(size_t) av_len(av)+1;
10402 parameters=(double *) AcquireQuantumMemory(number_parameters,
10403 sizeof(*parameters));
10404 if (parameters == (double *) NULL)
10406 ThrowPerlException(exception,ResourceLimitFatalError,
10407 "MemoryAllocationFailed",PackageName);
10408 goto PerlException;
10410 for (j=0; j < (ssize_t) number_parameters; j++)
10411 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10412 virtual_pixel=UndefinedVirtualPixelMethod;
10413 if (attribute_flag[2] != 0)
10414 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10415 argument_list[2].integer_reference);
10416 (void) FunctionImage(image,function,number_parameters,parameters,
10418 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10419 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10420 parameters=(double *) RelinquishMagickMemory(parameters);
10423 case 121: /* SelectiveBlur */
10425 if (attribute_flag[0] != 0)
10427 flags=ParseGeometry(argument_list[0].string_reference,
10429 if ((flags & SigmaValue) == 0)
10430 geometry_info.sigma=1.0;
10431 if ((flags & PercentValue) != 0)
10432 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10434 if (attribute_flag[1] != 0)
10435 geometry_info.rho=argument_list[1].real_reference;
10436 if (attribute_flag[2] != 0)
10437 geometry_info.sigma=argument_list[2].real_reference;
10438 if (attribute_flag[3] != 0)
10439 geometry_info.xi=argument_list[3].integer_reference;;
10440 if (attribute_flag[4] != 0)
10441 geometry_info.psi=argument_list[4].integer_reference;;
10442 if (attribute_flag[5] != 0)
10443 channel=(ChannelType) argument_list[5].integer_reference;
10444 channel_mask=SetPixelChannelMask(image,channel);
10445 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10446 geometry_info.xi,geometry_info.psi,exception);
10447 if (image != (Image *) NULL)
10448 (void) SetPixelChannelMask(image,channel_mask);
10451 case 122: /* HaldClut */
10453 if (attribute_flag[0] == 0)
10455 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10457 goto PerlException;
10459 if (attribute_flag[1] != 0)
10460 channel=(ChannelType) argument_list[1].integer_reference;
10461 channel_mask=SetPixelChannelMask(image,channel);
10462 (void) HaldClutImage(image,argument_list[0].image_reference,
10464 (void) SetPixelChannelMask(image,channel_mask);
10467 case 123: /* BlueShift */
10469 if (attribute_flag[0] != 0)
10470 (void) ParseGeometry(argument_list[0].string_reference,
10472 image=BlueShiftImage(image,geometry_info.rho,exception);
10475 case 124: /* ForwardFourierTransformImage */
10477 image=ForwardFourierTransformImage(image,
10478 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10482 case 125: /* InverseFourierTransformImage */
10484 image=InverseFourierTransformImage(image,image->next,
10485 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10489 case 126: /* ColorDecisionList */
10491 if (attribute_flag[0] == 0)
10492 argument_list[0].string_reference=(char *) NULL;
10493 (void) ColorDecisionListImage(image,
10494 argument_list[0].string_reference,exception);
10497 case 127: /* AutoGamma */
10499 if (attribute_flag[0] != 0)
10500 channel=(ChannelType) argument_list[0].integer_reference;
10501 channel_mask=SetPixelChannelMask(image,channel);
10502 (void) AutoGammaImage(image,exception);
10503 (void) SetPixelChannelMask(image,channel_mask);
10506 case 128: /* AutoLevel */
10508 if (attribute_flag[0] != 0)
10509 channel=(ChannelType) argument_list[0].integer_reference;
10510 channel_mask=SetPixelChannelMask(image,channel);
10511 (void) AutoLevelImage(image,exception);
10512 (void) SetPixelChannelMask(image,channel_mask);
10515 case 129: /* LevelColors */
10521 (void) QueryMagickColor("#000000",&black_point,exception);
10522 (void) QueryMagickColor("#ffffff",&white_point,exception);
10523 if (attribute_flag[1] != 0)
10524 (void) QueryMagickColor(argument_list[1].string_reference,
10525 &black_point,exception);
10526 if (attribute_flag[2] != 0)
10527 (void) QueryMagickColor(argument_list[2].string_reference,
10528 &white_point,exception);
10529 if (attribute_flag[3] != 0)
10530 channel=(ChannelType) argument_list[3].integer_reference;
10531 channel_mask=SetPixelChannelMask(image,channel);
10532 (void) LevelImageColors(image,&black_point,&white_point,
10533 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10535 (void) SetPixelChannelMask(image,channel_mask);
10538 case 130: /* Clamp */
10540 if (attribute_flag[0] != 0)
10541 channel=(ChannelType) argument_list[0].integer_reference;
10542 channel_mask=SetPixelChannelMask(image,channel);
10543 (void) ClampImage(image);
10544 (void) SetPixelChannelMask(image,channel_mask);
10547 case 132: /* BrightnessContrast */
10555 if (attribute_flag[0] != 0)
10557 flags=ParseGeometry(argument_list[0].string_reference,
10559 brightness=geometry_info.rho;
10560 if ((flags & SigmaValue) == 0)
10561 contrast=geometry_info.sigma;
10563 if (attribute_flag[1] != 0)
10564 brightness=argument_list[1].real_reference;
10565 if (attribute_flag[2] != 0)
10566 contrast=argument_list[2].real_reference;
10567 if (attribute_flag[4] != 0)
10568 channel=(ChannelType) argument_list[4].integer_reference;
10569 channel_mask=SetPixelChannelMask(image,channel);
10570 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10571 (void) SetPixelChannelMask(image,channel_mask);
10574 case 133: /* Morphology */
10585 if (attribute_flag[0] == 0)
10587 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10588 if (kernel == (KernelInfo *) NULL)
10590 if (attribute_flag[1] != 0)
10591 channel=(ChannelType) argument_list[1].integer_reference;
10592 method=UndefinedMorphology;
10593 if (attribute_flag[2] != 0)
10594 method=argument_list[2].integer_reference;
10596 if (attribute_flag[3] != 0)
10597 iterations=argument_list[4].integer_reference;
10598 channel_mask=SetPixelChannelMask(image,channel);
10599 image=MorphologyImage(image,method,iterations,kernel,exception);
10600 if (image != (Image *) NULL)
10601 (void) SetPixelChannelMask(image,channel_mask);
10602 kernel=DestroyKernelInfo(kernel);
10605 case 108: /* Recolor */
10606 case 134: /* ColorMatrix */
10620 if (attribute_flag[0] == 0)
10622 av=(AV *) argument_list[0].array_reference;
10623 if (av == (AV *) NULL)
10625 order=(size_t) sqrt(av_len(av)+1);
10626 color_matrix=(double *) AcquireQuantumMemory(order,order*
10627 sizeof(*color_matrix));
10628 if (color_matrix == (double *) NULL)
10630 ThrowPerlException(exception,ResourceLimitFatalError,
10631 "MemoryAllocationFailed",PackageName);
10632 goto PerlException;
10634 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10635 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10636 for ( ; j < (ssize_t) (order*order); j++)
10637 color_matrix[j]=0.0;
10638 kernel_info=AcquireKernelInfo((const char *) NULL);
10639 if (kernel_info == (KernelInfo *) NULL)
10641 kernel_info->width=order;
10642 kernel_info->height=order;
10643 kernel_info->values=color_matrix;
10644 image=ColorMatrixImage(image,kernel_info,exception);
10645 kernel_info->values=(double *) NULL;
10646 kernel_info=DestroyKernelInfo(kernel_info);
10647 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10650 case 135: /* Color */
10655 (void) QueryMagickColor("none",&color,exception);
10656 if (attribute_flag[0] != 0)
10657 (void) QueryMagickColor(argument_list[0].string_reference,
10659 (void) SetImageColor(image,&color);
10662 case 136: /* Mode */
10664 if (attribute_flag[0] != 0)
10666 flags=ParseGeometry(argument_list[0].string_reference,
10668 if ((flags & SigmaValue) == 0)
10669 geometry_info.sigma=1.0;
10671 if (attribute_flag[1] != 0)
10672 geometry_info.rho=argument_list[1].real_reference;
10673 if (attribute_flag[2] != 0)
10674 geometry_info.sigma=argument_list[2].real_reference;
10675 if (attribute_flag[3] != 0)
10676 channel=(ChannelType) argument_list[3].integer_reference;
10677 channel_mask=SetPixelChannelMask(image,channel);
10678 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10679 (size_t) geometry_info.sigma,exception);
10680 if (image != (Image *) NULL)
10681 (void) SetPixelChannelMask(image,channel_mask);
10684 case 137: /* Statistic */
10689 statistic=UndefinedStatistic;
10690 if (attribute_flag[0] != 0)
10692 flags=ParseGeometry(argument_list[0].string_reference,
10694 if ((flags & SigmaValue) == 0)
10695 geometry_info.sigma=1.0;
10697 if (attribute_flag[1] != 0)
10698 geometry_info.rho=argument_list[1].real_reference;
10699 if (attribute_flag[2] != 0)
10700 geometry_info.sigma=argument_list[2].real_reference;
10701 if (attribute_flag[3] != 0)
10702 channel=(ChannelType) argument_list[3].integer_reference;
10703 if (attribute_flag[4] != 0)
10704 statistic=(StatisticType) argument_list[4].integer_reference;
10705 channel_mask=SetPixelChannelMask(image,channel);
10706 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10707 (size_t) geometry_info.sigma,exception);
10708 if (image != (Image *) NULL)
10709 (void) SetPixelChannelMask(image,channel_mask);
10713 if (next != (Image *) NULL)
10714 (void) CatchImageException(next);
10715 if (region_image != (Image *) NULL)
10720 status=CompositeImage(region_image,CopyCompositeOp,image,
10721 region_info.x,region_info.y);
10723 (void) CatchImageException(region_image);
10724 image=DestroyImage(image);
10725 image=region_image;
10727 if (image != (Image *) NULL)
10730 if (next && (next != image))
10732 image->next=next->next;
10733 if (image->next != (Image *) NULL)
10734 image->next->previous=image;
10735 DeleteImageFromRegistry(*pv,next);
10737 sv_setiv(*pv,(IV) image);
10745 if (reference_vector)
10746 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10747 InheritPerlException(exception,perl_exception);
10748 exception=DestroyExceptionInfo(exception);
10749 sv_setiv(perl_exception,(IV) number_images);
10750 SvPOK_on(perl_exception);
10751 ST(0)=sv_2mortal(perl_exception);
10756 ###############################################################################
10764 ###############################################################################
10769 Image::Magick ref=NO_INIT
10814 PERL_UNUSED_VAR(ref);
10815 PERL_UNUSED_VAR(ix);
10816 exception=AcquireExceptionInfo();
10817 perl_exception=newSVpv("",0);
10820 if (sv_isobject(ST(0)) == 0)
10822 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10824 goto PerlException;
10826 reference=SvRV(ST(0));
10827 hv=SvSTASH(reference);
10829 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10831 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10832 if (image == (Image *) NULL)
10834 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10836 goto PerlException;
10841 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10842 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10843 (void) QueryMagickColor("none",&transparent_color,exception);
10844 for (i=2; i < items; i+=2)
10846 attribute=(char *) SvPV(ST(i-1),na);
10847 switch (*attribute)
10852 if (LocaleCompare(attribute,"background") == 0)
10854 (void) QueryColorDatabase(SvPV(ST(i),na),
10855 &montage_info->background_color,exception);
10856 for (next=image; next; next=next->next)
10857 next->background_color=montage_info->background_color;
10860 if (LocaleCompare(attribute,"border") == 0)
10862 montage_info->border_width=SvIV(ST(i));
10865 if (LocaleCompare(attribute,"bordercolor") == 0)
10867 (void) QueryColorDatabase(SvPV(ST(i),na),
10868 &montage_info->border_color,exception);
10869 for (next=image; next; next=next->next)
10870 next->border_color=montage_info->border_color;
10873 if (LocaleCompare(attribute,"borderwidth") == 0)
10875 montage_info->border_width=SvIV(ST(i));
10878 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10885 if (LocaleCompare(attribute,"compose") == 0)
10887 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10888 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10891 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10895 for (next=image; next; next=next->next)
10896 next->compose=(CompositeOperator) sp;
10899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10906 if (LocaleCompare(attribute,"fill") == 0)
10908 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10912 if (LocaleCompare(attribute,"font") == 0)
10914 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10917 if (LocaleCompare(attribute,"frame") == 0)
10923 if (IsGeometry(p) == MagickFalse)
10925 ThrowPerlException(exception,OptionError,"MissingGeometry",
10929 (void) CloneString(&montage_info->frame,p);
10931 montage_info->frame=(char *) NULL;
10934 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10941 if (LocaleCompare(attribute,"geometry") == 0)
10947 if (IsGeometry(p) == MagickFalse)
10949 ThrowPerlException(exception,OptionError,"MissingGeometry",
10953 (void) CloneString(&montage_info->geometry,p);
10955 montage_info->geometry=(char *) NULL;
10958 if (LocaleCompare(attribute,"gravity") == 0)
10963 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10964 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10967 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10971 montage_info->gravity=(GravityType) in;
10972 for (next=image; next; next=next->next)
10973 next->gravity=(GravityType) in;
10976 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10983 if (LocaleCompare(attribute,"label") == 0)
10985 for (next=image; next; next=next->next)
10986 (void) SetImageProperty(next,"label",InterpretImageProperties(
10987 info ? info->image_info : (ImageInfo *) NULL,next,
10988 SvPV(ST(i),na),exception));
10991 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10998 if (LocaleCompare(attribute,"mattecolor") == 0)
11000 (void) QueryColorDatabase(SvPV(ST(i),na),
11001 &montage_info->matte_color,exception);
11002 for (next=image; next; next=next->next)
11003 next->matte_color=montage_info->matte_color;
11006 if (LocaleCompare(attribute,"mode") == 0)
11011 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
11012 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11017 ThrowPerlException(exception,OptionError,
11018 "UnrecognizedModeType",SvPV(ST(i),na));
11023 (void) CloneString(&montage_info->frame,"15x15+3+3");
11024 montage_info->shadow=MagickTrue;
11029 montage_info->frame=(char *) NULL;
11030 montage_info->shadow=MagickFalse;
11031 montage_info->border_width=0;
11034 case ConcatenateMode:
11036 montage_info->frame=(char *) NULL;
11037 montage_info->shadow=MagickFalse;
11038 (void) CloneString(&montage_info->geometry,"+0+0");
11039 montage_info->border_width=0;
11044 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11051 if (LocaleCompare(attribute,"pointsize") == 0)
11053 montage_info->pointsize=SvIV(ST(i));
11056 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11063 if (LocaleCompare(attribute,"shadow") == 0)
11065 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11066 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11069 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11073 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11076 if (LocaleCompare(attribute,"stroke") == 0)
11078 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11089 if (LocaleCompare(attribute,"texture") == 0)
11091 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11094 if (LocaleCompare(attribute,"tile") == 0)
11096 char *p=SvPV(ST(i),na);
11097 if (IsGeometry(p) == MagickFalse)
11099 ThrowPerlException(exception,OptionError,"MissingGeometry",
11103 (void) CloneString(&montage_info->tile,p);
11105 montage_info->tile=(char *) NULL;
11108 if (LocaleCompare(attribute,"title") == 0)
11110 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11113 if (LocaleCompare(attribute,"transparent") == 0)
11118 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11119 for (next=image; next; next=next->next)
11120 (void) TransparentPaintImage(next,&transparent_color,
11121 TransparentAlpha,MagickFalse,exception);
11124 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11130 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11136 image=MontageImageList(info->image_info,montage_info,image,exception);
11137 montage_info=DestroyMontageInfo(montage_info);
11138 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11139 goto PerlException;
11140 if (transparent_color.alpha != TransparentAlpha)
11141 for (next=image; next; next=next->next)
11142 (void) TransparentPaintImage(next,&transparent_color,
11143 TransparentAlpha,MagickFalse,exception);
11144 for ( ; image; image=image->next)
11146 AddImageToRegistry(sv,image);
11148 av_push(av,sv_bless(rv,hv));
11151 exception=DestroyExceptionInfo(exception);
11152 ST(0)=av_reference;
11153 SvREFCNT_dec(perl_exception);
11157 InheritPerlException(exception,perl_exception);
11158 exception=DestroyExceptionInfo(exception);
11159 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11160 SvPOK_on(perl_exception);
11161 ST(0)=sv_2mortal(perl_exception);
11166 ###############################################################################
11174 ###############################################################################
11179 Image::Magick ref=NO_INIT
11217 PERL_UNUSED_VAR(ref);
11218 PERL_UNUSED_VAR(ix);
11219 exception=AcquireExceptionInfo();
11220 perl_exception=newSVpv("",0);
11224 if (sv_isobject(ST(0)) == 0)
11226 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11228 goto PerlException;
11230 reference=SvRV(ST(0));
11231 hv=SvSTASH(reference);
11233 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11235 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11236 if (image == (Image *) NULL)
11238 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11240 goto PerlException;
11242 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11247 for (i=2; i < items; i+=2)
11249 attribute=(char *) SvPV(ST(i-1),na);
11250 switch (*attribute)
11255 if (LocaleCompare(attribute,"frames") == 0)
11257 number_frames=SvIV(ST(i));
11260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11266 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11272 image=MorphImages(image,number_frames,exception);
11273 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11274 goto PerlException;
11275 for ( ; image; image=image->next)
11277 AddImageToRegistry(sv,image);
11279 av_push(av,sv_bless(rv,hv));
11282 exception=DestroyExceptionInfo(exception);
11283 ST(0)=av_reference;
11284 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11288 InheritPerlException(exception,perl_exception);
11289 exception=DestroyExceptionInfo(exception);
11290 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11291 SvPOK_on(perl_exception);
11292 ST(0)=sv_2mortal(perl_exception);
11297 ###############################################################################
11305 ###############################################################################
11310 Image::Magick ref=NO_INIT
11338 PERL_UNUSED_VAR(ref);
11339 PERL_UNUSED_VAR(ix);
11340 exception=AcquireExceptionInfo();
11341 perl_exception=newSVpv("",0);
11343 if (sv_isobject(ST(0)) == 0)
11345 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11347 goto PerlException;
11349 reference=SvRV(ST(0));
11350 hv=SvSTASH(reference);
11351 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11352 if (image == (Image *) NULL)
11354 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11356 goto PerlException;
11358 image=MergeImageLayers(image,MosaicLayer,exception);
11360 Create blessed Perl array for the returned image.
11363 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11365 AddImageToRegistry(sv,image);
11367 av_push(av,sv_bless(rv,hv));
11369 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11370 (void) CopyMagickString(info->image_info->filename,image->filename,
11372 SetImageInfo(info->image_info,0,&image->exception);
11373 exception=DestroyExceptionInfo(exception);
11374 SvREFCNT_dec(perl_exception);
11378 InheritPerlException(exception,perl_exception);
11379 exception=DestroyExceptionInfo(exception);
11380 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11381 SvPOK_on(perl_exception); /* return messages in string context */
11382 ST(0)=sv_2mortal(perl_exception);
11387 ###############################################################################
11395 ###############################################################################
11400 Image::Magick ref=NO_INIT
11450 PERL_UNUSED_VAR(ref);
11451 PERL_UNUSED_VAR(ix);
11452 exception=AcquireExceptionInfo();
11453 perl_exception=newSVpv("",0);
11454 package_info=(struct PackageInfo *) NULL;
11455 ac=(items < 2) ? 1 : items-1;
11456 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11458 length=(STRLEN *) NULL;
11459 if (list == (char **) NULL)
11461 ThrowPerlException(exception,ResourceLimitError,
11462 "MemoryAllocationFailed",PackageName);
11463 goto PerlException;
11466 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11467 if (length == (STRLEN *) NULL)
11469 ThrowPerlException(exception,ResourceLimitError,
11470 "MemoryAllocationFailed",PackageName);
11471 goto PerlException;
11473 if (sv_isobject(ST(0)) == 0)
11475 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11477 goto PerlException;
11479 reference=SvRV(ST(0));
11480 if (SvTYPE(reference) != SVt_PVAV)
11482 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11484 goto PerlException;
11486 av=(AV *) reference;
11487 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11489 package_info=ClonePackageInfo(info,exception);
11492 *list=(char *) (*package_info->image_info->filename ?
11493 package_info->image_info->filename : "XC:black");
11495 for (n=0, i=0; i < ac; i++)
11497 list[n]=(char *) SvPV(ST(i+1),length[n]);
11498 if ((items >= 3) && strEQcase(list[n],"blob"))
11504 blob=(void *) (SvPV(ST(i+1),length[n]));
11505 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11507 if ((items >= 3) && strEQcase(list[n],"filename"))
11509 if ((items >= 3) && strEQcase(list[n],"file"))
11518 io_info=IoIFP(sv_2io(ST(i+1)));
11519 if (io_info == (PerlIO *) NULL)
11521 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11525 file=PerlIO_findFILE(io_info);
11526 if (file == (FILE *) NULL)
11528 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11532 SetImageInfoFile(package_info->image_info,file);
11534 if ((items >= 3) && strEQcase(list[n],"magick"))
11538 list[n]=(char *) NULL;
11540 status=ExpandFilenames(&n,&list);
11541 if (status == MagickFalse)
11543 ThrowPerlException(exception,ResourceLimitError,
11544 "MemoryAllocationFailed",PackageName);
11545 goto PerlException;
11548 for (i=0; i < n; i++)
11550 (void) CopyMagickString(package_info->image_info->filename,list[i],
11552 image=PingImage(package_info->image_info,exception);
11553 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11555 if ((package_info->image_info->file != (FILE *) NULL) ||
11556 (package_info->image_info->blob != (void *) NULL))
11557 DisassociateImageStream(image);
11558 count+=GetImageListLength(image);
11559 EXTEND(sp,4*count);
11560 for (next=image; next; next=next->next)
11562 PUSHs(sv_2mortal(newSViv(next->columns)));
11563 PUSHs(sv_2mortal(newSViv(next->rows)));
11564 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11565 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11567 image=DestroyImageList(image);
11572 for (i=0; i < n; i++)
11573 if (list[i] != (char *) NULL)
11574 for (p=keep; list[i] != *p++; )
11577 list[i]=(char *) RelinquishMagickMemory(list[i]);
11582 if (package_info != (struct PackageInfo *) NULL)
11583 DestroyPackageInfo(package_info);
11584 if (list && (list != keep))
11585 list=(char **) RelinquishMagickMemory(list);
11587 keep=(char **) RelinquishMagickMemory(keep);
11589 length=(STRLEN *) RelinquishMagickMemory(length);
11590 InheritPerlException(exception,perl_exception);
11591 exception=DestroyExceptionInfo(exception);
11592 SvREFCNT_dec(perl_exception); /* throw away all errors */
11596 ###############################################################################
11604 ###############################################################################
11609 Image::Magick ref=NO_INIT
11642 PERL_UNUSED_VAR(ref);
11643 PERL_UNUSED_VAR(ix);
11644 exception=AcquireExceptionInfo();
11645 perl_exception=newSVpv("",0);
11648 if (sv_isobject(ST(0)) == 0)
11650 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11652 goto PerlException;
11654 reference=SvRV(ST(0));
11655 hv=SvSTASH(reference);
11657 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11659 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11660 if (image == (Image *) NULL)
11662 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11664 goto PerlException;
11666 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11667 preview_type=GammaPreview;
11669 preview_type=(PreviewType)
11670 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11671 for ( ; image; image=image->next)
11673 preview_image=PreviewImage(image,preview_type,exception);
11674 if (preview_image == (Image *) NULL)
11675 goto PerlException;
11676 AddImageToRegistry(sv,preview_image);
11678 av_push(av,sv_bless(rv,hv));
11681 exception=DestroyExceptionInfo(exception);
11682 ST(0)=av_reference;
11683 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11687 InheritPerlException(exception,perl_exception);
11688 exception=DestroyExceptionInfo(exception);
11689 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11690 SvPOK_on(perl_exception);
11691 ST(0)=sv_2mortal(perl_exception);
11696 ###############################################################################
11700 # Q u e r y C o l o r #
11704 ###############################################################################
11708 QueryColor(ref,...)
11709 Image::Magick ref=NO_INIT
11729 PERL_UNUSED_VAR(ref);
11730 PERL_UNUSED_VAR(ix);
11731 exception=AcquireExceptionInfo();
11732 perl_exception=newSVpv("",0);
11741 colorlist=GetColorInfoList("*",&colors,exception);
11743 for (i=0; i < (ssize_t) colors; i++)
11745 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11747 colorlist=(const ColorInfo **)
11748 RelinquishMagickMemory((ColorInfo **) colorlist);
11749 goto PerlException;
11751 EXTEND(sp,5*items);
11752 for (i=1; i < items; i++)
11754 name=(char *) SvPV(ST(i),na);
11755 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11760 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11761 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11762 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11763 if (color.colorspace == CMYKColorspace)
11764 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11765 if (color.matte != MagickFalse)
11766 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11770 InheritPerlException(exception,perl_exception);
11771 exception=DestroyExceptionInfo(exception);
11772 SvREFCNT_dec(perl_exception);
11776 ###############################################################################
11780 # Q u e r y C o l o r N a m e #
11784 ###############################################################################
11788 QueryColorname(ref,...)
11789 Image::Magick ref=NO_INIT
11798 message[MaxTextExtent];
11817 *reference; /* reference is the SV* of ref=SvIV(reference) */
11819 PERL_UNUSED_VAR(ref);
11820 PERL_UNUSED_VAR(ix);
11821 exception=AcquireExceptionInfo();
11822 perl_exception=newSVpv("",0);
11823 reference=SvRV(ST(0));
11824 av=(AV *) reference;
11825 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11827 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11828 if (image == (Image *) NULL)
11830 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11832 goto PerlException;
11835 for (i=1; i < items; i++)
11837 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11838 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11840 PUSHs(sv_2mortal(newSVpv(message,0)));
11844 InheritPerlException(exception,perl_exception);
11845 exception=DestroyExceptionInfo(exception);
11846 SvREFCNT_dec(perl_exception);
11850 ###############################################################################
11854 # Q u e r y F o n t #
11858 ###############################################################################
11863 Image::Magick ref=NO_INIT
11870 message[MaxTextExtent];
11881 volatile const TypeInfo
11884 PERL_UNUSED_VAR(ref);
11885 PERL_UNUSED_VAR(ix);
11886 exception=AcquireExceptionInfo();
11887 perl_exception=newSVpv("",0);
11896 typelist=GetTypeInfoList("*",&types,exception);
11898 for (i=0; i < (ssize_t) types; i++)
11900 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11902 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11904 goto PerlException;
11906 EXTEND(sp,10*items);
11907 for (i=1; i < items; i++)
11909 name=(char *) SvPV(ST(i),na);
11910 type_info=GetTypeInfo(name,exception);
11911 if (type_info == (TypeInfo *) NULL)
11916 if (type_info->name == (char *) NULL)
11919 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11920 if (type_info->description == (char *) NULL)
11923 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11924 if (type_info->family == (char *) NULL)
11927 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11928 if (type_info->style == UndefinedStyle)
11931 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11932 type_info->style),0)));
11933 if (type_info->stretch == UndefinedStretch)
11936 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11937 type_info->stretch),0)));
11938 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11939 type_info->weight);
11940 PUSHs(sv_2mortal(newSVpv(message,0)));
11941 if (type_info->encoding == (char *) NULL)
11944 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11945 if (type_info->foundry == (char *) NULL)
11948 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11949 if (type_info->format == (char *) NULL)
11952 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11953 if (type_info->metrics == (char *) NULL)
11956 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11957 if (type_info->glyphs == (char *) NULL)
11960 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11964 InheritPerlException(exception,perl_exception);
11965 exception=DestroyExceptionInfo(exception);
11966 SvREFCNT_dec(perl_exception);
11970 ###############################################################################
11974 # Q u e r y F o n t M e t r i c s #
11978 ###############################################################################
11982 QueryFontMetrics(ref,...)
11983 Image::Magick ref=NO_INIT
11985 queryfontmetrics = 1
12032 *reference; /* reference is the SV* of ref=SvIV(reference) */
12037 PERL_UNUSED_VAR(ref);
12038 PERL_UNUSED_VAR(ix);
12039 exception=AcquireExceptionInfo();
12040 package_info=(struct PackageInfo *) NULL;
12041 perl_exception=newSVpv("",0);
12042 reference=SvRV(ST(0));
12043 av=(AV *) reference;
12044 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12046 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12047 if (image == (Image *) NULL)
12049 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12051 goto PerlException;
12053 package_info=ClonePackageInfo(info,exception);
12054 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12055 CloneString(&draw_info->text,"");
12056 current=draw_info->affine;
12057 GetAffineMatrix(&affine);
12060 EXTEND(sp,7*items);
12061 for (i=2; i < items; i+=2)
12063 attribute=(char *) SvPV(ST(i-1),na);
12064 switch (*attribute)
12069 if (LocaleCompare(attribute,"antialias") == 0)
12071 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12075 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12079 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12089 if (LocaleCompare(attribute,"density") == 0)
12091 CloneString(&draw_info->density,SvPV(ST(i),na));
12094 if (LocaleCompare(attribute,"direction") == 0)
12096 draw_info->direction=(DirectionType) ParseCommandOption(
12097 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12100 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12107 if (LocaleCompare(attribute,"encoding") == 0)
12109 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12112 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12119 if (LocaleCompare(attribute,"family") == 0)
12121 CloneString(&draw_info->family,SvPV(ST(i),na));
12124 if (LocaleCompare(attribute,"fill") == 0)
12127 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12128 &image->exception);
12131 if (LocaleCompare(attribute,"font") == 0)
12133 CloneString(&draw_info->font,SvPV(ST(i),na));
12136 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12143 if (LocaleCompare(attribute,"geometry") == 0)
12145 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12148 if (LocaleCompare(attribute,"gravity") == 0)
12150 draw_info->gravity=(GravityType) ParseCommandOption(
12151 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12154 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12161 if (LocaleCompare(attribute,"interline-spacing") == 0)
12163 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12164 draw_info->interline_spacing=geometry_info.rho;
12167 if (LocaleCompare(attribute,"interword-spacing") == 0)
12169 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12170 draw_info->interword_spacing=geometry_info.rho;
12173 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12180 if (LocaleCompare(attribute,"kerning") == 0)
12182 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12183 draw_info->kerning=geometry_info.rho;
12186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12193 if (LocaleCompare(attribute,"pointsize") == 0)
12195 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12196 draw_info->pointsize=geometry_info.rho;
12199 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12206 if (LocaleCompare(attribute,"rotate") == 0)
12208 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12209 affine.rx=geometry_info.rho;
12210 affine.ry=geometry_info.sigma;
12211 if ((flags & SigmaValue) == 0)
12212 affine.ry=affine.rx;
12215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12222 if (LocaleCompare(attribute,"scale") == 0)
12224 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12225 affine.sx=geometry_info.rho;
12226 affine.sy=geometry_info.sigma;
12227 if ((flags & SigmaValue) == 0)
12228 affine.sy=affine.sx;
12231 if (LocaleCompare(attribute,"skew") == 0)
12237 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12238 x_angle=geometry_info.rho;
12239 y_angle=geometry_info.sigma;
12240 if ((flags & SigmaValue) == 0)
12242 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12243 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12246 if (LocaleCompare(attribute,"stroke") == 0)
12249 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12250 &image->exception);
12253 if (LocaleCompare(attribute,"style") == 0)
12255 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12259 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12263 draw_info->style=(StyleType) type;
12266 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12273 if (LocaleCompare(attribute,"text") == 0)
12275 CloneString(&draw_info->text,SvPV(ST(i),na));
12278 if (LocaleCompare(attribute,"translate") == 0)
12280 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12281 affine.tx=geometry_info.rho;
12282 affine.ty=geometry_info.sigma;
12283 if ((flags & SigmaValue) == 0)
12284 affine.ty=affine.tx;
12287 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12294 if (LocaleCompare(attribute,"weight") == 0)
12296 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12297 draw_info->weight=(size_t) geometry_info.rho;
12300 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12307 if (LocaleCompare(attribute,"x") == 0)
12309 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12310 x=geometry_info.rho;
12313 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12320 if (LocaleCompare(attribute,"y") == 0)
12322 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12323 y=geometry_info.rho;
12326 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12338 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12339 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12340 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12341 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12342 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12343 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12344 if (draw_info->geometry == (char *) NULL)
12346 draw_info->geometry=AcquireString((char *) NULL);
12347 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12348 "%.15g,%.15g",x,y);
12350 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12351 (void) CatchImageException(image);
12352 if (status == MagickFalse)
12356 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12357 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12358 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12359 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12360 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12361 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12362 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12363 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12364 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12365 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12366 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12367 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12368 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12370 draw_info=DestroyDrawInfo(draw_info);
12373 if (package_info != (struct PackageInfo *) NULL)
12374 DestroyPackageInfo(package_info);
12375 InheritPerlException(exception,perl_exception);
12376 exception=DestroyExceptionInfo(exception);
12377 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12381 ###############################################################################
12385 # 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 #
12389 ###############################################################################
12393 QueryMultilineFontMetrics(ref,...)
12394 Image::Magick ref=NO_INIT
12396 querymultilinefontmetrics = 1
12443 *reference; /* reference is the SV* of ref=SvIV(reference) */
12448 PERL_UNUSED_VAR(ref);
12449 PERL_UNUSED_VAR(ix);
12450 exception=AcquireExceptionInfo();
12451 package_info=(struct PackageInfo *) NULL;
12452 perl_exception=newSVpv("",0);
12453 reference=SvRV(ST(0));
12454 av=(AV *) reference;
12455 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12457 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12458 if (image == (Image *) NULL)
12460 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12462 goto PerlException;
12464 package_info=ClonePackageInfo(info,exception);
12465 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12466 CloneString(&draw_info->text,"");
12467 current=draw_info->affine;
12468 GetAffineMatrix(&affine);
12471 EXTEND(sp,7*items);
12472 for (i=2; i < items; i+=2)
12474 attribute=(char *) SvPV(ST(i-1),na);
12475 switch (*attribute)
12480 if (LocaleCompare(attribute,"antialias") == 0)
12482 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12486 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12490 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12493 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12500 if (LocaleCompare(attribute,"density") == 0)
12502 CloneString(&draw_info->density,SvPV(ST(i),na));
12505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12512 if (LocaleCompare(attribute,"encoding") == 0)
12514 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12524 if (LocaleCompare(attribute,"family") == 0)
12526 CloneString(&draw_info->family,SvPV(ST(i),na));
12529 if (LocaleCompare(attribute,"fill") == 0)
12532 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12533 &image->exception);
12536 if (LocaleCompare(attribute,"font") == 0)
12538 CloneString(&draw_info->font,SvPV(ST(i),na));
12541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12548 if (LocaleCompare(attribute,"geometry") == 0)
12550 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12553 if (LocaleCompare(attribute,"gravity") == 0)
12555 draw_info->gravity=(GravityType) ParseCommandOption(
12556 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12566 if (LocaleCompare(attribute,"pointsize") == 0)
12568 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12569 draw_info->pointsize=geometry_info.rho;
12572 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12579 if (LocaleCompare(attribute,"rotate") == 0)
12581 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12582 affine.rx=geometry_info.rho;
12583 affine.ry=geometry_info.sigma;
12584 if ((flags & SigmaValue) == 0)
12585 affine.ry=affine.rx;
12588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12595 if (LocaleCompare(attribute,"scale") == 0)
12597 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12598 affine.sx=geometry_info.rho;
12599 affine.sy=geometry_info.sigma;
12600 if ((flags & SigmaValue) == 0)
12601 affine.sy=affine.sx;
12604 if (LocaleCompare(attribute,"skew") == 0)
12610 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12611 x_angle=geometry_info.rho;
12612 y_angle=geometry_info.sigma;
12613 if ((flags & SigmaValue) == 0)
12615 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12616 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12619 if (LocaleCompare(attribute,"stroke") == 0)
12622 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12623 &image->exception);
12626 if (LocaleCompare(attribute,"style") == 0)
12628 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12632 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12636 draw_info->style=(StyleType) type;
12639 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12646 if (LocaleCompare(attribute,"text") == 0)
12648 CloneString(&draw_info->text,SvPV(ST(i),na));
12651 if (LocaleCompare(attribute,"translate") == 0)
12653 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12654 affine.tx=geometry_info.rho;
12655 affine.ty=geometry_info.sigma;
12656 if ((flags & SigmaValue) == 0)
12657 affine.ty=affine.tx;
12660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12667 if (LocaleCompare(attribute,"weight") == 0)
12669 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12670 draw_info->weight=(size_t) geometry_info.rho;
12673 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12680 if (LocaleCompare(attribute,"x") == 0)
12682 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12683 x=geometry_info.rho;
12686 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12693 if (LocaleCompare(attribute,"y") == 0)
12695 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12696 y=geometry_info.rho;
12699 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12705 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12711 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12712 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12713 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12714 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12715 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12716 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12717 if (draw_info->geometry == (char *) NULL)
12719 draw_info->geometry=AcquireString((char *) NULL);
12720 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12721 "%.15g,%.15g",x,y);
12723 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12724 (void) CatchException(exception);
12725 if (status == MagickFalse)
12729 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12730 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12731 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12732 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12733 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12734 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12735 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12736 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12737 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12738 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12739 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12740 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12741 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12743 draw_info=DestroyDrawInfo(draw_info);
12746 if (package_info != (struct PackageInfo *) NULL)
12747 DestroyPackageInfo(package_info);
12748 InheritPerlException(exception,perl_exception);
12749 exception=DestroyExceptionInfo(exception);
12750 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12754 ###############################################################################
12758 # Q u e r y F o r m a t #
12762 ###############################################################################
12766 QueryFormat(ref,...)
12767 Image::Magick ref=NO_INIT
12784 volatile const MagickInfo
12787 PERL_UNUSED_VAR(ref);
12788 PERL_UNUSED_VAR(ix);
12789 exception=AcquireExceptionInfo();
12790 perl_exception=newSVpv("",0);
12794 format[MaxTextExtent];
12802 format_list=GetMagickInfoList("*",&types,exception);
12804 for (i=0; i < (ssize_t) types; i++)
12806 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12807 LocaleLower(format);
12808 PUSHs(sv_2mortal(newSVpv(format,0)));
12810 format_list=(const MagickInfo **)
12811 RelinquishMagickMemory((MagickInfo *) format_list);
12812 goto PerlException;
12814 EXTEND(sp,8*items);
12815 for (i=1; i < items; i++)
12817 name=(char *) SvPV(ST(i),na);
12818 magick_info=GetMagickInfo(name,exception);
12819 if (magick_info == (const MagickInfo *) NULL)
12824 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12825 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12826 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12827 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12828 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12829 if (magick_info->description == (char *) NULL)
12832 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12833 if (magick_info->module == (char *) NULL)
12836 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12840 InheritPerlException(exception,perl_exception);
12841 exception=DestroyExceptionInfo(exception);
12842 SvREFCNT_dec(perl_exception);
12846 ###############################################################################
12850 # Q u e r y O p t i o n #
12854 ###############################################################################
12858 QueryOption(ref,...)
12859 Image::Magick ref=NO_INIT
12880 PERL_UNUSED_VAR(ref);
12881 PERL_UNUSED_VAR(ix);
12882 exception=AcquireExceptionInfo();
12883 perl_exception=newSVpv("",0);
12884 EXTEND(sp,8*items);
12885 for (i=1; i < items; i++)
12887 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12889 options=GetCommandOptions((CommandOption) option);
12890 if (options == (char **) NULL)
12894 for (j=0; options[j] != (char *) NULL; j++)
12895 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12896 options=DestroyStringList(options);
12900 InheritPerlException(exception,perl_exception);
12901 exception=DestroyExceptionInfo(exception);
12902 SvREFCNT_dec(perl_exception);
12906 ###############################################################################
12914 ###############################################################################
12919 Image::Magick ref=NO_INIT
12966 *perl_exception, /* Perl variable for storing messages */
12971 PERL_UNUSED_VAR(ref);
12972 PERL_UNUSED_VAR(ix);
12973 exception=AcquireExceptionInfo();
12974 perl_exception=newSVpv("",0);
12976 package_info=(struct PackageInfo *) NULL;
12978 ac=(items < 2) ? 1 : items-1;
12979 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12981 length=(STRLEN *) NULL;
12982 if (list == (char **) NULL)
12984 ThrowPerlException(exception,ResourceLimitError,
12985 "MemoryAllocationFailed",PackageName);
12986 goto PerlException;
12988 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12989 if (length == (STRLEN *) NULL)
12991 ThrowPerlException(exception,ResourceLimitError,
12992 "MemoryAllocationFailed",PackageName);
12993 goto PerlException;
12995 if (sv_isobject(ST(0)) == 0)
12997 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12999 goto PerlException;
13001 reference=SvRV(ST(0));
13002 hv=SvSTASH(reference);
13003 if (SvTYPE(reference) != SVt_PVAV)
13005 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13007 goto PerlException;
13009 av=(AV *) reference;
13010 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13012 package_info=ClonePackageInfo(info,exception);
13015 *list=(char *) (*package_info->image_info->filename ?
13016 package_info->image_info->filename : "XC:black");
13018 for (n=0, i=0; i < ac; i++)
13020 list[n]=(char *) SvPV(ST(i+1),length[n]);
13021 if ((items >= 3) && strEQcase(list[n],"blob"))
13027 blob=(void *) (SvPV(ST(i+1),length[n]));
13028 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13030 if ((items >= 3) && strEQcase(list[n],"filename"))
13032 if ((items >= 3) && strEQcase(list[n],"file"))
13041 io_info=IoIFP(sv_2io(ST(i+1)));
13042 if (io_info == (PerlIO *) NULL)
13044 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13048 file=PerlIO_findFILE(io_info);
13049 if (file == (FILE *) NULL)
13051 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13055 SetImageInfoFile(package_info->image_info,file);
13057 if ((items >= 3) && strEQcase(list[n],"magick"))
13061 list[n]=(char *) NULL;
13063 status=ExpandFilenames(&n,&list);
13064 if (status == MagickFalse)
13066 ThrowPerlException(exception,ResourceLimitError,
13067 "MemoryAllocationFailed",PackageName);
13068 goto PerlException;
13071 for (i=0; i < n; i++)
13073 if ((package_info->image_info->file != (FILE *) NULL) ||
13074 (package_info->image_info->blob != (void *) NULL))
13076 image=ReadImages(package_info->image_info,exception);
13077 if (image != (Image *) NULL)
13078 DisassociateImageStream(image);
13082 (void) CopyMagickString(package_info->image_info->filename,list[i],
13084 image=ReadImages(package_info->image_info,exception);
13086 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13088 for ( ; image; image=image->next)
13090 AddImageToRegistry(sv,image);
13092 av_push(av,sv_bless(rv,hv));
13100 for (i=0; i < n; i++)
13101 if (list[i] != (char *) NULL)
13102 for (p=keep; list[i] != *p++; )
13103 if (*p == (char *) NULL)
13105 list[i]=(char *) RelinquishMagickMemory(list[i]);
13110 if (package_info != (struct PackageInfo *) NULL)
13111 DestroyPackageInfo(package_info);
13112 if (list && (list != keep))
13113 list=(char **) RelinquishMagickMemory(list);
13115 keep=(char **) RelinquishMagickMemory(keep);
13117 length=(STRLEN *) RelinquishMagickMemory(length);
13118 InheritPerlException(exception,perl_exception);
13119 exception=DestroyExceptionInfo(exception);
13120 sv_setiv(perl_exception,(IV) number_images);
13121 SvPOK_on(perl_exception);
13122 ST(0)=sv_2mortal(perl_exception);
13127 ###############################################################################
13135 ###############################################################################
13140 Image::Magick ref=NO_INIT
13163 PERL_UNUSED_VAR(ref);
13164 PERL_UNUSED_VAR(ix);
13165 exception=AcquireExceptionInfo();
13166 perl_exception=newSVpv("",0);
13167 reference=SvRV(ST(0));
13168 av=(AV *) reference;
13169 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13171 for (i=1; i < items; i++)
13172 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13173 SvPV(ST(i),na),exception);
13174 InheritPerlException(exception,perl_exception);
13175 exception=DestroyExceptionInfo(exception);
13176 SvREFCNT_dec(perl_exception); /* throw away all errors */
13180 ###############################################################################
13188 ###############################################################################
13193 Image::Magick ref=NO_INIT
13216 *reference; /* reference is the SV* of ref=SvIV(reference) */
13218 PERL_UNUSED_VAR(ref);
13219 PERL_UNUSED_VAR(ix);
13220 exception=AcquireExceptionInfo();
13221 perl_exception=newSVpv("",0);
13222 if (sv_isobject(ST(0)) == 0)
13224 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13226 goto PerlException;
13228 reference=SvRV(ST(0));
13229 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13231 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13233 for (i=2; i < items; i+=2)
13234 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13237 InheritPerlException(exception,perl_exception);
13238 exception=DestroyExceptionInfo(exception);
13239 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13240 SvPOK_on(perl_exception);
13241 ST(0)=sv_2mortal(perl_exception);
13246 ###############################################################################
13250 # S e t P i x e l #
13254 ###############################################################################
13259 Image::Magick ref=NO_INIT
13301 *reference; /* reference is the SV* of ref=SvIV(reference) */
13303 PERL_UNUSED_VAR(ref);
13304 PERL_UNUSED_VAR(ix);
13305 exception=AcquireExceptionInfo();
13306 perl_exception=newSVpv("",0);
13307 reference=SvRV(ST(0));
13308 av=(AV *) reference;
13309 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13311 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13312 if (image == (Image *) NULL)
13314 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13316 goto PerlException;
13319 normalize=MagickTrue;
13322 region.width=image->columns;
13325 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13326 channel=DefaultChannels;
13327 for (i=2; i < items; i+=2)
13329 attribute=(char *) SvPV(ST(i-1),na);
13330 switch (*attribute)
13335 if (LocaleCompare(attribute,"channel") == 0)
13340 option=ParseChannelOption(SvPV(ST(i),na));
13343 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13347 channel=(ChannelType) option;
13350 if (LocaleCompare(attribute,"color") == 0)
13352 if (SvTYPE(ST(i)) != SVt_RV)
13355 message[MaxTextExtent];
13357 (void) FormatLocaleString(message,MaxTextExtent,
13358 "invalid %.60s value",attribute);
13359 ThrowPerlException(exception,OptionError,message,
13362 av=(AV *) SvRV(ST(i));
13365 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13372 if (LocaleCompare(attribute,"geometry") == 0)
13374 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13377 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13384 if (LocaleCompare(attribute,"normalize") == 0)
13386 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13390 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13394 normalize=option != 0 ? MagickTrue : MagickFalse;
13397 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13404 if (LocaleCompare(attribute,"x") == 0)
13406 region.x=SvIV(ST(i));
13409 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13416 if (LocaleCompare(attribute,"y") == 0)
13418 region.y=SvIV(ST(i));
13421 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13427 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13433 (void) SetImageStorageClass(image,DirectClass,exception);
13434 channel_mask=SetPixelChannelMask(image,channel);
13435 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13436 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13437 (SvTYPE(av) != SVt_PVAV))
13449 if (normalize != MagickFalse)
13450 scale=QuantumRange;
13451 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13454 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13455 av_fetch(av,i,0)))),q);
13458 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13461 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13462 av_fetch(av,i,0)))),q);
13465 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13468 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13469 av_fetch(av,i,0)))),q);
13472 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13473 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13475 SetPixelBlack(image,ClampToQuantum(scale*
13476 SvNV(*(av_fetch(av,i,0)))),q);
13479 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13482 SetPixelAlpha(image,ClampToQuantum(scale*
13483 SvNV(*(av_fetch(av,i,0)))),q);
13486 (void) SyncAuthenticPixels(image,exception);
13488 (void) SetPixelChannelMask(image,channel_mask);
13491 InheritPerlException(exception,perl_exception);
13492 exception=DestroyExceptionInfo(exception);
13493 SvREFCNT_dec(perl_exception);
13497 ###############################################################################
13505 ###############################################################################
13510 Image::Magick ref=NO_INIT
13549 PERL_UNUSED_VAR(ref);
13550 PERL_UNUSED_VAR(ix);
13551 exception=AcquireExceptionInfo();
13552 perl_exception=newSVpv("",0);
13556 if (sv_isobject(ST(0)) == 0)
13558 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13560 goto PerlException;
13562 reference=SvRV(ST(0));
13563 hv=SvSTASH(reference);
13565 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13567 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13568 if (image == (Image *) NULL)
13570 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13572 goto PerlException;
13574 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13580 for (i=2; i < items; i+=2)
13582 attribute=(char *) SvPV(ST(i-1),na);
13583 switch (*attribute)
13588 if (LocaleCompare(attribute,"offset") == 0)
13590 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13593 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13600 if (LocaleCompare(attribute,"stack") == 0)
13602 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13606 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13612 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13618 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13624 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13626 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13627 goto PerlException;
13628 for ( ; image; image=image->next)
13630 AddImageToRegistry(sv,image);
13632 av_push(av,sv_bless(rv,hv));
13635 exception=DestroyExceptionInfo(exception);
13636 ST(0)=av_reference;
13637 SvREFCNT_dec(perl_exception);
13641 InheritPerlException(exception,perl_exception);
13642 exception=DestroyExceptionInfo(exception);
13643 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13644 SvPOK_on(perl_exception);
13645 ST(0)=sv_2mortal(perl_exception);
13650 ###############################################################################
13654 # S t a t i s t i c s #
13658 ###############################################################################
13662 Statistics(ref,...)
13663 Image::Magick ref=NO_INIT
13665 StatisticsImage = 1
13667 statisticsimage = 3
13670 #define ChannelStatistics(channel) \
13672 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13673 (double) channel_statistics[channel].depth); \
13674 PUSHs(sv_2mortal(newSVpv(message,0))); \
13675 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13676 channel_statistics[channel].minima/scale); \
13677 PUSHs(sv_2mortal(newSVpv(message,0))); \
13678 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13679 channel_statistics[channel].maxima/scale); \
13680 PUSHs(sv_2mortal(newSVpv(message,0))); \
13681 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13682 channel_statistics[channel].mean/scale); \
13683 PUSHs(sv_2mortal(newSVpv(message,0))); \
13684 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13685 channel_statistics[channel].standard_deviation/scale); \
13686 PUSHs(sv_2mortal(newSVpv(message,0))); \
13687 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13688 channel_statistics[channel].kurtosis); \
13689 PUSHs(sv_2mortal(newSVpv(message,0))); \
13690 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13691 channel_statistics[channel].skewness); \
13692 PUSHs(sv_2mortal(newSVpv(message,0))); \
13699 message[MaxTextExtent];
13702 *channel_statistics;
13723 PERL_UNUSED_VAR(ref);
13724 PERL_UNUSED_VAR(ix);
13725 exception=AcquireExceptionInfo();
13726 perl_exception=newSVpv("",0);
13728 if (sv_isobject(ST(0)) == 0)
13730 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13732 goto PerlException;
13734 reference=SvRV(ST(0));
13737 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13738 if (image == (Image *) NULL)
13740 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13742 goto PerlException;
13744 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13746 for ( ; image; image=image->next)
13748 channel_statistics=GetImageStatistics(image,&image->exception);
13749 if (channel_statistics == (ChannelStatistics *) NULL)
13752 EXTEND(sp,35*count);
13753 scale=(double) QuantumRange;
13754 ChannelStatistics(RedChannel);
13755 ChannelStatistics(GreenChannel);
13756 ChannelStatistics(BlueChannel);
13757 if (image->colorspace == CMYKColorspace)
13758 ChannelStatistics(BlackChannel);
13759 if (image->matte != MagickFalse)
13760 ChannelStatistics(AlphaChannel);
13761 channel_statistics=(ChannelStatistics *)
13762 RelinquishMagickMemory(channel_statistics);
13766 InheritPerlException(exception,perl_exception);
13767 exception=DestroyExceptionInfo(exception);
13768 SvREFCNT_dec(perl_exception);
13772 ###############################################################################
13776 # S y n c A u t h e n t i c P i x e l s #
13780 ###############################################################################
13784 SyncAuthenticPixels(ref,...)
13785 Image::Magick ref = NO_INIT
13787 Syncauthenticpixels = 1
13788 SyncImagePixels = 2
13789 syncimagepixels = 3
13808 PERL_UNUSED_VAR(ref);
13809 PERL_UNUSED_VAR(ix);
13810 exception=AcquireExceptionInfo();
13811 perl_exception=newSVpv("",0);
13812 if (sv_isobject(ST(0)) == 0)
13814 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13816 goto PerlException;
13819 reference=SvRV(ST(0));
13820 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13821 if (image == (Image *) NULL)
13823 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13825 goto PerlException;
13828 status=SyncAuthenticPixels(image,exception);
13829 if (status != MagickFalse)
13831 InheritException(exception,&image->exception);
13834 InheritPerlException(exception,perl_exception);
13835 exception=DestroyExceptionInfo(exception);
13836 SvREFCNT_dec(perl_exception); /* throw away all errors */
13840 ###############################################################################
13844 # T r a n s f o r m #
13848 ###############################################################################
13853 Image::Magick ref=NO_INIT
13891 PERL_UNUSED_VAR(ref);
13892 PERL_UNUSED_VAR(ix);
13893 exception=AcquireExceptionInfo();
13894 perl_exception=newSVpv("",0);
13898 if (sv_isobject(ST(0)) == 0)
13900 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13902 goto PerlException;
13904 reference=SvRV(ST(0));
13905 hv=SvSTASH(reference);
13907 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13909 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13910 if (image == (Image *) NULL)
13912 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13914 goto PerlException;
13916 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13920 crop_geometry=(char *) NULL;
13921 geometry=(char *) NULL;
13922 for (i=2; i < items; i+=2)
13924 attribute=(char *) SvPV(ST(i-1),na);
13925 switch (*attribute)
13930 if (LocaleCompare(attribute,"crop") == 0)
13932 crop_geometry=SvPV(ST(i),na);
13935 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13942 if (LocaleCompare(attribute,"geometry") == 0)
13944 geometry=SvPV(ST(i),na);
13947 if (LocaleCompare(attribute,"gravity") == 0)
13955 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13956 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13959 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13963 for (next=image; next; next=next->next)
13964 next->gravity=(GravityType) in;
13967 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13973 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13979 for ( ; image; image=image->next)
13981 clone=CloneImage(image,0,0,MagickTrue,exception);
13982 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13983 goto PerlException;
13984 TransformImage(&clone,crop_geometry,geometry);
13985 for ( ; clone; clone=clone->next)
13987 AddImageToRegistry(sv,clone);
13989 av_push(av,sv_bless(rv,hv));
13993 exception=DestroyExceptionInfo(exception);
13994 ST(0)=av_reference;
13995 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13999 InheritPerlException(exception,perl_exception);
14000 exception=DestroyExceptionInfo(exception);
14001 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14002 SvPOK_on(perl_exception);
14003 ST(0)=sv_2mortal(perl_exception);
14008 ###############################################################################
14016 ###############################################################################
14021 Image::Magick ref=NO_INIT
14029 filename[MaxTextExtent];
14053 PERL_UNUSED_VAR(ref);
14054 PERL_UNUSED_VAR(ix);
14055 exception=AcquireExceptionInfo();
14056 perl_exception=newSVpv("",0);
14058 package_info=(struct PackageInfo *) NULL;
14059 if (sv_isobject(ST(0)) == 0)
14061 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14063 goto PerlException;
14065 reference=SvRV(ST(0));
14066 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14067 if (image == (Image *) NULL)
14069 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14071 goto PerlException;
14073 package_info=ClonePackageInfo(info,exception);
14075 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14078 for (i=2; i < items; i+=2)
14079 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14081 (void) CopyMagickString(filename,package_info->image_info->filename,
14084 for (next=image; next; next=next->next)
14086 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14087 next->scene=scene++;
14089 SetImageInfo(package_info->image_info,(unsigned int)
14090 GetImageListLength(image),&image->exception);
14091 for (next=image; next; next=next->next)
14093 (void) WriteImage(package_info->image_info,next,exception);
14095 if (package_info->image_info->adjoin)
14100 if (package_info != (struct PackageInfo *) NULL)
14101 DestroyPackageInfo(package_info);
14102 InheritPerlException(exception,perl_exception);
14103 exception=DestroyExceptionInfo(exception);
14104 sv_setiv(perl_exception,(IV) number_images);
14105 SvPOK_on(perl_exception);
14106 ST(0)=sv_2mortal(perl_exception);