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.
55 #if defined(__cplusplus) || defined(c_plusplus)
59 #define PERL_NO_GET_CONTEXT
64 #include <MagickCore/MagickCore.h>
67 #if defined(__cplusplus) || defined(c_plusplus)
79 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
80 #define EndOf(array) (&array[NumberOf(array)])
81 #define MaxArguments 33
85 #define NumberOf(array) (sizeof(array)/sizeof(*array))
86 #define PackageName "Image::Magick"
89 #define PerlIO_importFILE(f, fl) (f)
90 #define PerlIO_findFILE(f) NULL
93 #define sv_undef PL_sv_undef
96 #define AddImageToRegistry(sv,image) \
98 if (magick_registry != (SplayTreeInfo *) NULL) \
100 (void) AddValueToSplayTree(magick_registry,image,image); \
101 (sv)=newSViv((IV) image); \
105 #define DeleteImageFromRegistry(reference,image) \
107 if (magick_registry != (SplayTreeInfo *) NULL) \
109 if (GetImageReferenceCount(image) == 1) \
110 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
111 image=DestroyImage(image); \
112 sv_setiv(reference,0); \
116 #define InheritPerlException(exception,perl_exception) \
119 message[MaxTextExtent]; \
121 if ((exception)->severity != UndefinedException) \
123 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
124 (exception)->severity, (exception)->reason ? \
125 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
126 "Unknown", (exception)->description ? " (" : "", \
127 (exception)->description ? GetLocaleExceptionMessage( \
128 (exception)->severity,(exception)->description) : "", \
129 (exception)->description ? ")" : ""); \
130 if ((perl_exception) != (SV *) NULL) \
132 if (SvCUR(perl_exception)) \
133 sv_catpv(perl_exception,"\n"); \
134 sv_catpv(perl_exception,message); \
139 #define ThrowPerlException(exception,severity,tag,reason) \
140 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
141 tag,"`%s'",reason); \
144 Typedef and structure declarations.
148 ArrayReference = (~0),
149 RealReference = (~0)-1,
150 FileReference = (~0)-2,
151 ImageReference = (~0)-3,
152 IntegerReference = (~0)-4,
153 StringReference = (~0)-5
156 typedef struct _Arguments
196 *Image__Magick; /* data type for the Image::Magick package */
208 arguments[MaxArguments];
211 { "Comment", { {"comment", StringReference} } },
212 { "Label", { {"label", StringReference} } },
213 { "AddNoise", { {"noise", MagickNoiseOptions},
214 {"channel", MagickChannelOptions} } },
215 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
216 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
217 {"height", IntegerReference}, {"fill", StringReference},
218 {"bordercolor", StringReference}, {"color", StringReference},
219 {"compose", MagickComposeOptions} } },
220 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
221 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
222 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference} } },
225 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
226 {"height", IntegerReference}, {"x", IntegerReference},
227 {"y", IntegerReference}, {"fuzz", StringReference},
228 {"gravity", MagickGravityOptions} } },
230 { "Edge", { {"radius", RealReference} } },
231 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
232 {"sigma", RealReference} } },
236 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
237 {"height", IntegerReference}, {"inner", IntegerReference},
238 {"outer", IntegerReference}, {"fill", StringReference},
239 {"color", StringReference}, {"compose", MagickComposeOptions} } },
240 { "Implode", { {"amount", RealReference},
241 {"interpolate", MagickInterpolateOptions} } },
243 { "MedianFilter", { {"geometry", StringReference},
244 {"width", IntegerReference},{"height", IntegerReference},
245 {"channel", MagickChannelOptions} } },
247 { "OilPaint", { {"radius", RealReference} } },
248 { "ReduceNoise", { {"geometry", StringReference},
249 {"width", IntegerReference},{"height", IntegerReference},
250 {"channel", MagickChannelOptions} } },
251 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
252 {"y", IntegerReference} } },
253 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
254 {"color", StringReference}, {"background", StringReference} } },
255 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
256 {"height", IntegerReference} } },
257 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
258 {"height", IntegerReference} } },
259 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
260 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
261 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
262 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
263 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
264 {"y", RealReference}, { "fill", StringReference},
265 {"color", StringReference} } },
266 { "Spread", { {"radius", RealReference} } },
267 { "Swirl", { {"degrees", RealReference},
268 {"interpolate", MagickInterpolateOptions} } },
269 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", StringReference }, {"blur", RealReference } } },
272 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
273 {"height", IntegerReference}, {"filter", MagickFilterOptions},
274 {"support", RealReference }, {"blur", RealReference } } },
275 { "Annotate", { {"text", StringReference}, {"font", StringReference},
276 {"pointsize", RealReference}, {"density", StringReference},
277 {"undercolor", StringReference}, {"stroke", StringReference},
278 {"fill", StringReference}, {"geometry", StringReference},
279 {"pen", StringReference}, {"x", RealReference},
280 {"y", RealReference}, {"gravity", MagickGravityOptions},
281 {"translate", StringReference}, {"scale", StringReference},
282 {"rotate", RealReference}, {"skewX", RealReference},
283 {"skewY", RealReference}, {"strokewidth", RealReference},
284 {"antialias", MagickBooleanOptions}, {"family", StringReference},
285 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
286 {"weight", IntegerReference}, {"align", MagickAlignOptions},
287 {"encoding", StringReference}, {"affine", ArrayReference},
288 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
289 {"tile", ImageReference}, {"kerning", RealReference},
290 {"interline-spacing", RealReference},
291 {"interword-spacing", RealReference},
292 {"direction", MagickDirectionOptions} } },
293 { "ColorFloodfill", { {"geometry", StringReference},
294 {"x", IntegerReference}, {"y", IntegerReference},
295 {"fill", StringReference}, {"bordercolor", StringReference},
296 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
297 { "Composite", { {"image", ImageReference},
298 {"compose", MagickComposeOptions}, {"geometry", StringReference},
299 {"x", IntegerReference}, {"y", IntegerReference},
300 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
301 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
302 {"color", StringReference}, {"mask", ImageReference},
303 {"channel", MagickChannelOptions},
304 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
305 {"blend", StringReference} } },
306 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
307 { "CycleColormap", { {"display", IntegerReference} } },
308 { "Draw", { {"primitive", MagickPrimitiveOptions},
309 {"points", StringReference}, {"method", MagickMethodOptions},
310 {"stroke", StringReference}, {"fill", StringReference},
311 {"strokewidth", RealReference}, {"font", StringReference},
312 {"bordercolor", StringReference}, {"x", RealReference},
313 {"y", RealReference}, {"translate", StringReference},
314 {"scale", StringReference}, {"rotate", RealReference},
315 {"skewX", RealReference}, {"skewY", RealReference},
316 {"tile", ImageReference}, {"pointsize", RealReference},
317 {"antialias", MagickBooleanOptions}, {"density", StringReference},
318 {"linewidth", RealReference}, {"affine", ArrayReference},
319 {"stroke-dashoffset", RealReference},
320 {"stroke-dasharray", ArrayReference},
321 {"interpolate", MagickInterpolateOptions},
322 {"origin", StringReference}, {"text", StringReference},
323 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
324 {"vector-graphics", StringReference}, {"kerning", RealReference},
325 {"interline-spacing", RealReference},
326 {"interword-spacing", RealReference},
327 {"direction", MagickDirectionOptions} } },
328 { "Equalize", { {"channel", MagickChannelOptions} } },
329 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
330 {"red", RealReference}, {"green", RealReference},
331 {"blue", RealReference} } },
332 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
333 {"dither-method", MagickDitherOptions} } },
334 { "MatteFloodfill", { {"geometry", StringReference},
335 {"x", IntegerReference}, {"y", IntegerReference},
336 {"opacity", StringReference}, {"bordercolor", StringReference},
337 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
338 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
339 {"saturation", RealReference}, {"whiteness", RealReference},
340 {"brightness", RealReference}, {"lightness", RealReference},
341 {"blackness", RealReference} } },
342 { "Negate", { {"gray", MagickBooleanOptions},
343 {"channel", MagickChannelOptions} } },
344 { "Normalize", { {"channel", MagickChannelOptions} } },
346 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
347 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
348 {"invert", MagickBooleanOptions} } },
349 { "Quantize", { {"colors", IntegerReference},
350 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
351 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
352 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
353 {"dither-method", MagickDitherOptions} } },
354 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
355 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
356 { "Segment", { {"geometry", StringReference},
357 {"cluster-threshold", RealReference},
358 {"smoothing-threshold", RealReference},
359 {"colorspace", MagickColorspaceOptions},
360 {"verbose", MagickBooleanOptions} } },
362 { "Solarize", { {"geometry", StringReference},
363 {"threshold", StringReference} } },
365 { "Texture", { {"texture", ImageReference} } },
366 { "Evaluate", { {"value", RealReference},
367 {"operator", MagickEvaluateOptions},
368 {"channel", MagickChannelOptions} } },
369 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
370 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
371 { "Threshold", { {"threshold", StringReference},
372 {"channel", MagickChannelOptions} } },
373 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
374 {"sigma", RealReference} } },
375 { "Trim", { {"fuzz", StringReference} } },
376 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
377 {"wavelength", RealReference},
378 {"interpolate", MagickInterpolateOptions} } },
379 { "Separate", { {"channel", MagickChannelOptions} } },
381 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
382 {"y", IntegerReference} } },
383 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
385 { "GaussianBlur", { {"geometry", StringReference},
386 {"radius", RealReference}, {"sigma", RealReference},
387 {"channel", MagickChannelOptions} } },
388 { "Convolve", { {"coefficients", ArrayReference},
389 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
390 { "Profile", { {"name", StringReference}, {"profile", StringReference},
391 { "rendering-intent", MagickIntentOptions},
392 { "black-point-compensation", MagickBooleanOptions} } },
393 { "UnsharpMask", { {"geometry", StringReference},
394 {"radius", RealReference}, {"sigma", RealReference},
395 {"amount", RealReference}, {"threshold", RealReference},
396 {"channel", MagickChannelOptions} } },
397 { "MotionBlur", { {"geometry", StringReference},
398 {"radius", RealReference}, {"sigma", RealReference},
399 {"angle", RealReference}, {"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 {"offset", IntegerReference} } },
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 {"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 {"channel", MagickChannelOptions} } },
465 { "AdaptiveBlur", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"channel", MagickChannelOptions} } },
468 { "Sketch", { {"geometry", StringReference},
469 {"radius", RealReference}, {"sigma", RealReference},
470 {"angle", 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}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "Filter", { {"kernel", StringReference},
529 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
530 { "BrightnessContrast", { {"levels", StringReference},
531 {"brightness", RealReference},{"contrast", RealReference},
532 {"channel", MagickChannelOptions} } },
533 { "Morphology", { {"kernel", StringReference},
534 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
535 {"iterations", IntegerReference} } },
536 { "ColorMatrix", { {"matrix", ArrayReference} } },
537 { "Color", { {"color", StringReference} } },
538 { "Mode", { {"geometry", StringReference},
539 {"width", IntegerReference},{"height", IntegerReference},
540 {"channel", MagickChannelOptions} } },
541 { "Statistic", { {"geometry", StringReference},
542 {"width", IntegerReference},{"height", IntegerReference},
543 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
547 *magick_registry = (SplayTreeInfo *) NULL;
550 Forward declarations.
553 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
556 strEQcase(const char *,const char *);
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 % C l o n e P a c k a g e I n f o %
567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
572 % The format of the ClonePackageInfo routine is:
574 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
577 % A description of each parameter follows:
579 % o info: a structure of type info.
581 % o exception: Return any errors or warnings in this structure.
584 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
585 ExceptionInfo *exception)
590 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
591 if (clone_info == (struct PackageInfo *) NULL)
593 ThrowPerlException(exception,ResourceLimitError,
594 "UnableToClonePackageInfo",PackageName);
595 return((struct PackageInfo *) NULL);
597 if (info == (struct PackageInfo *) NULL)
599 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
603 clone_info->image_info=CloneImageInfo(info->image_info);
608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618 % constant() returns a double value for the specified name.
620 % The format of the constant routine is:
622 % double constant(char *name,ssize_t sans)
624 % A description of each parameter follows:
626 % o value: Method constant returns a double value for the specified name.
628 % o name: The name of the constant.
630 % o sans: This integer value is not used.
633 static double constant(char *name,ssize_t sans)
641 if (strEQ(name,"BlobError"))
643 if (strEQ(name,"BlobWarning"))
649 if (strEQ(name,"CacheError"))
651 if (strEQ(name,"CacheWarning"))
652 return(CacheWarning);
653 if (strEQ(name,"CoderError"))
655 if (strEQ(name,"CoderWarning"))
656 return(CoderWarning);
657 if (strEQ(name,"ConfigureError"))
658 return(ConfigureError);
659 if (strEQ(name,"ConfigureWarning"))
660 return(ConfigureWarning);
661 if (strEQ(name,"CorruptImageError"))
662 return(CorruptImageError);
663 if (strEQ(name,"CorruptImageWarning"))
664 return(CorruptImageWarning);
669 if (strEQ(name,"DelegateError"))
670 return(DelegateError);
671 if (strEQ(name,"DelegateWarning"))
672 return(DelegateWarning);
673 if (strEQ(name,"DrawError"))
675 if (strEQ(name,"DrawWarning"))
681 if (strEQ(name,"ErrorException"))
682 return(ErrorException);
683 if (strEQ(name,"ExceptionError"))
685 if (strEQ(name,"ExceptionWarning"))
686 return(CoderWarning);
691 if (strEQ(name,"FatalErrorException"))
692 return(FatalErrorException);
693 if (strEQ(name,"FileOpenError"))
694 return(FileOpenError);
695 if (strEQ(name,"FileOpenWarning"))
696 return(FileOpenWarning);
701 if (strEQ(name,"ImageError"))
703 if (strEQ(name,"ImageWarning"))
704 return(ImageWarning);
709 if (strEQ(name,"MaxRGB"))
710 return(QuantumRange);
711 if (strEQ(name,"MissingDelegateError"))
712 return(MissingDelegateError);
713 if (strEQ(name,"MissingDelegateWarning"))
714 return(MissingDelegateWarning);
715 if (strEQ(name,"ModuleError"))
717 if (strEQ(name,"ModuleWarning"))
718 return(ModuleWarning);
723 if (strEQ(name,"Opaque"))
725 if (strEQ(name,"OptionError"))
727 if (strEQ(name,"OptionWarning"))
728 return(OptionWarning);
733 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
734 return(MAGICKCORE_QUANTUM_DEPTH);
735 if (strEQ(name,"QuantumDepth"))
736 return(MAGICKCORE_QUANTUM_DEPTH);
737 if (strEQ(name,"QuantumRange"))
738 return(QuantumRange);
743 if (strEQ(name,"ResourceLimitError"))
744 return(ResourceLimitError);
745 if (strEQ(name,"ResourceLimitWarning"))
746 return(ResourceLimitWarning);
747 if (strEQ(name,"RegistryError"))
748 return(RegistryError);
749 if (strEQ(name,"RegistryWarning"))
750 return(RegistryWarning);
755 if (strEQ(name,"StreamError"))
757 if (strEQ(name,"StreamWarning"))
758 return(StreamWarning);
759 if (strEQ(name,"Success"))
765 if (strEQ(name,"Transparent"))
766 return(TransparentAlpha);
767 if (strEQ(name,"TypeError"))
769 if (strEQ(name,"TypeWarning"))
775 if (strEQ(name,"WarningException"))
776 return(WarningException);
781 if (strEQ(name,"XServerError"))
782 return(XServerError);
783 if (strEQ(name,"XServerWarning"))
784 return(XServerWarning);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % D e s t r o y P a c k a g e I n f o %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % Method DestroyPackageInfo frees a previously created info structure.
805 % The format of the DestroyPackageInfo routine is:
807 % DestroyPackageInfo(struct PackageInfo *info)
809 % A description of each parameter follows:
811 % o info: a structure of type info.
814 static void DestroyPackageInfo(struct PackageInfo *info)
816 info->image_info=DestroyImageInfo(info->image_info);
817 info=(struct PackageInfo *) RelinquishMagickMemory(info);
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 % Method GetList is recursively called by SetupList to traverse the
832 % Image__Magick reference. If building an reference_vector (see SetupList),
833 % *current is the current position in *reference_vector and *last is the final
834 % entry in *reference_vector.
836 % The format of the GetList routine is:
840 % A description of each parameter follows:
842 % o info: a structure of type info.
845 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
846 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
851 if (reference == (SV *) NULL)
853 switch (SvTYPE(reference))
873 previous=(Image *) NULL;
877 for (i=0; i <= n; i++)
883 if (rv && *rv && sv_isobject(*rv))
885 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
887 if (image == (Image *) NULL)
889 if (image == previous)
891 image=CloneImage(image,0,0,MagickTrue,exception);
892 if (image == (Image *) NULL)
895 image->previous=previous;
896 *(previous ? &previous->next : &head)=image;
897 for (previous=image; previous->next; previous=previous->next) ;
905 Blessed scalar, one image.
907 image=(Image *) SvIV(reference);
908 if (image == (Image *) NULL)
910 image->previous=(Image *) NULL;
911 image->next=(Image *) NULL;
912 if (reference_vector)
914 if (*current == *last)
917 if (*reference_vector == (SV **) NULL)
918 *reference_vector=(SV **) AcquireQuantumMemory(*last,
919 sizeof(*reference_vector));
921 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
922 *last,sizeof(*reference_vector));
924 if (*reference_vector == (SV **) NULL)
926 ThrowPerlException(exception,ResourceLimitError,
927 "MemoryAllocationFailed",PackageName);
928 return((Image *) NULL);
930 (*reference_vector)[*current]=reference;
931 (*reference_vector)[++(*current)]=NULL;
938 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
939 (double) SvTYPE(reference));
940 return((Image *) NULL);
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 % G e t P a c k a g e I n f o %
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % Method GetPackageInfo looks up or creates an info structure for the given
955 % Image__Magick reference. If it does create a new one, the information in
956 % package_info is used to initialize it.
958 % The format of the GetPackageInfo routine is:
960 % struct PackageInfo *GetPackageInfo(void *reference,
961 % struct PackageInfo *package_info,ExceptionInfo *exception)
963 % A description of each parameter follows:
965 % o info: a structure of type info.
967 % o exception: Return any errors or warnings in this structure.
970 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
971 struct PackageInfo *package_info,ExceptionInfo *exception)
974 message[MaxTextExtent];
982 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
983 PackageName,XS_VERSION,reference);
984 sv=perl_get_sv(message,(TRUE | 0x02));
985 if (sv == (SV *) NULL)
987 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
989 return(package_info);
991 if (SvREFCNT(sv) == 0)
992 (void) SvREFCNT_inc(sv);
993 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
995 clone_info=ClonePackageInfo(package_info,exception);
996 sv_setiv(sv,(IV) clone_info);
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 % S e t A t t r i b u t e %
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1011 % SetAttribute() sets the attribute to the value in sval. This can change
1012 % either or both of image or info.
1014 % The format of the SetAttribute routine is:
1016 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1017 % SV *sval,ExceptionInfo *exception)
1019 % A description of each parameter follows:
1021 % o list: a list of strings.
1023 % o string: a character string.
1027 static double SiPrefixToDouble(const char *string,const double interval)
1036 value=InterpretLocaleValue(string,&q);
1038 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1040 switch (tolower((int) ((unsigned char) *q)))
1042 case '%': value*=pow(scale,0)*interval/100.0; break;
1043 case 'k': value*=pow(scale,1); break;
1044 case 'm': value*=pow(scale,2); break;
1045 case 'g': value*=pow(scale,3); break;
1046 case 't': value*=pow(scale,4); break;
1047 case 'p': value*=pow(scale,5); break;
1048 case 'e': value*=pow(scale,6); break;
1049 case 'z': value*=pow(scale,7); break;
1050 case 'y': value*=pow(scale,8); break;
1056 static inline ssize_t StringToLong(const char *value)
1058 return(strtol(value,(char **) NULL,10));
1061 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1062 const char *attribute,SV *sval,ExceptionInfo *exception)
1089 if (LocaleCompare(attribute,"adjoin") == 0)
1091 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1092 SvPV(sval,na)) : SvIV(sval);
1095 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1100 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1103 if (LocaleCompare(attribute,"alpha") == 0)
1105 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1106 SvPV(sval,na)) : SvIV(sval);
1109 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1113 for ( ; image; image=image->next)
1114 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1117 if (LocaleCompare(attribute,"antialias") == 0)
1119 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1120 SvPV(sval,na)) : SvIV(sval);
1123 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1128 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1131 if (LocaleCompare(attribute,"area-limit") == 0)
1136 limit=MagickResourceInfinity;
1137 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1138 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1139 (void) SetMagickResourceLimit(AreaResource,limit);
1142 if (LocaleCompare(attribute,"attenuate") == 0)
1145 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1148 if (LocaleCompare(attribute,"authenticate") == 0)
1151 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1155 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1156 for ( ; image; image=image->next)
1157 SetImageProperty(image,attribute,SvPV(sval,na));
1163 if (LocaleCompare(attribute,"background") == 0)
1165 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1167 info->image_info->background_color=target_color;
1168 for ( ; image; image=image->next)
1169 image->background_color=target_color;
1172 if (LocaleCompare(attribute,"bias") == 0)
1174 for ( ; image; image=image->next)
1175 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1178 if (LocaleCompare(attribute,"blue-primary") == 0)
1180 for ( ; image; image=image->next)
1182 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1183 image->chromaticity.blue_primary.x=geometry_info.rho;
1184 image->chromaticity.blue_primary.y=geometry_info.sigma;
1185 if ((flags & SigmaValue) == 0)
1186 image->chromaticity.blue_primary.y=
1187 image->chromaticity.blue_primary.x;
1191 if (LocaleCompare(attribute,"bordercolor") == 0)
1193 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1195 info->image_info->border_color=target_color;
1196 for ( ; image; image=image->next)
1197 image->border_color=target_color;
1201 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1202 for ( ; image; image=image->next)
1203 SetImageProperty(image,attribute,SvPV(sval,na));
1209 if (LocaleCompare(attribute,"cache-threshold") == 0)
1211 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1212 SiPrefixToDouble(SvPV(sval,na),100.0));
1213 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1214 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1217 if (LocaleCompare(attribute,"clip-mask") == 0)
1222 clip_mask=(Image *) NULL;
1224 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1225 for ( ; image; image=image->next)
1226 SetImageClipMask(image,clip_mask);
1229 if (LocaleNCompare(attribute,"colormap",8) == 0)
1231 for ( ; image; image=image->next)
1239 if (image->storage_class == DirectClass)
1242 items=sscanf(attribute,"%*[^[][%ld",&i);
1244 if (i > (ssize_t) image->colors)
1246 if ((strchr(SvPV(sval,na),',') == 0) ||
1247 (strchr(SvPV(sval,na),')') != 0))
1248 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1251 color=image->colormap+i;
1252 pixel.red=color->red;
1253 pixel.green=color->green;
1254 pixel.blue=color->blue;
1255 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1256 pixel.red=geometry_info.rho;
1257 pixel.green=geometry_info.sigma;
1258 pixel.blue=geometry_info.xi;
1259 color->red=ClampToQuantum(pixel.red);
1260 color->green=ClampToQuantum(pixel.green);
1261 color->blue=ClampToQuantum(pixel.blue);
1266 if (LocaleCompare(attribute,"colorspace") == 0)
1268 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1269 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1272 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1276 for ( ; image; image=image->next)
1277 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1280 if (LocaleCompare(attribute,"comment") == 0)
1282 for ( ; image; image=image->next)
1283 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1284 info ? info->image_info : (ImageInfo *) NULL,image,
1288 if (LocaleCompare(attribute,"compression") == 0)
1290 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1291 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1294 ThrowPerlException(exception,OptionError,
1295 "UnrecognizedImageCompression",SvPV(sval,na));
1299 info->image_info->compression=(CompressionType) sp;
1300 for ( ; image; image=image->next)
1301 image->compression=(CompressionType) sp;
1305 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1306 for ( ; image; image=image->next)
1307 SetImageProperty(image,attribute,SvPV(sval,na));
1313 if (LocaleCompare(attribute,"debug") == 0)
1315 SetLogEventMask(SvPV(sval,na));
1318 if (LocaleCompare(attribute,"delay") == 0)
1320 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1321 for ( ; image; image=image->next)
1323 image->delay=(size_t) floor(geometry_info.rho+0.5);
1324 if ((flags & SigmaValue) != 0)
1325 image->ticks_per_second=(ssize_t)
1326 floor(geometry_info.sigma+0.5);
1330 if (LocaleCompare(attribute,"disk-limit") == 0)
1335 limit=MagickResourceInfinity;
1336 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1337 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1338 (void) SetMagickResourceLimit(DiskResource,limit);
1341 if (LocaleCompare(attribute,"density") == 0)
1343 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1345 ThrowPerlException(exception,OptionError,"MissingGeometry",
1350 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1351 for ( ; image; image=image->next)
1353 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1354 image->x_resolution=geometry_info.rho;
1355 image->y_resolution=geometry_info.sigma;
1356 if ((flags & SigmaValue) == 0)
1357 image->y_resolution=image->x_resolution;
1361 if (LocaleCompare(attribute,"depth") == 0)
1364 info->image_info->depth=SvIV(sval);
1365 for ( ; image; image=image->next)
1366 (void) SetImageDepth(image,SvIV(sval));
1369 if (LocaleCompare(attribute,"dispose") == 0)
1371 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1372 SvPV(sval,na)) : SvIV(sval);
1375 ThrowPerlException(exception,OptionError,
1376 "UnrecognizedDisposeMethod",SvPV(sval,na));
1379 for ( ; image; image=image->next)
1380 image->dispose=(DisposeType) sp;
1383 if (LocaleCompare(attribute,"dither") == 0)
1387 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1388 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1391 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1395 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1399 if (LocaleCompare(attribute,"display") == 0)
1403 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1407 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1408 for ( ; image; image=image->next)
1409 SetImageProperty(image,attribute,SvPV(sval,na));
1415 if (LocaleCompare(attribute,"endian") == 0)
1417 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1418 SvPV(sval,na)) : SvIV(sval);
1421 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1426 info->image_info->endian=(EndianType) sp;
1427 for ( ; image; image=image->next)
1428 image->endian=(EndianType) sp;
1431 if (LocaleCompare(attribute,"extract") == 0)
1434 Set image extract geometry.
1436 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1440 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1441 for ( ; image; image=image->next)
1442 SetImageProperty(image,attribute,SvPV(sval,na));
1448 if (LocaleCompare(attribute,"filename") == 0)
1451 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1453 for ( ; image; image=image->next)
1454 (void) CopyMagickString(image->filename,SvPV(sval,na),
1458 if (LocaleCompare(attribute,"file") == 0)
1466 if (info == (struct PackageInfo *) NULL)
1468 io_info=IoIFP(sv_2io(sval));
1469 if (io_info == (PerlIO *) NULL)
1471 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1475 file=PerlIO_findFILE(io_info);
1476 if (file == (FILE *) NULL)
1478 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1482 SetImageInfoFile(info->image_info,file);
1485 if (LocaleCompare(attribute,"fill") == 0)
1488 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1491 if (LocaleCompare(attribute,"font") == 0)
1494 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1497 if (LocaleCompare(attribute,"foreground") == 0)
1499 if (LocaleCompare(attribute,"fuzz") == 0)
1502 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1503 for ( ; image; image=image->next)
1504 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1508 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1509 for ( ; image; image=image->next)
1510 SetImageProperty(image,attribute,SvPV(sval,na));
1516 if (LocaleCompare(attribute,"gamma") == 0)
1518 for ( ; image; image=image->next)
1519 image->gamma=SvNV(sval);
1522 if (LocaleCompare(attribute,"gravity") == 0)
1524 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1525 SvPV(sval,na)) : SvIV(sval);
1528 ThrowPerlException(exception,OptionError,
1529 "UnrecognizedGravityType",SvPV(sval,na));
1533 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1534 for ( ; image; image=image->next)
1535 image->gravity=(GravityType) sp;
1538 if (LocaleCompare(attribute,"green-primary") == 0)
1540 for ( ; image; image=image->next)
1542 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1543 image->chromaticity.green_primary.x=geometry_info.rho;
1544 image->chromaticity.green_primary.y=geometry_info.sigma;
1545 if ((flags & SigmaValue) == 0)
1546 image->chromaticity.green_primary.y=
1547 image->chromaticity.green_primary.x;
1552 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1553 for ( ; image; image=image->next)
1554 SetImageProperty(image,attribute,SvPV(sval,na));
1560 if (LocaleNCompare(attribute,"index",5) == 0)
1574 for ( ; image; image=image->next)
1576 if (image->storage_class != PseudoClass)
1580 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1582 image_view=AcquireCacheView(image);
1583 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1584 if (q != (Quantum *) NULL)
1586 items=sscanf(SvPV(sval,na),"%ld",&index);
1587 if ((index >= 0) && (index < (ssize_t) image->colors))
1588 SetPixelIndex(image,index,q);
1589 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1591 image_view=DestroyCacheView(image_view);
1595 if (LocaleCompare(attribute,"iterations") == 0)
1598 for ( ; image; image=image->next)
1599 image->iterations=SvIV(sval);
1602 if (LocaleCompare(attribute,"interlace") == 0)
1604 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1605 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1608 ThrowPerlException(exception,OptionError,
1609 "UnrecognizedInterlaceType",SvPV(sval,na));
1613 info->image_info->interlace=(InterlaceType) sp;
1614 for ( ; image; image=image->next)
1615 image->interlace=(InterlaceType) sp;
1619 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1620 for ( ; image; image=image->next)
1621 SetImageProperty(image,attribute,SvPV(sval,na));
1627 if (LocaleCompare(attribute,"label") == 0)
1629 for ( ; image; image=image->next)
1630 (void) SetImageProperty(image,"label",InterpretImageProperties(
1631 info ? info->image_info : (ImageInfo *) NULL,image,
1635 if (LocaleCompare(attribute,"loop") == 0)
1638 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1639 for ( ; image; image=image->next)
1640 SetImageProperty(image,attribute,SvPV(sval,na));
1646 if (LocaleCompare(attribute,"magick") == 0)
1649 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1650 "%s:",SvPV(sval,na));
1651 for ( ; image; image=image->next)
1652 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1655 if (LocaleCompare(attribute,"map-limit") == 0)
1660 limit=MagickResourceInfinity;
1661 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1662 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1663 (void) SetMagickResourceLimit(MapResource,limit);
1666 if (LocaleCompare(attribute,"mask") == 0)
1671 mask=(Image *) NULL;
1673 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1674 for ( ; image; image=image->next)
1675 SetImageMask(image,mask);
1678 if (LocaleCompare(attribute,"mattecolor") == 0)
1680 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1682 info->image_info->matte_color=target_color;
1683 for ( ; image; image=image->next)
1684 image->matte_color=target_color;
1687 if (LocaleCompare(attribute,"matte") == 0)
1689 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1690 SvPV(sval,na)) : SvIV(sval);
1693 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1697 for ( ; image; image=image->next)
1698 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1701 if (LocaleCompare(attribute,"memory-limit") == 0)
1706 limit=MagickResourceInfinity;
1707 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1708 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1709 (void) SetMagickResourceLimit(MemoryResource,limit);
1712 if (LocaleCompare(attribute,"monochrome") == 0)
1714 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1715 SvPV(sval,na)) : SvIV(sval);
1718 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1723 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1724 for ( ; image; image=image->next)
1725 (void) SetImageType(image,BilevelType);
1729 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1730 for ( ; image; image=image->next)
1731 SetImageProperty(image,attribute,SvPV(sval,na));
1737 if (LocaleCompare(attribute,"option") == 0)
1740 DefineImageOption(info->image_info,SvPV(sval,na));
1743 if (LocaleCompare(attribute,"orientation") == 0)
1745 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1746 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1749 ThrowPerlException(exception,OptionError,
1750 "UnrecognizedOrientationType",SvPV(sval,na));
1754 info->image_info->orientation=(OrientationType) sp;
1755 for ( ; image; image=image->next)
1756 image->orientation=(OrientationType) sp;
1760 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1761 for ( ; image; image=image->next)
1762 SetImageProperty(image,attribute,SvPV(sval,na));
1768 if (LocaleCompare(attribute,"page") == 0)
1773 geometry=GetPageGeometry(SvPV(sval,na));
1775 (void) CloneString(&info->image_info->page,geometry);
1776 for ( ; image; image=image->next)
1777 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1778 geometry=(char *) RelinquishMagickMemory(geometry);
1781 if (LocaleCompare(attribute,"pen") == 0)
1784 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1787 if (LocaleNCompare(attribute,"pixel",5) == 0)
1801 for ( ; image; image=image->next)
1803 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1807 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1809 image_view=AcquireCacheView(image);
1810 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1811 if (q != (Quantum *) NULL)
1813 if ((strchr(SvPV(sval,na),',') == 0) ||
1814 (strchr(SvPV(sval,na),')') != 0))
1815 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1818 GetPixelInfo(image,&pixel);
1819 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1820 pixel.red=geometry_info.rho;
1821 if ((flags & SigmaValue) != 0)
1822 pixel.green=geometry_info.sigma;
1823 if ((flags & XiValue) != 0)
1824 pixel.blue=geometry_info.xi;
1825 if ((flags & PsiValue) != 0)
1826 pixel.alpha=geometry_info.psi;
1827 if ((flags & ChiValue) != 0)
1828 pixel.black=geometry_info.chi;
1830 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1831 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1832 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1833 if (image->colorspace == CMYKColorspace)
1834 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1835 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1836 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1838 image_view=DestroyCacheView(image_view);
1842 if (LocaleCompare(attribute,"pointsize") == 0)
1846 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1847 info->image_info->pointsize=geometry_info.rho;
1851 if (LocaleCompare(attribute,"preview") == 0)
1853 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1854 SvPV(sval,na)) : SvIV(sval);
1857 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1862 info->image_info->preview_type=(PreviewType) sp;
1866 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1867 for ( ; image; image=image->next)
1868 SetImageProperty(image,attribute,SvPV(sval,na));
1874 if (LocaleCompare(attribute,"quality") == 0)
1877 info->image_info->quality=SvIV(sval);
1878 for ( ; image; image=image->next)
1879 image->quality=SvIV(sval);
1883 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1884 for ( ; image; image=image->next)
1885 SetImageProperty(image,attribute,SvPV(sval,na));
1891 if (LocaleCompare(attribute,"red-primary") == 0)
1893 for ( ; image; image=image->next)
1895 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1896 image->chromaticity.red_primary.x=geometry_info.rho;
1897 image->chromaticity.red_primary.y=geometry_info.sigma;
1898 if ((flags & SigmaValue) == 0)
1899 image->chromaticity.red_primary.y=
1900 image->chromaticity.red_primary.x;
1904 if (LocaleCompare(attribute,"render") == 0)
1906 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1907 SvPV(sval,na)) : SvIV(sval);
1910 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1914 for ( ; image; image=image->next)
1915 image->rendering_intent=(RenderingIntent) sp;
1918 if (LocaleCompare(attribute,"repage") == 0)
1923 for ( ; image; image=image->next)
1925 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1926 if ((flags & WidthValue) != 0)
1928 if ((flags & HeightValue) == 0)
1929 geometry.height=geometry.width;
1930 image->page.width=geometry.width;
1931 image->page.height=geometry.height;
1933 if ((flags & AspectValue) != 0)
1935 if ((flags & XValue) != 0)
1936 image->page.x+=geometry.x;
1937 if ((flags & YValue) != 0)
1938 image->page.y+=geometry.y;
1942 if ((flags & XValue) != 0)
1944 image->page.x=geometry.x;
1945 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1946 image->page.width=image->columns+geometry.x;
1948 if ((flags & YValue) != 0)
1950 image->page.y=geometry.y;
1951 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1952 image->page.height=image->rows+geometry.y;
1959 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1960 for ( ; image; image=image->next)
1961 SetImageProperty(image,attribute,SvPV(sval,na));
1967 if (LocaleCompare(attribute,"sampling-factor") == 0)
1969 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1971 ThrowPerlException(exception,OptionError,"MissingGeometry",
1976 (void) CloneString(&info->image_info->sampling_factor,
1980 if (LocaleCompare(attribute,"scene") == 0)
1982 for ( ; image; image=image->next)
1983 image->scene=SvIV(sval);
1986 if (LocaleCompare(attribute,"server") == 0)
1988 if (LocaleCompare(attribute,"size") == 0)
1992 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1994 ThrowPerlException(exception,OptionError,"MissingGeometry",
1998 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2002 if (LocaleCompare(attribute,"stroke") == 0)
2005 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2009 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2010 for ( ; image; image=image->next)
2011 SetImageProperty(image,attribute,SvPV(sval,na));
2017 if (LocaleCompare(attribute,"texture") == 0)
2020 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2023 if (LocaleCompare(attribute,"thread-limit") == 0)
2028 limit=MagickResourceInfinity;
2029 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2030 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2031 (void) SetMagickResourceLimit(ThreadResource,limit);
2034 if (LocaleCompare(attribute,"tile-offset") == 0)
2039 geometry=GetPageGeometry(SvPV(sval,na));
2041 (void) CloneString(&info->image_info->page,geometry);
2042 for ( ; image; image=image->next)
2043 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2045 geometry=(char *) RelinquishMagickMemory(geometry);
2048 if (LocaleCompare(attribute,"time-limit") == 0)
2053 limit=MagickResourceInfinity;
2054 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2055 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2056 (void) SetMagickResourceLimit(TimeResource,limit);
2059 if (LocaleCompare(attribute,"transparent-color") == 0)
2061 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2063 info->image_info->transparent_color=target_color;
2064 for ( ; image; image=image->next)
2065 image->transparent_color=target_color;
2068 if (LocaleCompare(attribute,"type") == 0)
2070 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2071 SvPV(sval,na)) : SvIV(sval);
2074 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2079 info->image_info->type=(ImageType) sp;
2080 for ( ; image; image=image->next)
2081 SetImageType(image,(ImageType) sp);
2085 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2086 for ( ; image; image=image->next)
2087 SetImageProperty(image,attribute,SvPV(sval,na));
2093 if (LocaleCompare(attribute,"units") == 0)
2095 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2096 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2099 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2104 info->image_info->units=(ResolutionType) sp;
2105 for ( ; image; image=image->next)
2110 units=(ResolutionType) sp;
2111 if (image->units != units)
2112 switch (image->units)
2114 case UndefinedResolution:
2115 case PixelsPerInchResolution:
2117 if (units == PixelsPerCentimeterResolution)
2119 image->x_resolution*=2.54;
2120 image->y_resolution*=2.54;
2124 case PixelsPerCentimeterResolution:
2126 if (units == PixelsPerInchResolution)
2128 image->x_resolution/=2.54;
2129 image->y_resolution/=2.54;
2139 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2140 for ( ; image; image=image->next)
2141 SetImageProperty(image,attribute,SvPV(sval,na));
2147 if (LocaleCompare(attribute,"verbose") == 0)
2149 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2150 SvPV(sval,na)) : SvIV(sval);
2153 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2158 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2161 if (LocaleCompare(attribute,"view") == 0)
2164 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2167 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2169 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2170 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2173 ThrowPerlException(exception,OptionError,
2174 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2178 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2179 for ( ; image; image=image->next)
2180 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2184 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2185 for ( ; image; image=image->next)
2186 SetImageProperty(image,attribute,SvPV(sval,na));
2192 if (LocaleCompare(attribute,"white-point") == 0)
2194 for ( ; image; image=image->next)
2196 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2197 image->chromaticity.white_point.x=geometry_info.rho;
2198 image->chromaticity.white_point.y=geometry_info.sigma;
2199 if ((flags & SigmaValue) == 0)
2200 image->chromaticity.white_point.y=
2201 image->chromaticity.white_point.x;
2206 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2207 for ( ; image; image=image->next)
2208 SetImageProperty(image,attribute,SvPV(sval,na));
2214 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2215 for ( ; image; image=image->next)
2216 SetImageProperty(image,attribute,SvPV(sval,na));
2223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2227 % S e t u p L i s t %
2231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2233 % Method SetupList returns the list of all the images linked by their
2234 % image->next and image->previous link lists for use with ImageMagick. If
2235 % info is non-NULL, an info structure is returned in *info. If
2236 % reference_vector is non-NULL,an array of SV* are returned in
2237 % *reference_vector. Reference_vector is used when the images are going to be
2238 % replaced with new Image*'s.
2240 % The format of the SetupList routine is:
2242 % Image *SetupList(SV *reference,struct PackageInfo **info,
2243 % SV ***reference_vector,ExceptionInfo *exception)
2245 % A description of each parameter follows:
2247 % o list: a list of strings.
2249 % o string: a character string.
2251 % o exception: Return any errors or warnings in this structure.
2254 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2255 SV ***reference_vector,ExceptionInfo *exception)
2264 if (reference_vector)
2265 *reference_vector=NULL;
2270 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2271 if (info && (SvTYPE(reference) == SVt_PVAV))
2272 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2282 % s t r E Q c a s e %
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 % strEQcase() compares two strings and returns 0 if they are the
2289 % same or if the second string runs out first. The comparison is case
2292 % The format of the strEQcase routine is:
2294 % ssize_t strEQcase(const char *p,const char *q)
2296 % A description of each parameter follows:
2298 % o p: a character string.
2300 % o q: a character string.
2304 static ssize_t strEQcase(const char *p,const char *q)
2312 for (i=0 ; (c=(*q)) != 0; i++)
2314 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2315 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2320 return(((*q == 0) && (*p == 0)) ? i : 0);
2324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2328 % I m a g e : : M a g i c k %
2332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2336 MODULE = Image::Magick PACKAGE = Image::Magick
2341 MagickCoreGenesis("PerlMagick",MagickFalse);
2342 SetWarningHandler(NULL);
2343 SetErrorHandler(NULL);
2344 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2345 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2351 if (magick_registry != (SplayTreeInfo *) NULL)
2352 magick_registry=DestroySplayTree(magick_registry);
2353 MagickCoreTerminus();
2357 constant(name,argument)
2362 ###############################################################################
2370 ###############################################################################
2375 Image::Magick ref=NO_INIT
2399 PERL_UNUSED_VAR(ref);
2400 PERL_UNUSED_VAR(ix);
2401 exception=AcquireExceptionInfo();
2402 perl_exception=newSVpv("",0);
2403 package_info=(struct PackageInfo *) NULL;
2404 if (sv_isobject(ST(0)) == 0)
2406 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2410 reference=SvRV(ST(0));
2411 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2412 if (image == (Image *) NULL)
2414 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2418 package_info=ClonePackageInfo(info,exception);
2420 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2423 for (i=2; i < items; i+=2)
2424 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2426 (void) AnimateImages(package_info->image_info,image);
2427 (void) CatchImageException(image);
2428 InheritException(exception,&image->exception);
2431 if (package_info != (struct PackageInfo *) NULL)
2432 DestroyPackageInfo(package_info);
2433 InheritPerlException(exception,perl_exception);
2434 exception=DestroyExceptionInfo(exception);
2435 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2436 SvPOK_on(perl_exception);
2437 ST(0)=sv_2mortal(perl_exception);
2442 ###############################################################################
2450 ###############################################################################
2455 Image::Magick ref=NO_INIT
2493 PERL_UNUSED_VAR(ref);
2494 PERL_UNUSED_VAR(ix);
2495 exception=AcquireExceptionInfo();
2496 perl_exception=newSVpv("",0);
2500 if (sv_isobject(ST(0)) == 0)
2502 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2506 reference=SvRV(ST(0));
2507 hv=SvSTASH(reference);
2509 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2511 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2512 if (image == (Image *) NULL)
2514 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2518 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2523 for (i=2; i < items; i+=2)
2525 attribute=(char *) SvPV(ST(i-1),na);
2531 if (LocaleCompare(attribute,"stack") == 0)
2533 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2537 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2555 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2556 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2558 for ( ; image; image=image->next)
2560 AddImageToRegistry(sv,image);
2562 av_push(av,sv_bless(rv,hv));
2565 exception=DestroyExceptionInfo(exception);
2567 SvREFCNT_dec(perl_exception);
2571 InheritPerlException(exception,perl_exception);
2572 exception=DestroyExceptionInfo(exception);
2573 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2574 SvPOK_on(perl_exception);
2575 ST(0)=sv_2mortal(perl_exception);
2580 ###############################################################################
2588 ###############################################################################
2593 Image::Magick ref=NO_INIT
2624 PERL_UNUSED_VAR(ref);
2625 PERL_UNUSED_VAR(ix);
2626 exception=AcquireExceptionInfo();
2627 perl_exception=newSVpv("",0);
2629 if (sv_isobject(ST(0)) == 0)
2631 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2635 reference=SvRV(ST(0));
2636 hv=SvSTASH(reference);
2637 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2638 if (image == (Image *) NULL)
2640 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2644 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2645 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2648 Create blessed Perl array for the returned image.
2651 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2653 AddImageToRegistry(sv,image);
2655 av_push(av,sv_bless(rv,hv));
2657 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2658 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2659 "average-%.*s",(int) (MaxTextExtent-9),
2660 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2661 (void) CopyMagickString(image->filename,info->image_info->filename,
2663 SetImageInfo(info->image_info,0,exception);
2664 exception=DestroyExceptionInfo(exception);
2665 SvREFCNT_dec(perl_exception);
2669 InheritPerlException(exception,perl_exception);
2670 exception=DestroyExceptionInfo(exception);
2671 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2672 SvPOK_on(perl_exception);
2673 ST(0)=sv_2mortal(perl_exception);
2678 ###############################################################################
2682 # B l o b T o I m a g e #
2686 ###############################################################################
2690 BlobToImage(ref,...)
2691 Image::Magick ref=NO_INIT
2737 PERL_UNUSED_VAR(ref);
2738 PERL_UNUSED_VAR(ix);
2739 exception=AcquireExceptionInfo();
2740 perl_exception=newSVpv("",0);
2743 ac=(items < 2) ? 1 : items-1;
2744 length=(STRLEN *) NULL;
2745 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2746 if (list == (char **) NULL)
2748 ThrowPerlException(exception,ResourceLimitError,
2749 "MemoryAllocationFailed",PackageName);
2752 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2753 if (length == (STRLEN *) NULL)
2755 ThrowPerlException(exception,ResourceLimitError,
2756 "MemoryAllocationFailed",PackageName);
2759 if (sv_isobject(ST(0)) == 0)
2761 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2765 reference=SvRV(ST(0));
2766 hv=SvSTASH(reference);
2767 if (SvTYPE(reference) != SVt_PVAV)
2769 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2773 av=(AV *) reference;
2774 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2779 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2782 for (n=0, i=0; i < ac; i++)
2784 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2785 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2787 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2792 list[n]=(char *) NULL;
2794 for (i=number_images=0; i < n; i++)
2796 image=BlobToImage(info->image_info,list[i],length[i],exception);
2797 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2799 for ( ; image; image=image->next)
2801 AddImageToRegistry(sv,image);
2803 av_push(av,sv_bless(rv,hv));
2811 for (i=0; i < n; i++)
2812 if (list[i] != (char *) NULL)
2813 for (p=keep; list[i] != *p++; )
2814 if (*p == (char *) NULL)
2816 list[i]=(char *) RelinquishMagickMemory(list[i]);
2822 list=(char **) RelinquishMagickMemory(list);
2824 length=(STRLEN *) RelinquishMagickMemory(length);
2825 InheritPerlException(exception,perl_exception);
2826 exception=DestroyExceptionInfo(exception);
2827 sv_setiv(perl_exception,(IV) number_images);
2828 SvPOK_on(perl_exception);
2829 ST(0)=sv_2mortal(perl_exception);
2834 ###############################################################################
2842 ###############################################################################
2847 Image::Magick ref=NO_INIT
2880 PERL_UNUSED_VAR(ref);
2881 PERL_UNUSED_VAR(ix);
2882 exception=AcquireExceptionInfo();
2883 perl_exception=newSVpv("",0);
2885 if (sv_isobject(ST(0)) == 0)
2887 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2891 reference=SvRV(ST(0));
2892 hv=SvSTASH(reference);
2893 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2894 if (image == (Image *) NULL)
2896 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2901 Create blessed Perl array for the returned image.
2904 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2906 for ( ; image; image=image->next)
2908 clone=CloneImage(image,0,0,MagickTrue,exception);
2909 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2911 AddImageToRegistry(sv,clone);
2913 av_push(av,sv_bless(rv,hv));
2916 exception=DestroyExceptionInfo(exception);
2917 SvREFCNT_dec(perl_exception);
2921 InheritPerlException(exception,perl_exception);
2922 exception=DestroyExceptionInfo(exception);
2923 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2924 SvPOK_on(perl_exception);
2925 ST(0)=sv_2mortal(perl_exception);
2930 ###############################################################################
2938 ###############################################################################
2946 PERL_UNUSED_VAR(ref);
2947 if (magick_registry != (SplayTreeInfo *) NULL)
2952 ResetSplayTreeIterator(magick_registry);
2953 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2954 while (p != (Image *) NULL)
2957 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2963 ###############################################################################
2971 ###############################################################################
2976 Image::Magick ref=NO_INIT
3005 PERL_UNUSED_VAR(ref);
3006 PERL_UNUSED_VAR(ix);
3007 exception=AcquireExceptionInfo();
3008 perl_exception=newSVpv("",0);
3010 if (sv_isobject(ST(0)) == 0)
3012 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3016 reference=SvRV(ST(0));
3017 hv=SvSTASH(reference);
3019 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3021 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3022 if (image == (Image *) NULL)
3024 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3028 image=CoalesceImages(image,exception);
3029 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3031 for ( ; image; image=image->next)
3033 AddImageToRegistry(sv,image);
3035 av_push(av,sv_bless(rv,hv));
3038 exception=DestroyExceptionInfo(exception);
3040 SvREFCNT_dec(perl_exception);
3044 InheritPerlException(exception,perl_exception);
3045 exception=DestroyExceptionInfo(exception);
3046 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3047 SvPOK_on(perl_exception);
3048 ST(0)=sv_2mortal(perl_exception);
3053 ###############################################################################
3061 ###############################################################################
3066 Image::Magick ref=NO_INIT
3112 PERL_UNUSED_VAR(ref);
3113 PERL_UNUSED_VAR(ix);
3114 exception=AcquireExceptionInfo();
3115 perl_exception=newSVpv("",0);
3119 if (sv_isobject(ST(0)) == 0)
3121 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3125 reference=SvRV(ST(0));
3126 hv=SvSTASH(reference);
3128 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3130 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3131 if (image == (Image *) NULL)
3133 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3137 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3141 reconstruct_image=image;
3142 metric=RootMeanSquaredErrorMetric;
3143 for (i=2; i < items; i+=2)
3145 attribute=(char *) SvPV(ST(i-1),na);
3151 if (LocaleCompare(attribute,"channel") == 0)
3156 option=ParseChannelOption(SvPV(ST(i),na));
3159 ThrowPerlException(exception,OptionError,
3160 "UnrecognizedType",SvPV(ST(i),na));
3163 SetPixelComponentMap(image,(ChannelType) option);
3166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3173 if (LocaleCompare(attribute,"fuzz") == 0)
3175 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3185 if (LocaleCompare(attribute,"image") == 0)
3187 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3188 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3191 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3198 if (LocaleCompare(attribute,"metric") == 0)
3200 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3204 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3208 metric=(MetricType) option;
3211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3217 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3223 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3225 if (difference_image != (Image *) NULL)
3227 difference_image->error.mean_error_per_pixel=distortion;
3228 AddImageToRegistry(sv,difference_image);
3230 av_push(av,sv_bless(rv,hv));
3233 exception=DestroyExceptionInfo(exception);
3235 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3239 InheritPerlException(exception,perl_exception);
3240 exception=DestroyExceptionInfo(exception);
3241 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3242 SvPOK_on(perl_exception);
3243 ST(0)=sv_2mortal(perl_exception);
3248 ###############################################################################
3252 # C o m p a r e L a y e r s #
3256 ###############################################################################
3261 Image::Magick ref=NO_INIT
3263 CompareImagesLayers = 1
3265 compareimagelayers = 3
3302 PERL_UNUSED_VAR(ref);
3303 PERL_UNUSED_VAR(ix);
3304 exception=AcquireExceptionInfo();
3305 perl_exception=newSVpv("",0);
3307 if (sv_isobject(ST(0)) == 0)
3309 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3313 reference=SvRV(ST(0));
3314 hv=SvSTASH(reference);
3316 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3318 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3319 if (image == (Image *) NULL)
3321 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3325 method=CompareAnyLayer;
3326 for (i=2; i < items; i+=2)
3328 attribute=(char *) SvPV(ST(i-1),na);
3334 if (LocaleCompare(attribute,"method") == 0)
3336 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3340 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3344 method=(ImageLayerMethod) option;
3347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3353 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3359 image=CompareImagesLayers(image,method,exception);
3360 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3362 for ( ; image; image=image->next)
3364 AddImageToRegistry(sv,image);
3366 av_push(av,sv_bless(rv,hv));
3369 exception=DestroyExceptionInfo(exception);
3371 SvREFCNT_dec(perl_exception);
3375 InheritPerlException(exception,perl_exception);
3376 exception=DestroyExceptionInfo(exception);
3377 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3378 SvPOK_on(perl_exception);
3379 ST(0)=sv_2mortal(perl_exception);
3384 ###############################################################################
3392 ###############################################################################
3397 Image::Magick ref=NO_INIT
3403 PERL_UNUSED_VAR(ref);
3404 if (sv_isobject(ST(0)) == 0)
3405 croak("ReferenceIsNotMyType");
3406 reference=SvRV(ST(0));
3407 switch (SvTYPE(reference))
3412 message[MaxTextExtent];
3430 Array (AV *) reference
3432 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3433 XS_VERSION,reference);
3434 hv=gv_stashpv(PackageName, FALSE);
3437 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3441 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3443 info=(struct PackageInfo *) SvIV(sv);
3444 DestroyPackageInfo(info);
3446 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3456 Blessed scalar = (Image *) SvIV(reference)
3458 image=(Image *) SvIV(reference);
3459 if (image != (Image *) NULL)
3460 DeleteImageFromRegistry(reference,image);
3469 ###############################################################################
3477 ###############################################################################
3482 Image::Magick ref=NO_INIT
3506 PERL_UNUSED_VAR(ref);
3507 PERL_UNUSED_VAR(ix);
3508 exception=AcquireExceptionInfo();
3509 perl_exception=newSVpv("",0);
3510 package_info=(struct PackageInfo *) NULL;
3511 if (sv_isobject(ST(0)) == 0)
3513 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3517 reference=SvRV(ST(0));
3518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3519 if (image == (Image *) NULL)
3521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3525 package_info=ClonePackageInfo(info,exception);
3527 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3530 for (i=2; i < items; i+=2)
3531 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3533 (void) DisplayImages(package_info->image_info,image);
3534 (void) CatchImageException(image);
3535 InheritException(exception,&image->exception);
3538 if (package_info != (struct PackageInfo *) NULL)
3539 DestroyPackageInfo(package_info);
3540 InheritPerlException(exception,perl_exception);
3541 exception=DestroyExceptionInfo(exception);
3542 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3543 SvPOK_on(perl_exception);
3544 ST(0)=sv_2mortal(perl_exception);
3549 ###############################################################################
3553 # E v a l u a t e I m a g e s #
3557 ###############################################################################
3562 Image::Magick ref=NO_INIT
3584 MagickEvaluateOperator
3599 PERL_UNUSED_VAR(ref);
3600 PERL_UNUSED_VAR(ix);
3601 exception=AcquireExceptionInfo();
3602 perl_exception=newSVpv("",0);
3604 if (sv_isobject(ST(0)) == 0)
3606 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3610 reference=SvRV(ST(0));
3611 hv=SvSTASH(reference);
3612 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3613 if (image == (Image *) NULL)
3615 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3619 op=MeanEvaluateOperator;
3625 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3629 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3633 op=(MagickEvaluateOperator) in;
3636 for (i=2; i < items; i+=2)
3638 attribute=(char *) SvPV(ST(i-1),na);
3644 if (LocaleCompare(attribute,"operator") == 0)
3649 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3650 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3653 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3657 op=(MagickEvaluateOperator) in;
3660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3672 image=EvaluateImages(image,op,exception);
3673 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3676 Create blessed Perl array for the returned image.
3679 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3681 AddImageToRegistry(sv,image);
3683 av_push(av,sv_bless(rv,hv));
3685 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3686 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3687 "evaluate-%.*s",(int) (MaxTextExtent-9),
3688 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3689 (void) CopyMagickString(image->filename,info->image_info->filename,
3691 SetImageInfo(info->image_info,0,exception);
3692 exception=DestroyExceptionInfo(exception);
3693 SvREFCNT_dec(perl_exception);
3697 InheritPerlException(exception,perl_exception);
3698 exception=DestroyExceptionInfo(exception);
3699 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3700 SvPOK_on(perl_exception);
3701 ST(0)=sv_2mortal(perl_exception);
3706 ###############################################################################
3714 ###############################################################################
3719 Image::Magick ref=NO_INIT
3726 #define ChannelFeatures(channel,direction) \
3728 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3729 channel_features[channel].angular_second_moment[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].contrast[direction]); \
3736 PUSHs(sv_2mortal(newSVpv(message,0))); \
3737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3738 channel_features[channel].variance_sum_of_squares[direction]); \
3739 PUSHs(sv_2mortal(newSVpv(message,0))); \
3740 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3741 channel_features[channel].inverse_difference_moment[direction]); \
3742 PUSHs(sv_2mortal(newSVpv(message,0))); \
3743 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3744 channel_features[channel].sum_average[direction]); \
3745 PUSHs(sv_2mortal(newSVpv(message,0))); \
3746 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3747 channel_features[channel].sum_variance[direction]); \
3748 PUSHs(sv_2mortal(newSVpv(message,0))); \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].sum_entropy[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].entropy[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].difference_variance[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].difference_entropy[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].measure_of_correlation_1[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].measure_of_correlation_2[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].maximum_correlation_coefficient[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3777 message[MaxTextExtent];
3804 PERL_UNUSED_VAR(ref);
3805 PERL_UNUSED_VAR(ix);
3806 exception=AcquireExceptionInfo();
3807 perl_exception=newSVpv("",0);
3809 if (sv_isobject(ST(0)) == 0)
3811 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3815 reference=SvRV(ST(0));
3818 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3819 if (image == (Image *) NULL)
3821 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3825 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3827 for (i=2; i < items; i+=2)
3829 attribute=(char *) SvPV(ST(i-1),na);
3835 if (LocaleCompare(attribute,"distance") == 0)
3837 distance=StringToLong((char *) SvPV(ST(1),na));
3840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3846 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3853 for ( ; image; image=image->next)
3855 channel_features=GetImageChannelFeatures(image,distance,
3857 if (channel_features == (ChannelFeatures *) NULL)
3860 EXTEND(sp,75*count);
3861 for (i=0; i < 4; i++)
3863 ChannelFeatures(RedChannel,i);
3864 ChannelFeatures(GreenChannel,i);
3865 ChannelFeatures(BlueChannel,i);
3866 if (image->colorspace == CMYKColorspace)
3867 ChannelFeatures(BlackChannel,i);
3868 if (image->matte != MagickFalse)
3869 ChannelFeatures(AlphaChannel,i);
3871 channel_features=(ChannelFeatures *)
3872 RelinquishMagickMemory(channel_features);
3876 InheritPerlException(exception,perl_exception);
3877 exception=DestroyExceptionInfo(exception);
3878 SvREFCNT_dec(perl_exception);
3882 ###############################################################################
3890 ###############################################################################
3895 Image::Magick ref=NO_INIT
3933 PERL_UNUSED_VAR(ref);
3934 PERL_UNUSED_VAR(ix);
3935 exception=AcquireExceptionInfo();
3936 perl_exception=newSVpv("",0);
3938 if (sv_isobject(ST(0)) == 0)
3940 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3944 reference=SvRV(ST(0));
3945 hv=SvSTASH(reference);
3946 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3947 if (image == (Image *) NULL)
3949 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3953 background_color=image->background_color;
3955 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3958 for (i=2; i < items; i+=2)
3960 attribute=(char *) SvPV(ST(i-1),na);
3966 if (LocaleCompare(attribute,"background") == 0)
3968 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3969 &background_color,exception);
3972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3984 image->background_color=background_color;
3985 image=MergeImageLayers(image,FlattenLayer,exception);
3986 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3989 Create blessed Perl array for the returned image.
3992 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3994 AddImageToRegistry(sv,image);
3996 av_push(av,sv_bless(rv,hv));
3998 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3999 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4000 "flatten-%.*s",(int) (MaxTextExtent-9),
4001 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4002 (void) CopyMagickString(image->filename,info->image_info->filename,
4004 SetImageInfo(info->image_info,0,exception);
4005 exception=DestroyExceptionInfo(exception);
4006 SvREFCNT_dec(perl_exception);
4010 InheritPerlException(exception,perl_exception);
4011 exception=DestroyExceptionInfo(exception);
4012 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4013 SvPOK_on(perl_exception); /* return messages in string context */
4014 ST(0)=sv_2mortal(perl_exception);
4019 ###############################################################################
4027 ###############################################################################
4032 Image::Magick ref=NO_INIT
4044 expression[MaxTextExtent];
4071 PERL_UNUSED_VAR(ref);
4072 PERL_UNUSED_VAR(ix);
4073 exception=AcquireExceptionInfo();
4074 perl_exception=newSVpv("",0);
4078 if (sv_isobject(ST(0)) == 0)
4080 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4084 reference=SvRV(ST(0));
4085 hv=SvSTASH(reference);
4087 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4089 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4090 if (image == (Image *) NULL)
4092 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4096 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4100 channel=DefaultChannels;
4101 (void) CopyMagickString(expression,"u",MaxTextExtent);
4103 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4105 for (i=2; i < items; i+=2)
4107 attribute=(char *) SvPV(ST(i-1),na);
4113 if (LocaleCompare(attribute,"channel") == 0)
4118 option=ParseChannelOption(SvPV(ST(i),na));
4121 ThrowPerlException(exception,OptionError,
4122 "UnrecognizedType",SvPV(ST(i),na));
4125 channel=(ChannelType) option;
4128 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4135 if (LocaleCompare(attribute,"expression") == 0)
4137 (void) CopyMagickString(expression,SvPV(ST(i),na),
4141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4153 image=FxImageChannel(image,channel,expression,exception);
4154 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4156 for ( ; image; image=image->next)
4158 AddImageToRegistry(sv,image);
4160 av_push(av,sv_bless(rv,hv));
4163 exception=DestroyExceptionInfo(exception);
4165 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4169 InheritPerlException(exception,perl_exception);
4170 exception=DestroyExceptionInfo(exception);
4171 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4172 SvPOK_on(perl_exception);
4173 ST(0)=sv_2mortal(perl_exception);
4178 ###############################################################################
4186 ###############################################################################
4191 Image::Magick ref=NO_INIT
4202 color[MaxTextExtent];
4227 PERL_UNUSED_VAR(ref);
4228 PERL_UNUSED_VAR(ix);
4229 exception=AcquireExceptionInfo();
4230 perl_exception=newSVpv("",0);
4231 if (sv_isobject(ST(0)) == 0)
4233 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4237 reference=SvRV(ST(0));
4238 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4239 if (image == (Image *) NULL && !info)
4242 for (i=1; i < items; i++)
4244 attribute=(char *) SvPV(ST(i),na);
4251 if (LocaleCompare(attribute,"adjoin") == 0)
4254 s=newSViv((ssize_t) info->image_info->adjoin);
4255 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4258 if (LocaleCompare(attribute,"antialias") == 0)
4261 s=newSViv((ssize_t) info->image_info->antialias);
4262 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4265 if (LocaleCompare(attribute,"area") == 0)
4267 s=newSViv(GetMagickResource(AreaResource));
4268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4271 if (LocaleCompare(attribute,"attenuate") == 0)
4276 value=GetImageProperty(image,attribute);
4277 if (value != (const char *) NULL)
4279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4282 if (LocaleCompare(attribute,"authenticate") == 0)
4285 s=newSVpv(info->image_info->authenticate,0);
4286 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4289 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4296 if (LocaleCompare(attribute,"background") == 0)
4298 if (image == (Image *) NULL)
4300 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4301 QuantumFormat "," QuantumFormat "," QuantumFormat,
4302 image->background_color.red,image->background_color.green,
4303 image->background_color.blue,image->background_color.alpha);
4305 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4308 if (LocaleCompare(attribute,"base-columns") == 0)
4310 if (image != (Image *) NULL)
4311 s=newSViv((ssize_t) image->magick_columns);
4312 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4315 if (LocaleCompare(attribute,"base-filename") == 0)
4317 if (image != (Image *) NULL)
4318 s=newSVpv(image->magick_filename,0);
4319 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4322 if (LocaleCompare(attribute,"base-height") == 0)
4324 if (image != (Image *) NULL)
4325 s=newSViv((ssize_t) image->magick_rows);
4326 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4329 if (LocaleCompare(attribute,"base-rows") == 0)
4331 if (image != (Image *) NULL)
4332 s=newSViv((ssize_t) image->magick_rows);
4333 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4336 if (LocaleCompare(attribute,"base-width") == 0)
4338 if (image != (Image *) NULL)
4339 s=newSViv((ssize_t) image->magick_columns);
4340 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4343 if (LocaleCompare(attribute,"bias") == 0)
4345 if (image != (Image *) NULL)
4346 s=newSVnv(image->bias);
4347 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4350 if (LocaleCompare(attribute,"blue-primary") == 0)
4352 if (image == (Image *) NULL)
4354 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4355 image->chromaticity.blue_primary.x,
4356 image->chromaticity.blue_primary.y);
4358 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4361 if (LocaleCompare(attribute,"bordercolor") == 0)
4363 if (image == (Image *) NULL)
4365 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4366 QuantumFormat "," QuantumFormat "," QuantumFormat,
4367 image->border_color.red,image->border_color.green,
4368 image->border_color.blue,image->border_color.alpha);
4370 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4373 if (LocaleCompare(attribute,"bounding-box") == 0)
4376 geometry[MaxTextExtent];
4381 if (image == (Image *) NULL)
4383 page=GetImageBoundingBox(image,&image->exception);
4384 (void) FormatLocaleString(geometry,MaxTextExtent,
4385 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4386 page.height,(double) page.x,(double) page.y);
4387 s=newSVpv(geometry,0);
4388 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4398 if (LocaleCompare(attribute,"class") == 0)
4400 if (image == (Image *) NULL)
4402 s=newSViv(image->storage_class);
4403 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4404 image->storage_class));
4406 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4409 if (LocaleCompare(attribute,"clip-mask") == 0)
4411 if (image != (Image *) NULL)
4417 if (image->mask == (Image *) NULL)
4419 if (image->mask != (Image *) NULL)
4421 AddImageToRegistry(sv,image->mask);
4422 s=sv_bless(newRV(sv),SvSTASH(reference));
4425 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4428 if (LocaleCompare(attribute,"clip-path") == 0)
4430 if (image != (Image *) NULL)
4436 if (image->clip_mask == (Image *) NULL)
4438 if (image->clip_mask != (Image *) NULL)
4440 AddImageToRegistry(sv,image->clip_mask);
4441 s=sv_bless(newRV(sv),SvSTASH(reference));
4444 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4447 if (LocaleCompare(attribute,"compression") == 0)
4449 j=info ? info->image_info->compression : image ?
4450 image->compression : UndefinedCompression;
4452 if (info->image_info->compression == UndefinedCompression)
4453 j=image->compression;
4455 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4458 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4461 if (LocaleCompare(attribute,"colorspace") == 0)
4463 j=image ? image->colorspace : RGBColorspace;
4465 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4468 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4471 if (LocaleCompare(attribute,"colors") == 0)
4473 if (image != (Image *) NULL)
4474 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4475 &image->exception));
4476 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4479 if (LocaleNCompare(attribute,"colormap",8) == 0)
4484 if (image == (Image *) NULL || !image->colormap)
4487 items=sscanf(attribute,"%*[^[][%ld",&j);
4489 if (j > (ssize_t) image->colors)
4491 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4492 QuantumFormat "," QuantumFormat "," QuantumFormat,
4493 image->colormap[j].red,image->colormap[j].green,
4494 image->colormap[j].blue,image->colormap[j].alpha);
4496 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4499 if (LocaleCompare(attribute,"columns") == 0)
4501 if (image != (Image *) NULL)
4502 s=newSViv((ssize_t) image->columns);
4503 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4506 if (LocaleCompare(attribute,"comment") == 0)
4511 value=GetImageProperty(image,attribute);
4512 if (value != (const char *) NULL)
4514 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4517 if (LocaleCompare(attribute,"copyright") == 0)
4519 s=newSVpv(GetMagickCopyright(),0);
4520 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4523 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4530 if (LocaleCompare(attribute,"density") == 0)
4533 geometry[MaxTextExtent];
4535 if (image == (Image *) NULL)
4537 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4538 image->x_resolution,image->y_resolution);
4539 s=newSVpv(geometry,0);
4540 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4543 if (LocaleCompare(attribute,"delay") == 0)
4545 if (image != (Image *) NULL)
4546 s=newSViv((ssize_t) image->delay);
4547 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4550 if (LocaleCompare(attribute,"depth") == 0)
4552 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4553 if (image != (Image *) NULL)
4554 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4555 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4558 if (LocaleCompare(attribute,"directory") == 0)
4560 if (image && image->directory)
4561 s=newSVpv(image->directory,0);
4562 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4565 if (LocaleCompare(attribute,"dispose") == 0)
4567 if (image == (Image *) NULL)
4570 s=newSViv(image->dispose);
4572 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4574 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4577 if (LocaleCompare(attribute,"disk") == 0)
4579 s=newSViv(GetMagickResource(DiskResource));
4580 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4583 if (LocaleCompare(attribute,"dither") == 0)
4586 s=newSViv((ssize_t) info->image_info->dither);
4587 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4590 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4592 if (info && info->image_info->server_name)
4593 s=newSVpv(info->image_info->server_name,0);
4594 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4597 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4604 if (LocaleCompare(attribute,"elapsed-time") == 0)
4606 if (image != (Image *) NULL)
4607 s=newSVnv(GetElapsedTime(&image->timer));
4608 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4611 if (LocaleCompare(attribute,"endian") == 0)
4613 j=info ? info->image_info->endian : image ? image->endian :
4616 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4618 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4621 if (LocaleCompare(attribute,"error") == 0)
4623 if (image != (Image *) NULL)
4624 s=newSVnv(image->error.mean_error_per_pixel);
4625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4628 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4635 if (LocaleCompare(attribute,"filesize") == 0)
4637 if (image != (Image *) NULL)
4638 s=newSViv((ssize_t) GetBlobSize(image));
4639 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4642 if (LocaleCompare(attribute,"filename") == 0)
4644 if (info && info->image_info->filename &&
4645 *info->image_info->filename)
4646 s=newSVpv(info->image_info->filename,0);
4647 if (image != (Image *) NULL)
4648 s=newSVpv(image->filename,0);
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 if (LocaleCompare(attribute,"filter") == 0)
4654 s=image ? newSViv(image->filter) : newSViv(0);
4655 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4658 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4661 if (LocaleCompare(attribute,"font") == 0)
4663 if (info && info->image_info->font)
4664 s=newSVpv(info->image_info->font,0);
4665 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4668 if (LocaleCompare(attribute,"foreground") == 0)
4670 if (LocaleCompare(attribute,"format") == 0)
4675 magick_info=(const MagickInfo *) NULL;
4676 if (info && (*info->image_info->magick != '\0'))
4677 magick_info=GetMagickInfo(info->image_info->magick,exception);
4678 if (image != (Image *) NULL)
4679 magick_info=GetMagickInfo(image->magick,&image->exception);
4680 if ((magick_info != (const MagickInfo *) NULL) &&
4681 (*magick_info->description != '\0'))
4682 s=newSVpv((char *) magick_info->description,0);
4683 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4686 if (LocaleCompare(attribute,"fuzz") == 0)
4689 s=newSVnv(info->image_info->fuzz);
4690 if (image != (Image *) NULL)
4691 s=newSVnv(image->fuzz);
4692 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4695 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4702 if (LocaleCompare(attribute,"gamma") == 0)
4704 if (image != (Image *) NULL)
4705 s=newSVnv(image->gamma);
4706 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4709 if (LocaleCompare(attribute,"geometry") == 0)
4711 if (image && image->geometry)
4712 s=newSVpv(image->geometry,0);
4713 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4716 if (LocaleCompare(attribute,"gravity") == 0)
4718 s=image ? newSViv(image->gravity) : newSViv(0);
4719 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4722 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4725 if (LocaleCompare(attribute,"green-primary") == 0)
4727 if (image == (Image *) NULL)
4729 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4730 image->chromaticity.green_primary.x,
4731 image->chromaticity.green_primary.y);
4733 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4736 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4743 if (LocaleCompare(attribute,"height") == 0)
4745 if (image != (Image *) NULL)
4746 s=newSViv((ssize_t) image->rows);
4747 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4750 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4757 if (LocaleCompare(attribute,"icc") == 0)
4759 if (image != (Image *) NULL)
4764 profile=GetImageProfile(image,"icc");
4765 if (profile != (StringInfo *) NULL)
4766 s=newSVpv((const char *) GetStringInfoDatum(profile),
4767 GetStringInfoLength(profile));
4769 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4772 if (LocaleCompare(attribute,"icm") == 0)
4774 if (image != (Image *) NULL)
4779 profile=GetImageProfile(image,"icm");
4780 if (profile != (const StringInfo *) NULL)
4781 s=newSVpv((const char *) GetStringInfoDatum(profile),
4782 GetStringInfoLength(profile));
4784 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4787 if (LocaleCompare(attribute,"id") == 0)
4789 if (image != (Image *) NULL)
4800 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4802 status=SetImageRegistry(ImageRegistryType,key,image,
4807 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4810 if (LocaleNCompare(attribute,"index",5) == 0)
4813 name[MaxTextExtent];
4822 register const Quantum
4828 if (image == (Image *) NULL)
4830 if (image->storage_class != PseudoClass)
4834 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4836 image_view=AcquireCacheView(image);
4837 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4838 if (p != (const Quantum *) NULL)
4840 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4841 GetPixelIndex(image,p));
4843 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4845 image_view=DestroyCacheView(image_view);
4848 if (LocaleCompare(attribute,"iptc") == 0)
4850 if (image != (Image *) NULL)
4855 profile=GetImageProfile(image,"iptc");
4856 if (profile != (const StringInfo *) NULL)
4857 s=newSVpv((const char *) GetStringInfoDatum(profile),
4858 GetStringInfoLength(profile));
4860 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4863 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4865 if (image != (Image *) NULL)
4866 s=newSViv((ssize_t) image->iterations);
4867 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4870 if (LocaleCompare(attribute,"interlace") == 0)
4872 j=info ? info->image_info->interlace : image ? image->interlace :
4875 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4878 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4881 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4888 if (LocaleCompare(attribute,"label") == 0)
4893 if (image == (Image *) NULL)
4895 value=GetImageProperty(image,"Label");
4896 if (value != (const char *) NULL)
4898 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4901 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4903 if (image != (Image *) NULL)
4904 s=newSViv((ssize_t) image->iterations);
4905 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4908 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4915 if (LocaleCompare(attribute,"magick") == 0)
4917 if (info && *info->image_info->magick)
4918 s=newSVpv(info->image_info->magick,0);
4919 if (image != (Image *) NULL)
4920 s=newSVpv(image->magick,0);
4921 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4924 if (LocaleCompare(attribute,"map") == 0)
4926 s=newSViv(GetMagickResource(MapResource));
4927 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4930 if (LocaleCompare(attribute,"maximum-error") == 0)
4932 if (image != (Image *) NULL)
4933 s=newSVnv(image->error.normalized_maximum_error);
4934 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4937 if (LocaleCompare(attribute,"memory") == 0)
4939 s=newSViv(GetMagickResource(MemoryResource));
4940 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4943 if (LocaleCompare(attribute,"mean-error") == 0)
4945 if (image != (Image *) NULL)
4946 s=newSVnv(image->error.normalized_mean_error);
4947 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4950 if (LocaleCompare(attribute,"mime") == 0)
4952 if (info && *info->image_info->magick)
4953 s=newSVpv(MagickToMime(info->image_info->magick),0);
4954 if (image != (Image *) NULL)
4955 s=newSVpv(MagickToMime(image->magick),0);
4956 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4959 if (LocaleCompare(attribute,"mattecolor") == 0)
4961 if (image == (Image *) NULL)
4963 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4964 QuantumFormat "," QuantumFormat "," QuantumFormat,
4965 image->matte_color.red,image->matte_color.green,
4966 image->matte_color.blue,image->matte_color.alpha);
4968 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4971 if (LocaleCompare(attribute,"matte") == 0)
4973 if (image != (Image *) NULL)
4974 s=newSViv((ssize_t) image->matte);
4975 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4978 if (LocaleCompare(attribute,"mime") == 0)
4984 if (info && *info->image_info->magick)
4985 magick=info->image_info->magick;
4986 if (image != (Image *) NULL)
4987 magick=image->magick;
4993 mime=MagickToMime(magick);
4995 mime=(char *) RelinquishMagickMemory(mime);
4997 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5000 if (LocaleCompare(attribute,"monochrome") == 0)
5002 if (image == (Image *) NULL)
5004 j=info ? info->image_info->monochrome :
5005 IsImageMonochrome(image,&image->exception);
5007 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5010 if (LocaleCompare(attribute,"montage") == 0)
5012 if (image && image->montage)
5013 s=newSVpv(image->montage,0);
5014 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5017 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5024 if (LocaleCompare(attribute,"orientation") == 0)
5026 j=info ? info->image_info->orientation : image ?
5027 image->orientation : UndefinedOrientation;
5029 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5032 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5035 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5042 if (LocaleCompare(attribute,"page") == 0)
5044 if (info && info->image_info->page)
5045 s=newSVpv(info->image_info->page,0);
5046 if (image != (Image *) NULL)
5049 geometry[MaxTextExtent];
5051 (void) FormatLocaleString(geometry,MaxTextExtent,
5052 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5053 (double) image->page.height,(double) image->page.x,(double)
5055 s=newSVpv(geometry,0);
5057 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5060 if (LocaleCompare(attribute,"page.x") == 0)
5062 if (image != (Image *) NULL)
5063 s=newSViv((ssize_t) image->page.x);
5064 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5067 if (LocaleCompare(attribute,"page.y") == 0)
5069 if (image != (Image *) NULL)
5070 s=newSViv((ssize_t) image->page.y);
5071 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5074 if (LocaleNCompare(attribute,"pixel",5) == 0)
5077 tuple[MaxTextExtent];
5086 register const Quantum
5089 if (image == (Image *) NULL)
5093 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5095 p=GetVirtualPixels(image,x,y,1,1,exception);
5096 if (image->colorspace != CMYKColorspace)
5097 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5098 QuantumFormat "," QuantumFormat "," QuantumFormat,
5099 GetPixelRed(image,p),GetPixelGreen(image,p),
5100 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5102 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5103 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5104 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5105 GetPixelBlue(image,p),GetPixelBlack(image,p),
5106 GetPixelAlpha(image,p));
5108 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5111 if (LocaleCompare(attribute,"pointsize") == 0)
5114 s=newSViv((ssize_t) info->image_info->pointsize);
5115 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5118 if (LocaleCompare(attribute,"preview") == 0)
5120 s=newSViv(info->image_info->preview_type);
5121 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5122 info->image_info->preview_type));
5124 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5127 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5134 if (LocaleCompare(attribute,"quality") == 0)
5137 s=newSViv((ssize_t) info->image_info->quality);
5138 if (image != (Image *) NULL)
5139 s=newSViv((ssize_t) image->quality);
5140 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5143 if (LocaleCompare(attribute,"quantum") == 0)
5146 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5147 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5150 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5157 if (LocaleCompare(attribute,"rendering-intent") == 0)
5159 s=newSViv(image->rendering_intent);
5160 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5161 image->rendering_intent));
5163 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5166 if (LocaleCompare(attribute,"red-primary") == 0)
5168 if (image == (Image *) NULL)
5170 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5171 image->chromaticity.red_primary.x,
5172 image->chromaticity.red_primary.y);
5174 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5177 if (LocaleCompare(attribute,"rows") == 0)
5179 if (image != (Image *) NULL)
5180 s=newSViv((ssize_t) image->rows);
5181 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5184 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5191 if (LocaleCompare(attribute,"sampling-factor") == 0)
5193 if (info && info->image_info->sampling_factor)
5194 s=newSVpv(info->image_info->sampling_factor,0);
5195 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5198 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5200 if (info && info->image_info->server_name)
5201 s=newSVpv(info->image_info->server_name,0);
5202 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5205 if (LocaleCompare(attribute,"size") == 0)
5207 if (info && info->image_info->size)
5208 s=newSVpv(info->image_info->size,0);
5209 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5212 if (LocaleCompare(attribute,"scene") == 0)
5214 if (image != (Image *) NULL)
5215 s=newSViv((ssize_t) image->scene);
5216 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5219 if (LocaleCompare(attribute,"scenes") == 0)
5221 if (image != (Image *) NULL)
5222 s=newSViv((ssize_t) info->image_info->number_scenes);
5223 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5226 if (LocaleCompare(attribute,"signature") == 0)
5231 if (image == (Image *) NULL)
5233 (void) SignatureImage(image);
5234 value=GetImageProperty(image,"Signature");
5235 if (value != (const char *) NULL)
5237 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5240 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5247 if (LocaleCompare(attribute,"taint") == 0)
5249 if (image != (Image *) NULL)
5250 s=newSViv((ssize_t) IsTaintImage(image));
5251 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5254 if (LocaleCompare(attribute,"texture") == 0)
5256 if (info && info->image_info->texture)
5257 s=newSVpv(info->image_info->texture,0);
5258 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5261 if (LocaleCompare(attribute,"total-ink-density") == 0)
5263 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5264 if (image != (Image *) NULL)
5265 s=newSVnv(GetImageTotalInkDensity(image));
5266 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5269 if (LocaleCompare(attribute,"transparent-color") == 0)
5271 if (image == (Image *) NULL)
5273 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5274 QuantumFormat "," QuantumFormat "," QuantumFormat,
5275 image->transparent_color.red,image->transparent_color.green,
5276 image->transparent_color.blue,image->transparent_color.alpha);
5278 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5281 if (LocaleCompare(attribute,"type") == 0)
5283 if (image == (Image *) NULL)
5285 j=(ssize_t) GetImageType(image,&image->exception);
5287 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5289 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5292 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5299 if (LocaleCompare(attribute,"units") == 0)
5301 j=info ? info->image_info->units : image ? image->units :
5302 UndefinedResolution;
5303 if (info && (info->image_info->units == UndefinedResolution))
5306 if (j == UndefinedResolution)
5307 s=newSVpv("undefined units",0);
5309 if (j == PixelsPerInchResolution)
5310 s=newSVpv("pixels / inch",0);
5312 s=newSVpv("pixels / centimeter",0);
5313 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5316 if (LocaleCompare(attribute,"user-time") == 0)
5318 if (image != (Image *) NULL)
5319 s=newSVnv(GetUserTime(&image->timer));
5320 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5323 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5330 if (LocaleCompare(attribute,"verbose") == 0)
5333 s=newSViv((ssize_t) info->image_info->verbose);
5334 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5337 if (LocaleCompare(attribute,"version") == 0)
5339 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5340 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5343 if (LocaleCompare(attribute,"view") == 0)
5345 if (info && info->image_info->view)
5346 s=newSVpv(info->image_info->view,0);
5347 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5350 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5352 if (image == (Image *) NULL)
5354 j=(ssize_t) GetImageVirtualPixelMethod(image);
5356 (void) sv_setpv(s,CommandOptionToMnemonic(
5357 MagickVirtualPixelOptions,j));
5359 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5362 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5369 if (LocaleCompare(attribute,"white-point") == 0)
5371 if (image == (Image *) NULL)
5373 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5374 image->chromaticity.white_point.x,
5375 image->chromaticity.white_point.y);
5377 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5380 if (LocaleCompare(attribute,"width") == 0)
5382 if (image != (Image *) NULL)
5383 s=newSViv((ssize_t) image->columns);
5384 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5387 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5394 if (LocaleCompare(attribute,"x-resolution") == 0)
5396 if (image != (Image *) NULL)
5397 s=newSVnv(image->x_resolution);
5398 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5401 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5408 if (LocaleCompare(attribute,"y-resolution") == 0)
5410 if (image != (Image *) NULL)
5411 s=newSVnv(image->y_resolution);
5412 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5415 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5422 if (image == (Image *) NULL)
5423 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5427 value=GetImageProperty(image,attribute);
5428 if (value != (const char *) NULL)
5431 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5434 if (*attribute != '%')
5435 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5442 meta=InterpretImageProperties(info ? info->image_info :
5443 (ImageInfo *) NULL,image,attribute);
5445 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5446 meta=(char *) RelinquishMagickMemory(meta);
5450 exception=DestroyExceptionInfo(exception);
5451 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5455 ###############################################################################
5459 # G e t A u t h e n t i c P i x e l s #
5463 ###############################################################################
5467 GetAuthenticPixels(ref,...)
5468 Image::Magick ref = NO_INIT
5470 getauthenticpixels = 1
5500 PERL_UNUSED_VAR(ref);
5501 PERL_UNUSED_VAR(ix);
5502 exception=AcquireExceptionInfo();
5503 perl_exception=newSVpv("",0);
5504 if (sv_isobject(ST(0)) == 0)
5506 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5510 reference=SvRV(ST(0));
5512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5513 if (image == (Image *) NULL)
5515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5522 region.width=image->columns;
5525 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5526 for (i=2; i < items; i+=2)
5528 attribute=(char *) SvPV(ST(i-1),na);
5534 if (LocaleCompare(attribute,"geometry") == 0)
5536 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5539 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5546 if (LocaleCompare(attribute,"height") == 0)
5548 region.height=SvIV(ST(i));
5551 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5558 if (LocaleCompare(attribute,"x") == 0)
5560 region.x=SvIV(ST(i));
5563 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5570 if (LocaleCompare(attribute,"y") == 0)
5572 region.y=SvIV(ST(i));
5575 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5582 if (LocaleCompare(attribute,"width") == 0)
5584 region.width=SvIV(ST(i));
5587 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5593 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5594 region.height,exception);
5595 if (blob != (void *) NULL)
5599 InheritPerlException(exception,perl_exception);
5600 exception=DestroyExceptionInfo(exception);
5601 SvREFCNT_dec(perl_exception); /* throw away all errors */
5610 ###############################################################################
5614 # G e t V i r t u a l P i x e l s #
5618 ###############################################################################
5622 GetVirtualPixels(ref,...)
5623 Image::Magick ref = NO_INIT
5625 getvirtualpixels = 1
5626 AcquireImagePixels = 2
5627 acquireimagepixels = 3
5655 PERL_UNUSED_VAR(ref);
5656 PERL_UNUSED_VAR(ix);
5657 exception=AcquireExceptionInfo();
5658 perl_exception=newSVpv("",0);
5659 if (sv_isobject(ST(0)) == 0)
5661 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5665 reference=SvRV(ST(0));
5667 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5668 if (image == (Image *) NULL)
5670 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5677 region.width=image->columns;
5680 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5681 for (i=2; i < items; i+=2)
5683 attribute=(char *) SvPV(ST(i-1),na);
5689 if (LocaleCompare(attribute,"geometry") == 0)
5691 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5694 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5701 if (LocaleCompare(attribute,"height") == 0)
5703 region.height=SvIV(ST(i));
5706 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5713 if (LocaleCompare(attribute,"x") == 0)
5715 region.x=SvIV(ST(i));
5718 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5725 if (LocaleCompare(attribute,"y") == 0)
5727 region.y=SvIV(ST(i));
5730 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5737 if (LocaleCompare(attribute,"width") == 0)
5739 region.width=SvIV(ST(i));
5742 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5748 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5749 region.height,exception);
5750 if (blob != (void *) NULL)
5754 InheritPerlException(exception,perl_exception);
5755 exception=DestroyExceptionInfo(exception);
5756 SvREFCNT_dec(perl_exception); /* throw away all errors */
5759 RETVAL = (void *) blob;
5765 ###############################################################################
5769 # G e t A u t h e n t i c M e t a c o n t e n t #
5773 ###############################################################################
5777 GetAuthenticMetacontent(ref,...)
5778 Image::Magick ref = NO_INIT
5780 getauthenticmetacontent = 1
5801 PERL_UNUSED_VAR(ref);
5802 PERL_UNUSED_VAR(ix);
5803 exception=AcquireExceptionInfo();
5804 perl_exception=newSVpv("",0);
5805 if (sv_isobject(ST(0)) == 0)
5807 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5811 reference=SvRV(ST(0));
5813 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5814 if (image == (Image *) NULL)
5816 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5821 blob=(void *) GetAuthenticMetacontent(image);
5822 if (blob != (void *) NULL)
5826 InheritPerlException(exception,perl_exception);
5827 exception=DestroyExceptionInfo(exception);
5828 SvREFCNT_dec(perl_exception); /* throw away all errors */
5837 ###############################################################################
5841 # G e t V i r t u a l M e t a c o n t e n t #
5845 ###############################################################################
5849 GetVirtualMetacontent(ref,...)
5850 Image::Magick ref = NO_INIT
5852 getvirtualmetacontent = 1
5871 PERL_UNUSED_VAR(ref);
5872 PERL_UNUSED_VAR(ix);
5873 exception=AcquireExceptionInfo();
5874 perl_exception=newSVpv("",0);
5875 if (sv_isobject(ST(0)) == 0)
5877 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5881 reference=SvRV(ST(0));
5883 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5884 if (image == (Image *) NULL)
5886 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5891 blob=(void *) GetVirtualMetacontent(image);
5892 if (blob != (void *) NULL)
5896 InheritPerlException(exception,perl_exception);
5897 exception=DestroyExceptionInfo(exception);
5898 SvREFCNT_dec(perl_exception); /* throw away all errors */
5907 ###############################################################################
5911 # H i s t o g r a m #
5915 ###############################################################################
5920 Image::Magick ref=NO_INIT
5931 message[MaxTextExtent];
5958 PERL_UNUSED_VAR(ref);
5959 PERL_UNUSED_VAR(ix);
5960 exception=AcquireExceptionInfo();
5961 perl_exception=newSVpv("",0);
5963 if (sv_isobject(ST(0)) == 0)
5965 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5969 reference=SvRV(ST(0));
5972 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5973 if (image == (Image *) NULL)
5975 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5979 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5981 for ( ; image; image=image->next)
5983 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5984 if (histogram == (PixelPacket *) NULL)
5986 count+=(ssize_t) number_colors;
5988 for (i=0; i < (ssize_t) number_colors; i++)
5990 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5992 PUSHs(sv_2mortal(newSVpv(message,0)));
5993 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5994 histogram[i].green);
5995 PUSHs(sv_2mortal(newSVpv(message,0)));
5996 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5998 PUSHs(sv_2mortal(newSVpv(message,0)));
5999 if (image->colorspace == CMYKColorspace)
6001 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6002 histogram[i].black);
6003 PUSHs(sv_2mortal(newSVpv(message,0)));
6005 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6006 histogram[i].alpha);
6007 PUSHs(sv_2mortal(newSVpv(message,0)));
6008 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6009 histogram[i].count);
6010 PUSHs(sv_2mortal(newSVpv(message,0)));
6012 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6016 InheritPerlException(exception,perl_exception);
6017 exception=DestroyExceptionInfo(exception);
6018 SvREFCNT_dec(perl_exception);
6022 ###############################################################################
6030 ###############################################################################
6035 Image::Magick ref=NO_INIT
6059 register const Quantum
6073 *reference; /* reference is the SV* of ref=SvIV(reference) */
6075 PERL_UNUSED_VAR(ref);
6076 PERL_UNUSED_VAR(ix);
6077 exception=AcquireExceptionInfo();
6078 perl_exception=newSVpv("",0);
6079 reference=SvRV(ST(0));
6080 av=(AV *) reference;
6081 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6083 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6084 if (image == (Image *) NULL)
6086 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6090 normalize=MagickTrue;
6093 region.width=image->columns;
6096 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6097 for (i=2; i < items; i+=2)
6099 attribute=(char *) SvPV(ST(i-1),na);
6105 if (LocaleCompare(attribute,"channel") == 0)
6110 option=ParseChannelOption(SvPV(ST(i),na));
6113 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6117 SetPixelComponentMap(image,(ChannelType) option);
6120 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6127 if (LocaleCompare(attribute,"geometry") == 0)
6129 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6132 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6139 if (LocaleCompare(attribute,"normalize") == 0)
6141 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6145 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6149 normalize=option != 0 ? MagickTrue : MagickFalse;
6152 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6159 if (LocaleCompare(attribute,"x") == 0)
6161 region.x=SvIV(ST(i));
6164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6171 if (LocaleCompare(attribute,"y") == 0)
6173 region.y=SvIV(ST(i));
6176 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6182 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6188 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6189 if (p == (const Quantum *) NULL)
6197 if (normalize != MagickFalse)
6198 scale=1.0/QuantumRange;
6199 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
6200 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6201 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
6202 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6203 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
6204 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6205 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
6206 (image->colorspace == CMYKColorspace))
6207 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6208 if ((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0)
6209 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6213 InheritPerlException(exception,perl_exception);
6214 exception=DestroyExceptionInfo(exception);
6215 SvREFCNT_dec(perl_exception);
6219 ###############################################################################
6223 # G e t P i x e l s #
6227 ###############################################################################
6232 Image::Magick ref=NO_INIT
6271 *reference; /* reference is the SV* of ref=SvIV(reference) */
6273 PERL_UNUSED_VAR(ref);
6274 PERL_UNUSED_VAR(ix);
6275 exception=AcquireExceptionInfo();
6276 perl_exception=newSVpv("",0);
6277 reference=SvRV(ST(0));
6278 av=(AV *) reference;
6279 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6281 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6282 if (image == (Image *) NULL)
6284 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6289 if (image->matte != MagickFalse)
6291 if (image->colorspace == CMYKColorspace)
6294 if (image->matte != MagickFalse)
6297 normalize=MagickFalse;
6300 region.width=image->columns;
6303 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6304 for (i=2; i < items; i+=2)
6306 attribute=(char *) SvPV(ST(i-1),na);
6312 if (LocaleCompare(attribute,"geometry") == 0)
6314 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6317 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6324 if (LocaleCompare(attribute,"height") == 0)
6326 region.height=SvIV(ST(i));
6329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6336 if (LocaleCompare(attribute,"map") == 0)
6341 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6348 if (LocaleCompare(attribute,"normalize") == 0)
6350 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6354 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6358 normalize=option != 0 ? MagickTrue : MagickFalse;
6361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6368 if (LocaleCompare(attribute,"width") == 0)
6370 region.width=SvIV(ST(i));
6373 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6380 if (LocaleCompare(attribute,"x") == 0)
6382 region.x=SvIV(ST(i));
6385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6392 if (LocaleCompare(attribute,"y") == 0)
6394 region.y=SvIV(ST(i));
6397 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6409 if (normalize != MagickFalse)
6414 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6415 region.height*sizeof(*pixels));
6416 if (pixels == (float *) NULL)
6418 ThrowPerlException(exception,ResourceLimitError,
6419 "MemoryAllocationFailed",PackageName);
6422 status=ExportImagePixels(image,region.x,region.y,region.width,
6423 region.height,map,FloatPixel,pixels,exception);
6424 if (status == MagickFalse)
6428 EXTEND(sp,strlen(map)*region.width*region.height);
6429 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6430 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6432 pixels=(float *) RelinquishMagickMemory(pixels);
6439 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6440 region.height*sizeof(*pixels));
6441 if (pixels == (Quantum *) NULL)
6443 ThrowPerlException(exception,ResourceLimitError,
6444 "MemoryAllocationFailed",PackageName);
6447 status=ExportImagePixels(image,region.x,region.y,region.width,
6448 region.height,map,QuantumPixel,pixels,exception);
6449 if (status == MagickFalse)
6453 EXTEND(sp,strlen(map)*region.width*region.height);
6454 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6455 PUSHs(sv_2mortal(newSViv(pixels[i])));
6457 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6461 InheritPerlException(exception,perl_exception);
6462 exception=DestroyExceptionInfo(exception);
6463 SvREFCNT_dec(perl_exception);
6467 ###############################################################################
6471 # I m a g e T o B l o b #
6475 ###############################################################################
6479 ImageToBlob(ref,...)
6480 Image::Magick ref=NO_INIT
6489 filename[MaxTextExtent];
6518 PERL_UNUSED_VAR(ref);
6519 PERL_UNUSED_VAR(ix);
6520 exception=AcquireExceptionInfo();
6521 perl_exception=newSVpv("",0);
6522 package_info=(struct PackageInfo *) NULL;
6523 if (sv_isobject(ST(0)) == 0)
6525 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6529 reference=SvRV(ST(0));
6530 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6531 if (image == (Image *) NULL)
6533 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6537 package_info=ClonePackageInfo(info,exception);
6538 for (i=2; i < items; i+=2)
6539 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6540 (void) CopyMagickString(filename,package_info->image_info->filename,
6543 for (next=image; next; next=next->next)
6545 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6546 next->scene=scene++;
6548 SetImageInfo(package_info->image_info,(unsigned int)
6549 GetImageListLength(image),&image->exception);
6550 EXTEND(sp,(ssize_t) GetImageListLength(image));
6551 for ( ; image; image=image->next)
6554 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6555 if (blob != (char *) NULL)
6557 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6558 blob=(unsigned char *) RelinquishMagickMemory(blob);
6560 if (package_info->image_info->adjoin)
6565 if (package_info != (struct PackageInfo *) NULL)
6566 DestroyPackageInfo(package_info);
6567 InheritPerlException(exception,perl_exception);
6568 exception=DestroyExceptionInfo(exception);
6569 SvREFCNT_dec(perl_exception); /* throw away all errors */
6573 ###############################################################################
6581 ###############################################################################
6586 Image::Magick ref=NO_INIT
6590 OptimizeImageLayers = 3
6592 optimizeimagelayers = 5
6634 PERL_UNUSED_VAR(ref);
6635 PERL_UNUSED_VAR(ix);
6636 exception=AcquireExceptionInfo();
6637 perl_exception=newSVpv("",0);
6639 if (sv_isobject(ST(0)) == 0)
6641 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6645 reference=SvRV(ST(0));
6646 hv=SvSTASH(reference);
6648 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6650 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6651 if (image == (Image *) NULL)
6653 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6657 compose=image->compose;
6658 method=OptimizeLayer;
6659 for (i=2; i < items; i+=2)
6661 attribute=(char *) SvPV(ST(i-1),na);
6667 if (LocaleCompare(attribute,"compose") == 0)
6669 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6670 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6673 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6677 compose=(CompositeOperator) sp;
6680 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6687 if (LocaleCompare(attribute,"method") == 0)
6689 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6693 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6697 method=(ImageLayerMethod) option;
6700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6706 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6712 layers=(Image *) NULL;
6715 case CompareAnyLayer:
6716 case CompareClearLayer:
6717 case CompareOverlayLayer:
6720 layers=CompareImagesLayers(image,method,exception);
6727 layers=MergeImageLayers(image,method,exception);
6732 layers=DisposeImages(image,exception);
6735 case OptimizeImageLayer:
6737 layers=OptimizeImageLayers(image,exception);
6740 case OptimizePlusLayer:
6742 layers=OptimizePlusImageLayers(image,exception);
6745 case OptimizeTransLayer:
6747 OptimizeImageTransparency(image,exception);
6748 InheritException(&(image->exception),exception);
6751 case RemoveDupsLayer:
6753 RemoveDuplicateLayers(&image,exception);
6754 InheritException(&(image->exception),exception);
6757 case RemoveZeroLayer:
6759 RemoveZeroDelayLayers(&image,exception);
6760 InheritException(&(image->exception),exception);
6769 General Purpose, GIF Animation Optimizer.
6771 layers=CoalesceImages(image,exception);
6772 if (layers == (Image *) NULL)
6774 InheritException(&(layers->exception),exception);
6776 layers=OptimizeImageLayers(image,exception);
6777 if (layers == (Image *) NULL)
6779 InheritException(&(layers->exception),exception);
6780 image=DestroyImageList(image);
6782 layers=(Image *) NULL;
6783 OptimizeImageTransparency(image,exception);
6784 InheritException(&(image->exception),exception);
6785 quantize_info=AcquireQuantizeInfo(info->image_info);
6786 (void) RemapImages(quantize_info,image,(Image *) NULL);
6787 quantize_info=DestroyQuantizeInfo(quantize_info);
6790 case CompositeLayer:
6799 Split image sequence at the first 'NULL:' image.
6802 while (source != (Image *) NULL)
6804 source=GetNextImageInList(source);
6805 if ((source != (Image *) NULL) &&
6806 (LocaleCompare(source->magick,"NULL") == 0))
6809 if (source != (Image *) NULL)
6811 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6812 (GetNextImageInList(source) == (Image *) NULL))
6813 source=(Image *) NULL;
6817 Separate the two lists, junk the null: image.
6819 source=SplitImageList(source->previous);
6820 DeleteImageFromList(&source);
6823 if (source == (Image *) NULL)
6825 (void) ThrowMagickException(exception,GetMagickModule(),
6826 OptionError,"MissingNullSeparator","layers Composite");
6830 Adjust offset with gravity and virtual canvas.
6832 SetGeometry(image,&geometry);
6833 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6834 geometry.width=source->page.width != 0 ? source->page.width :
6836 geometry.height=source->page.height != 0 ? source->page.height :
6838 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6839 image->columns,image->page.height != 0 ? image->page.height :
6840 image->rows,image->gravity,&geometry);
6841 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6842 source=DestroyImageList(source);
6843 InheritException(&(image->exception),exception);
6847 if (layers != (Image *) NULL)
6849 InheritException(&(layers->exception),exception);
6852 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6854 for ( ; image; image=image->next)
6856 AddImageToRegistry(sv,image);
6858 av_push(av,sv_bless(rv,hv));
6861 exception=DestroyExceptionInfo(exception);
6863 SvREFCNT_dec(perl_exception);
6867 InheritPerlException(exception,perl_exception);
6868 exception=DestroyExceptionInfo(exception);
6869 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6870 SvPOK_on(perl_exception);
6871 ST(0)=sv_2mortal(perl_exception);
6876 ###############################################################################
6880 # M a g i c k T o M i m e #
6884 ###############################################################################
6888 MagickToMime(ref,name)
6889 Image::Magick ref=NO_INIT
6898 PERL_UNUSED_VAR(ref);
6899 PERL_UNUSED_VAR(ix);
6900 mime=MagickToMime(name);
6901 RETVAL=newSVpv(mime,0);
6902 mime=(char *) RelinquishMagickMemory(mime);
6908 ###############################################################################
6916 ###############################################################################
6921 Image::Magick ref=NO_INIT
6958 MedianFilterImage = 36
6964 ReduceNoiseImage = 42
6990 ColorFloodfillImage= 68
6996 CycleColormapImage = 74
7006 MatteFloodfillImage= 84
7014 NumberColorsImage = 92
7024 SignatureImage = 102
7034 TransparentImage = 112
7036 ThresholdImage = 114
7050 DeconstructImage = 130
7052 GaussianBlurImage = 132
7058 UnsharpMaskImage = 138
7060 MotionBlurImage = 140
7062 OrderedDitherImage = 142
7069 AffineTransform = 149
7070 AffineTransformImage = 150
7072 DifferenceImage = 152
7073 AdaptiveThreshold = 153
7074 AdaptiveThresholdImage = 154
7079 BlackThreshold = 159
7080 BlackThresholdImage= 160
7081 WhiteThreshold = 161
7082 WhiteThresholdImage= 162
7084 RadialBlurImage = 164
7086 ThumbnailImage = 166
7096 PosterizeImage = 176
7102 SepiaToneImage = 182
7103 SigmoidalContrast = 183
7104 SigmoidalContrastImage = 184
7109 ContrastStretch = 189
7110 ContrastStretchImage = 190
7115 AdaptiveSharpen = 195
7116 AdaptiveSharpenImage = 196
7118 TransposeImage = 198
7120 TransverseImage = 200
7122 AutoOrientImage = 202
7124 AdaptiveBlurImage = 204
7128 UniqueColorsImage = 208
7129 AdaptiveResize = 209
7130 AdaptiveResizeImage= 210
7134 LinearStretchImage = 214
7141 FloodfillPaint = 221
7142 FloodfillPaintImage= 222
7148 LiquidRescaleImage = 228
7158 SparseColorImage = 238
7162 SelectiveBlurImage = 242
7166 BlueShiftImage = 246
7167 ForwardFourierTransform = 247
7168 ForwardFourierTransformImage = 248
7169 InverseFourierTransform = 249
7170 InverseFourierTransformImage = 250
7171 ColorDecisionList = 251
7172 ColorDecisionListImage = 252
7174 AutoGammaImage = 254
7176 AutoLevelImage = 256
7178 LevelColorsImage = 258
7183 BrightnessContrast = 263
7184 BrightnessContrastImage = 264
7186 MorphologyImage = 266
7188 ColorMatrixImage = 268
7194 StatisticImage = 274
7203 attribute_flag[MaxArguments],
7204 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));
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));
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 image=AddNoiseImageChannel(image,channel,(NoiseType)
7495 argument_list[0].integer_reference,exception);
7498 case 4: /* Colorize */
7503 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7504 if (attribute_flag[0] != 0)
7505 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7507 if (attribute_flag[1] == 0)
7508 argument_list[1].string_reference="100%";
7509 image=ColorizeImage(image,argument_list[1].string_reference,target,
7513 case 5: /* Border */
7517 if (attribute_flag[0] != 0)
7519 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7520 &geometry,exception);
7521 if ((flags & HeightValue) == 0)
7522 geometry.height=geometry.width;
7524 if (attribute_flag[1] != 0)
7525 geometry.width=argument_list[1].integer_reference;
7526 if (attribute_flag[2] != 0)
7527 geometry.height=argument_list[2].integer_reference;
7528 if (attribute_flag[3] != 0)
7529 QueryColorDatabase(argument_list[3].string_reference,
7530 &image->border_color,exception);
7531 if (attribute_flag[4] != 0)
7532 QueryColorDatabase(argument_list[4].string_reference,
7533 &image->border_color,exception);
7534 if (attribute_flag[5] != 0)
7535 QueryColorDatabase(argument_list[5].string_reference,
7536 &image->border_color,exception);
7537 if (attribute_flag[6] != 0)
7538 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7539 image=BorderImage(image,&geometry,exception);
7544 if (attribute_flag[0] != 0)
7546 flags=ParseGeometry(argument_list[0].string_reference,
7548 if ((flags & SigmaValue) == 0)
7549 geometry_info.sigma=1.0;
7551 if (attribute_flag[1] != 0)
7552 geometry_info.rho=argument_list[1].real_reference;
7553 if (attribute_flag[2] != 0)
7554 geometry_info.sigma=argument_list[2].real_reference;
7555 if (attribute_flag[3] != 0)
7556 channel=(ChannelType) argument_list[3].integer_reference;
7557 image=BlurImageChannel(image,channel,geometry_info.rho,
7558 geometry_info.sigma,exception);
7563 if (attribute_flag[0] != 0)
7564 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7565 &geometry,exception);
7566 if (attribute_flag[1] != 0)
7567 geometry.width=argument_list[1].integer_reference;
7568 if (attribute_flag[2] != 0)
7569 geometry.height=argument_list[2].integer_reference;
7570 if (attribute_flag[3] != 0)
7571 geometry.x=argument_list[3].integer_reference;
7572 if (attribute_flag[4] != 0)
7573 geometry.y=argument_list[4].integer_reference;
7574 image=ChopImage(image,&geometry,exception);
7579 if (attribute_flag[6] != 0)
7580 image->gravity=(GravityType) argument_list[6].integer_reference;
7581 if (attribute_flag[0] != 0)
7582 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7583 &geometry,exception);
7584 if (attribute_flag[1] != 0)
7585 geometry.width=argument_list[1].integer_reference;
7586 if (attribute_flag[2] != 0)
7587 geometry.height=argument_list[2].integer_reference;
7588 if (attribute_flag[3] != 0)
7589 geometry.x=argument_list[3].integer_reference;
7590 if (attribute_flag[4] != 0)
7591 geometry.y=argument_list[4].integer_reference;
7592 if (attribute_flag[5] != 0)
7594 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7595 image=CropImage(image,&geometry,exception);
7598 case 9: /* Despeckle */
7600 image=DespeckleImage(image,exception);
7605 if (attribute_flag[0] != 0)
7606 geometry_info.rho=argument_list[0].real_reference;
7607 image=EdgeImage(image,geometry_info.rho,exception);
7610 case 11: /* Emboss */
7612 if (attribute_flag[0] != 0)
7614 flags=ParseGeometry(argument_list[0].string_reference,
7616 if ((flags & SigmaValue) == 0)
7617 geometry_info.sigma=1.0;
7619 if (attribute_flag[1] != 0)
7620 geometry_info.rho=argument_list[1].real_reference;
7621 if (attribute_flag[2] != 0)
7622 geometry_info.sigma=argument_list[2].real_reference;
7623 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7627 case 12: /* Enhance */
7629 image=EnhanceImage(image,exception);
7634 image=FlipImage(image,exception);
7639 image=FlopImage(image,exception);
7642 case 15: /* Frame */
7647 if (attribute_flag[0] != 0)
7649 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7650 &geometry,exception);
7651 if ((flags & HeightValue) == 0)
7652 geometry.height=geometry.width;
7653 frame_info.width=geometry.width;
7654 frame_info.height=geometry.height;
7655 frame_info.outer_bevel=geometry.x;
7656 frame_info.inner_bevel=geometry.y;
7658 if (attribute_flag[1] != 0)
7659 frame_info.width=argument_list[1].integer_reference;
7660 if (attribute_flag[2] != 0)
7661 frame_info.height=argument_list[2].integer_reference;
7662 if (attribute_flag[3] != 0)
7663 frame_info.inner_bevel=argument_list[3].integer_reference;
7664 if (attribute_flag[4] != 0)
7665 frame_info.outer_bevel=argument_list[4].integer_reference;
7666 if (attribute_flag[5] != 0)
7667 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7669 if (attribute_flag[6] != 0)
7670 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7672 frame_info.x=(ssize_t) frame_info.width;
7673 frame_info.y=(ssize_t) frame_info.height;
7674 frame_info.width=image->columns+2*frame_info.x;
7675 frame_info.height=image->rows+2*frame_info.y;
7676 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7677 image->matte_color=fill_color;
7678 if (attribute_flag[7] != 0)
7679 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7680 image=FrameImage(image,&frame_info,exception);
7683 case 16: /* Implode */
7685 if (attribute_flag[0] == 0)
7686 argument_list[0].real_reference=0.5;
7687 if (attribute_flag[1] != 0)
7688 image->interpolate=(InterpolatePixelMethod)
7689 argument_list[1].integer_reference;
7690 image=ImplodeImage(image,argument_list[0].real_reference,
7694 case 17: /* Magnify */
7696 image=MagnifyImage(image,exception);
7699 case 18: /* MedianFilter */
7701 if (attribute_flag[0] != 0)
7703 flags=ParseGeometry(argument_list[0].string_reference,
7705 if ((flags & SigmaValue) == 0)
7706 geometry_info.sigma=1.0;
7708 if (attribute_flag[1] != 0)
7709 geometry_info.rho=argument_list[1].real_reference;
7710 if (attribute_flag[2] != 0)
7711 geometry_info.sigma=argument_list[2].real_reference;
7712 if (attribute_flag[3] != 0)
7713 channel=(ChannelType) argument_list[3].integer_reference;
7714 image=StatisticImageChannel(image,channel,MedianStatistic,
7715 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7718 case 19: /* Minify */
7720 image=MinifyImage(image,exception);
7723 case 20: /* OilPaint */
7725 if (attribute_flag[0] == 0)
7726 argument_list[0].real_reference=0.0;
7727 image=OilPaintImage(image,argument_list[0].real_reference,
7731 case 21: /* ReduceNoise */
7733 if (attribute_flag[0] != 0)
7735 flags=ParseGeometry(argument_list[0].string_reference,
7737 if ((flags & SigmaValue) == 0)
7738 geometry_info.sigma=1.0;
7740 if (attribute_flag[1] != 0)
7741 geometry_info.rho=argument_list[1].real_reference;
7742 if (attribute_flag[2] != 0)
7743 geometry_info.sigma=argument_list[2].real_reference;
7744 if (attribute_flag[3] != 0)
7745 channel=(ChannelType) argument_list[3].integer_reference;
7746 image=StatisticImageChannel(image,channel,NonpeakStatistic,
7747 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7752 if (attribute_flag[0] != 0)
7753 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7754 &geometry,exception);
7755 if (attribute_flag[1] != 0)
7756 geometry.x=argument_list[1].integer_reference;
7757 if (attribute_flag[2] != 0)
7758 geometry.y=argument_list[2].integer_reference;
7759 image=RollImage(image,geometry.x,geometry.y,exception);
7762 case 23: /* Rotate */
7764 if (attribute_flag[0] == 0)
7765 argument_list[0].real_reference=90.0;
7766 if (attribute_flag[1] != 0)
7767 QueryColorDatabase(argument_list[1].string_reference,
7768 &image->background_color,exception);
7769 if (attribute_flag[2] != 0)
7770 QueryColorDatabase(argument_list[2].string_reference,
7771 &image->background_color,exception);
7772 if (attribute_flag[3] != 0)
7773 QueryColorDatabase(argument_list[3].string_reference,
7774 &image->background_color,exception);
7775 image=RotateImage(image,argument_list[0].real_reference,exception);
7778 case 24: /* Sample */
7780 if (attribute_flag[0] != 0)
7781 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7782 &geometry,exception);
7783 if (attribute_flag[1] != 0)
7784 geometry.width=argument_list[1].integer_reference;
7785 if (attribute_flag[2] != 0)
7786 geometry.height=argument_list[2].integer_reference;
7787 image=SampleImage(image,geometry.width,geometry.height,exception);
7790 case 25: /* Scale */
7792 if (attribute_flag[0] != 0)
7793 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7794 &geometry,exception);
7795 if (attribute_flag[1] != 0)
7796 geometry.width=argument_list[1].integer_reference;
7797 if (attribute_flag[2] != 0)
7798 geometry.height=argument_list[2].integer_reference;
7799 image=ScaleImage(image,geometry.width,geometry.height,exception);
7802 case 26: /* Shade */
7804 if (attribute_flag[0] != 0)
7806 flags=ParseGeometry(argument_list[0].string_reference,
7808 if ((flags & SigmaValue) == 0)
7809 geometry_info.sigma=0.0;
7811 if (attribute_flag[1] != 0)
7812 geometry_info.rho=argument_list[1].real_reference;
7813 if (attribute_flag[2] != 0)
7814 geometry_info.sigma=argument_list[2].real_reference;
7815 image=ShadeImage(image,
7816 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7817 geometry_info.rho,geometry_info.sigma,exception);
7820 case 27: /* Sharpen */
7822 if (attribute_flag[0] != 0)
7824 flags=ParseGeometry(argument_list[0].string_reference,
7826 if ((flags & SigmaValue) == 0)
7827 geometry_info.sigma=1.0;
7829 if (attribute_flag[1] != 0)
7830 geometry_info.rho=argument_list[1].real_reference;
7831 if (attribute_flag[2] != 0)
7832 geometry_info.sigma=argument_list[2].real_reference;
7833 if (attribute_flag[3] != 0)
7834 channel=(ChannelType) argument_list[3].integer_reference;
7835 image=SharpenImageChannel(image,channel,geometry_info.rho,
7836 geometry_info.sigma,exception);
7839 case 28: /* Shear */
7841 if (attribute_flag[0] != 0)
7843 flags=ParseGeometry(argument_list[0].string_reference,
7845 if ((flags & SigmaValue) == 0)
7846 geometry_info.sigma=geometry_info.rho;
7848 if (attribute_flag[1] != 0)
7849 geometry_info.rho=argument_list[1].real_reference;
7850 if (attribute_flag[2] != 0)
7851 geometry_info.sigma=argument_list[2].real_reference;
7852 if (attribute_flag[3] != 0)
7853 QueryColorDatabase(argument_list[3].string_reference,
7854 &image->background_color,exception);
7855 if (attribute_flag[4] != 0)
7856 QueryColorDatabase(argument_list[4].string_reference,
7857 &image->background_color,exception);
7858 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7862 case 29: /* Spread */
7864 if (attribute_flag[0] == 0)
7865 argument_list[0].real_reference=1.0;
7866 image=SpreadImage(image,argument_list[0].real_reference,exception);
7869 case 30: /* Swirl */
7871 if (attribute_flag[0] == 0)
7872 argument_list[0].real_reference=50.0;
7873 if (attribute_flag[1] != 0)
7874 image->interpolate=(InterpolatePixelMethod)
7875 argument_list[1].integer_reference;
7876 image=SwirlImage(image,argument_list[0].real_reference,exception);
7879 case 31: /* Resize */
7882 if (attribute_flag[0] != 0)
7883 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7884 &geometry,exception);
7885 if (attribute_flag[1] != 0)
7886 geometry.width=argument_list[1].integer_reference;
7887 if (attribute_flag[2] != 0)
7888 geometry.height=argument_list[2].integer_reference;
7889 if (attribute_flag[3] == 0)
7890 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7891 if (attribute_flag[4] != 0)
7892 SetImageArtifact(image,"filter:support",
7893 argument_list[4].string_reference);
7894 if (attribute_flag[5] == 0)
7895 argument_list[5].real_reference=1.0;
7896 image=ResizeImage(image,geometry.width,geometry.height,
7897 (FilterTypes) argument_list[3].integer_reference,
7898 argument_list[5].real_reference,exception);
7901 case 33: /* Annotate */
7906 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7908 if (attribute_flag[0] != 0)
7913 text=InterpretImageProperties(info ? info->image_info :
7914 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7915 (void) CloneString(&draw_info->text,text);
7916 text=DestroyString(text);
7918 if (attribute_flag[1] != 0)
7919 (void) CloneString(&draw_info->font,
7920 argument_list[1].string_reference);
7921 if (attribute_flag[2] != 0)
7922 draw_info->pointsize=argument_list[2].real_reference;
7923 if (attribute_flag[3] != 0)
7924 (void) CloneString(&draw_info->density,
7925 argument_list[3].string_reference);
7926 if (attribute_flag[4] != 0)
7927 (void) QueryColorDatabase(argument_list[4].string_reference,
7928 &draw_info->undercolor,exception);
7929 if (attribute_flag[5] != 0)
7931 (void) QueryColorDatabase(argument_list[5].string_reference,
7932 &draw_info->stroke,exception);
7933 if (argument_list[5].image_reference != (Image *) NULL)
7934 draw_info->stroke_pattern=CloneImage(
7935 argument_list[5].image_reference,0,0,MagickTrue,exception);
7937 if (attribute_flag[6] != 0)
7939 (void) QueryColorDatabase(argument_list[6].string_reference,
7940 &draw_info->fill,exception);
7941 if (argument_list[6].image_reference != (Image *) NULL)
7942 draw_info->fill_pattern=CloneImage(
7943 argument_list[6].image_reference,0,0,MagickTrue,exception);
7945 if (attribute_flag[7] != 0)
7947 (void) CloneString(&draw_info->geometry,
7948 argument_list[7].string_reference);
7949 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7950 &geometry,exception);
7951 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7952 geometry_info.sigma=geometry_info.xi;
7954 if (attribute_flag[8] != 0)
7955 (void) QueryColorDatabase(argument_list[8].string_reference,
7956 &draw_info->fill,exception);
7957 if (attribute_flag[11] != 0)
7958 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7959 if (attribute_flag[25] != 0)
7964 av=(AV *) argument_list[25].array_reference;
7965 if ((av_len(av) != 3) && (av_len(av) != 5))
7967 ThrowPerlException(exception,OptionError,
7968 "affine matrix must have 4 or 6 elements",PackageName);
7971 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7972 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7973 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7974 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7975 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7976 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7978 ThrowPerlException(exception,OptionError,
7979 "affine matrix is singular",PackageName);
7982 if (av_len(av) == 5)
7984 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7985 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
7988 for (j=12; j < 17; j++)
7990 if (attribute_flag[j] == 0)
7992 value=argument_list[j].string_reference;
7993 angle=argument_list[j].real_reference;
7994 current=draw_info->affine;
7995 GetAffineMatrix(&affine);
8003 flags=ParseGeometry(value,&geometry_info);
8004 affine.tx=geometry_info.xi;
8005 affine.ty=geometry_info.psi;
8006 if ((flags & PsiValue) == 0)
8007 affine.ty=affine.tx;
8015 flags=ParseGeometry(value,&geometry_info);
8016 affine.sx=geometry_info.rho;
8017 affine.sy=geometry_info.sigma;
8018 if ((flags & SigmaValue) == 0)
8019 affine.sy=affine.sx;
8029 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8030 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8031 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8032 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8040 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8048 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8052 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8053 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8054 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8055 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8056 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8058 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8061 if (attribute_flag[9] == 0)
8062 argument_list[9].real_reference=0.0;
8063 if (attribute_flag[10] == 0)
8064 argument_list[10].real_reference=0.0;
8065 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8068 geometry[MaxTextExtent];
8070 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8071 (double) argument_list[9].real_reference+draw_info->affine.tx,
8072 (double) argument_list[10].real_reference+draw_info->affine.ty);
8073 (void) CloneString(&draw_info->geometry,geometry);
8075 if (attribute_flag[17] != 0)
8076 draw_info->stroke_width=argument_list[17].real_reference;
8077 if (attribute_flag[18] != 0)
8079 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8080 MagickTrue : MagickFalse;
8081 draw_info->stroke_antialias=draw_info->text_antialias;
8083 if (attribute_flag[19] != 0)
8084 (void) CloneString(&draw_info->family,
8085 argument_list[19].string_reference);
8086 if (attribute_flag[20] != 0)
8087 draw_info->style=(StyleType) argument_list[20].integer_reference;
8088 if (attribute_flag[21] != 0)
8089 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8090 if (attribute_flag[22] != 0)
8091 draw_info->weight=argument_list[22].integer_reference;
8092 if (attribute_flag[23] != 0)
8093 draw_info->align=(AlignType) argument_list[23].integer_reference;
8094 if (attribute_flag[24] != 0)
8095 (void) CloneString(&draw_info->encoding,
8096 argument_list[24].string_reference);
8097 if (attribute_flag[25] != 0)
8098 draw_info->fill_pattern=CloneImage(
8099 argument_list[25].image_reference,0,0,MagickTrue,exception);
8100 if (attribute_flag[26] != 0)
8101 draw_info->fill_pattern=CloneImage(
8102 argument_list[26].image_reference,0,0,MagickTrue,exception);
8103 if (attribute_flag[27] != 0)
8104 draw_info->stroke_pattern=CloneImage(
8105 argument_list[27].image_reference,0,0,MagickTrue,exception);
8106 if (attribute_flag[29] != 0)
8107 draw_info->kerning=argument_list[29].real_reference;
8108 if (attribute_flag[30] != 0)
8109 draw_info->interline_spacing=argument_list[30].real_reference;
8110 if (attribute_flag[31] != 0)
8111 draw_info->interword_spacing=argument_list[31].real_reference;
8112 if (attribute_flag[32] != 0)
8113 draw_info->direction=(DirectionType)
8114 argument_list[32].integer_reference;
8115 (void) AnnotateImage(image,draw_info);
8116 draw_info=DestroyDrawInfo(draw_info);
8119 case 34: /* ColorFloodfill */
8130 draw_info=CloneDrawInfo(info ? info->image_info :
8131 (ImageInfo *) NULL,(DrawInfo *) NULL);
8132 if (attribute_flag[0] != 0)
8133 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8134 &geometry,exception);
8135 if (attribute_flag[1] != 0)
8136 geometry.x=argument_list[1].integer_reference;
8137 if (attribute_flag[2] != 0)
8138 geometry.y=argument_list[2].integer_reference;
8139 if (attribute_flag[3] != 0)
8140 (void) QueryColorDatabase(argument_list[3].string_reference,
8141 &draw_info->fill,exception);
8142 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8145 if (attribute_flag[4] != 0)
8147 QueryMagickColor(argument_list[4].string_reference,&target,
8151 if (attribute_flag[5] != 0)
8152 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8154 if (attribute_flag[6] != 0)
8155 invert=(MagickBooleanType) argument_list[6].integer_reference;
8156 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8157 geometry.x,geometry.y,invert);
8158 draw_info=DestroyDrawInfo(draw_info);
8161 case 35: /* Composite */
8164 composite_geometry[MaxTextExtent];
8170 compose=OverCompositeOp;
8171 if (attribute_flag[0] != 0)
8172 composite_image=argument_list[0].image_reference;
8175 ThrowPerlException(exception,OptionError,
8176 "CompositeImageRequired",PackageName);
8180 Parameter Handling used for BOTH normal and tiled composition.
8182 if (attribute_flag[1] != 0) /* compose */
8183 compose=(CompositeOperator) argument_list[1].integer_reference;
8184 if (attribute_flag[6] != 0) /* opacity */
8186 if (compose != DissolveCompositeOp)
8187 (void) SetImageOpacity(composite_image,(Quantum)
8188 SiPrefixToDouble(argument_list[6].string_reference,
8211 Handle dissolve composite operator (patch by
8214 (void) CloneString(&image->geometry,
8215 argument_list[6].string_reference);
8216 opacity=(Quantum) SiPrefixToDouble(
8217 argument_list[6].string_reference,QuantumRange);
8218 if (composite_image->matte != MagickTrue)
8219 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8220 composite_view=AcquireCacheView(composite_image);
8221 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8223 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8224 composite_image->columns,1,exception);
8225 for (x=0; x < (ssize_t) composite_image->columns; x++)
8227 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8228 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8229 q+=GetPixelChannels(composite_image);
8231 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8232 if (sync == MagickFalse)
8235 composite_view=DestroyCacheView(composite_view);
8238 if (attribute_flag[9] != 0) /* "color=>" */
8239 QueryColorDatabase(argument_list[9].string_reference,
8240 &composite_image->background_color,exception);
8241 if (attribute_flag[12] != 0) /* "interpolate=>" */
8242 image->interpolate=(InterpolatePixelMethod)
8243 argument_list[12].integer_reference;
8244 if (attribute_flag[13] != 0) /* "args=>" */
8245 (void) SetImageArtifact(composite_image,"compose:args",
8246 argument_list[13].string_reference);
8247 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8248 (void) SetImageArtifact(composite_image,"compose:args",
8249 argument_list[14].string_reference);
8251 Tiling Composition (with orthogonal rotate).
8253 rotate_image=(Image *) NULL;
8254 if (attribute_flag[8] != 0) /* "rotate=>" */
8259 rotate_image=RotateImage(composite_image,
8260 argument_list[8].real_reference,exception);
8261 if (rotate_image == (Image *) NULL)
8264 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8271 Tile the composite image.
8273 if (attribute_flag[8] != 0) /* "tile=>" */
8274 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8277 (void) SetImageArtifact(composite_image,
8278 "compose:outside-overlay","false");
8279 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8280 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8282 if (attribute_flag[8] != 0) /* rotate */
8283 (void) CompositeImage(image,compose,rotate_image,x,y);
8285 (void) CompositeImage(image,compose,composite_image,x,y);
8287 if (attribute_flag[8] != 0) /* rotate */
8288 rotate_image=DestroyImage(rotate_image);
8292 Parameter Handling used used ONLY for normal composition.
8294 if (attribute_flag[5] != 0) /* gravity */
8295 image->gravity=(GravityType) argument_list[5].integer_reference;
8296 if (attribute_flag[2] != 0) /* geometry offset */
8298 SetGeometry(image,&geometry);
8299 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8301 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8304 if (attribute_flag[3] != 0) /* x offset */
8305 geometry.x=argument_list[3].integer_reference;
8306 if (attribute_flag[4] != 0) /* y offset */
8307 geometry.y=argument_list[4].integer_reference;
8308 if (attribute_flag[10] != 0) /* mask */
8310 if ((image->compose == DisplaceCompositeOp) ||
8311 (image->compose == DistortCompositeOp))
8314 Merge Y displacement into X displacement image.
8316 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8318 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8319 argument_list[10].image_reference,0,0);
8324 Set a blending mask for the composition.
8326 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8327 MagickTrue,&image->exception);
8328 (void) NegateImage(image->mask,MagickFalse);
8331 if (attribute_flag[11] != 0) /* channel */
8332 channel=(ChannelType) argument_list[11].integer_reference;
8334 Composite two images (normal composition).
8336 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8337 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8338 (double) composite_image->rows,(double) geometry.x,(double)
8340 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8342 if (attribute_flag[8] == 0) /* no rotate */
8343 CompositeImageChannel(image,channel,compose,composite_image,
8344 geometry.x,geometry.y);
8348 Position adjust rotated image then composite.
8350 geometry.x-=(ssize_t) (rotate_image->columns-
8351 composite_image->columns)/2;
8352 geometry.y-=(ssize_t) (rotate_image->rows-
8353 composite_image->rows)/2;
8354 CompositeImageChannel(image,channel,compose,rotate_image,
8355 geometry.x,geometry.y);
8356 rotate_image=DestroyImage(rotate_image);
8358 if (attribute_flag[10] != 0) /* mask */
8360 if ((image->compose == DisplaceCompositeOp) ||
8361 (image->compose == DistortCompositeOp))
8362 composite_image=DestroyImage(composite_image);
8364 image->mask=DestroyImage(image->mask);
8368 case 36: /* Contrast */
8370 if (attribute_flag[0] == 0)
8371 argument_list[0].integer_reference=0;
8372 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8373 MagickTrue : MagickFalse);
8376 case 37: /* CycleColormap */
8378 if (attribute_flag[0] == 0)
8379 argument_list[0].integer_reference=6;
8380 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8388 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8390 (void) CloneString(&draw_info->primitive,"point");
8391 if (attribute_flag[0] != 0)
8393 if (argument_list[0].integer_reference < 0)
8394 (void) CloneString(&draw_info->primitive,
8395 argument_list[0].string_reference);
8397 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8398 MagickPrimitiveOptions,argument_list[0].integer_reference));
8400 if (attribute_flag[1] != 0)
8402 if (LocaleCompare(draw_info->primitive,"path") == 0)
8404 (void) ConcatenateString(&draw_info->primitive," '");
8405 ConcatenateString(&draw_info->primitive,
8406 argument_list[1].string_reference);
8407 (void) ConcatenateString(&draw_info->primitive,"'");
8411 (void) ConcatenateString(&draw_info->primitive," ");
8412 ConcatenateString(&draw_info->primitive,
8413 argument_list[1].string_reference);
8416 if (attribute_flag[2] != 0)
8418 (void) ConcatenateString(&draw_info->primitive," ");
8419 (void) ConcatenateString(&draw_info->primitive,
8420 CommandOptionToMnemonic(MagickMethodOptions,
8421 argument_list[2].integer_reference));
8423 if (attribute_flag[3] != 0)
8425 (void) QueryColorDatabase(argument_list[3].string_reference,
8426 &draw_info->stroke,exception);
8427 if (argument_list[3].image_reference != (Image *) NULL)
8428 draw_info->stroke_pattern=CloneImage(
8429 argument_list[3].image_reference,0,0,MagickTrue,exception);
8431 if (attribute_flag[4] != 0)
8433 (void) QueryColorDatabase(argument_list[4].string_reference,
8434 &draw_info->fill,exception);
8435 if (argument_list[4].image_reference != (Image *) NULL)
8436 draw_info->fill_pattern=CloneImage(
8437 argument_list[4].image_reference,0,0,MagickTrue,exception);
8439 if (attribute_flag[5] != 0)
8440 draw_info->stroke_width=argument_list[5].real_reference;
8441 if (attribute_flag[6] != 0)
8442 (void) CloneString(&draw_info->font,
8443 argument_list[6].string_reference);
8444 if (attribute_flag[7] != 0)
8445 (void) QueryColorDatabase(argument_list[7].string_reference,
8446 &draw_info->border_color,exception);
8447 if (attribute_flag[8] != 0)
8448 draw_info->affine.tx=argument_list[8].real_reference;
8449 if (attribute_flag[9] != 0)
8450 draw_info->affine.ty=argument_list[9].real_reference;
8451 if (attribute_flag[20] != 0)
8456 av=(AV *) argument_list[20].array_reference;
8457 if ((av_len(av) != 3) && (av_len(av) != 5))
8459 ThrowPerlException(exception,OptionError,
8460 "affine matrix must have 4 or 6 elements",PackageName);
8463 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8464 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8465 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8466 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8467 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8468 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8470 ThrowPerlException(exception,OptionError,
8471 "affine matrix is singular",PackageName);
8474 if (av_len(av) == 5)
8476 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8477 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8480 for (j=10; j < 15; j++)
8482 if (attribute_flag[j] == 0)
8484 value=argument_list[j].string_reference;
8485 angle=argument_list[j].real_reference;
8486 current=draw_info->affine;
8487 GetAffineMatrix(&affine);
8495 flags=ParseGeometry(value,&geometry_info);
8496 affine.tx=geometry_info.xi;
8497 affine.ty=geometry_info.psi;
8498 if ((flags & PsiValue) == 0)
8499 affine.ty=affine.tx;
8507 flags=ParseGeometry(value,&geometry_info);
8508 affine.sx=geometry_info.rho;
8509 affine.sy=geometry_info.sigma;
8510 if ((flags & SigmaValue) == 0)
8511 affine.sy=affine.sx;
8521 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8522 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8523 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8524 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8532 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8540 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8544 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8545 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8546 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8547 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8548 draw_info->affine.tx=
8549 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8550 draw_info->affine.ty=
8551 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8553 if (attribute_flag[15] != 0)
8554 draw_info->fill_pattern=CloneImage(
8555 argument_list[15].image_reference,0,0,MagickTrue,exception);
8556 if (attribute_flag[16] != 0)
8557 draw_info->pointsize=argument_list[16].real_reference;
8558 if (attribute_flag[17] != 0)
8560 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8561 ? MagickTrue : MagickFalse;
8562 draw_info->text_antialias=draw_info->stroke_antialias;
8564 if (attribute_flag[18] != 0)
8565 (void) CloneString(&draw_info->density,
8566 argument_list[18].string_reference);
8567 if (attribute_flag[19] != 0)
8568 draw_info->stroke_width=argument_list[19].real_reference;
8569 if (attribute_flag[21] != 0)
8570 draw_info->dash_offset=argument_list[21].real_reference;
8571 if (attribute_flag[22] != 0)
8576 av=(AV *) argument_list[22].array_reference;
8577 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8578 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8579 if (draw_info->dash_pattern != (double *) NULL)
8581 for (i=0; i <= av_len(av); i++)
8582 draw_info->dash_pattern[i]=(double)
8583 SvNV(*(av_fetch(av,i,0)));
8584 draw_info->dash_pattern[i]=0.0;
8587 if (attribute_flag[23] != 0)
8588 image->interpolate=(InterpolatePixelMethod)
8589 argument_list[23].integer_reference;
8590 if ((attribute_flag[24] != 0) &&
8591 (draw_info->fill_pattern != (Image *) NULL))
8592 flags=ParsePageGeometry(draw_info->fill_pattern,
8593 argument_list[24].string_reference,
8594 &draw_info->fill_pattern->tile_offset,exception);
8595 if (attribute_flag[25] != 0)
8597 (void) ConcatenateString(&draw_info->primitive," '");
8598 (void) ConcatenateString(&draw_info->primitive,
8599 argument_list[25].string_reference);
8600 (void) ConcatenateString(&draw_info->primitive,"'");
8602 if (attribute_flag[26] != 0)
8603 draw_info->fill_pattern=CloneImage(
8604 argument_list[26].image_reference,0,0,MagickTrue,exception);
8605 if (attribute_flag[27] != 0)
8606 draw_info->stroke_pattern=CloneImage(
8607 argument_list[27].image_reference,0,0,MagickTrue,exception);
8608 if (attribute_flag[28] != 0)
8609 (void) CloneString(&draw_info->primitive,
8610 argument_list[28].string_reference);
8611 if (attribute_flag[29] != 0)
8612 draw_info->kerning=argument_list[29].real_reference;
8613 if (attribute_flag[30] != 0)
8614 draw_info->interline_spacing=argument_list[30].real_reference;
8615 if (attribute_flag[31] != 0)
8616 draw_info->interword_spacing=argument_list[31].real_reference;
8617 if (attribute_flag[32] != 0)
8618 draw_info->direction=(DirectionType)
8619 argument_list[32].integer_reference;
8620 DrawImage(image,draw_info);
8621 draw_info=DestroyDrawInfo(draw_info);
8624 case 39: /* Equalize */
8626 if (attribute_flag[0] != 0)
8627 channel=(ChannelType) argument_list[0].integer_reference;
8628 EqualizeImageChannel(image,channel);
8631 case 40: /* Gamma */
8633 if (attribute_flag[1] != 0)
8634 channel=(ChannelType) argument_list[1].integer_reference;
8635 if (attribute_flag[2] == 0)
8636 argument_list[2].real_reference=1.0;
8637 if (attribute_flag[3] == 0)
8638 argument_list[3].real_reference=1.0;
8639 if (attribute_flag[4] == 0)
8640 argument_list[4].real_reference=1.0;
8641 if (attribute_flag[0] == 0)
8643 (void) FormatLocaleString(message,MaxTextExtent,
8644 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8645 (double) argument_list[3].real_reference,
8646 (double) argument_list[4].real_reference);
8647 argument_list[0].string_reference=message;
8649 if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
8650 (void) GammaImage(image,argument_list[0].string_reference);
8652 (void) GammaImageChannel(image,channel,InterpretLocaleValue(
8653 argument_list[0].string_reference,(char **) NULL));
8661 if (attribute_flag[0] == 0)
8663 ThrowPerlException(exception,OptionError,"MapImageRequired",
8667 quantize_info=AcquireQuantizeInfo(info->image_info);
8668 if (attribute_flag[1] != 0)
8669 quantize_info->dither=(MagickBooleanType)
8670 argument_list[1].integer_reference;
8671 if (attribute_flag[2] != 0)
8672 quantize_info->dither_method=(DitherMethod)
8673 argument_list[2].integer_reference;
8674 (void) RemapImages(quantize_info,image,
8675 argument_list[0].image_reference);
8676 quantize_info=DestroyQuantizeInfo(quantize_info);
8679 case 42: /* MatteFloodfill */
8690 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8692 if (attribute_flag[0] != 0)
8693 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8694 &geometry,exception);
8695 if (attribute_flag[1] != 0)
8696 geometry.x=argument_list[1].integer_reference;
8697 if (attribute_flag[2] != 0)
8698 geometry.y=argument_list[2].integer_reference;
8699 if (image->matte == MagickFalse)
8700 (void) SetImageOpacity(image,OpaqueAlpha);
8701 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8703 if (attribute_flag[4] != 0)
8704 QueryMagickColor(argument_list[4].string_reference,&target,
8706 if (attribute_flag[3] != 0)
8707 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8709 if (attribute_flag[5] != 0)
8710 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8713 if (attribute_flag[6] != 0)
8714 invert=(MagickBooleanType) argument_list[6].integer_reference;
8715 SetPixelComponentMap(image,AlphaChannel);
8716 (void) FloodfillPaintImage(image,AlphaChannel,draw_info,&target,
8717 geometry.x,geometry.y,invert);
8718 StandardPixelComponentMap(image);
8719 draw_info=DestroyDrawInfo(draw_info);
8722 case 43: /* Modulate */
8725 modulate[MaxTextExtent];
8727 geometry_info.rho=100.0;
8728 geometry_info.sigma=100.0;
8729 geometry_info.xi=100.0;
8730 if (attribute_flag[0] != 0)
8731 (void)ParseGeometry(argument_list[0].string_reference,
8733 if (attribute_flag[1] != 0)
8734 geometry_info.xi=argument_list[1].real_reference;
8735 if (attribute_flag[2] != 0)
8736 geometry_info.sigma=argument_list[2].real_reference;
8737 if (attribute_flag[3] != 0)
8739 geometry_info.sigma=argument_list[3].real_reference;
8740 SetImageArtifact(image,"modulate:colorspace","HWB");
8742 if (attribute_flag[4] != 0)
8744 geometry_info.rho=argument_list[4].real_reference;
8745 SetImageArtifact(image,"modulate:colorspace","HSB");
8747 if (attribute_flag[5] != 0)
8749 geometry_info.sigma=argument_list[5].real_reference;
8750 SetImageArtifact(image,"modulate:colorspace","HSL");
8752 if (attribute_flag[6] != 0)
8754 geometry_info.rho=argument_list[6].real_reference;
8755 SetImageArtifact(image,"modulate:colorspace","HWB");
8757 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8758 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8759 (void) ModulateImage(image,modulate);
8762 case 44: /* Negate */
8764 if (attribute_flag[0] == 0)
8765 argument_list[0].integer_reference=0;
8766 if (attribute_flag[1] != 0)
8767 channel=(ChannelType) argument_list[1].integer_reference;
8768 (void) NegateImageChannel(image,channel,
8769 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
8772 case 45: /* Normalize */
8774 if (attribute_flag[0] != 0)
8775 channel=(ChannelType) argument_list[0].integer_reference;
8776 NormalizeImageChannel(image,channel);
8779 case 46: /* NumberColors */
8781 case 47: /* Opaque */
8790 (void) QueryMagickColor("none",&target,exception);
8791 (void) QueryMagickColor("none",&fill_color,exception);
8792 if (attribute_flag[0] != 0)
8793 (void) QueryMagickColor(argument_list[0].string_reference,
8795 if (attribute_flag[1] != 0)
8796 (void) QueryMagickColor(argument_list[1].string_reference,
8797 &fill_color,exception);
8798 if (attribute_flag[2] != 0)
8799 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8801 if (attribute_flag[3] != 0)
8802 channel=(ChannelType) argument_list[3].integer_reference;
8804 if (attribute_flag[4] != 0)
8805 invert=(MagickBooleanType) argument_list[4].integer_reference;
8806 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8810 case 48: /* Quantize */
8815 quantize_info=AcquireQuantizeInfo(info->image_info);
8816 if (attribute_flag[0] != 0)
8817 quantize_info->number_colors=(size_t)
8818 argument_list[0].integer_reference;
8819 if (attribute_flag[1] != 0)
8820 quantize_info->tree_depth=(size_t)
8821 argument_list[1].integer_reference;
8822 if (attribute_flag[2] != 0)
8823 quantize_info->colorspace=(ColorspaceType)
8824 argument_list[2].integer_reference;
8825 if (attribute_flag[3] != 0)
8826 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8827 MagickTrue : MagickFalse;
8828 if (attribute_flag[4] != 0)
8829 quantize_info->measure_error=
8830 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8831 if (attribute_flag[5] != 0)
8832 (void) QueryColorDatabase(argument_list[5].string_reference,
8833 &image->transparent_color,exception);
8834 if (attribute_flag[5] && argument_list[5].integer_reference)
8836 (void) QuantizeImages(quantize_info,image);
8839 if (attribute_flag[6] != 0)
8840 quantize_info->dither_method=(DitherMethod)
8841 argument_list[6].integer_reference;
8842 if ((image->storage_class == DirectClass) ||
8843 (image->colors > quantize_info->number_colors) ||
8844 (quantize_info->colorspace == GRAYColorspace))
8845 (void) QuantizeImage(quantize_info,image);
8847 CompressImageColormap(image);
8848 quantize_info=DestroyQuantizeInfo(quantize_info);
8851 case 49: /* Raise */
8853 if (attribute_flag[0] != 0)
8854 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8855 &geometry,exception);
8856 if (attribute_flag[1] != 0)
8857 geometry.width=argument_list[1].integer_reference;
8858 if (attribute_flag[2] != 0)
8859 geometry.height=argument_list[2].integer_reference;
8860 if (attribute_flag[3] == 0)
8861 argument_list[3].integer_reference=1;
8862 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8863 0 ? MagickTrue : MagickFalse);
8866 case 50: /* Segment */
8873 smoothing_threshold;
8878 cluster_threshold=1.0;
8879 smoothing_threshold=1.5;
8880 colorspace=RGBColorspace;
8881 verbose=MagickFalse;
8882 if (attribute_flag[0] != 0)
8884 flags=ParseGeometry(argument_list[0].string_reference,
8886 cluster_threshold=geometry_info.rho;
8887 if (flags & SigmaValue)
8888 smoothing_threshold=geometry_info.sigma;
8890 if (attribute_flag[1] != 0)
8891 cluster_threshold=argument_list[1].real_reference;
8892 if (attribute_flag[2] != 0)
8893 smoothing_threshold=argument_list[2].real_reference;
8894 if (attribute_flag[3] != 0)
8895 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8896 if (attribute_flag[4] != 0)
8897 verbose=argument_list[4].integer_reference != 0 ?
8898 MagickTrue : MagickFalse;
8899 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8900 smoothing_threshold);
8903 case 51: /* Signature */
8905 (void) SignatureImage(image);
8908 case 52: /* Solarize */
8910 geometry_info.rho=QuantumRange/2.0;
8911 if (attribute_flag[0] != 0)
8912 flags=ParseGeometry(argument_list[0].string_reference,
8914 if (attribute_flag[1] != 0)
8915 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8917 (void) SolarizeImage(image,geometry_info.rho);
8922 (void) SyncImage(image);
8925 case 54: /* Texture */
8927 if (attribute_flag[0] == 0)
8929 TextureImage(image,argument_list[0].image_reference);
8932 case 55: /* Evalute */
8934 MagickEvaluateOperator
8937 op=SetEvaluateOperator;
8938 if (attribute_flag[0] == MagickFalse)
8939 argument_list[0].real_reference=0.0;
8940 if (attribute_flag[1] != MagickFalse)
8941 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8942 if (attribute_flag[2] != MagickFalse)
8943 channel=(ChannelType) argument_list[2].integer_reference;
8944 (void) EvaluateImageChannel(image,channel,op,
8945 argument_list[0].real_reference,exception);
8948 case 56: /* Transparent */
8959 (void) QueryMagickColor("none",&target,exception);
8960 if (attribute_flag[0] != 0)
8961 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8963 opacity=TransparentAlpha;
8964 if (attribute_flag[1] != 0)
8965 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8967 if (attribute_flag[2] != 0)
8968 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8970 if (attribute_flag[3] == 0)
8971 argument_list[3].integer_reference=0;
8973 if (attribute_flag[3] != 0)
8974 invert=(MagickBooleanType) argument_list[3].integer_reference;
8975 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
8979 case 57: /* Threshold */
8984 if (attribute_flag[0] == 0)
8985 argument_list[0].string_reference="50%";
8986 if (attribute_flag[1] != 0)
8987 channel=(ChannelType) argument_list[1].integer_reference;
8988 threshold=SiPrefixToDouble(argument_list[0].string_reference,
8990 (void) BilevelImageChannel(image,channel,threshold);
8993 case 58: /* Charcoal */
8995 if (attribute_flag[0] != 0)
8997 flags=ParseGeometry(argument_list[0].string_reference,
8999 if ((flags & SigmaValue) == 0)
9000 geometry_info.sigma=1.0;
9002 if (attribute_flag[1] != 0)
9003 geometry_info.rho=argument_list[1].real_reference;
9004 if (attribute_flag[2] != 0)
9005 geometry_info.sigma=argument_list[2].real_reference;
9006 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9012 if (attribute_flag[0] != 0)
9013 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9015 image=TrimImage(image,exception);
9020 if (attribute_flag[0] != 0)
9022 flags=ParseGeometry(argument_list[0].string_reference,
9024 if ((flags & SigmaValue) == 0)
9025 geometry_info.sigma=1.0;
9027 if (attribute_flag[1] != 0)
9028 geometry_info.rho=argument_list[1].real_reference;
9029 if (attribute_flag[2] != 0)
9030 geometry_info.sigma=argument_list[2].real_reference;
9031 if (attribute_flag[3] != 0)
9032 image->interpolate=(InterpolatePixelMethod)
9033 argument_list[3].integer_reference;
9034 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9038 case 61: /* Separate */
9040 if (attribute_flag[0] != 0)
9041 channel=(ChannelType) argument_list[0].integer_reference;
9042 (void) SeparateImageChannel(image,channel);
9045 case 63: /* Stereo */
9047 if (attribute_flag[0] == 0)
9049 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9053 if (attribute_flag[1] != 0)
9054 geometry.x=argument_list[1].integer_reference;
9055 if (attribute_flag[2] != 0)
9056 geometry.y=argument_list[2].integer_reference;
9057 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9058 geometry.x,geometry.y,exception);
9061 case 64: /* Stegano */
9063 if (attribute_flag[0] == 0)
9065 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9069 if (attribute_flag[1] == 0)
9070 argument_list[1].integer_reference=0;
9071 image->offset=argument_list[1].integer_reference;
9072 image=SteganoImage(image,argument_list[0].image_reference,exception);
9075 case 65: /* Deconstruct */
9077 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9080 case 66: /* GaussianBlur */
9082 if (attribute_flag[0] != 0)
9084 flags=ParseGeometry(argument_list[0].string_reference,
9086 if ((flags & SigmaValue) == 0)
9087 geometry_info.sigma=1.0;
9089 if (attribute_flag[1] != 0)
9090 geometry_info.rho=argument_list[1].real_reference;
9091 if (attribute_flag[2] != 0)
9092 geometry_info.sigma=argument_list[2].real_reference;
9093 if (attribute_flag[3] != 0)
9094 channel=(ChannelType) argument_list[3].integer_reference;
9095 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9096 geometry_info.sigma,exception);
9099 case 67: /* Convolve */
9110 if (attribute_flag[0] == 0)
9112 if (attribute_flag[1] != 0)
9113 channel=(ChannelType) argument_list[1].integer_reference;
9114 if (attribute_flag[2] != 0)
9115 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9117 av=(AV *) argument_list[0].array_reference;
9118 order=(size_t) sqrt(av_len(av)+1);
9119 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9120 if (kernel == (double *) NULL)
9122 ThrowPerlException(exception,ResourceLimitFatalError,
9123 "MemoryAllocationFailed",PackageName);
9126 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9127 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9128 for ( ; j < (ssize_t) (order*order); j++)
9130 image=ConvolveImageChannel(image,channel,order,kernel,exception);
9131 kernel=(double *) RelinquishMagickMemory(kernel);
9134 case 68: /* Profile */
9149 if (attribute_flag[0] != 0)
9150 name=argument_list[0].string_reference;
9151 if (attribute_flag[2] != 0)
9152 image->rendering_intent=(RenderingIntent)
9153 argument_list[2].integer_reference;
9154 if (attribute_flag[3] != 0)
9155 image->black_point_compensation=
9156 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9157 if (attribute_flag[1] != 0)
9159 if (argument_list[1].length == 0)
9162 Remove a profile from the image.
9164 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9169 Associate user supplied profile with the image.
9171 profile=AcquireStringInfo(argument_list[1].length);
9172 SetStringInfoDatum(profile,(const unsigned char *)
9173 argument_list[1].string_reference);
9174 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9175 (size_t) GetStringInfoLength(profile),MagickFalse);
9176 profile=DestroyStringInfo(profile);
9180 Associate a profile with the image.
9183 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9184 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9185 profile_image=ReadImages(profile_info,&image->exception);
9186 if (profile_image == (Image *) NULL)
9188 ResetImageProfileIterator(profile_image);
9189 name=GetNextImageProfile(profile_image);
9190 while (name != (const char *) NULL)
9195 profile=GetImageProfile(profile_image,name);
9196 if (profile != (const StringInfo *) NULL)
9197 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9198 (size_t) GetStringInfoLength(profile),MagickFalse);
9199 name=GetNextImageProfile(profile_image);
9201 profile_image=DestroyImage(profile_image);
9202 profile_info=DestroyImageInfo(profile_info);
9205 case 69: /* UnsharpMask */
9207 if (attribute_flag[0] != 0)
9209 flags=ParseGeometry(argument_list[0].string_reference,
9211 if ((flags & SigmaValue) == 0)
9212 geometry_info.sigma=1.0;
9213 if ((flags & XiValue) == 0)
9214 geometry_info.xi=1.0;
9215 if ((flags & PsiValue) == 0)
9216 geometry_info.psi=0.5;
9218 if (attribute_flag[1] != 0)
9219 geometry_info.rho=argument_list[1].real_reference;
9220 if (attribute_flag[2] != 0)
9221 geometry_info.sigma=argument_list[2].real_reference;
9222 if (attribute_flag[3] != 0)
9223 geometry_info.xi=argument_list[3].real_reference;
9224 if (attribute_flag[4] != 0)
9225 geometry_info.psi=argument_list[4].real_reference;
9226 if (attribute_flag[5] != 0)
9227 channel=(ChannelType) argument_list[5].integer_reference;
9228 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9229 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9232 case 70: /* MotionBlur */
9234 if (attribute_flag[0] != 0)
9236 flags=ParseGeometry(argument_list[0].string_reference,
9238 if ((flags & SigmaValue) == 0)
9239 geometry_info.sigma=1.0;
9240 if ((flags & XiValue) == 0)
9241 geometry_info.xi=1.0;
9243 if (attribute_flag[1] != 0)
9244 geometry_info.rho=argument_list[1].real_reference;
9245 if (attribute_flag[2] != 0)
9246 geometry_info.sigma=argument_list[2].real_reference;
9247 if (attribute_flag[3] != 0)
9248 geometry_info.xi=argument_list[3].real_reference;
9249 if (attribute_flag[4] != 0)
9250 channel=(ChannelType) argument_list[4].integer_reference;
9251 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9252 geometry_info.sigma,geometry_info.xi,exception);
9255 case 71: /* OrderedDither */
9257 if (attribute_flag[0] == 0)
9258 argument_list[0].string_reference="o8x8";
9259 if (attribute_flag[1] != 0)
9260 channel=(ChannelType) argument_list[1].integer_reference;
9261 (void) OrderedPosterizeImageChannel(image,channel,
9262 argument_list[0].string_reference,exception);
9265 case 72: /* Shave */
9267 if (attribute_flag[0] != 0)
9268 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9269 &geometry,exception);
9270 if (attribute_flag[1] != 0)
9271 geometry.width=argument_list[1].integer_reference;
9272 if (attribute_flag[2] != 0)
9273 geometry.height=argument_list[2].integer_reference;
9274 image=ShaveImage(image,&geometry,exception);
9277 case 73: /* Level */
9285 white_point=(MagickRealType) image->columns*image->rows;
9287 if (attribute_flag[0] != 0)
9289 flags=ParseGeometry(argument_list[0].string_reference,
9291 black_point=geometry_info.rho;
9292 if ((flags & SigmaValue) != 0)
9293 white_point=geometry_info.sigma;
9294 if ((flags & XiValue) != 0)
9295 gamma=geometry_info.xi;
9296 if ((flags & PercentValue) != 0)
9298 black_point*=(double) (QuantumRange/100.0);
9299 white_point*=(double) (QuantumRange/100.0);
9301 if ((flags & SigmaValue) == 0)
9302 white_point=(double) QuantumRange-black_point;
9304 if (attribute_flag[1] != 0)
9305 black_point=argument_list[1].real_reference;
9306 if (attribute_flag[2] != 0)
9307 white_point=argument_list[2].real_reference;
9308 if (attribute_flag[3] != 0)
9309 gamma=argument_list[3].real_reference;
9310 if (attribute_flag[4] != 0)
9312 channel=(ChannelType) argument_list[4].integer_reference;
9313 SetPixelComponentMap(image,channel);
9315 if (attribute_flag[5] != 0)
9317 argument_list[0].real_reference=argument_list[5].real_reference;
9318 attribute_flag[0]=attribute_flag[5];
9320 (void) LevelImage(image,black_point,white_point,gamma);
9325 if (attribute_flag[0] == 0)
9326 argument_list[0].string_reference="#1";
9327 if (attribute_flag[1] == 0)
9328 argument_list[1].integer_reference=MagickTrue;
9329 (void) ClipImagePath(image,argument_list[0].string_reference,
9330 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9333 case 75: /* AffineTransform */
9338 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9340 if (attribute_flag[0] != 0)
9345 av=(AV *) argument_list[0].array_reference;
9346 if ((av_len(av) != 3) && (av_len(av) != 5))
9348 ThrowPerlException(exception,OptionError,
9349 "affine matrix must have 4 or 6 elements",PackageName);
9352 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9353 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9354 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9355 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9356 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9357 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9359 ThrowPerlException(exception,OptionError,
9360 "affine matrix is singular",PackageName);
9363 if (av_len(av) == 5)
9365 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9366 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9369 for (j=1; j < 6; j++)
9371 if (attribute_flag[j] == 0)
9373 value=argument_list[j].string_reference;
9374 angle=argument_list[j].real_reference;
9375 current=draw_info->affine;
9376 GetAffineMatrix(&affine);
9384 flags=ParseGeometry(value,&geometry_info);
9385 affine.tx=geometry_info.xi;
9386 affine.ty=geometry_info.psi;
9387 if ((flags & PsiValue) == 0)
9388 affine.ty=affine.tx;
9396 flags=ParseGeometry(value,&geometry_info);
9397 affine.sx=geometry_info.rho;
9398 affine.sy=geometry_info.sigma;
9399 if ((flags & SigmaValue) == 0)
9400 affine.sy=affine.sx;
9410 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9411 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9412 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9413 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9421 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9429 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9433 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9434 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9435 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9436 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9437 draw_info->affine.tx=
9438 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9439 draw_info->affine.ty=
9440 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9442 if (attribute_flag[6] != 0)
9443 image->interpolate=(InterpolatePixelMethod)
9444 argument_list[6].integer_reference;
9445 if (attribute_flag[7] != 0)
9446 QueryColorDatabase(argument_list[7].string_reference,
9447 &image->background_color,exception);
9448 image=AffineTransformImage(image,&draw_info->affine,exception);
9449 draw_info=DestroyDrawInfo(draw_info);
9452 case 76: /* Difference */
9454 if (attribute_flag[0] == 0)
9456 ThrowPerlException(exception,OptionError,
9457 "ReferenceImageRequired",PackageName);
9460 if (attribute_flag[1] != 0)
9461 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9463 (void) IsImagesEqual(image,argument_list[0].image_reference);
9466 case 77: /* AdaptiveThreshold */
9468 if (attribute_flag[0] != 0)
9470 flags=ParseGeometry(argument_list[0].string_reference,
9472 if ((flags & PercentValue) != 0)
9473 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9475 if (attribute_flag[1] != 0)
9476 geometry_info.rho=argument_list[1].integer_reference;
9477 if (attribute_flag[2] != 0)
9478 geometry_info.sigma=argument_list[2].integer_reference;
9479 if (attribute_flag[3] != 0)
9480 geometry_info.xi=argument_list[3].integer_reference;;
9481 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9482 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9486 case 78: /* Resample */
9492 if (attribute_flag[0] != 0)
9494 flags=ParseGeometry(argument_list[0].string_reference,
9496 if ((flags & SigmaValue) == 0)
9497 geometry_info.sigma=geometry_info.rho;
9499 if (attribute_flag[1] != 0)
9500 geometry_info.rho=argument_list[1].real_reference;
9501 if (attribute_flag[2] != 0)
9502 geometry_info.sigma=argument_list[2].real_reference;
9503 if (attribute_flag[3] == 0)
9504 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9505 if (attribute_flag[4] == 0)
9506 SetImageArtifact(image,"filter:support",
9507 argument_list[4].string_reference);
9508 if (attribute_flag[5] != 0)
9509 argument_list[5].real_reference=1.0;
9510 width=(size_t) (geometry_info.rho*image->columns/
9511 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9512 height=(size_t) (geometry_info.sigma*image->rows/
9513 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9514 image=ResizeImage(image,width,height,(FilterTypes)
9515 argument_list[3].integer_reference,argument_list[5].real_reference,
9517 if (image != (Image *) NULL)
9519 image->x_resolution=geometry_info.rho;
9520 image->y_resolution=geometry_info.sigma;
9524 case 79: /* Describe */
9526 if (attribute_flag[0] == 0)
9527 argument_list[0].file_reference=(FILE *) NULL;
9528 if (attribute_flag[1] != 0)
9529 (void) SetImageArtifact(image,"identify:features",
9530 argument_list[1].string_reference);
9531 (void) IdentifyImage(image,argument_list[0].file_reference,
9535 case 80: /* BlackThreshold */
9537 if (attribute_flag[0] == 0)
9538 argument_list[0].string_reference="50%";
9539 if (attribute_flag[2] != 0)
9540 channel=(ChannelType) argument_list[2].integer_reference;
9541 BlackThresholdImageChannel(image,channel,
9542 argument_list[0].string_reference,exception);
9545 case 81: /* WhiteThreshold */
9547 if (attribute_flag[0] == 0)
9548 argument_list[0].string_reference="50%";
9549 if (attribute_flag[2] != 0)
9550 channel=(ChannelType) argument_list[2].integer_reference;
9551 WhiteThresholdImageChannel(image,channel,
9552 argument_list[0].string_reference,exception);
9555 case 82: /* RadialBlur */
9557 if (attribute_flag[0] != 0)
9559 flags=ParseGeometry(argument_list[0].string_reference,
9561 if ((flags & SigmaValue) == 0)
9562 geometry_info.sigma=1.0;
9564 if (attribute_flag[1] != 0)
9565 geometry_info.rho=argument_list[1].real_reference;
9566 if (attribute_flag[2] != 0)
9567 channel=(ChannelType) argument_list[2].integer_reference;
9568 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9572 case 83: /* Thumbnail */
9574 if (attribute_flag[0] != 0)
9575 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9576 &geometry,exception);
9577 if (attribute_flag[1] != 0)
9578 geometry.width=argument_list[1].integer_reference;
9579 if (attribute_flag[2] != 0)
9580 geometry.height=argument_list[2].integer_reference;
9581 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9584 case 84: /* Strip */
9586 (void) StripImage(image);
9594 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9595 if (attribute_flag[0] != 0)
9596 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9598 if (attribute_flag[1] == 0)
9599 argument_list[1].string_reference="100";
9600 image=TintImage(image,argument_list[1].string_reference,target,
9604 case 86: /* Channel */
9606 if (attribute_flag[0] != 0)
9607 channel=(ChannelType) argument_list[0].integer_reference;
9608 (void) SeparateImageChannel(image,channel);
9611 case 87: /* Splice */
9613 if (attribute_flag[0] != 0)
9614 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9615 &geometry,exception);
9616 if (attribute_flag[1] != 0)
9617 geometry.width=argument_list[1].integer_reference;
9618 if (attribute_flag[2] != 0)
9619 geometry.height=argument_list[2].integer_reference;
9620 if (attribute_flag[3] != 0)
9621 geometry.x=argument_list[3].integer_reference;
9622 if (attribute_flag[4] != 0)
9623 geometry.y=argument_list[4].integer_reference;
9624 if (attribute_flag[5] != 0)
9625 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9627 if (attribute_flag[6] != 0)
9628 (void) QueryColorDatabase(argument_list[6].string_reference,
9629 &image->background_color,exception);
9630 if (attribute_flag[7] != 0)
9631 image->gravity=(GravityType) argument_list[7].integer_reference;
9632 image=SpliceImage(image,&geometry,exception);
9635 case 88: /* Posterize */
9637 if (attribute_flag[0] == 0)
9638 argument_list[0].integer_reference=3;
9639 if (attribute_flag[1] == 0)
9640 argument_list[1].integer_reference=0;
9641 (void) PosterizeImage(image,argument_list[0].integer_reference,
9642 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9645 case 89: /* Shadow */
9647 if (attribute_flag[0] != 0)
9649 flags=ParseGeometry(argument_list[0].string_reference,
9651 if ((flags & SigmaValue) == 0)
9652 geometry_info.sigma=1.0;
9653 if ((flags & XiValue) == 0)
9654 geometry_info.xi=4.0;
9655 if ((flags & PsiValue) == 0)
9656 geometry_info.psi=4.0;
9658 if (attribute_flag[1] != 0)
9659 geometry_info.rho=argument_list[1].real_reference;
9660 if (attribute_flag[2] != 0)
9661 geometry_info.sigma=argument_list[2].real_reference;
9662 if (attribute_flag[3] != 0)
9663 geometry_info.xi=argument_list[3].integer_reference;
9664 if (attribute_flag[4] != 0)
9665 geometry_info.psi=argument_list[4].integer_reference;
9666 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9667 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9671 case 90: /* Identify */
9673 if (attribute_flag[0] == 0)
9674 argument_list[0].file_reference=(FILE *) NULL;
9675 if (attribute_flag[1] != 0)
9676 (void) SetImageArtifact(image,"identify:features",
9677 argument_list[1].string_reference);
9678 if ((attribute_flag[2] != 0) &&
9679 (argument_list[2].integer_reference != 0))
9680 (void) SetImageArtifact(image,"identify:unique","true");
9681 (void) IdentifyImage(image,argument_list[0].file_reference,
9685 case 91: /* SepiaTone */
9687 if (attribute_flag[0] == 0)
9688 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9689 image=SepiaToneImage(image,argument_list[0].real_reference,
9693 case 92: /* SigmoidalContrast */
9698 if (attribute_flag[0] != 0)
9700 flags=ParseGeometry(argument_list[0].string_reference,
9702 if ((flags & SigmaValue) == 0)
9703 geometry_info.sigma=QuantumRange/2.0;
9704 if ((flags & PercentValue) != 0)
9705 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9707 if (attribute_flag[1] != 0)
9708 geometry_info.rho=argument_list[1].real_reference;
9709 if (attribute_flag[2] != 0)
9710 geometry_info.sigma=argument_list[2].real_reference;
9711 if (attribute_flag[3] != 0)
9713 channel=(ChannelType) argument_list[3].integer_reference;
9714 SetPixelComponentMap(image,channel);
9717 if (attribute_flag[4] != 0)
9718 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9720 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9721 geometry_info.sigma);
9724 case 93: /* Extent */
9726 if (attribute_flag[7] != 0)
9727 image->gravity=(GravityType) argument_list[7].integer_reference;
9728 if (attribute_flag[0] != 0)
9733 flags=ParseGravityGeometry(image,
9734 argument_list[0].string_reference,&geometry,exception);
9736 if (geometry.width == 0)
9737 geometry.width=image->columns;
9738 if (geometry.height == 0)
9739 geometry.height=image->rows;
9741 if (attribute_flag[1] != 0)
9742 geometry.width=argument_list[1].integer_reference;
9743 if (attribute_flag[2] != 0)
9744 geometry.height=argument_list[2].integer_reference;
9745 if (attribute_flag[3] != 0)
9746 geometry.x=argument_list[3].integer_reference;
9747 if (attribute_flag[4] != 0)
9748 geometry.y=argument_list[4].integer_reference;
9749 if (attribute_flag[5] != 0)
9750 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9752 if (attribute_flag[6] != 0)
9753 (void) QueryColorDatabase(argument_list[6].string_reference,
9754 &image->background_color,exception);
9755 image=ExtentImage(image,&geometry,exception);
9758 case 94: /* Vignette */
9760 if (attribute_flag[0] != 0)
9762 flags=ParseGeometry(argument_list[0].string_reference,
9764 if ((flags & SigmaValue) == 0)
9765 geometry_info.sigma=1.0;
9766 if ((flags & XiValue) == 0)
9767 geometry_info.xi=0.1*image->columns;
9768 if ((flags & PsiValue) == 0)
9769 geometry_info.psi=0.1*image->rows;
9771 if (attribute_flag[1] != 0)
9772 geometry_info.rho=argument_list[1].real_reference;
9773 if (attribute_flag[2] != 0)
9774 geometry_info.sigma=argument_list[2].real_reference;
9775 if (attribute_flag[3] != 0)
9776 geometry_info.xi=argument_list[3].integer_reference;
9777 if (attribute_flag[4] != 0)
9778 geometry_info.psi=argument_list[4].integer_reference;
9779 if (attribute_flag[5] != 0)
9780 (void) QueryColorDatabase(argument_list[5].string_reference,
9781 &image->background_color,exception);
9782 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9783 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9787 case 95: /* ContrastStretch */
9794 white_point=(MagickRealType) image->columns*image->rows;
9795 if (attribute_flag[0] != 0)
9797 flags=ParseGeometry(argument_list[0].string_reference,
9799 black_point=geometry_info.rho;
9800 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9802 if ((flags & PercentValue) != 0)
9804 black_point*=(double) image->columns*image->rows/100.0;
9805 white_point*=(double) image->columns*image->rows/100.0;
9807 white_point=(MagickRealType) image->columns*image->rows-
9810 if (attribute_flag[1] != 0)
9811 black_point=argument_list[1].real_reference;
9812 if (attribute_flag[2] != 0)
9813 white_point=argument_list[2].real_reference;
9814 if (attribute_flag[4] != 0)
9815 channel=(ChannelType) argument_list[4].integer_reference;
9816 (void) ContrastStretchImageChannel(image,channel,black_point,
9820 case 96: /* Sans0 */
9824 case 97: /* Sans1 */
9828 case 98: /* AdaptiveSharpen */
9830 if (attribute_flag[0] != 0)
9832 flags=ParseGeometry(argument_list[0].string_reference,
9834 if ((flags & SigmaValue) == 0)
9835 geometry_info.sigma=1.0;
9837 if (attribute_flag[1] != 0)
9838 geometry_info.rho=argument_list[1].real_reference;
9839 if (attribute_flag[2] != 0)
9840 geometry_info.sigma=argument_list[2].real_reference;
9841 if (attribute_flag[3] != 0)
9842 channel=(ChannelType) argument_list[3].integer_reference;
9843 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9844 geometry_info.sigma,exception);
9847 case 99: /* Transpose */
9849 image=TransposeImage(image,exception);
9852 case 100: /* Tranverse */
9854 image=TransverseImage(image,exception);
9857 case 101: /* AutoOrient */
9859 switch (image->orientation)
9861 case TopRightOrientation:
9863 image=FlopImage(image,exception);
9866 case BottomRightOrientation:
9868 image=RotateImage(image,180.0,exception);
9871 case BottomLeftOrientation:
9873 image=FlipImage(image,exception);
9876 case LeftTopOrientation:
9878 image=TransposeImage(image,exception);
9881 case RightTopOrientation:
9883 image=RotateImage(image,90.0,exception);
9886 case RightBottomOrientation:
9888 image=TransverseImage(image,exception);
9891 case LeftBottomOrientation:
9893 image=RotateImage(image,270.0,exception);
9901 case 102: /* AdaptiveBlur */
9903 if (attribute_flag[0] != 0)
9905 flags=ParseGeometry(argument_list[0].string_reference,
9907 if ((flags & SigmaValue) == 0)
9908 geometry_info.sigma=1.0;
9910 if (attribute_flag[1] != 0)
9911 geometry_info.rho=argument_list[1].real_reference;
9912 if (attribute_flag[2] != 0)
9913 geometry_info.sigma=argument_list[2].real_reference;
9914 if (attribute_flag[3] != 0)
9915 channel=(ChannelType) argument_list[3].integer_reference;
9916 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
9917 geometry_info.sigma,exception);
9920 case 103: /* Sketch */
9922 if (attribute_flag[0] != 0)
9924 flags=ParseGeometry(argument_list[0].string_reference,
9926 if ((flags & SigmaValue) == 0)
9927 geometry_info.sigma=1.0;
9928 if ((flags & XiValue) == 0)
9929 geometry_info.xi=1.0;
9931 if (attribute_flag[1] != 0)
9932 geometry_info.rho=argument_list[1].real_reference;
9933 if (attribute_flag[2] != 0)
9934 geometry_info.sigma=argument_list[2].real_reference;
9935 if (attribute_flag[3] != 0)
9936 geometry_info.xi=argument_list[3].real_reference;
9937 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9938 geometry_info.xi,exception);
9941 case 104: /* UniqueColors */
9943 image=UniqueImageColors(image,exception);
9946 case 105: /* AdaptiveResize */
9948 if (attribute_flag[0] != 0)
9949 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9950 &geometry,exception);
9951 if (attribute_flag[1] != 0)
9952 geometry.width=argument_list[1].integer_reference;
9953 if (attribute_flag[2] != 0)
9954 geometry.height=argument_list[2].integer_reference;
9955 if (attribute_flag[3] != 0)
9956 image->filter=(FilterTypes) argument_list[4].integer_reference;
9957 if (attribute_flag[4] != 0)
9958 SetImageArtifact(image,"filter:support",
9959 argument_list[4].string_reference);
9960 if (attribute_flag[5] != 0)
9961 image->blur=argument_list[5].real_reference;
9962 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
9966 case 106: /* ClipMask */
9968 if (attribute_flag[0] == 0)
9970 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9974 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
9975 MagickTrue,exception);
9976 (void) NegateImage(image->clip_mask,MagickFalse);
9979 case 107: /* LinearStretch */
9986 white_point=(MagickRealType) image->columns*image->rows;
9987 if (attribute_flag[0] != 0)
9989 flags=ParseGeometry(argument_list[0].string_reference,
9991 if ((flags & SigmaValue) != 0)
9992 white_point=geometry_info.sigma;
9993 if ((flags & PercentValue) != 0)
9995 black_point*=(double) image->columns*image->rows/100.0;
9996 white_point*=(double) image->columns*image->rows/100.0;
9998 if ((flags & SigmaValue) == 0)
9999 white_point=(double) image->columns*image->rows-black_point;
10001 if (attribute_flag[1] != 0)
10002 black_point=argument_list[1].real_reference;
10003 if (attribute_flag[2] != 0)
10004 white_point=argument_list[2].real_reference;
10005 (void) LinearStretchImage(image,black_point,white_point);
10008 case 109: /* Mask */
10010 if (attribute_flag[0] == 0)
10012 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10014 goto PerlException;
10016 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10017 MagickTrue,exception);
10018 (void) NegateImage(image->mask,MagickFalse);
10021 case 110: /* Polaroid */
10029 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10030 (DrawInfo *) NULL);
10031 if (attribute_flag[0] != 0)
10032 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10033 info ? info->image_info : (ImageInfo *) NULL,image,
10034 argument_list[0].string_reference));
10036 if (attribute_flag[1] != 0)
10037 angle=argument_list[1].real_reference;
10038 if (attribute_flag[2] != 0)
10039 (void) CloneString(&draw_info->font,
10040 argument_list[2].string_reference);
10041 if (attribute_flag[3] != 0)
10042 (void) QueryColorDatabase(argument_list[3].string_reference,
10043 &draw_info->stroke,exception);
10044 if (attribute_flag[4] != 0)
10045 (void) QueryColorDatabase(argument_list[4].string_reference,
10046 &draw_info->fill,exception);
10047 if (attribute_flag[5] != 0)
10048 draw_info->stroke_width=argument_list[5].real_reference;
10049 if (attribute_flag[6] != 0)
10050 draw_info->pointsize=argument_list[6].real_reference;
10051 if (attribute_flag[7] != 0)
10052 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10053 if (attribute_flag[8] != 0)
10054 (void) QueryColorDatabase(argument_list[8].string_reference,
10055 &image->background_color,exception);
10056 image=PolaroidImage(image,draw_info,angle,exception);
10057 draw_info=DestroyDrawInfo(draw_info);
10060 case 111: /* FloodfillPaint */
10071 draw_info=CloneDrawInfo(info ? info->image_info :
10072 (ImageInfo *) NULL,(DrawInfo *) NULL);
10073 if (attribute_flag[0] != 0)
10074 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10075 &geometry,exception);
10076 if (attribute_flag[1] != 0)
10077 geometry.x=argument_list[1].integer_reference;
10078 if (attribute_flag[2] != 0)
10079 geometry.y=argument_list[2].integer_reference;
10080 if (attribute_flag[3] != 0)
10081 (void) QueryColorDatabase(argument_list[3].string_reference,
10082 &draw_info->fill,exception);
10083 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10085 if (attribute_flag[4] != 0)
10086 QueryMagickColor(argument_list[4].string_reference,&target,
10088 if (attribute_flag[5] != 0)
10089 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10091 if (attribute_flag[6] != 0)
10092 channel=(ChannelType) argument_list[6].integer_reference;
10093 invert=MagickFalse;
10094 if (attribute_flag[7] != 0)
10095 invert=(MagickBooleanType) argument_list[7].integer_reference;
10096 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10097 geometry.y,invert);
10098 draw_info=DestroyDrawInfo(draw_info);
10101 case 112: /* Distort */
10113 number_coordinates;
10118 if (attribute_flag[0] == 0)
10120 method=UndefinedDistortion;
10121 if (attribute_flag[1] != 0)
10122 method=(DistortImageMethod) argument_list[1].integer_reference;
10123 av=(AV *) argument_list[0].array_reference;
10124 number_coordinates=(size_t) av_len(av)+1;
10125 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10126 sizeof(*coordinates));
10127 if (coordinates == (double *) NULL)
10129 ThrowPerlException(exception,ResourceLimitFatalError,
10130 "MemoryAllocationFailed",PackageName);
10131 goto PerlException;
10133 for (j=0; j < (ssize_t) number_coordinates; j++)
10134 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10135 virtual_pixel=UndefinedVirtualPixelMethod;
10136 if (attribute_flag[2] != 0)
10137 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10138 argument_list[2].integer_reference);
10139 image=DistortImage(image,method,number_coordinates,coordinates,
10140 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10142 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10143 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10144 coordinates=(double *) RelinquishMagickMemory(coordinates);
10147 case 113: /* Clut */
10149 if (attribute_flag[0] == 0)
10151 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10153 goto PerlException;
10155 if (attribute_flag[1] != 0)
10156 channel=(ChannelType) argument_list[1].integer_reference;
10157 (void) ClutImage(image,channel,
10158 argument_list[0].image_reference);
10161 case 114: /* LiquidRescale */
10163 if (attribute_flag[0] != 0)
10164 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10165 &geometry,exception);
10166 if (attribute_flag[1] != 0)
10167 geometry.width=argument_list[1].integer_reference;
10168 if (attribute_flag[2] != 0)
10169 geometry.height=argument_list[2].integer_reference;
10170 if (attribute_flag[3] == 0)
10171 argument_list[3].real_reference=1.0;
10172 if (attribute_flag[4] == 0)
10173 argument_list[4].real_reference=0.0;
10174 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10175 argument_list[3].real_reference,argument_list[4].real_reference,
10179 case 115: /* EncipherImage */
10181 (void) EncipherImage(image,argument_list[0].string_reference,
10185 case 116: /* DecipherImage */
10187 (void) DecipherImage(image,argument_list[0].string_reference,
10191 case 117: /* Deskew */
10193 geometry_info.rho=QuantumRange/2.0;
10194 if (attribute_flag[0] != 0)
10195 flags=ParseGeometry(argument_list[0].string_reference,
10197 if (attribute_flag[1] != 0)
10198 geometry_info.rho=SiPrefixToDouble(
10199 argument_list[1].string_reference,QuantumRange);
10200 image=DeskewImage(image,geometry_info.rho,exception);
10203 case 118: /* Remap */
10208 if (attribute_flag[0] == 0)
10210 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10212 goto PerlException;
10214 quantize_info=AcquireQuantizeInfo(info->image_info);
10215 if (attribute_flag[1] != 0)
10216 quantize_info->dither=(MagickBooleanType)
10217 argument_list[1].integer_reference;
10218 if (attribute_flag[2] != 0)
10219 quantize_info->dither_method=(DitherMethod)
10220 argument_list[2].integer_reference;
10221 (void) RemapImages(quantize_info,image,
10222 argument_list[0].image_reference);
10223 quantize_info=DestroyQuantizeInfo(quantize_info);
10226 case 119: /* SparseColor */
10238 number_coordinates;
10243 if (attribute_flag[0] == 0)
10245 method=UndefinedColorInterpolate;
10246 if (attribute_flag[1] != 0)
10247 method=(SparseColorMethod) argument_list[1].integer_reference;
10248 av=(AV *) argument_list[0].array_reference;
10249 number_coordinates=(size_t) av_len(av)+1;
10250 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10251 sizeof(*coordinates));
10252 if (coordinates == (double *) NULL)
10254 ThrowPerlException(exception,ResourceLimitFatalError,
10255 "MemoryAllocationFailed",PackageName);
10256 goto PerlException;
10258 for (j=0; j < (ssize_t) number_coordinates; j++)
10259 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10260 virtual_pixel=UndefinedVirtualPixelMethod;
10261 if (attribute_flag[2] != 0)
10262 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10263 argument_list[2].integer_reference);
10264 if (attribute_flag[3] != 0)
10265 channel=(ChannelType) argument_list[3].integer_reference;
10266 image=SparseColorImage(image,channel,method,number_coordinates,
10267 coordinates,exception);
10268 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10269 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10270 coordinates=(double *) RelinquishMagickMemory(coordinates);
10273 case 120: /* Function */
10290 if (attribute_flag[0] == 0)
10292 function=UndefinedFunction;
10293 if (attribute_flag[1] != 0)
10294 function=(MagickFunction) argument_list[1].integer_reference;
10295 av=(AV *) argument_list[0].array_reference;
10296 number_parameters=(size_t) av_len(av)+1;
10297 parameters=(double *) AcquireQuantumMemory(number_parameters,
10298 sizeof(*parameters));
10299 if (parameters == (double *) NULL)
10301 ThrowPerlException(exception,ResourceLimitFatalError,
10302 "MemoryAllocationFailed",PackageName);
10303 goto PerlException;
10305 for (j=0; j < (ssize_t) number_parameters; j++)
10306 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10307 virtual_pixel=UndefinedVirtualPixelMethod;
10308 if (attribute_flag[2] != 0)
10309 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10310 argument_list[2].integer_reference);
10311 (void) FunctionImage(image,function,number_parameters,parameters,
10313 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10314 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10315 parameters=(double *) RelinquishMagickMemory(parameters);
10318 case 121: /* SelectiveBlur */
10320 if (attribute_flag[0] != 0)
10322 flags=ParseGeometry(argument_list[0].string_reference,
10324 if ((flags & SigmaValue) == 0)
10325 geometry_info.sigma=1.0;
10326 if ((flags & PercentValue) != 0)
10327 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10329 if (attribute_flag[1] != 0)
10330 geometry_info.rho=argument_list[1].real_reference;
10331 if (attribute_flag[2] != 0)
10332 geometry_info.sigma=argument_list[2].real_reference;
10333 if (attribute_flag[3] != 0)
10334 geometry_info.xi=argument_list[3].integer_reference;;
10335 if (attribute_flag[4] != 0)
10336 channel=(ChannelType) argument_list[4].integer_reference;
10337 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10338 geometry_info.sigma,geometry_info.xi,exception);
10341 case 122: /* HaldClut */
10343 if (attribute_flag[0] == 0)
10345 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10347 goto PerlException;
10349 if (attribute_flag[1] != 0)
10351 channel=(ChannelType) argument_list[1].integer_reference;
10352 SetPixelComponentMap(image,channel);
10354 (void) HaldClutImage(image,argument_list[0].image_reference);
10357 case 123: /* BlueShift */
10359 if (attribute_flag[0] != 0)
10360 (void) ParseGeometry(argument_list[0].string_reference,
10362 image=BlueShiftImage(image,geometry_info.rho,exception);
10365 case 124: /* ForwardFourierTransformImage */
10367 image=ForwardFourierTransformImage(image,
10368 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10372 case 125: /* InverseFourierTransformImage */
10374 image=InverseFourierTransformImage(image,image->next,
10375 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10379 case 126: /* ColorDecisionList */
10381 if (attribute_flag[0] == 0)
10382 argument_list[0].string_reference=(char *) NULL;
10383 (void) ColorDecisionListImage(image,
10384 argument_list[0].string_reference);
10387 case 127: /* AutoGamma */
10389 if (attribute_flag[0] != 0)
10391 channel=(ChannelType) argument_list[0].integer_reference;
10392 SetPixelComponentMap(image,channel);
10394 (void) AutoGammaImage(image);
10397 case 128: /* AutoLevel */
10399 if (attribute_flag[0] != 0)
10401 channel=(ChannelType) argument_list[0].integer_reference;
10402 SetPixelComponentMap(image,channel);
10404 (void) AutoLevelImage(image);
10407 case 129: /* LevelColors */
10413 (void) QueryMagickColor("#000000",&black_point,exception);
10414 (void) QueryMagickColor("#ffffff",&white_point,exception);
10415 if (attribute_flag[1] != 0)
10416 (void) QueryMagickColor(argument_list[1].string_reference,
10417 &black_point,exception);
10418 if (attribute_flag[2] != 0)
10419 (void) QueryMagickColor(argument_list[2].string_reference,
10420 &white_point,exception);
10421 if (attribute_flag[3] != 0)
10422 channel=(ChannelType) argument_list[3].integer_reference;
10423 (void) LevelColorsImageChannel(image,channel,&black_point,
10424 &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
10428 case 130: /* Clamp */
10430 if (attribute_flag[0] != 0)
10431 channel=(ChannelType) argument_list[0].integer_reference;
10432 (void) ClampImageChannel(image,channel);
10435 case 131: /* Filter */
10440 if (attribute_flag[0] == 0)
10442 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10443 if (kernel == (KernelInfo *) NULL)
10445 if (attribute_flag[1] != 0)
10446 channel=(ChannelType) argument_list[1].integer_reference;
10447 if (attribute_flag[2] != 0)
10448 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10450 image=FilterImageChannel(image,channel,kernel,exception);
10451 kernel=DestroyKernelInfo(kernel);
10454 case 132: /* BrightnessContrast */
10462 if (attribute_flag[0] != 0)
10464 flags=ParseGeometry(argument_list[0].string_reference,
10466 brightness=geometry_info.rho;
10467 if ((flags & SigmaValue) == 0)
10468 contrast=geometry_info.sigma;
10470 if (attribute_flag[1] != 0)
10471 brightness=argument_list[1].real_reference;
10472 if (attribute_flag[2] != 0)
10473 contrast=argument_list[2].real_reference;
10474 if (attribute_flag[4] != 0)
10476 channel=(ChannelType) argument_list[4].integer_reference;
10477 SetPixelComponentMap(image,channel);
10479 (void) BrightnessContrastImage(image,brightness,contrast);
10482 case 133: /* Morphology */
10493 if (attribute_flag[0] == 0)
10495 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10496 if (kernel == (KernelInfo *) NULL)
10498 if (attribute_flag[1] != 0)
10499 channel=(ChannelType) argument_list[1].integer_reference;
10500 method=UndefinedMorphology;
10501 if (attribute_flag[2] != 0)
10502 method=argument_list[2].integer_reference;
10504 if (attribute_flag[3] != 0)
10505 iterations=argument_list[4].integer_reference;
10506 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10508 kernel=DestroyKernelInfo(kernel);
10511 case 108: /* Recolor */
10512 case 134: /* ColorMatrix */
10526 if (attribute_flag[0] == 0)
10528 av=(AV *) argument_list[0].array_reference;
10529 order=(size_t) sqrt(av_len(av)+1);
10530 color_matrix=(double *) AcquireQuantumMemory(order,order*
10531 sizeof(*color_matrix));
10532 if (color_matrix == (double *) NULL)
10534 ThrowPerlException(exception,ResourceLimitFatalError,
10535 "MemoryAllocationFailed",PackageName);
10536 goto PerlException;
10538 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10539 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10540 for ( ; j < (ssize_t) (order*order); j++)
10541 color_matrix[j]=0.0;
10542 kernel_info=AcquireKernelInfo("1");
10543 if (kernel_info == (KernelInfo *) NULL)
10545 kernel_info->width=order;
10546 kernel_info->height=order;
10547 kernel_info->values=color_matrix;
10548 image=ColorMatrixImage(image,kernel_info,exception);
10549 kernel_info->values=(double *) NULL;
10550 kernel_info=DestroyKernelInfo(kernel_info);
10551 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10554 case 135: /* Color */
10559 (void) QueryMagickColor("none",&color,exception);
10560 if (attribute_flag[0] != 0)
10561 (void) QueryMagickColor(argument_list[0].string_reference,
10563 (void) SetImageColor(image,&color);
10566 case 136: /* Mode */
10568 if (attribute_flag[0] != 0)
10570 flags=ParseGeometry(argument_list[0].string_reference,
10572 if ((flags & SigmaValue) == 0)
10573 geometry_info.sigma=1.0;
10575 if (attribute_flag[1] != 0)
10576 geometry_info.rho=argument_list[1].real_reference;
10577 if (attribute_flag[2] != 0)
10578 geometry_info.sigma=argument_list[2].real_reference;
10579 if (attribute_flag[3] != 0)
10580 channel=(ChannelType) argument_list[3].integer_reference;
10581 image=StatisticImageChannel(image,channel,ModeStatistic,
10582 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10585 case 137: /* Statistic */
10590 statistic=UndefinedStatistic;
10591 if (attribute_flag[0] != 0)
10593 flags=ParseGeometry(argument_list[0].string_reference,
10595 if ((flags & SigmaValue) == 0)
10596 geometry_info.sigma=1.0;
10598 if (attribute_flag[1] != 0)
10599 geometry_info.rho=argument_list[1].real_reference;
10600 if (attribute_flag[2] != 0)
10601 geometry_info.sigma=argument_list[2].real_reference;
10602 if (attribute_flag[3] != 0)
10603 channel=(ChannelType) argument_list[3].integer_reference;
10604 if (attribute_flag[4] != 0)
10605 statistic=(StatisticType) argument_list[4].integer_reference;
10606 image=StatisticImageChannel(image,channel,statistic,
10607 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10611 if (next != (Image *) NULL)
10612 (void) CatchImageException(next);
10613 if (region_image != (Image *) NULL)
10618 status=CompositeImage(region_image,CopyCompositeOp,image,
10619 region_info.x,region_info.y);
10621 (void) CatchImageException(region_image);
10622 image=DestroyImage(image);
10623 image=region_image;
10625 if (image != (Image *) NULL)
10628 if (next && (next != image))
10630 image->next=next->next;
10631 DeleteImageFromRegistry(*pv,next);
10633 sv_setiv(*pv,(IV) image);
10641 if (reference_vector)
10642 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10643 InheritPerlException(exception,perl_exception);
10644 exception=DestroyExceptionInfo(exception);
10645 sv_setiv(perl_exception,(IV) number_images);
10646 SvPOK_on(perl_exception);
10647 ST(0)=sv_2mortal(perl_exception);
10652 ###############################################################################
10660 ###############################################################################
10665 Image::Magick ref=NO_INIT
10710 PERL_UNUSED_VAR(ref);
10711 PERL_UNUSED_VAR(ix);
10712 exception=AcquireExceptionInfo();
10713 perl_exception=newSVpv("",0);
10716 if (sv_isobject(ST(0)) == 0)
10718 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10720 goto PerlException;
10722 reference=SvRV(ST(0));
10723 hv=SvSTASH(reference);
10725 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10727 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10728 if (image == (Image *) NULL)
10730 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10732 goto PerlException;
10737 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10738 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10739 (void) QueryMagickColor("none",&transparent_color,exception);
10740 for (i=2; i < items; i+=2)
10742 attribute=(char *) SvPV(ST(i-1),na);
10743 switch (*attribute)
10748 if (LocaleCompare(attribute,"background") == 0)
10750 (void) QueryColorDatabase(SvPV(ST(i),na),
10751 &montage_info->background_color,exception);
10752 for (next=image; next; next=next->next)
10753 next->background_color=montage_info->background_color;
10756 if (LocaleCompare(attribute,"border") == 0)
10758 montage_info->border_width=SvIV(ST(i));
10761 if (LocaleCompare(attribute,"bordercolor") == 0)
10763 (void) QueryColorDatabase(SvPV(ST(i),na),
10764 &montage_info->border_color,exception);
10765 for (next=image; next; next=next->next)
10766 next->border_color=montage_info->border_color;
10769 if (LocaleCompare(attribute,"borderwidth") == 0)
10771 montage_info->border_width=SvIV(ST(i));
10774 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10781 if (LocaleCompare(attribute,"compose") == 0)
10783 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10784 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10787 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10791 for (next=image; next; next=next->next)
10792 next->compose=(CompositeOperator) sp;
10795 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10802 if (LocaleCompare(attribute,"fill") == 0)
10804 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10808 if (LocaleCompare(attribute,"font") == 0)
10810 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10813 if (LocaleCompare(attribute,"frame") == 0)
10819 if (IsGeometry(p) == MagickFalse)
10821 ThrowPerlException(exception,OptionError,"MissingGeometry",
10825 (void) CloneString(&montage_info->frame,p);
10827 montage_info->frame=(char *) NULL;
10830 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10837 if (LocaleCompare(attribute,"geometry") == 0)
10843 if (IsGeometry(p) == MagickFalse)
10845 ThrowPerlException(exception,OptionError,"MissingGeometry",
10849 (void) CloneString(&montage_info->geometry,p);
10851 montage_info->geometry=(char *) NULL;
10854 if (LocaleCompare(attribute,"gravity") == 0)
10859 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10860 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10863 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10867 montage_info->gravity=(GravityType) in;
10868 for (next=image; next; next=next->next)
10869 next->gravity=(GravityType) in;
10872 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10879 if (LocaleCompare(attribute,"label") == 0)
10881 for (next=image; next; next=next->next)
10882 (void) SetImageProperty(next,"label",InterpretImageProperties(
10883 info ? info->image_info : (ImageInfo *) NULL,next,
10887 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10894 if (LocaleCompare(attribute,"mattecolor") == 0)
10896 (void) QueryColorDatabase(SvPV(ST(i),na),
10897 &montage_info->matte_color,exception);
10898 for (next=image; next; next=next->next)
10899 next->matte_color=montage_info->matte_color;
10902 if (LocaleCompare(attribute,"mode") == 0)
10907 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10908 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10913 ThrowPerlException(exception,OptionError,
10914 "UnrecognizedModeType",SvPV(ST(i),na));
10919 (void) CloneString(&montage_info->frame,"15x15+3+3");
10920 montage_info->shadow=MagickTrue;
10925 montage_info->frame=(char *) NULL;
10926 montage_info->shadow=MagickFalse;
10927 montage_info->border_width=0;
10930 case ConcatenateMode:
10932 montage_info->frame=(char *) NULL;
10933 montage_info->shadow=MagickFalse;
10934 (void) CloneString(&montage_info->geometry,"+0+0");
10935 montage_info->border_width=0;
10940 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10947 if (LocaleCompare(attribute,"pointsize") == 0)
10949 montage_info->pointsize=SvIV(ST(i));
10952 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10959 if (LocaleCompare(attribute,"shadow") == 0)
10961 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10962 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
10965 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10969 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
10972 if (LocaleCompare(attribute,"stroke") == 0)
10974 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
10978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10985 if (LocaleCompare(attribute,"texture") == 0)
10987 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
10990 if (LocaleCompare(attribute,"tile") == 0)
10992 char *p=SvPV(ST(i),na);
10993 if (IsGeometry(p) == MagickFalse)
10995 ThrowPerlException(exception,OptionError,"MissingGeometry",
10999 (void) CloneString(&montage_info->tile,p);
11001 montage_info->tile=(char *) NULL;
11004 if (LocaleCompare(attribute,"title") == 0)
11006 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11009 if (LocaleCompare(attribute,"transparent") == 0)
11014 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11015 for (next=image; next; next=next->next)
11016 (void) TransparentPaintImage(next,&transparent_color,
11017 TransparentAlpha,MagickFalse);
11020 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11026 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11032 image=MontageImageList(info->image_info,montage_info,image,exception);
11033 montage_info=DestroyMontageInfo(montage_info);
11034 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11035 goto PerlException;
11036 if (transparent_color.alpha != TransparentAlpha)
11037 for (next=image; next; next=next->next)
11038 (void) TransparentPaintImage(next,&transparent_color,
11039 TransparentAlpha,MagickFalse);
11040 for ( ; image; image=image->next)
11042 AddImageToRegistry(sv,image);
11044 av_push(av,sv_bless(rv,hv));
11047 exception=DestroyExceptionInfo(exception);
11048 ST(0)=av_reference;
11049 SvREFCNT_dec(perl_exception);
11053 InheritPerlException(exception,perl_exception);
11054 exception=DestroyExceptionInfo(exception);
11055 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11056 SvPOK_on(perl_exception);
11057 ST(0)=sv_2mortal(perl_exception);
11062 ###############################################################################
11070 ###############################################################################
11075 Image::Magick ref=NO_INIT
11113 PERL_UNUSED_VAR(ref);
11114 PERL_UNUSED_VAR(ix);
11115 exception=AcquireExceptionInfo();
11116 perl_exception=newSVpv("",0);
11120 if (sv_isobject(ST(0)) == 0)
11122 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11124 goto PerlException;
11126 reference=SvRV(ST(0));
11127 hv=SvSTASH(reference);
11129 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11131 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11132 if (image == (Image *) NULL)
11134 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11136 goto PerlException;
11138 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11143 for (i=2; i < items; i+=2)
11145 attribute=(char *) SvPV(ST(i-1),na);
11146 switch (*attribute)
11151 if (LocaleCompare(attribute,"frames") == 0)
11153 number_frames=SvIV(ST(i));
11156 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11162 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11168 image=MorphImages(image,number_frames,exception);
11169 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11170 goto PerlException;
11171 for ( ; image; image=image->next)
11173 AddImageToRegistry(sv,image);
11175 av_push(av,sv_bless(rv,hv));
11178 exception=DestroyExceptionInfo(exception);
11179 ST(0)=av_reference;
11180 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11184 InheritPerlException(exception,perl_exception);
11185 exception=DestroyExceptionInfo(exception);
11186 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11187 SvPOK_on(perl_exception);
11188 ST(0)=sv_2mortal(perl_exception);
11193 ###############################################################################
11201 ###############################################################################
11206 Image::Magick ref=NO_INIT
11234 PERL_UNUSED_VAR(ref);
11235 PERL_UNUSED_VAR(ix);
11236 exception=AcquireExceptionInfo();
11237 perl_exception=newSVpv("",0);
11239 if (sv_isobject(ST(0)) == 0)
11241 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11243 goto PerlException;
11245 reference=SvRV(ST(0));
11246 hv=SvSTASH(reference);
11247 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11248 if (image == (Image *) NULL)
11250 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11252 goto PerlException;
11254 image=MergeImageLayers(image,MosaicLayer,exception);
11256 Create blessed Perl array for the returned image.
11259 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11261 AddImageToRegistry(sv,image);
11263 av_push(av,sv_bless(rv,hv));
11265 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11266 (void) CopyMagickString(image->filename,info->image_info->filename,
11268 SetImageInfo(info->image_info,0,&image->exception);
11269 exception=DestroyExceptionInfo(exception);
11270 SvREFCNT_dec(perl_exception);
11274 InheritPerlException(exception,perl_exception);
11275 exception=DestroyExceptionInfo(exception);
11276 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11277 SvPOK_on(perl_exception); /* return messages in string context */
11278 ST(0)=sv_2mortal(perl_exception);
11283 ###############################################################################
11291 ###############################################################################
11296 Image::Magick ref=NO_INIT
11346 PERL_UNUSED_VAR(ref);
11347 PERL_UNUSED_VAR(ix);
11348 exception=AcquireExceptionInfo();
11349 perl_exception=newSVpv("",0);
11350 package_info=(struct PackageInfo *) NULL;
11351 ac=(items < 2) ? 1 : items-1;
11352 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11354 length=(STRLEN *) NULL;
11355 if (list == (char **) NULL)
11357 ThrowPerlException(exception,ResourceLimitError,
11358 "MemoryAllocationFailed",PackageName);
11359 goto PerlException;
11362 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11363 if (length == (STRLEN *) NULL)
11365 ThrowPerlException(exception,ResourceLimitError,
11366 "MemoryAllocationFailed",PackageName);
11367 goto PerlException;
11369 if (sv_isobject(ST(0)) == 0)
11371 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11373 goto PerlException;
11375 reference=SvRV(ST(0));
11376 if (SvTYPE(reference) != SVt_PVAV)
11378 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11380 goto PerlException;
11382 av=(AV *) reference;
11383 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11385 package_info=ClonePackageInfo(info,exception);
11388 *list=(char *) (*package_info->image_info->filename ?
11389 package_info->image_info->filename : "XC:black");
11391 for (n=0, i=0; i < ac; i++)
11393 list[n]=(char *) SvPV(ST(i+1),length[n]);
11394 if ((items >= 3) && strEQcase(list[n],"blob"))
11400 blob=(void *) (SvPV(ST(i+1),length[n]));
11401 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11403 if ((items >= 3) && strEQcase(list[n],"filename"))
11405 if ((items >= 3) && strEQcase(list[n],"file"))
11414 io_info=IoIFP(sv_2io(ST(i+1)));
11415 if (io_info == (PerlIO *) NULL)
11417 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11421 file=PerlIO_findFILE(io_info);
11422 if (file == (FILE *) NULL)
11424 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11428 SetImageInfoFile(package_info->image_info,file);
11430 if ((items >= 3) && strEQcase(list[n],"magick"))
11434 list[n]=(char *) NULL;
11436 status=ExpandFilenames(&n,&list);
11437 if (status == MagickFalse)
11439 ThrowPerlException(exception,ResourceLimitError,
11440 "MemoryAllocationFailed",PackageName);
11441 goto PerlException;
11444 for (i=0; i < n; i++)
11446 (void) CopyMagickString(package_info->image_info->filename,list[i],
11448 image=PingImage(package_info->image_info,exception);
11449 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11451 if ((package_info->image_info->file != (FILE *) NULL) ||
11452 (package_info->image_info->blob != (void *) NULL))
11453 DisassociateImageStream(image);
11454 count+=GetImageListLength(image);
11455 EXTEND(sp,4*count);
11456 for (next=image; next; next=next->next)
11458 PUSHs(sv_2mortal(newSViv(next->columns)));
11459 PUSHs(sv_2mortal(newSViv(next->rows)));
11460 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11461 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11463 image=DestroyImageList(image);
11468 for (i=0; i < n; i++)
11469 if (list[i] != (char *) NULL)
11470 for (p=keep; list[i] != *p++; )
11473 list[i]=(char *) RelinquishMagickMemory(list[i]);
11478 if (package_info != (struct PackageInfo *) NULL)
11479 DestroyPackageInfo(package_info);
11480 if (list && (list != keep))
11481 list=(char **) RelinquishMagickMemory(list);
11483 keep=(char **) RelinquishMagickMemory(keep);
11485 length=(STRLEN *) RelinquishMagickMemory(length);
11486 InheritPerlException(exception,perl_exception);
11487 exception=DestroyExceptionInfo(exception);
11488 SvREFCNT_dec(perl_exception); /* throw away all errors */
11492 ###############################################################################
11500 ###############################################################################
11505 Image::Magick ref=NO_INIT
11538 PERL_UNUSED_VAR(ref);
11539 PERL_UNUSED_VAR(ix);
11540 exception=AcquireExceptionInfo();
11541 perl_exception=newSVpv("",0);
11544 if (sv_isobject(ST(0)) == 0)
11546 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11548 goto PerlException;
11550 reference=SvRV(ST(0));
11551 hv=SvSTASH(reference);
11553 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11555 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11556 if (image == (Image *) NULL)
11558 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11560 goto PerlException;
11562 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11563 preview_type=GammaPreview;
11565 preview_type=(PreviewType)
11566 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11567 for ( ; image; image=image->next)
11569 preview_image=PreviewImage(image,preview_type,exception);
11570 if (preview_image == (Image *) NULL)
11571 goto PerlException;
11572 AddImageToRegistry(sv,preview_image);
11574 av_push(av,sv_bless(rv,hv));
11577 exception=DestroyExceptionInfo(exception);
11578 ST(0)=av_reference;
11579 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11583 InheritPerlException(exception,perl_exception);
11584 exception=DestroyExceptionInfo(exception);
11585 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11586 SvPOK_on(perl_exception);
11587 ST(0)=sv_2mortal(perl_exception);
11592 ###############################################################################
11596 # Q u e r y C o l o r #
11600 ###############################################################################
11604 QueryColor(ref,...)
11605 Image::Magick ref=NO_INIT
11625 PERL_UNUSED_VAR(ref);
11626 PERL_UNUSED_VAR(ix);
11627 exception=AcquireExceptionInfo();
11628 perl_exception=newSVpv("",0);
11637 colorlist=GetColorInfoList("*",&colors,exception);
11639 for (i=0; i < (ssize_t) colors; i++)
11641 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11643 colorlist=(const ColorInfo **)
11644 RelinquishMagickMemory((ColorInfo **) colorlist);
11645 goto PerlException;
11647 EXTEND(sp,5*items);
11648 for (i=1; i < items; i++)
11650 name=(char *) SvPV(ST(i),na);
11651 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11656 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11657 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11658 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11659 if (color.colorspace == CMYKColorspace)
11660 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11661 if (color.matte != MagickFalse)
11662 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11666 InheritPerlException(exception,perl_exception);
11667 exception=DestroyExceptionInfo(exception);
11668 SvREFCNT_dec(perl_exception);
11672 ###############################################################################
11676 # Q u e r y C o l o r N a m e #
11680 ###############################################################################
11684 QueryColorname(ref,...)
11685 Image::Magick ref=NO_INIT
11694 message[MaxTextExtent];
11713 *reference; /* reference is the SV* of ref=SvIV(reference) */
11715 PERL_UNUSED_VAR(ref);
11716 PERL_UNUSED_VAR(ix);
11717 exception=AcquireExceptionInfo();
11718 perl_exception=newSVpv("",0);
11719 reference=SvRV(ST(0));
11720 av=(AV *) reference;
11721 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11723 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11724 if (image == (Image *) NULL)
11726 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11728 goto PerlException;
11731 for (i=1; i < items; i++)
11733 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11734 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11736 PUSHs(sv_2mortal(newSVpv(message,0)));
11740 InheritPerlException(exception,perl_exception);
11741 exception=DestroyExceptionInfo(exception);
11742 SvREFCNT_dec(perl_exception);
11746 ###############################################################################
11750 # Q u e r y F o n t #
11754 ###############################################################################
11759 Image::Magick ref=NO_INIT
11766 message[MaxTextExtent];
11777 volatile const TypeInfo
11780 PERL_UNUSED_VAR(ref);
11781 PERL_UNUSED_VAR(ix);
11782 exception=AcquireExceptionInfo();
11783 perl_exception=newSVpv("",0);
11792 typelist=GetTypeInfoList("*",&types,exception);
11794 for (i=0; i < (ssize_t) types; i++)
11796 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11798 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11800 goto PerlException;
11802 EXTEND(sp,10*items);
11803 for (i=1; i < items; i++)
11805 name=(char *) SvPV(ST(i),na);
11806 type_info=GetTypeInfo(name,exception);
11807 if (type_info == (TypeInfo *) NULL)
11812 if (type_info->name == (char *) NULL)
11815 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11816 if (type_info->description == (char *) NULL)
11819 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11820 if (type_info->family == (char *) NULL)
11823 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11824 if (type_info->style == UndefinedStyle)
11827 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11828 type_info->style),0)));
11829 if (type_info->stretch == UndefinedStretch)
11832 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11833 type_info->stretch),0)));
11834 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11835 type_info->weight);
11836 PUSHs(sv_2mortal(newSVpv(message,0)));
11837 if (type_info->encoding == (char *) NULL)
11840 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11841 if (type_info->foundry == (char *) NULL)
11844 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11845 if (type_info->format == (char *) NULL)
11848 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11849 if (type_info->metrics == (char *) NULL)
11852 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11853 if (type_info->glyphs == (char *) NULL)
11856 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11860 InheritPerlException(exception,perl_exception);
11861 exception=DestroyExceptionInfo(exception);
11862 SvREFCNT_dec(perl_exception);
11866 ###############################################################################
11870 # Q u e r y F o n t M e t r i c s #
11874 ###############################################################################
11878 QueryFontMetrics(ref,...)
11879 Image::Magick ref=NO_INIT
11881 queryfontmetrics = 1
11928 *reference; /* reference is the SV* of ref=SvIV(reference) */
11933 PERL_UNUSED_VAR(ref);
11934 PERL_UNUSED_VAR(ix);
11935 exception=AcquireExceptionInfo();
11936 package_info=(struct PackageInfo *) NULL;
11937 perl_exception=newSVpv("",0);
11938 reference=SvRV(ST(0));
11939 av=(AV *) reference;
11940 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11942 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11943 if (image == (Image *) NULL)
11945 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11947 goto PerlException;
11949 package_info=ClonePackageInfo(info,exception);
11950 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
11951 CloneString(&draw_info->text,"");
11952 current=draw_info->affine;
11953 GetAffineMatrix(&affine);
11956 EXTEND(sp,7*items);
11957 for (i=2; i < items; i+=2)
11959 attribute=(char *) SvPV(ST(i-1),na);
11960 switch (*attribute)
11965 if (LocaleCompare(attribute,"antialias") == 0)
11967 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
11971 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11975 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
11978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11985 if (LocaleCompare(attribute,"density") == 0)
11987 CloneString(&draw_info->density,SvPV(ST(i),na));
11990 if (LocaleCompare(attribute,"direction") == 0)
11992 draw_info->direction=(DirectionType) ParseCommandOption(
11993 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
11996 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12003 if (LocaleCompare(attribute,"encoding") == 0)
12005 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12008 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12015 if (LocaleCompare(attribute,"family") == 0)
12017 CloneString(&draw_info->family,SvPV(ST(i),na));
12020 if (LocaleCompare(attribute,"fill") == 0)
12023 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12024 &image->exception);
12027 if (LocaleCompare(attribute,"font") == 0)
12029 CloneString(&draw_info->font,SvPV(ST(i),na));
12032 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12039 if (LocaleCompare(attribute,"geometry") == 0)
12041 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12044 if (LocaleCompare(attribute,"gravity") == 0)
12046 draw_info->gravity=(GravityType) ParseCommandOption(
12047 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12050 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12057 if (LocaleCompare(attribute,"interline-spacing") == 0)
12059 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12060 draw_info->interline_spacing=geometry_info.rho;
12063 if (LocaleCompare(attribute,"interword-spacing") == 0)
12065 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12066 draw_info->interword_spacing=geometry_info.rho;
12069 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12076 if (LocaleCompare(attribute,"kerning") == 0)
12078 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12079 draw_info->kerning=geometry_info.rho;
12082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12089 if (LocaleCompare(attribute,"pointsize") == 0)
12091 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12092 draw_info->pointsize=geometry_info.rho;
12095 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12102 if (LocaleCompare(attribute,"rotate") == 0)
12104 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12105 affine.rx=geometry_info.rho;
12106 affine.ry=geometry_info.sigma;
12107 if ((flags & SigmaValue) == 0)
12108 affine.ry=affine.rx;
12111 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12118 if (LocaleCompare(attribute,"scale") == 0)
12120 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12121 affine.sx=geometry_info.rho;
12122 affine.sy=geometry_info.sigma;
12123 if ((flags & SigmaValue) == 0)
12124 affine.sy=affine.sx;
12127 if (LocaleCompare(attribute,"skew") == 0)
12133 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12134 x_angle=geometry_info.rho;
12135 y_angle=geometry_info.sigma;
12136 if ((flags & SigmaValue) == 0)
12138 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12139 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12142 if (LocaleCompare(attribute,"stroke") == 0)
12145 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12146 &image->exception);
12149 if (LocaleCompare(attribute,"style") == 0)
12151 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12155 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12159 draw_info->style=(StyleType) type;
12162 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12169 if (LocaleCompare(attribute,"text") == 0)
12171 CloneString(&draw_info->text,SvPV(ST(i),na));
12174 if (LocaleCompare(attribute,"translate") == 0)
12176 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12177 affine.tx=geometry_info.rho;
12178 affine.ty=geometry_info.sigma;
12179 if ((flags & SigmaValue) == 0)
12180 affine.ty=affine.tx;
12183 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12190 if (LocaleCompare(attribute,"weight") == 0)
12192 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12193 draw_info->weight=(size_t) geometry_info.rho;
12196 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12203 if (LocaleCompare(attribute,"x") == 0)
12205 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12206 x=geometry_info.rho;
12209 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12216 if (LocaleCompare(attribute,"y") == 0)
12218 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12219 y=geometry_info.rho;
12222 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12228 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12234 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12235 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12236 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12237 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12238 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12239 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12240 if (draw_info->geometry == (char *) NULL)
12242 draw_info->geometry=AcquireString((char *) NULL);
12243 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12244 "%.15g,%.15g",x,y);
12246 status=GetTypeMetrics(image,draw_info,&metrics);
12247 (void) CatchImageException(image);
12248 if (status == MagickFalse)
12252 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12253 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12254 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12255 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12256 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12257 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12258 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12259 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12260 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12261 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12262 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12263 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12264 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12266 draw_info=DestroyDrawInfo(draw_info);
12269 if (package_info != (struct PackageInfo *) NULL)
12270 DestroyPackageInfo(package_info);
12271 InheritPerlException(exception,perl_exception);
12272 exception=DestroyExceptionInfo(exception);
12273 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12277 ###############################################################################
12281 # 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 #
12285 ###############################################################################
12289 QueryMultilineFontMetrics(ref,...)
12290 Image::Magick ref=NO_INIT
12292 querymultilinefontmetrics = 1
12339 *reference; /* reference is the SV* of ref=SvIV(reference) */
12344 PERL_UNUSED_VAR(ref);
12345 PERL_UNUSED_VAR(ix);
12346 exception=AcquireExceptionInfo();
12347 package_info=(struct PackageInfo *) NULL;
12348 perl_exception=newSVpv("",0);
12349 reference=SvRV(ST(0));
12350 av=(AV *) reference;
12351 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12353 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12354 if (image == (Image *) NULL)
12356 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12358 goto PerlException;
12360 package_info=ClonePackageInfo(info,exception);
12361 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12362 CloneString(&draw_info->text,"");
12363 current=draw_info->affine;
12364 GetAffineMatrix(&affine);
12367 EXTEND(sp,7*items);
12368 for (i=2; i < items; i+=2)
12370 attribute=(char *) SvPV(ST(i-1),na);
12371 switch (*attribute)
12376 if (LocaleCompare(attribute,"antialias") == 0)
12378 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12382 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12386 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12389 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12396 if (LocaleCompare(attribute,"density") == 0)
12398 CloneString(&draw_info->density,SvPV(ST(i),na));
12401 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12408 if (LocaleCompare(attribute,"encoding") == 0)
12410 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12413 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12420 if (LocaleCompare(attribute,"family") == 0)
12422 CloneString(&draw_info->family,SvPV(ST(i),na));
12425 if (LocaleCompare(attribute,"fill") == 0)
12428 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12429 &image->exception);
12432 if (LocaleCompare(attribute,"font") == 0)
12434 CloneString(&draw_info->font,SvPV(ST(i),na));
12437 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12444 if (LocaleCompare(attribute,"geometry") == 0)
12446 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12449 if (LocaleCompare(attribute,"gravity") == 0)
12451 draw_info->gravity=(GravityType) ParseCommandOption(
12452 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12455 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12462 if (LocaleCompare(attribute,"pointsize") == 0)
12464 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12465 draw_info->pointsize=geometry_info.rho;
12468 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12475 if (LocaleCompare(attribute,"rotate") == 0)
12477 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12478 affine.rx=geometry_info.rho;
12479 affine.ry=geometry_info.sigma;
12480 if ((flags & SigmaValue) == 0)
12481 affine.ry=affine.rx;
12484 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12491 if (LocaleCompare(attribute,"scale") == 0)
12493 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12494 affine.sx=geometry_info.rho;
12495 affine.sy=geometry_info.sigma;
12496 if ((flags & SigmaValue) == 0)
12497 affine.sy=affine.sx;
12500 if (LocaleCompare(attribute,"skew") == 0)
12506 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12507 x_angle=geometry_info.rho;
12508 y_angle=geometry_info.sigma;
12509 if ((flags & SigmaValue) == 0)
12511 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12512 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12515 if (LocaleCompare(attribute,"stroke") == 0)
12518 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12519 &image->exception);
12522 if (LocaleCompare(attribute,"style") == 0)
12524 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12528 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12532 draw_info->style=(StyleType) type;
12535 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12542 if (LocaleCompare(attribute,"text") == 0)
12544 CloneString(&draw_info->text,SvPV(ST(i),na));
12547 if (LocaleCompare(attribute,"translate") == 0)
12549 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12550 affine.tx=geometry_info.rho;
12551 affine.ty=geometry_info.sigma;
12552 if ((flags & SigmaValue) == 0)
12553 affine.ty=affine.tx;
12556 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12563 if (LocaleCompare(attribute,"weight") == 0)
12565 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12566 draw_info->weight=(size_t) geometry_info.rho;
12569 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12576 if (LocaleCompare(attribute,"x") == 0)
12578 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12579 x=geometry_info.rho;
12582 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12589 if (LocaleCompare(attribute,"y") == 0)
12591 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12592 y=geometry_info.rho;
12595 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12607 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12608 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12609 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12610 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12611 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12612 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12613 if (draw_info->geometry == (char *) NULL)
12615 draw_info->geometry=AcquireString((char *) NULL);
12616 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12617 "%.15g,%.15g",x,y);
12619 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12620 (void) CatchImageException(image);
12621 if (status == MagickFalse)
12625 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12626 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12627 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12628 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12629 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12630 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12631 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12632 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12633 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12634 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12635 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12636 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12637 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12639 draw_info=DestroyDrawInfo(draw_info);
12642 if (package_info != (struct PackageInfo *) NULL)
12643 DestroyPackageInfo(package_info);
12644 InheritPerlException(exception,perl_exception);
12645 exception=DestroyExceptionInfo(exception);
12646 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12650 ###############################################################################
12654 # Q u e r y F o r m a t #
12658 ###############################################################################
12662 QueryFormat(ref,...)
12663 Image::Magick ref=NO_INIT
12680 volatile const MagickInfo
12683 PERL_UNUSED_VAR(ref);
12684 PERL_UNUSED_VAR(ix);
12685 exception=AcquireExceptionInfo();
12686 perl_exception=newSVpv("",0);
12690 format[MaxTextExtent];
12698 format_list=GetMagickInfoList("*",&types,exception);
12700 for (i=0; i < (ssize_t) types; i++)
12702 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12703 LocaleLower(format);
12704 PUSHs(sv_2mortal(newSVpv(format,0)));
12706 format_list=(const MagickInfo **)
12707 RelinquishMagickMemory((MagickInfo *) format_list);
12708 goto PerlException;
12710 EXTEND(sp,8*items);
12711 for (i=1; i < items; i++)
12713 name=(char *) SvPV(ST(i),na);
12714 magick_info=GetMagickInfo(name,exception);
12715 if (magick_info == (const MagickInfo *) NULL)
12720 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12721 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12722 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12723 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12724 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12725 if (magick_info->description == (char *) NULL)
12728 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12729 if (magick_info->module == (char *) NULL)
12732 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12736 InheritPerlException(exception,perl_exception);
12737 exception=DestroyExceptionInfo(exception);
12738 SvREFCNT_dec(perl_exception);
12742 ###############################################################################
12746 # Q u e r y O p t i o n #
12750 ###############################################################################
12754 QueryOption(ref,...)
12755 Image::Magick ref=NO_INIT
12776 PERL_UNUSED_VAR(ref);
12777 PERL_UNUSED_VAR(ix);
12778 exception=AcquireExceptionInfo();
12779 perl_exception=newSVpv("",0);
12780 EXTEND(sp,8*items);
12781 for (i=1; i < items; i++)
12783 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12785 options=GetCommandOptions((CommandOption) option);
12786 if (options == (char **) NULL)
12790 for (j=0; options[j] != (char *) NULL; j++)
12791 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12792 options=DestroyStringList(options);
12796 InheritPerlException(exception,perl_exception);
12797 exception=DestroyExceptionInfo(exception);
12798 SvREFCNT_dec(perl_exception);
12802 ###############################################################################
12810 ###############################################################################
12815 Image::Magick ref=NO_INIT
12862 *perl_exception, /* Perl variable for storing messages */
12867 PERL_UNUSED_VAR(ref);
12868 PERL_UNUSED_VAR(ix);
12869 exception=AcquireExceptionInfo();
12870 perl_exception=newSVpv("",0);
12872 package_info=(struct PackageInfo *) NULL;
12874 ac=(items < 2) ? 1 : items-1;
12875 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12877 length=(STRLEN *) NULL;
12878 if (list == (char **) NULL)
12880 ThrowPerlException(exception,ResourceLimitError,
12881 "MemoryAllocationFailed",PackageName);
12882 goto PerlException;
12884 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12885 if (length == (STRLEN *) NULL)
12887 ThrowPerlException(exception,ResourceLimitError,
12888 "MemoryAllocationFailed",PackageName);
12889 goto PerlException;
12891 if (sv_isobject(ST(0)) == 0)
12893 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12895 goto PerlException;
12897 reference=SvRV(ST(0));
12898 hv=SvSTASH(reference);
12899 if (SvTYPE(reference) != SVt_PVAV)
12901 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12903 goto PerlException;
12905 av=(AV *) reference;
12906 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12908 package_info=ClonePackageInfo(info,exception);
12911 *list=(char *) (*package_info->image_info->filename ?
12912 package_info->image_info->filename : "XC:black");
12914 for (n=0, i=0; i < ac; i++)
12916 list[n]=(char *) SvPV(ST(i+1),length[n]);
12917 if ((items >= 3) && strEQcase(list[n],"blob"))
12923 blob=(void *) (SvPV(ST(i+1),length[n]));
12924 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12926 if ((items >= 3) && strEQcase(list[n],"filename"))
12928 if ((items >= 3) && strEQcase(list[n],"file"))
12937 io_info=IoIFP(sv_2io(ST(i+1)));
12938 if (io_info == (PerlIO *) NULL)
12940 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12944 file=PerlIO_findFILE(io_info);
12945 if (file == (FILE *) NULL)
12947 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12951 SetImageInfoFile(package_info->image_info,file);
12953 if ((items >= 3) && strEQcase(list[n],"magick"))
12957 list[n]=(char *) NULL;
12959 status=ExpandFilenames(&n,&list);
12960 if (status == MagickFalse)
12962 ThrowPerlException(exception,ResourceLimitError,
12963 "MemoryAllocationFailed",PackageName);
12964 goto PerlException;
12967 for (i=0; i < n; i++)
12969 if ((package_info->image_info->file != (FILE *) NULL) ||
12970 (package_info->image_info->blob != (void *) NULL))
12972 image=ReadImages(package_info->image_info,exception);
12973 if (image != (Image *) NULL)
12974 DisassociateImageStream(image);
12978 (void) CopyMagickString(package_info->image_info->filename,list[i],
12980 image=ReadImages(package_info->image_info,exception);
12982 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
12984 for ( ; image; image=image->next)
12986 AddImageToRegistry(sv,image);
12988 av_push(av,sv_bless(rv,hv));
12996 for (i=0; i < n; i++)
12997 if (list[i] != (char *) NULL)
12998 for (p=keep; list[i] != *p++; )
12999 if (*p == (char *) NULL)
13001 list[i]=(char *) RelinquishMagickMemory(list[i]);
13006 if (package_info != (struct PackageInfo *) NULL)
13007 DestroyPackageInfo(package_info);
13008 if (list && (list != keep))
13009 list=(char **) RelinquishMagickMemory(list);
13011 keep=(char **) RelinquishMagickMemory(keep);
13013 length=(STRLEN *) RelinquishMagickMemory(length);
13014 InheritPerlException(exception,perl_exception);
13015 exception=DestroyExceptionInfo(exception);
13016 sv_setiv(perl_exception,(IV) number_images);
13017 SvPOK_on(perl_exception);
13018 ST(0)=sv_2mortal(perl_exception);
13023 ###############################################################################
13031 ###############################################################################
13036 Image::Magick ref=NO_INIT
13059 PERL_UNUSED_VAR(ref);
13060 PERL_UNUSED_VAR(ix);
13061 exception=AcquireExceptionInfo();
13062 perl_exception=newSVpv("",0);
13063 reference=SvRV(ST(0));
13064 av=(AV *) reference;
13065 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13067 for (i=1; i < items; i++)
13068 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13069 SvPV(ST(i),na),exception);
13070 InheritPerlException(exception,perl_exception);
13071 exception=DestroyExceptionInfo(exception);
13072 SvREFCNT_dec(perl_exception); /* throw away all errors */
13076 ###############################################################################
13084 ###############################################################################
13089 Image::Magick ref=NO_INIT
13112 *reference; /* reference is the SV* of ref=SvIV(reference) */
13114 PERL_UNUSED_VAR(ref);
13115 PERL_UNUSED_VAR(ix);
13116 exception=AcquireExceptionInfo();
13117 perl_exception=newSVpv("",0);
13118 if (sv_isobject(ST(0)) == 0)
13120 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13122 goto PerlException;
13124 reference=SvRV(ST(0));
13125 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13127 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13129 for (i=2; i < items; i+=2)
13130 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13133 InheritPerlException(exception,perl_exception);
13134 exception=DestroyExceptionInfo(exception);
13135 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13136 SvPOK_on(perl_exception);
13137 ST(0)=sv_2mortal(perl_exception);
13142 ###############################################################################
13146 # S e t P i x e l #
13150 ###############################################################################
13155 Image::Magick ref=NO_INIT
13196 *reference; /* reference is the SV* of ref=SvIV(reference) */
13198 PERL_UNUSED_VAR(ref);
13199 PERL_UNUSED_VAR(ix);
13200 exception=AcquireExceptionInfo();
13201 perl_exception=newSVpv("",0);
13202 reference=SvRV(ST(0));
13203 av=(AV *) reference;
13204 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13206 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13207 if (image == (Image *) NULL)
13209 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13211 goto PerlException;
13214 channel=DefaultChannels;
13215 normalize=MagickTrue;
13218 region.width=image->columns;
13221 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13222 for (i=2; i < items; i+=2)
13224 attribute=(char *) SvPV(ST(i-1),na);
13225 switch (*attribute)
13230 if (LocaleCompare(attribute,"channel") == 0)
13235 option=ParseChannelOption(SvPV(ST(i),na));
13238 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13242 channel=(ChannelType) option;
13245 if (LocaleCompare(attribute,"color") == 0)
13247 if (SvTYPE(ST(i)) != SVt_RV)
13250 message[MaxTextExtent];
13252 (void) FormatLocaleString(message,MaxTextExtent,
13253 "invalid %.60s value",attribute);
13254 ThrowPerlException(exception,OptionError,message,
13257 av=(AV *) SvRV(ST(i));
13260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13267 if (LocaleCompare(attribute,"geometry") == 0)
13269 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13272 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13279 if (LocaleCompare(attribute,"normalize") == 0)
13281 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13285 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13289 normalize=option != 0 ? MagickTrue : MagickFalse;
13292 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13299 if (LocaleCompare(attribute,"x") == 0)
13301 region.x=SvIV(ST(i));
13304 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13311 if (LocaleCompare(attribute,"y") == 0)
13313 region.y=SvIV(ST(i));
13316 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13322 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13328 (void) SetImageStorageClass(image,DirectClass);
13329 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13330 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13331 (SvTYPE(av) != SVt_PVAV))
13343 if (normalize != MagickFalse)
13344 scale=QuantumRange;
13345 if (((GetPixelRedTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13347 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13348 av_fetch(av,i,0)))),q);
13351 if (((GetPixelGreenTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13353 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13354 av_fetch(av,i,0)))),q);
13357 if (((GetPixelBlueTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13359 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13360 av_fetch(av,i,0)))),q);
13363 if ((((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
13364 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13366 SetPixelBlack(image,ClampToQuantum(scale*
13367 SvNV(*(av_fetch(av,i,0)))),q);
13370 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13372 SetPixelAlpha(image,ClampToQuantum(scale*
13373 SvNV(*(av_fetch(av,i,0)))),q);
13376 (void) SyncAuthenticPixels(image,exception);
13380 InheritPerlException(exception,perl_exception);
13381 exception=DestroyExceptionInfo(exception);
13382 SvREFCNT_dec(perl_exception);
13386 ###############################################################################
13394 ###############################################################################
13399 Image::Magick ref=NO_INIT
13438 PERL_UNUSED_VAR(ref);
13439 PERL_UNUSED_VAR(ix);
13440 exception=AcquireExceptionInfo();
13441 perl_exception=newSVpv("",0);
13445 if (sv_isobject(ST(0)) == 0)
13447 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13449 goto PerlException;
13451 reference=SvRV(ST(0));
13452 hv=SvSTASH(reference);
13454 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13456 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13457 if (image == (Image *) NULL)
13459 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13461 goto PerlException;
13463 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13469 for (i=2; i < items; i+=2)
13471 attribute=(char *) SvPV(ST(i-1),na);
13472 switch (*attribute)
13477 if (LocaleCompare(attribute,"offset") == 0)
13479 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13482 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13489 if (LocaleCompare(attribute,"stack") == 0)
13491 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13495 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13501 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13507 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13513 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13515 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13516 goto PerlException;
13517 for ( ; image; image=image->next)
13519 AddImageToRegistry(sv,image);
13521 av_push(av,sv_bless(rv,hv));
13524 exception=DestroyExceptionInfo(exception);
13525 ST(0)=av_reference;
13526 SvREFCNT_dec(perl_exception);
13530 InheritPerlException(exception,perl_exception);
13531 exception=DestroyExceptionInfo(exception);
13532 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13533 SvPOK_on(perl_exception);
13534 ST(0)=sv_2mortal(perl_exception);
13539 ###############################################################################
13543 # S t a t i s t i c s #
13547 ###############################################################################
13551 Statistics(ref,...)
13552 Image::Magick ref=NO_INIT
13554 StatisticsImage = 1
13556 statisticsimage = 3
13559 #define ChannelStatistics(channel) \
13561 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13562 (double) channel_statistics[channel].depth); \
13563 PUSHs(sv_2mortal(newSVpv(message,0))); \
13564 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13565 channel_statistics[channel].minima/scale); \
13566 PUSHs(sv_2mortal(newSVpv(message,0))); \
13567 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13568 channel_statistics[channel].maxima/scale); \
13569 PUSHs(sv_2mortal(newSVpv(message,0))); \
13570 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13571 channel_statistics[channel].mean/scale); \
13572 PUSHs(sv_2mortal(newSVpv(message,0))); \
13573 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13574 channel_statistics[channel].standard_deviation/scale); \
13575 PUSHs(sv_2mortal(newSVpv(message,0))); \
13576 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13577 channel_statistics[channel].kurtosis); \
13578 PUSHs(sv_2mortal(newSVpv(message,0))); \
13579 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13580 channel_statistics[channel].skewness); \
13581 PUSHs(sv_2mortal(newSVpv(message,0))); \
13588 message[MaxTextExtent];
13591 *channel_statistics;
13612 PERL_UNUSED_VAR(ref);
13613 PERL_UNUSED_VAR(ix);
13614 exception=AcquireExceptionInfo();
13615 perl_exception=newSVpv("",0);
13617 if (sv_isobject(ST(0)) == 0)
13619 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13621 goto PerlException;
13623 reference=SvRV(ST(0));
13626 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13627 if (image == (Image *) NULL)
13629 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13631 goto PerlException;
13633 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13635 for ( ; image; image=image->next)
13637 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13638 if (channel_statistics == (ChannelStatistics *) NULL)
13641 EXTEND(sp,35*count);
13642 scale=(double) QuantumRange;
13643 ChannelStatistics(RedChannel);
13644 ChannelStatistics(GreenChannel);
13645 ChannelStatistics(BlueChannel);
13646 if (image->colorspace == CMYKColorspace)
13647 ChannelStatistics(BlackChannel);
13648 if (image->matte != MagickFalse)
13649 ChannelStatistics(AlphaChannel);
13650 channel_statistics=(ChannelStatistics *)
13651 RelinquishMagickMemory(channel_statistics);
13655 InheritPerlException(exception,perl_exception);
13656 exception=DestroyExceptionInfo(exception);
13657 SvREFCNT_dec(perl_exception);
13661 ###############################################################################
13665 # S y n c A u t h e n t i c P i x e l s #
13669 ###############################################################################
13673 SyncAuthenticPixels(ref,...)
13674 Image::Magick ref = NO_INIT
13676 Syncauthenticpixels = 1
13677 SyncImagePixels = 2
13678 syncimagepixels = 3
13697 PERL_UNUSED_VAR(ref);
13698 PERL_UNUSED_VAR(ix);
13699 exception=AcquireExceptionInfo();
13700 perl_exception=newSVpv("",0);
13701 if (sv_isobject(ST(0)) == 0)
13703 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13705 goto PerlException;
13708 reference=SvRV(ST(0));
13709 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13710 if (image == (Image *) NULL)
13712 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13714 goto PerlException;
13717 status=SyncAuthenticPixels(image,exception);
13718 if (status != MagickFalse)
13720 InheritException(exception,&image->exception);
13723 InheritPerlException(exception,perl_exception);
13724 exception=DestroyExceptionInfo(exception);
13725 SvREFCNT_dec(perl_exception); /* throw away all errors */
13729 ###############################################################################
13733 # T r a n s f o r m #
13737 ###############################################################################
13742 Image::Magick ref=NO_INIT
13780 PERL_UNUSED_VAR(ref);
13781 PERL_UNUSED_VAR(ix);
13782 exception=AcquireExceptionInfo();
13783 perl_exception=newSVpv("",0);
13787 if (sv_isobject(ST(0)) == 0)
13789 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13791 goto PerlException;
13793 reference=SvRV(ST(0));
13794 hv=SvSTASH(reference);
13796 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13798 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13799 if (image == (Image *) NULL)
13801 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13803 goto PerlException;
13805 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13809 crop_geometry=(char *) NULL;
13810 geometry=(char *) NULL;
13811 for (i=2; i < items; i+=2)
13813 attribute=(char *) SvPV(ST(i-1),na);
13814 switch (*attribute)
13819 if (LocaleCompare(attribute,"crop") == 0)
13821 crop_geometry=SvPV(ST(i),na);
13824 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13831 if (LocaleCompare(attribute,"geometry") == 0)
13833 geometry=SvPV(ST(i),na);
13836 if (LocaleCompare(attribute,"gravity") == 0)
13844 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13845 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13848 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13852 for (next=image; next; next=next->next)
13853 next->gravity=(GravityType) in;
13856 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13862 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13868 for ( ; image; image=image->next)
13870 clone=CloneImage(image,0,0,MagickTrue,exception);
13871 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13872 goto PerlException;
13873 TransformImage(&clone,crop_geometry,geometry);
13874 for ( ; clone; clone=clone->next)
13876 AddImageToRegistry(sv,clone);
13878 av_push(av,sv_bless(rv,hv));
13882 exception=DestroyExceptionInfo(exception);
13883 ST(0)=av_reference;
13884 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13888 InheritPerlException(exception,perl_exception);
13889 exception=DestroyExceptionInfo(exception);
13890 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13891 SvPOK_on(perl_exception);
13892 ST(0)=sv_2mortal(perl_exception);
13897 ###############################################################################
13905 ###############################################################################
13910 Image::Magick ref=NO_INIT
13918 filename[MaxTextExtent];
13942 PERL_UNUSED_VAR(ref);
13943 PERL_UNUSED_VAR(ix);
13944 exception=AcquireExceptionInfo();
13945 perl_exception=newSVpv("",0);
13947 package_info=(struct PackageInfo *) NULL;
13948 if (sv_isobject(ST(0)) == 0)
13950 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13952 goto PerlException;
13954 reference=SvRV(ST(0));
13955 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13956 if (image == (Image *) NULL)
13958 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13960 goto PerlException;
13962 package_info=ClonePackageInfo(info,exception);
13964 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
13967 for (i=2; i < items; i+=2)
13968 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
13970 (void) CopyMagickString(filename,package_info->image_info->filename,
13973 for (next=image; next; next=next->next)
13975 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
13976 next->scene=scene++;
13978 SetImageInfo(package_info->image_info,(unsigned int)
13979 GetImageListLength(image),&image->exception);
13980 for (next=image; next; next=next->next)
13982 (void) WriteImage(package_info->image_info,next);
13983 if (next->exception.severity >= ErrorException)
13984 InheritException(exception,&next->exception);
13985 GetImageException(next,exception);
13987 if (package_info->image_info->adjoin)
13992 if (package_info != (struct PackageInfo *) NULL)
13993 DestroyPackageInfo(package_info);
13994 InheritPerlException(exception,perl_exception);
13995 exception=DestroyExceptionInfo(exception);
13996 sv_setiv(perl_exception,(IV) number_images);
13997 SvPOK_on(perl_exception);
13998 ST(0)=sv_2mortal(perl_exception);