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
3115 PERL_UNUSED_VAR(ref);
3116 PERL_UNUSED_VAR(ix);
3117 exception=AcquireExceptionInfo();
3118 perl_exception=newSVpv("",0);
3122 if (sv_isobject(ST(0)) == 0)
3124 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3128 reference=SvRV(ST(0));
3129 hv=SvSTASH(reference);
3131 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3133 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3134 if (image == (Image *) NULL)
3136 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3140 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3144 channel=DefaultChannels;
3145 reconstruct_image=image;
3146 metric=RootMeanSquaredErrorMetric;
3147 for (i=2; i < items; i+=2)
3149 attribute=(char *) SvPV(ST(i-1),na);
3155 if (LocaleCompare(attribute,"channel") == 0)
3160 option=ParseChannelOption(SvPV(ST(i),na));
3163 ThrowPerlException(exception,OptionError,
3164 "UnrecognizedType",SvPV(ST(i),na));
3167 channel=(ChannelType) option;
3170 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3177 if (LocaleCompare(attribute,"fuzz") == 0)
3179 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3182 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3189 if (LocaleCompare(attribute,"image") == 0)
3191 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3192 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3195 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3202 if (LocaleCompare(attribute,"metric") == 0)
3204 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3208 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3212 metric=(MetricType) option;
3215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3221 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3227 difference_image=CompareImageChannels(image,reconstruct_image,channel,
3228 metric,&distortion,exception);
3229 if (difference_image != (Image *) NULL)
3231 difference_image->error.mean_error_per_pixel=distortion;
3232 AddImageToRegistry(sv,difference_image);
3234 av_push(av,sv_bless(rv,hv));
3237 exception=DestroyExceptionInfo(exception);
3239 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3243 InheritPerlException(exception,perl_exception);
3244 exception=DestroyExceptionInfo(exception);
3245 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3246 SvPOK_on(perl_exception);
3247 ST(0)=sv_2mortal(perl_exception);
3252 ###############################################################################
3256 # C o m p a r e L a y e r s #
3260 ###############################################################################
3265 Image::Magick ref=NO_INIT
3267 CompareImageLayers = 1
3269 compareimagelayers = 3
3306 PERL_UNUSED_VAR(ref);
3307 PERL_UNUSED_VAR(ix);
3308 exception=AcquireExceptionInfo();
3309 perl_exception=newSVpv("",0);
3311 if (sv_isobject(ST(0)) == 0)
3313 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3317 reference=SvRV(ST(0));
3318 hv=SvSTASH(reference);
3320 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3322 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3323 if (image == (Image *) NULL)
3325 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3329 method=CompareAnyLayer;
3330 for (i=2; i < items; i+=2)
3332 attribute=(char *) SvPV(ST(i-1),na);
3338 if (LocaleCompare(attribute,"method") == 0)
3340 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3344 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3348 method=(ImageLayerMethod) option;
3351 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3357 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3363 image=CompareImageLayers(image,method,exception);
3364 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3366 for ( ; image; image=image->next)
3368 AddImageToRegistry(sv,image);
3370 av_push(av,sv_bless(rv,hv));
3373 exception=DestroyExceptionInfo(exception);
3375 SvREFCNT_dec(perl_exception);
3379 InheritPerlException(exception,perl_exception);
3380 exception=DestroyExceptionInfo(exception);
3381 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3382 SvPOK_on(perl_exception);
3383 ST(0)=sv_2mortal(perl_exception);
3388 ###############################################################################
3396 ###############################################################################
3401 Image::Magick ref=NO_INIT
3407 PERL_UNUSED_VAR(ref);
3408 if (sv_isobject(ST(0)) == 0)
3409 croak("ReferenceIsNotMyType");
3410 reference=SvRV(ST(0));
3411 switch (SvTYPE(reference))
3416 message[MaxTextExtent];
3434 Array (AV *) reference
3436 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3437 XS_VERSION,reference);
3438 hv=gv_stashpv(PackageName, FALSE);
3441 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3445 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3447 info=(struct PackageInfo *) SvIV(sv);
3448 DestroyPackageInfo(info);
3450 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3460 Blessed scalar = (Image *) SvIV(reference)
3462 image=(Image *) SvIV(reference);
3463 if (image != (Image *) NULL)
3464 DeleteImageFromRegistry(reference,image);
3473 ###############################################################################
3481 ###############################################################################
3486 Image::Magick ref=NO_INIT
3510 PERL_UNUSED_VAR(ref);
3511 PERL_UNUSED_VAR(ix);
3512 exception=AcquireExceptionInfo();
3513 perl_exception=newSVpv("",0);
3514 package_info=(struct PackageInfo *) NULL;
3515 if (sv_isobject(ST(0)) == 0)
3517 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3521 reference=SvRV(ST(0));
3522 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3523 if (image == (Image *) NULL)
3525 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3529 package_info=ClonePackageInfo(info,exception);
3531 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3534 for (i=2; i < items; i+=2)
3535 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3537 (void) DisplayImages(package_info->image_info,image);
3538 (void) CatchImageException(image);
3539 InheritException(exception,&image->exception);
3542 if (package_info != (struct PackageInfo *) NULL)
3543 DestroyPackageInfo(package_info);
3544 InheritPerlException(exception,perl_exception);
3545 exception=DestroyExceptionInfo(exception);
3546 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3547 SvPOK_on(perl_exception);
3548 ST(0)=sv_2mortal(perl_exception);
3553 ###############################################################################
3557 # E v a l u a t e I m a g e s #
3561 ###############################################################################
3566 Image::Magick ref=NO_INIT
3588 MagickEvaluateOperator
3603 PERL_UNUSED_VAR(ref);
3604 PERL_UNUSED_VAR(ix);
3605 exception=AcquireExceptionInfo();
3606 perl_exception=newSVpv("",0);
3608 if (sv_isobject(ST(0)) == 0)
3610 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3614 reference=SvRV(ST(0));
3615 hv=SvSTASH(reference);
3616 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3617 if (image == (Image *) NULL)
3619 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3623 op=MeanEvaluateOperator;
3629 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3633 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3637 op=(MagickEvaluateOperator) in;
3640 for (i=2; i < items; i+=2)
3642 attribute=(char *) SvPV(ST(i-1),na);
3648 if (LocaleCompare(attribute,"operator") == 0)
3653 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3654 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3657 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3661 op=(MagickEvaluateOperator) in;
3664 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3670 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3676 image=EvaluateImages(image,op,exception);
3677 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3680 Create blessed Perl array for the returned image.
3683 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3685 AddImageToRegistry(sv,image);
3687 av_push(av,sv_bless(rv,hv));
3689 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3690 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3691 "evaluate-%.*s",(int) (MaxTextExtent-9),
3692 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3693 (void) CopyMagickString(image->filename,info->image_info->filename,
3695 SetImageInfo(info->image_info,0,exception);
3696 exception=DestroyExceptionInfo(exception);
3697 SvREFCNT_dec(perl_exception);
3701 InheritPerlException(exception,perl_exception);
3702 exception=DestroyExceptionInfo(exception);
3703 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3704 SvPOK_on(perl_exception);
3705 ST(0)=sv_2mortal(perl_exception);
3710 ###############################################################################
3718 ###############################################################################
3723 Image::Magick ref=NO_INIT
3730 #define ChannelFeatures(channel,direction) \
3732 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3733 channel_features[channel].angular_second_moment[direction]); \
3734 PUSHs(sv_2mortal(newSVpv(message,0))); \
3735 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3736 channel_features[channel].contrast[direction]); \
3737 PUSHs(sv_2mortal(newSVpv(message,0))); \
3738 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3739 channel_features[channel].contrast[direction]); \
3740 PUSHs(sv_2mortal(newSVpv(message,0))); \
3741 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3742 channel_features[channel].variance_sum_of_squares[direction]); \
3743 PUSHs(sv_2mortal(newSVpv(message,0))); \
3744 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3745 channel_features[channel].inverse_difference_moment[direction]); \
3746 PUSHs(sv_2mortal(newSVpv(message,0))); \
3747 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3748 channel_features[channel].sum_average[direction]); \
3749 PUSHs(sv_2mortal(newSVpv(message,0))); \
3750 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3751 channel_features[channel].sum_variance[direction]); \
3752 PUSHs(sv_2mortal(newSVpv(message,0))); \
3753 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3754 channel_features[channel].sum_entropy[direction]); \
3755 PUSHs(sv_2mortal(newSVpv(message,0))); \
3756 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3757 channel_features[channel].entropy[direction]); \
3758 PUSHs(sv_2mortal(newSVpv(message,0))); \
3759 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3760 channel_features[channel].difference_variance[direction]); \
3761 PUSHs(sv_2mortal(newSVpv(message,0))); \
3762 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3763 channel_features[channel].difference_entropy[direction]); \
3764 PUSHs(sv_2mortal(newSVpv(message,0))); \
3765 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3766 channel_features[channel].measure_of_correlation_1[direction]); \
3767 PUSHs(sv_2mortal(newSVpv(message,0))); \
3768 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3769 channel_features[channel].measure_of_correlation_2[direction]); \
3770 PUSHs(sv_2mortal(newSVpv(message,0))); \
3771 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3772 channel_features[channel].maximum_correlation_coefficient[direction]); \
3773 PUSHs(sv_2mortal(newSVpv(message,0))); \
3781 message[MaxTextExtent];
3808 PERL_UNUSED_VAR(ref);
3809 PERL_UNUSED_VAR(ix);
3810 exception=AcquireExceptionInfo();
3811 perl_exception=newSVpv("",0);
3813 if (sv_isobject(ST(0)) == 0)
3815 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3819 reference=SvRV(ST(0));
3822 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3823 if (image == (Image *) NULL)
3825 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3829 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3831 for (i=2; i < items; i+=2)
3833 attribute=(char *) SvPV(ST(i-1),na);
3839 if (LocaleCompare(attribute,"distance") == 0)
3841 distance=StringToLong((char *) SvPV(ST(1),na));
3844 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3850 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3857 for ( ; image; image=image->next)
3859 channel_features=GetImageChannelFeatures(image,distance,
3861 if (channel_features == (ChannelFeatures *) NULL)
3864 EXTEND(sp,75*count);
3865 for (i=0; i < 4; i++)
3867 ChannelFeatures(RedChannel,i);
3868 ChannelFeatures(GreenChannel,i);
3869 ChannelFeatures(BlueChannel,i);
3870 if (image->colorspace == CMYKColorspace)
3871 ChannelFeatures(BlackChannel,i);
3872 if (image->matte != MagickFalse)
3873 ChannelFeatures(AlphaChannel,i);
3875 channel_features=(ChannelFeatures *)
3876 RelinquishMagickMemory(channel_features);
3880 InheritPerlException(exception,perl_exception);
3881 exception=DestroyExceptionInfo(exception);
3882 SvREFCNT_dec(perl_exception);
3886 ###############################################################################
3894 ###############################################################################
3899 Image::Magick ref=NO_INIT
3937 PERL_UNUSED_VAR(ref);
3938 PERL_UNUSED_VAR(ix);
3939 exception=AcquireExceptionInfo();
3940 perl_exception=newSVpv("",0);
3942 if (sv_isobject(ST(0)) == 0)
3944 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3948 reference=SvRV(ST(0));
3949 hv=SvSTASH(reference);
3950 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3951 if (image == (Image *) NULL)
3953 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3957 background_color=image->background_color;
3959 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3962 for (i=2; i < items; i+=2)
3964 attribute=(char *) SvPV(ST(i-1),na);
3970 if (LocaleCompare(attribute,"background") == 0)
3972 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3973 &background_color,exception);
3976 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3982 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3988 image->background_color=background_color;
3989 image=MergeImageLayers(image,FlattenLayer,exception);
3990 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3993 Create blessed Perl array for the returned image.
3996 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3998 AddImageToRegistry(sv,image);
4000 av_push(av,sv_bless(rv,hv));
4002 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4003 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4004 "flatten-%.*s",(int) (MaxTextExtent-9),
4005 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4006 (void) CopyMagickString(image->filename,info->image_info->filename,
4008 SetImageInfo(info->image_info,0,exception);
4009 exception=DestroyExceptionInfo(exception);
4010 SvREFCNT_dec(perl_exception);
4014 InheritPerlException(exception,perl_exception);
4015 exception=DestroyExceptionInfo(exception);
4016 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4017 SvPOK_on(perl_exception); /* return messages in string context */
4018 ST(0)=sv_2mortal(perl_exception);
4023 ###############################################################################
4031 ###############################################################################
4036 Image::Magick ref=NO_INIT
4048 expression[MaxTextExtent];
4075 PERL_UNUSED_VAR(ref);
4076 PERL_UNUSED_VAR(ix);
4077 exception=AcquireExceptionInfo();
4078 perl_exception=newSVpv("",0);
4082 if (sv_isobject(ST(0)) == 0)
4084 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4088 reference=SvRV(ST(0));
4089 hv=SvSTASH(reference);
4091 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4093 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4094 if (image == (Image *) NULL)
4096 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4100 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4104 channel=DefaultChannels;
4105 (void) CopyMagickString(expression,"u",MaxTextExtent);
4107 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4109 for (i=2; i < items; i+=2)
4111 attribute=(char *) SvPV(ST(i-1),na);
4117 if (LocaleCompare(attribute,"channel") == 0)
4122 option=ParseChannelOption(SvPV(ST(i),na));
4125 ThrowPerlException(exception,OptionError,
4126 "UnrecognizedType",SvPV(ST(i),na));
4129 channel=(ChannelType) option;
4132 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4139 if (LocaleCompare(attribute,"expression") == 0)
4141 (void) CopyMagickString(expression,SvPV(ST(i),na),
4145 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4157 image=FxImageChannel(image,channel,expression,exception);
4158 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4160 for ( ; image; image=image->next)
4162 AddImageToRegistry(sv,image);
4164 av_push(av,sv_bless(rv,hv));
4167 exception=DestroyExceptionInfo(exception);
4169 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4173 InheritPerlException(exception,perl_exception);
4174 exception=DestroyExceptionInfo(exception);
4175 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4176 SvPOK_on(perl_exception);
4177 ST(0)=sv_2mortal(perl_exception);
4182 ###############################################################################
4190 ###############################################################################
4195 Image::Magick ref=NO_INIT
4206 color[MaxTextExtent];
4231 PERL_UNUSED_VAR(ref);
4232 PERL_UNUSED_VAR(ix);
4233 exception=AcquireExceptionInfo();
4234 perl_exception=newSVpv("",0);
4235 if (sv_isobject(ST(0)) == 0)
4237 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4241 reference=SvRV(ST(0));
4242 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4243 if (image == (Image *) NULL && !info)
4246 for (i=1; i < items; i++)
4248 attribute=(char *) SvPV(ST(i),na);
4255 if (LocaleCompare(attribute,"adjoin") == 0)
4258 s=newSViv((ssize_t) info->image_info->adjoin);
4259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4262 if (LocaleCompare(attribute,"antialias") == 0)
4265 s=newSViv((ssize_t) info->image_info->antialias);
4266 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4269 if (LocaleCompare(attribute,"area") == 0)
4271 s=newSViv(GetMagickResource(AreaResource));
4272 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4275 if (LocaleCompare(attribute,"attenuate") == 0)
4280 value=GetImageProperty(image,attribute);
4281 if (value != (const char *) NULL)
4283 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4286 if (LocaleCompare(attribute,"authenticate") == 0)
4289 s=newSVpv(info->image_info->authenticate,0);
4290 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4293 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4300 if (LocaleCompare(attribute,"background") == 0)
4302 if (image == (Image *) NULL)
4304 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4305 QuantumFormat "," QuantumFormat "," QuantumFormat,
4306 image->background_color.red,image->background_color.green,
4307 image->background_color.blue,image->background_color.alpha);
4309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4312 if (LocaleCompare(attribute,"base-columns") == 0)
4314 if (image != (Image *) NULL)
4315 s=newSViv((ssize_t) image->magick_columns);
4316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4319 if (LocaleCompare(attribute,"base-filename") == 0)
4321 if (image != (Image *) NULL)
4322 s=newSVpv(image->magick_filename,0);
4323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4326 if (LocaleCompare(attribute,"base-height") == 0)
4328 if (image != (Image *) NULL)
4329 s=newSViv((ssize_t) image->magick_rows);
4330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4333 if (LocaleCompare(attribute,"base-rows") == 0)
4335 if (image != (Image *) NULL)
4336 s=newSViv((ssize_t) image->magick_rows);
4337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4340 if (LocaleCompare(attribute,"base-width") == 0)
4342 if (image != (Image *) NULL)
4343 s=newSViv((ssize_t) image->magick_columns);
4344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4347 if (LocaleCompare(attribute,"bias") == 0)
4349 if (image != (Image *) NULL)
4350 s=newSVnv(image->bias);
4351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4354 if (LocaleCompare(attribute,"blue-primary") == 0)
4356 if (image == (Image *) NULL)
4358 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4359 image->chromaticity.blue_primary.x,
4360 image->chromaticity.blue_primary.y);
4362 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4365 if (LocaleCompare(attribute,"bordercolor") == 0)
4367 if (image == (Image *) NULL)
4369 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4370 QuantumFormat "," QuantumFormat "," QuantumFormat,
4371 image->border_color.red,image->border_color.green,
4372 image->border_color.blue,image->border_color.alpha);
4374 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4377 if (LocaleCompare(attribute,"bounding-box") == 0)
4380 geometry[MaxTextExtent];
4385 if (image == (Image *) NULL)
4387 page=GetImageBoundingBox(image,&image->exception);
4388 (void) FormatLocaleString(geometry,MaxTextExtent,
4389 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4390 page.height,(double) page.x,(double) page.y);
4391 s=newSVpv(geometry,0);
4392 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4395 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4402 if (LocaleCompare(attribute,"class") == 0)
4404 if (image == (Image *) NULL)
4406 s=newSViv(image->storage_class);
4407 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4408 image->storage_class));
4410 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4413 if (LocaleCompare(attribute,"clip-mask") == 0)
4415 if (image != (Image *) NULL)
4421 if (image->mask == (Image *) NULL)
4423 if (image->mask != (Image *) NULL)
4425 AddImageToRegistry(sv,image->mask);
4426 s=sv_bless(newRV(sv),SvSTASH(reference));
4429 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4432 if (LocaleCompare(attribute,"clip-path") == 0)
4434 if (image != (Image *) NULL)
4440 if (image->clip_mask == (Image *) NULL)
4442 if (image->clip_mask != (Image *) NULL)
4444 AddImageToRegistry(sv,image->clip_mask);
4445 s=sv_bless(newRV(sv),SvSTASH(reference));
4448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4451 if (LocaleCompare(attribute,"compression") == 0)
4453 j=info ? info->image_info->compression : image ?
4454 image->compression : UndefinedCompression;
4456 if (info->image_info->compression == UndefinedCompression)
4457 j=image->compression;
4459 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4465 if (LocaleCompare(attribute,"colorspace") == 0)
4467 j=image ? image->colorspace : RGBColorspace;
4469 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4472 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4475 if (LocaleCompare(attribute,"colors") == 0)
4477 if (image != (Image *) NULL)
4478 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4479 &image->exception));
4480 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4483 if (LocaleNCompare(attribute,"colormap",8) == 0)
4488 if (image == (Image *) NULL || !image->colormap)
4491 items=sscanf(attribute,"%*[^[][%ld",&j);
4493 if (j > (ssize_t) image->colors)
4495 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4496 QuantumFormat "," QuantumFormat "," QuantumFormat,
4497 image->colormap[j].red,image->colormap[j].green,
4498 image->colormap[j].blue,image->colormap[j].alpha);
4500 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4503 if (LocaleCompare(attribute,"columns") == 0)
4505 if (image != (Image *) NULL)
4506 s=newSViv((ssize_t) image->columns);
4507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4510 if (LocaleCompare(attribute,"comment") == 0)
4515 value=GetImageProperty(image,attribute);
4516 if (value != (const char *) NULL)
4518 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4521 if (LocaleCompare(attribute,"copyright") == 0)
4523 s=newSVpv(GetMagickCopyright(),0);
4524 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4527 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4534 if (LocaleCompare(attribute,"density") == 0)
4537 geometry[MaxTextExtent];
4539 if (image == (Image *) NULL)
4541 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4542 image->x_resolution,image->y_resolution);
4543 s=newSVpv(geometry,0);
4544 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4547 if (LocaleCompare(attribute,"delay") == 0)
4549 if (image != (Image *) NULL)
4550 s=newSViv((ssize_t) image->delay);
4551 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4554 if (LocaleCompare(attribute,"depth") == 0)
4556 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4557 if (image != (Image *) NULL)
4558 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4562 if (LocaleCompare(attribute,"directory") == 0)
4564 if (image && image->directory)
4565 s=newSVpv(image->directory,0);
4566 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4569 if (LocaleCompare(attribute,"dispose") == 0)
4571 if (image == (Image *) NULL)
4574 s=newSViv(image->dispose);
4576 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4581 if (LocaleCompare(attribute,"disk") == 0)
4583 s=newSViv(GetMagickResource(DiskResource));
4584 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4587 if (LocaleCompare(attribute,"dither") == 0)
4590 s=newSViv((ssize_t) info->image_info->dither);
4591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4594 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4596 if (info && info->image_info->server_name)
4597 s=newSVpv(info->image_info->server_name,0);
4598 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4608 if (LocaleCompare(attribute,"elapsed-time") == 0)
4610 if (image != (Image *) NULL)
4611 s=newSVnv(GetElapsedTime(&image->timer));
4612 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4615 if (LocaleCompare(attribute,"endian") == 0)
4617 j=info ? info->image_info->endian : image ? image->endian :
4620 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4622 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4625 if (LocaleCompare(attribute,"error") == 0)
4627 if (image != (Image *) NULL)
4628 s=newSVnv(image->error.mean_error_per_pixel);
4629 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4632 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4639 if (LocaleCompare(attribute,"filesize") == 0)
4641 if (image != (Image *) NULL)
4642 s=newSViv((ssize_t) GetBlobSize(image));
4643 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4646 if (LocaleCompare(attribute,"filename") == 0)
4648 if (info && info->image_info->filename &&
4649 *info->image_info->filename)
4650 s=newSVpv(info->image_info->filename,0);
4651 if (image != (Image *) NULL)
4652 s=newSVpv(image->filename,0);
4653 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4656 if (LocaleCompare(attribute,"filter") == 0)
4658 s=image ? newSViv(image->filter) : newSViv(0);
4659 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4665 if (LocaleCompare(attribute,"font") == 0)
4667 if (info && info->image_info->font)
4668 s=newSVpv(info->image_info->font,0);
4669 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4672 if (LocaleCompare(attribute,"foreground") == 0)
4674 if (LocaleCompare(attribute,"format") == 0)
4679 magick_info=(const MagickInfo *) NULL;
4680 if (info && (*info->image_info->magick != '\0'))
4681 magick_info=GetMagickInfo(info->image_info->magick,exception);
4682 if (image != (Image *) NULL)
4683 magick_info=GetMagickInfo(image->magick,&image->exception);
4684 if ((magick_info != (const MagickInfo *) NULL) &&
4685 (*magick_info->description != '\0'))
4686 s=newSVpv((char *) magick_info->description,0);
4687 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4690 if (LocaleCompare(attribute,"fuzz") == 0)
4693 s=newSVnv(info->image_info->fuzz);
4694 if (image != (Image *) NULL)
4695 s=newSVnv(image->fuzz);
4696 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4699 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4706 if (LocaleCompare(attribute,"gamma") == 0)
4708 if (image != (Image *) NULL)
4709 s=newSVnv(image->gamma);
4710 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4713 if (LocaleCompare(attribute,"geometry") == 0)
4715 if (image && image->geometry)
4716 s=newSVpv(image->geometry,0);
4717 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4720 if (LocaleCompare(attribute,"gravity") == 0)
4722 s=image ? newSViv(image->gravity) : newSViv(0);
4723 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4726 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4729 if (LocaleCompare(attribute,"green-primary") == 0)
4731 if (image == (Image *) NULL)
4733 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4734 image->chromaticity.green_primary.x,
4735 image->chromaticity.green_primary.y);
4737 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4740 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4747 if (LocaleCompare(attribute,"height") == 0)
4749 if (image != (Image *) NULL)
4750 s=newSViv((ssize_t) image->rows);
4751 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4754 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4761 if (LocaleCompare(attribute,"icc") == 0)
4763 if (image != (Image *) NULL)
4768 profile=GetImageProfile(image,"icc");
4769 if (profile != (StringInfo *) NULL)
4770 s=newSVpv((const char *) GetStringInfoDatum(profile),
4771 GetStringInfoLength(profile));
4773 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4776 if (LocaleCompare(attribute,"icm") == 0)
4778 if (image != (Image *) NULL)
4783 profile=GetImageProfile(image,"icm");
4784 if (profile != (const StringInfo *) NULL)
4785 s=newSVpv((const char *) GetStringInfoDatum(profile),
4786 GetStringInfoLength(profile));
4788 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4791 if (LocaleCompare(attribute,"id") == 0)
4793 if (image != (Image *) NULL)
4804 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4806 status=SetImageRegistry(ImageRegistryType,key,image,
4811 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4814 if (LocaleNCompare(attribute,"index",5) == 0)
4817 name[MaxTextExtent];
4826 register const Quantum
4832 if (image == (Image *) NULL)
4834 if (image->storage_class != PseudoClass)
4838 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4840 image_view=AcquireCacheView(image);
4841 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4842 if (p != (const Quantum *) NULL)
4844 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4845 GetPixelIndex(image,p));
4847 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4849 image_view=DestroyCacheView(image_view);
4852 if (LocaleCompare(attribute,"iptc") == 0)
4854 if (image != (Image *) NULL)
4859 profile=GetImageProfile(image,"iptc");
4860 if (profile != (const StringInfo *) NULL)
4861 s=newSVpv((const char *) GetStringInfoDatum(profile),
4862 GetStringInfoLength(profile));
4864 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4867 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4869 if (image != (Image *) NULL)
4870 s=newSViv((ssize_t) image->iterations);
4871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4874 if (LocaleCompare(attribute,"interlace") == 0)
4876 j=info ? info->image_info->interlace : image ? image->interlace :
4879 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4882 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4885 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4892 if (LocaleCompare(attribute,"label") == 0)
4897 if (image == (Image *) NULL)
4899 value=GetImageProperty(image,"Label");
4900 if (value != (const char *) NULL)
4902 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4905 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4907 if (image != (Image *) NULL)
4908 s=newSViv((ssize_t) image->iterations);
4909 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4912 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4919 if (LocaleCompare(attribute,"magick") == 0)
4921 if (info && *info->image_info->magick)
4922 s=newSVpv(info->image_info->magick,0);
4923 if (image != (Image *) NULL)
4924 s=newSVpv(image->magick,0);
4925 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4928 if (LocaleCompare(attribute,"map") == 0)
4930 s=newSViv(GetMagickResource(MapResource));
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 if (LocaleCompare(attribute,"maximum-error") == 0)
4936 if (image != (Image *) NULL)
4937 s=newSVnv(image->error.normalized_maximum_error);
4938 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4941 if (LocaleCompare(attribute,"memory") == 0)
4943 s=newSViv(GetMagickResource(MemoryResource));
4944 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4947 if (LocaleCompare(attribute,"mean-error") == 0)
4949 if (image != (Image *) NULL)
4950 s=newSVnv(image->error.normalized_mean_error);
4951 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4954 if (LocaleCompare(attribute,"mime") == 0)
4956 if (info && *info->image_info->magick)
4957 s=newSVpv(MagickToMime(info->image_info->magick),0);
4958 if (image != (Image *) NULL)
4959 s=newSVpv(MagickToMime(image->magick),0);
4960 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4963 if (LocaleCompare(attribute,"mattecolor") == 0)
4965 if (image == (Image *) NULL)
4967 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4968 QuantumFormat "," QuantumFormat "," QuantumFormat,
4969 image->matte_color.red,image->matte_color.green,
4970 image->matte_color.blue,image->matte_color.alpha);
4972 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4975 if (LocaleCompare(attribute,"matte") == 0)
4977 if (image != (Image *) NULL)
4978 s=newSViv((ssize_t) image->matte);
4979 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4982 if (LocaleCompare(attribute,"mime") == 0)
4988 if (info && *info->image_info->magick)
4989 magick=info->image_info->magick;
4990 if (image != (Image *) NULL)
4991 magick=image->magick;
4997 mime=MagickToMime(magick);
4999 mime=(char *) RelinquishMagickMemory(mime);
5001 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5004 if (LocaleCompare(attribute,"monochrome") == 0)
5006 if (image == (Image *) NULL)
5008 j=info ? info->image_info->monochrome :
5009 IsImageMonochrome(image,&image->exception);
5011 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5014 if (LocaleCompare(attribute,"montage") == 0)
5016 if (image && image->montage)
5017 s=newSVpv(image->montage,0);
5018 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5021 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5028 if (LocaleCompare(attribute,"orientation") == 0)
5030 j=info ? info->image_info->orientation : image ?
5031 image->orientation : UndefinedOrientation;
5033 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5036 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5039 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5046 if (LocaleCompare(attribute,"page") == 0)
5048 if (info && info->image_info->page)
5049 s=newSVpv(info->image_info->page,0);
5050 if (image != (Image *) NULL)
5053 geometry[MaxTextExtent];
5055 (void) FormatLocaleString(geometry,MaxTextExtent,
5056 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5057 (double) image->page.height,(double) image->page.x,(double)
5059 s=newSVpv(geometry,0);
5061 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5064 if (LocaleCompare(attribute,"page.x") == 0)
5066 if (image != (Image *) NULL)
5067 s=newSViv((ssize_t) image->page.x);
5068 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5071 if (LocaleCompare(attribute,"page.y") == 0)
5073 if (image != (Image *) NULL)
5074 s=newSViv((ssize_t) image->page.y);
5075 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5078 if (LocaleNCompare(attribute,"pixel",5) == 0)
5081 tuple[MaxTextExtent];
5090 register const Quantum
5093 if (image == (Image *) NULL)
5097 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5099 p=GetVirtualPixels(image,x,y,1,1,exception);
5100 if (image->colorspace != CMYKColorspace)
5101 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5102 QuantumFormat "," QuantumFormat "," QuantumFormat,
5103 GetPixelRed(image,p),GetPixelGreen(image,p),
5104 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5106 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5107 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5108 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5109 GetPixelBlue(image,p),GetPixelBlack(image,p),
5110 GetPixelAlpha(image,p));
5112 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5115 if (LocaleCompare(attribute,"pointsize") == 0)
5118 s=newSViv((ssize_t) info->image_info->pointsize);
5119 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5122 if (LocaleCompare(attribute,"preview") == 0)
5124 s=newSViv(info->image_info->preview_type);
5125 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5126 info->image_info->preview_type));
5128 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5131 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5138 if (LocaleCompare(attribute,"quality") == 0)
5141 s=newSViv((ssize_t) info->image_info->quality);
5142 if (image != (Image *) NULL)
5143 s=newSViv((ssize_t) image->quality);
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 if (LocaleCompare(attribute,"quantum") == 0)
5150 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5151 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5154 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5161 if (LocaleCompare(attribute,"rendering-intent") == 0)
5163 s=newSViv(image->rendering_intent);
5164 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5165 image->rendering_intent));
5167 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5170 if (LocaleCompare(attribute,"red-primary") == 0)
5172 if (image == (Image *) NULL)
5174 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5175 image->chromaticity.red_primary.x,
5176 image->chromaticity.red_primary.y);
5178 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5181 if (LocaleCompare(attribute,"rows") == 0)
5183 if (image != (Image *) NULL)
5184 s=newSViv((ssize_t) image->rows);
5185 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5195 if (LocaleCompare(attribute,"sampling-factor") == 0)
5197 if (info && info->image_info->sampling_factor)
5198 s=newSVpv(info->image_info->sampling_factor,0);
5199 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5202 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5204 if (info && info->image_info->server_name)
5205 s=newSVpv(info->image_info->server_name,0);
5206 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5209 if (LocaleCompare(attribute,"size") == 0)
5211 if (info && info->image_info->size)
5212 s=newSVpv(info->image_info->size,0);
5213 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5216 if (LocaleCompare(attribute,"scene") == 0)
5218 if (image != (Image *) NULL)
5219 s=newSViv((ssize_t) image->scene);
5220 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5223 if (LocaleCompare(attribute,"scenes") == 0)
5225 if (image != (Image *) NULL)
5226 s=newSViv((ssize_t) info->image_info->number_scenes);
5227 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5230 if (LocaleCompare(attribute,"signature") == 0)
5235 if (image == (Image *) NULL)
5237 (void) SignatureImage(image);
5238 value=GetImageProperty(image,"Signature");
5239 if (value != (const char *) NULL)
5241 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5244 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5251 if (LocaleCompare(attribute,"taint") == 0)
5253 if (image != (Image *) NULL)
5254 s=newSViv((ssize_t) IsTaintImage(image));
5255 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5258 if (LocaleCompare(attribute,"texture") == 0)
5260 if (info && info->image_info->texture)
5261 s=newSVpv(info->image_info->texture,0);
5262 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5265 if (LocaleCompare(attribute,"total-ink-density") == 0)
5267 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5268 if (image != (Image *) NULL)
5269 s=newSVnv(GetImageTotalInkDensity(image));
5270 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5273 if (LocaleCompare(attribute,"transparent-color") == 0)
5275 if (image == (Image *) NULL)
5277 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5278 QuantumFormat "," QuantumFormat "," QuantumFormat,
5279 image->transparent_color.red,image->transparent_color.green,
5280 image->transparent_color.blue,image->transparent_color.alpha);
5282 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5285 if (LocaleCompare(attribute,"type") == 0)
5287 if (image == (Image *) NULL)
5289 j=(ssize_t) GetImageType(image,&image->exception);
5291 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5293 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5296 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5303 if (LocaleCompare(attribute,"units") == 0)
5305 j=info ? info->image_info->units : image ? image->units :
5306 UndefinedResolution;
5307 if (info && (info->image_info->units == UndefinedResolution))
5310 if (j == UndefinedResolution)
5311 s=newSVpv("undefined units",0);
5313 if (j == PixelsPerInchResolution)
5314 s=newSVpv("pixels / inch",0);
5316 s=newSVpv("pixels / centimeter",0);
5317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 if (LocaleCompare(attribute,"user-time") == 0)
5322 if (image != (Image *) NULL)
5323 s=newSVnv(GetUserTime(&image->timer));
5324 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5327 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5334 if (LocaleCompare(attribute,"verbose") == 0)
5337 s=newSViv((ssize_t) info->image_info->verbose);
5338 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5341 if (LocaleCompare(attribute,"version") == 0)
5343 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"view") == 0)
5349 if (info && info->image_info->view)
5350 s=newSVpv(info->image_info->view,0);
5351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5354 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5356 if (image == (Image *) NULL)
5358 j=(ssize_t) GetImageVirtualPixelMethod(image);
5360 (void) sv_setpv(s,CommandOptionToMnemonic(
5361 MagickVirtualPixelOptions,j));
5363 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5366 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5373 if (LocaleCompare(attribute,"white-point") == 0)
5375 if (image == (Image *) NULL)
5377 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5378 image->chromaticity.white_point.x,
5379 image->chromaticity.white_point.y);
5381 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5384 if (LocaleCompare(attribute,"width") == 0)
5386 if (image != (Image *) NULL)
5387 s=newSViv((ssize_t) image->columns);
5388 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5398 if (LocaleCompare(attribute,"x-resolution") == 0)
5400 if (image != (Image *) NULL)
5401 s=newSVnv(image->x_resolution);
5402 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5412 if (LocaleCompare(attribute,"y-resolution") == 0)
5414 if (image != (Image *) NULL)
5415 s=newSVnv(image->y_resolution);
5416 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5419 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5426 if (image == (Image *) NULL)
5427 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5431 value=GetImageProperty(image,attribute);
5432 if (value != (const char *) NULL)
5435 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5438 if (*attribute != '%')
5439 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5446 meta=InterpretImageProperties(info ? info->image_info :
5447 (ImageInfo *) NULL,image,attribute);
5449 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5450 meta=(char *) RelinquishMagickMemory(meta);
5454 exception=DestroyExceptionInfo(exception);
5455 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5459 ###############################################################################
5463 # G e t A u t h e n t i c P i x e l s #
5467 ###############################################################################
5471 GetAuthenticPixels(ref,...)
5472 Image::Magick ref = NO_INIT
5474 getauthenticpixels = 1
5504 PERL_UNUSED_VAR(ref);
5505 PERL_UNUSED_VAR(ix);
5506 exception=AcquireExceptionInfo();
5507 perl_exception=newSVpv("",0);
5508 if (sv_isobject(ST(0)) == 0)
5510 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5514 reference=SvRV(ST(0));
5516 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5517 if (image == (Image *) NULL)
5519 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5526 region.width=image->columns;
5529 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5530 for (i=2; i < items; i+=2)
5532 attribute=(char *) SvPV(ST(i-1),na);
5538 if (LocaleCompare(attribute,"geometry") == 0)
5540 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5550 if (LocaleCompare(attribute,"height") == 0)
5552 region.height=SvIV(ST(i));
5555 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5562 if (LocaleCompare(attribute,"x") == 0)
5564 region.x=SvIV(ST(i));
5567 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5574 if (LocaleCompare(attribute,"y") == 0)
5576 region.y=SvIV(ST(i));
5579 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5586 if (LocaleCompare(attribute,"width") == 0)
5588 region.width=SvIV(ST(i));
5591 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5597 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5598 region.height,exception);
5599 if (blob != (void *) NULL)
5603 InheritPerlException(exception,perl_exception);
5604 exception=DestroyExceptionInfo(exception);
5605 SvREFCNT_dec(perl_exception); /* throw away all errors */
5614 ###############################################################################
5618 # G e t V i r t u a l P i x e l s #
5622 ###############################################################################
5626 GetVirtualPixels(ref,...)
5627 Image::Magick ref = NO_INIT
5629 getvirtualpixels = 1
5630 AcquireImagePixels = 2
5631 acquireimagepixels = 3
5659 PERL_UNUSED_VAR(ref);
5660 PERL_UNUSED_VAR(ix);
5661 exception=AcquireExceptionInfo();
5662 perl_exception=newSVpv("",0);
5663 if (sv_isobject(ST(0)) == 0)
5665 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5669 reference=SvRV(ST(0));
5671 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5672 if (image == (Image *) NULL)
5674 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5681 region.width=image->columns;
5684 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5685 for (i=2; i < items; i+=2)
5687 attribute=(char *) SvPV(ST(i-1),na);
5693 if (LocaleCompare(attribute,"geometry") == 0)
5695 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5705 if (LocaleCompare(attribute,"height") == 0)
5707 region.height=SvIV(ST(i));
5710 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5717 if (LocaleCompare(attribute,"x") == 0)
5719 region.x=SvIV(ST(i));
5722 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5729 if (LocaleCompare(attribute,"y") == 0)
5731 region.y=SvIV(ST(i));
5734 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5741 if (LocaleCompare(attribute,"width") == 0)
5743 region.width=SvIV(ST(i));
5746 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5752 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5753 region.height,exception);
5754 if (blob != (void *) NULL)
5758 InheritPerlException(exception,perl_exception);
5759 exception=DestroyExceptionInfo(exception);
5760 SvREFCNT_dec(perl_exception); /* throw away all errors */
5763 RETVAL = (void *) blob;
5769 ###############################################################################
5773 # G e t A u t h e n t i c M e t a c o n t e n t #
5777 ###############################################################################
5781 GetAuthenticMetacontent(ref,...)
5782 Image::Magick ref = NO_INIT
5784 getauthenticmetacontent = 1
5805 PERL_UNUSED_VAR(ref);
5806 PERL_UNUSED_VAR(ix);
5807 exception=AcquireExceptionInfo();
5808 perl_exception=newSVpv("",0);
5809 if (sv_isobject(ST(0)) == 0)
5811 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5815 reference=SvRV(ST(0));
5817 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5818 if (image == (Image *) NULL)
5820 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5825 blob=(void *) GetAuthenticMetacontent(image);
5826 if (blob != (void *) NULL)
5830 InheritPerlException(exception,perl_exception);
5831 exception=DestroyExceptionInfo(exception);
5832 SvREFCNT_dec(perl_exception); /* throw away all errors */
5841 ###############################################################################
5845 # G e t V i r t u a l M e t a c o n t e n t #
5849 ###############################################################################
5853 GetVirtualMetacontent(ref,...)
5854 Image::Magick ref = NO_INIT
5856 getvirtualmetacontent = 1
5875 PERL_UNUSED_VAR(ref);
5876 PERL_UNUSED_VAR(ix);
5877 exception=AcquireExceptionInfo();
5878 perl_exception=newSVpv("",0);
5879 if (sv_isobject(ST(0)) == 0)
5881 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5885 reference=SvRV(ST(0));
5887 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5888 if (image == (Image *) NULL)
5890 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5895 blob=(void *) GetVirtualMetacontent(image);
5896 if (blob != (void *) NULL)
5900 InheritPerlException(exception,perl_exception);
5901 exception=DestroyExceptionInfo(exception);
5902 SvREFCNT_dec(perl_exception); /* throw away all errors */
5911 ###############################################################################
5915 # H i s t o g r a m #
5919 ###############################################################################
5924 Image::Magick ref=NO_INIT
5935 message[MaxTextExtent];
5962 PERL_UNUSED_VAR(ref);
5963 PERL_UNUSED_VAR(ix);
5964 exception=AcquireExceptionInfo();
5965 perl_exception=newSVpv("",0);
5967 if (sv_isobject(ST(0)) == 0)
5969 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5973 reference=SvRV(ST(0));
5976 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5977 if (image == (Image *) NULL)
5979 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5983 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5985 for ( ; image; image=image->next)
5987 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5988 if (histogram == (PixelPacket *) NULL)
5990 count+=(ssize_t) number_colors;
5992 for (i=0; i < (ssize_t) number_colors; i++)
5994 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5996 PUSHs(sv_2mortal(newSVpv(message,0)));
5997 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5998 histogram[i].green);
5999 PUSHs(sv_2mortal(newSVpv(message,0)));
6000 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6002 PUSHs(sv_2mortal(newSVpv(message,0)));
6003 if (image->colorspace == CMYKColorspace)
6005 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6006 histogram[i].black);
6007 PUSHs(sv_2mortal(newSVpv(message,0)));
6009 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6010 histogram[i].alpha);
6011 PUSHs(sv_2mortal(newSVpv(message,0)));
6012 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6013 histogram[i].count);
6014 PUSHs(sv_2mortal(newSVpv(message,0)));
6016 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6020 InheritPerlException(exception,perl_exception);
6021 exception=DestroyExceptionInfo(exception);
6022 SvREFCNT_dec(perl_exception);
6026 ###############################################################################
6034 ###############################################################################
6039 Image::Magick ref=NO_INIT
6066 register const Quantum
6080 *reference; /* reference is the SV* of ref=SvIV(reference) */
6082 PERL_UNUSED_VAR(ref);
6083 PERL_UNUSED_VAR(ix);
6084 exception=AcquireExceptionInfo();
6085 perl_exception=newSVpv("",0);
6086 reference=SvRV(ST(0));
6087 av=(AV *) reference;
6088 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6090 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6091 if (image == (Image *) NULL)
6093 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6097 channel=DefaultChannels;
6098 normalize=MagickTrue;
6101 region.width=image->columns;
6104 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6105 for (i=2; i < items; i+=2)
6107 attribute=(char *) SvPV(ST(i-1),na);
6113 if (LocaleCompare(attribute,"channel") == 0)
6118 option=ParseChannelOption(SvPV(ST(i),na));
6121 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6125 channel=(ChannelType) option;
6128 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6135 if (LocaleCompare(attribute,"geometry") == 0)
6137 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6140 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6147 if (LocaleCompare(attribute,"normalize") == 0)
6149 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6153 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6157 normalize=option != 0 ? MagickTrue : MagickFalse;
6160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6167 if (LocaleCompare(attribute,"x") == 0)
6169 region.x=SvIV(ST(i));
6172 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6179 if (LocaleCompare(attribute,"y") == 0)
6181 region.y=SvIV(ST(i));
6184 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6190 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6196 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6197 if (p == (const Quantum *) NULL)
6205 if (normalize != MagickFalse)
6206 scale=1.0/QuantumRange;
6207 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
6208 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6209 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
6210 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6211 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
6212 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6213 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
6214 (image->colorspace == CMYKColorspace))
6215 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6216 if ((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0)
6217 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6221 InheritPerlException(exception,perl_exception);
6222 exception=DestroyExceptionInfo(exception);
6223 SvREFCNT_dec(perl_exception);
6227 ###############################################################################
6231 # G e t P i x e l s #
6235 ###############################################################################
6240 Image::Magick ref=NO_INIT
6279 *reference; /* reference is the SV* of ref=SvIV(reference) */
6281 PERL_UNUSED_VAR(ref);
6282 PERL_UNUSED_VAR(ix);
6283 exception=AcquireExceptionInfo();
6284 perl_exception=newSVpv("",0);
6285 reference=SvRV(ST(0));
6286 av=(AV *) reference;
6287 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6289 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6290 if (image == (Image *) NULL)
6292 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6297 if (image->matte != MagickFalse)
6299 if (image->colorspace == CMYKColorspace)
6302 if (image->matte != MagickFalse)
6305 normalize=MagickFalse;
6308 region.width=image->columns;
6311 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6312 for (i=2; i < items; i+=2)
6314 attribute=(char *) SvPV(ST(i-1),na);
6320 if (LocaleCompare(attribute,"geometry") == 0)
6322 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6325 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6332 if (LocaleCompare(attribute,"height") == 0)
6334 region.height=SvIV(ST(i));
6337 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6344 if (LocaleCompare(attribute,"map") == 0)
6349 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6356 if (LocaleCompare(attribute,"normalize") == 0)
6358 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6362 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6366 normalize=option != 0 ? MagickTrue : MagickFalse;
6369 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6376 if (LocaleCompare(attribute,"width") == 0)
6378 region.width=SvIV(ST(i));
6381 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6388 if (LocaleCompare(attribute,"x") == 0)
6390 region.x=SvIV(ST(i));
6393 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6400 if (LocaleCompare(attribute,"y") == 0)
6402 region.y=SvIV(ST(i));
6405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6411 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6417 if (normalize != MagickFalse)
6422 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6423 region.height*sizeof(*pixels));
6424 if (pixels == (float *) NULL)
6426 ThrowPerlException(exception,ResourceLimitError,
6427 "MemoryAllocationFailed",PackageName);
6430 status=ExportImagePixels(image,region.x,region.y,region.width,
6431 region.height,map,FloatPixel,pixels,exception);
6432 if (status == MagickFalse)
6436 EXTEND(sp,strlen(map)*region.width*region.height);
6437 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6438 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6440 pixels=(float *) RelinquishMagickMemory(pixels);
6447 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6448 region.height*sizeof(*pixels));
6449 if (pixels == (Quantum *) NULL)
6451 ThrowPerlException(exception,ResourceLimitError,
6452 "MemoryAllocationFailed",PackageName);
6455 status=ExportImagePixels(image,region.x,region.y,region.width,
6456 region.height,map,QuantumPixel,pixels,exception);
6457 if (status == MagickFalse)
6461 EXTEND(sp,strlen(map)*region.width*region.height);
6462 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6463 PUSHs(sv_2mortal(newSViv(pixels[i])));
6465 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6469 InheritPerlException(exception,perl_exception);
6470 exception=DestroyExceptionInfo(exception);
6471 SvREFCNT_dec(perl_exception);
6475 ###############################################################################
6479 # I m a g e T o B l o b #
6483 ###############################################################################
6487 ImageToBlob(ref,...)
6488 Image::Magick ref=NO_INIT
6497 filename[MaxTextExtent];
6526 PERL_UNUSED_VAR(ref);
6527 PERL_UNUSED_VAR(ix);
6528 exception=AcquireExceptionInfo();
6529 perl_exception=newSVpv("",0);
6530 package_info=(struct PackageInfo *) NULL;
6531 if (sv_isobject(ST(0)) == 0)
6533 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6537 reference=SvRV(ST(0));
6538 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6539 if (image == (Image *) NULL)
6541 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6545 package_info=ClonePackageInfo(info,exception);
6546 for (i=2; i < items; i+=2)
6547 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6548 (void) CopyMagickString(filename,package_info->image_info->filename,
6551 for (next=image; next; next=next->next)
6553 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6554 next->scene=scene++;
6556 SetImageInfo(package_info->image_info,(unsigned int)
6557 GetImageListLength(image),&image->exception);
6558 EXTEND(sp,(ssize_t) GetImageListLength(image));
6559 for ( ; image; image=image->next)
6562 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6563 if (blob != (char *) NULL)
6565 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6566 blob=(unsigned char *) RelinquishMagickMemory(blob);
6568 if (package_info->image_info->adjoin)
6573 if (package_info != (struct PackageInfo *) NULL)
6574 DestroyPackageInfo(package_info);
6575 InheritPerlException(exception,perl_exception);
6576 exception=DestroyExceptionInfo(exception);
6577 SvREFCNT_dec(perl_exception); /* throw away all errors */
6581 ###############################################################################
6589 ###############################################################################
6594 Image::Magick ref=NO_INIT
6598 OptimizeImageLayers = 3
6600 optimizeimagelayers = 5
6642 PERL_UNUSED_VAR(ref);
6643 PERL_UNUSED_VAR(ix);
6644 exception=AcquireExceptionInfo();
6645 perl_exception=newSVpv("",0);
6647 if (sv_isobject(ST(0)) == 0)
6649 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6653 reference=SvRV(ST(0));
6654 hv=SvSTASH(reference);
6656 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6658 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6659 if (image == (Image *) NULL)
6661 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6665 compose=image->compose;
6666 method=OptimizeLayer;
6667 for (i=2; i < items; i+=2)
6669 attribute=(char *) SvPV(ST(i-1),na);
6675 if (LocaleCompare(attribute,"compose") == 0)
6677 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6678 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6681 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6685 compose=(CompositeOperator) sp;
6688 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6695 if (LocaleCompare(attribute,"method") == 0)
6697 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6701 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6705 method=(ImageLayerMethod) option;
6708 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6714 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6720 layers=(Image *) NULL;
6723 case CompareAnyLayer:
6724 case CompareClearLayer:
6725 case CompareOverlayLayer:
6728 layers=CompareImageLayers(image,method,exception);
6735 layers=MergeImageLayers(image,method,exception);
6740 layers=DisposeImages(image,exception);
6743 case OptimizeImageLayer:
6745 layers=OptimizeImageLayers(image,exception);
6748 case OptimizePlusLayer:
6750 layers=OptimizePlusImageLayers(image,exception);
6753 case OptimizeTransLayer:
6755 OptimizeImageTransparency(image,exception);
6756 InheritException(&(image->exception),exception);
6759 case RemoveDupsLayer:
6761 RemoveDuplicateLayers(&image,exception);
6762 InheritException(&(image->exception),exception);
6765 case RemoveZeroLayer:
6767 RemoveZeroDelayLayers(&image,exception);
6768 InheritException(&(image->exception),exception);
6777 General Purpose, GIF Animation Optimizer.
6779 layers=CoalesceImages(image,exception);
6780 if (layers == (Image *) NULL)
6782 InheritException(&(layers->exception),exception);
6784 layers=OptimizeImageLayers(image,exception);
6785 if (layers == (Image *) NULL)
6787 InheritException(&(layers->exception),exception);
6788 image=DestroyImageList(image);
6790 layers=(Image *) NULL;
6791 OptimizeImageTransparency(image,exception);
6792 InheritException(&(image->exception),exception);
6793 quantize_info=AcquireQuantizeInfo(info->image_info);
6794 (void) RemapImages(quantize_info,image,(Image *) NULL);
6795 quantize_info=DestroyQuantizeInfo(quantize_info);
6798 case CompositeLayer:
6807 Split image sequence at the first 'NULL:' image.
6810 while (source != (Image *) NULL)
6812 source=GetNextImageInList(source);
6813 if ((source != (Image *) NULL) &&
6814 (LocaleCompare(source->magick,"NULL") == 0))
6817 if (source != (Image *) NULL)
6819 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6820 (GetNextImageInList(source) == (Image *) NULL))
6821 source=(Image *) NULL;
6825 Separate the two lists, junk the null: image.
6827 source=SplitImageList(source->previous);
6828 DeleteImageFromList(&source);
6831 if (source == (Image *) NULL)
6833 (void) ThrowMagickException(exception,GetMagickModule(),
6834 OptionError,"MissingNullSeparator","layers Composite");
6838 Adjust offset with gravity and virtual canvas.
6840 SetGeometry(image,&geometry);
6841 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6842 geometry.width=source->page.width != 0 ? source->page.width :
6844 geometry.height=source->page.height != 0 ? source->page.height :
6846 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6847 image->columns,image->page.height != 0 ? image->page.height :
6848 image->rows,image->gravity,&geometry);
6849 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6850 source=DestroyImageList(source);
6851 InheritException(&(image->exception),exception);
6855 if (layers != (Image *) NULL)
6857 InheritException(&(layers->exception),exception);
6860 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6862 for ( ; image; image=image->next)
6864 AddImageToRegistry(sv,image);
6866 av_push(av,sv_bless(rv,hv));
6869 exception=DestroyExceptionInfo(exception);
6871 SvREFCNT_dec(perl_exception);
6875 InheritPerlException(exception,perl_exception);
6876 exception=DestroyExceptionInfo(exception);
6877 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6878 SvPOK_on(perl_exception);
6879 ST(0)=sv_2mortal(perl_exception);
6884 ###############################################################################
6888 # M a g i c k T o M i m e #
6892 ###############################################################################
6896 MagickToMime(ref,name)
6897 Image::Magick ref=NO_INIT
6906 PERL_UNUSED_VAR(ref);
6907 PERL_UNUSED_VAR(ix);
6908 mime=MagickToMime(name);
6909 RETVAL=newSVpv(mime,0);
6910 mime=(char *) RelinquishMagickMemory(mime);
6916 ###############################################################################
6924 ###############################################################################
6929 Image::Magick ref=NO_INIT
6966 MedianFilterImage = 36
6972 ReduceNoiseImage = 42
6998 ColorFloodfillImage= 68
7004 CycleColormapImage = 74
7014 MatteFloodfillImage= 84
7022 NumberColorsImage = 92
7032 SignatureImage = 102
7042 TransparentImage = 112
7044 ThresholdImage = 114
7058 DeconstructImage = 130
7060 GaussianBlurImage = 132
7066 UnsharpMaskImage = 138
7068 MotionBlurImage = 140
7070 OrderedDitherImage = 142
7077 AffineTransform = 149
7078 AffineTransformImage = 150
7080 DifferenceImage = 152
7081 AdaptiveThreshold = 153
7082 AdaptiveThresholdImage = 154
7087 BlackThreshold = 159
7088 BlackThresholdImage= 160
7089 WhiteThreshold = 161
7090 WhiteThresholdImage= 162
7092 RadialBlurImage = 164
7094 ThumbnailImage = 166
7104 PosterizeImage = 176
7110 SepiaToneImage = 182
7111 SigmoidalContrast = 183
7112 SigmoidalContrastImage = 184
7117 ContrastStretch = 189
7118 ContrastStretchImage = 190
7123 AdaptiveSharpen = 195
7124 AdaptiveSharpenImage = 196
7126 TransposeImage = 198
7128 TransverseImage = 200
7130 AutoOrientImage = 202
7132 AdaptiveBlurImage = 204
7136 UniqueColorsImage = 208
7137 AdaptiveResize = 209
7138 AdaptiveResizeImage= 210
7142 LinearStretchImage = 214
7149 FloodfillPaint = 221
7150 FloodfillPaintImage= 222
7156 LiquidRescaleImage = 228
7166 SparseColorImage = 238
7170 SelectiveBlurImage = 242
7174 BlueShiftImage = 246
7175 ForwardFourierTransform = 247
7176 ForwardFourierTransformImage = 248
7177 InverseFourierTransform = 249
7178 InverseFourierTransformImage = 250
7179 ColorDecisionList = 251
7180 ColorDecisionListImage = 252
7182 AutoGammaImage = 254
7184 AutoLevelImage = 256
7186 LevelColorsImage = 258
7191 BrightnessContrast = 263
7192 BrightnessContrastImage = 264
7194 MorphologyImage = 266
7196 ColorMatrixImage = 268
7202 StatisticImage = 274
7211 attribute_flag[MaxArguments],
7212 message[MaxTextExtent];
7272 argument_list[MaxArguments];
7274 PERL_UNUSED_VAR(ref);
7275 PERL_UNUSED_VAR(ix);
7276 exception=AcquireExceptionInfo();
7277 perl_exception=newSVpv("",0);
7278 reference_vector=NULL;
7282 if (sv_isobject(ST(0)) == 0)
7284 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7288 reference=SvRV(ST(0));
7289 region_info.width=0;
7290 region_info.height=0;
7293 region_image=(Image *) NULL;
7294 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7295 if (ix && (ix != 666))
7298 Called as Method(...)
7301 rp=(&Methods[ix-1]);
7307 Called as Mogrify("Method",...)
7309 attribute=(char *) SvPV(ST(1),na);
7312 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7313 attribute=(char *) SvPV(ST(2),na);
7316 for (rp=Methods; ; rp++)
7318 if (rp >= EndOf(Methods))
7320 ThrowPerlException(exception,OptionError,
7321 "UnrecognizedPerlMagickMethod",attribute);
7324 if (strEQcase(attribute,rp->name))
7330 if (image == (Image *) NULL)
7332 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7335 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7336 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7337 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7354 pp=(Arguments *) NULL;
7362 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7364 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7366 if (strEQcase(attribute,qq->method) > ssize_test)
7369 ssize_test=strEQcase(attribute,qq->method);
7372 if (pp == (Arguments *) NULL)
7374 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7376 goto continue_outer_loop;
7378 al=(&argument_list[pp-rp->arguments]);
7381 case ArrayReference:
7383 if (SvTYPE(sv) != SVt_RV)
7385 (void) FormatLocaleString(message,MaxTextExtent,
7386 "invalid %.60s value",pp->method);
7387 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7388 goto continue_outer_loop;
7390 al->array_reference=SvRV(sv);
7395 al->real_reference=SvNV(sv);
7400 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7403 case ImageReference:
7405 if (!sv_isobject(sv) ||
7406 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7407 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7409 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7415 case IntegerReference:
7417 al->integer_reference=SvIV(sv);
7420 case StringReference:
7422 al->string_reference=(char *) SvPV(sv,al->length);
7423 if (sv_isobject(sv))
7424 al->image_reference=SetupList(aTHX_ SvRV(sv),
7425 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7431 Is a string; look up name.
7433 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7435 al->string_reference=(char *) SvPV(sv,al->length);
7436 al->integer_reference=(-1);
7439 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7440 MagickFalse,SvPV(sv,na));
7441 if (pp->type == MagickChannelOptions)
7442 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7443 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7445 (void) FormatLocaleString(message,MaxTextExtent,
7446 "invalid %.60s value",pp->method);
7447 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7448 goto continue_outer_loop;
7453 attribute_flag[pp-rp->arguments]++;
7454 continue_outer_loop: ;
7456 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7457 pv=reference_vector;
7458 SetGeometryInfo(&geometry_info);
7459 channel=DefaultChannels;
7460 for (next=image; next; next=next->next)
7463 SetGeometry(image,&geometry);
7464 if ((region_info.width*region_info.height) != 0)
7467 image=CropImage(image,®ion_info,exception);
7473 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7474 ThrowPerlException(exception,OptionError,
7475 "UnrecognizedPerlMagickMethod",message);
7478 case 1: /* Comment */
7480 if (attribute_flag[0] == 0)
7481 argument_list[0].string_reference=(char *) NULL;
7482 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7483 info ? info->image_info : (ImageInfo *) NULL,image,
7484 argument_list[0].string_reference));
7489 if (attribute_flag[0] == 0)
7490 argument_list[0].string_reference=(char *) NULL;
7491 (void) SetImageProperty(image,"label",InterpretImageProperties(
7492 info ? info->image_info : (ImageInfo *) NULL,image,
7493 argument_list[0].string_reference));
7496 case 3: /* AddNoise */
7498 if (attribute_flag[0] == 0)
7499 argument_list[0].integer_reference=UniformNoise;
7500 if (attribute_flag[1] != 0)
7501 channel=(ChannelType) argument_list[1].integer_reference;
7502 image=AddNoiseImageChannel(image,channel,(NoiseType)
7503 argument_list[0].integer_reference,exception);
7506 case 4: /* Colorize */
7511 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7512 if (attribute_flag[0] != 0)
7513 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7515 if (attribute_flag[1] == 0)
7516 argument_list[1].string_reference="100%";
7517 image=ColorizeImage(image,argument_list[1].string_reference,target,
7521 case 5: /* Border */
7525 if (attribute_flag[0] != 0)
7527 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7528 &geometry,exception);
7529 if ((flags & HeightValue) == 0)
7530 geometry.height=geometry.width;
7532 if (attribute_flag[1] != 0)
7533 geometry.width=argument_list[1].integer_reference;
7534 if (attribute_flag[2] != 0)
7535 geometry.height=argument_list[2].integer_reference;
7536 if (attribute_flag[3] != 0)
7537 QueryColorDatabase(argument_list[3].string_reference,
7538 &image->border_color,exception);
7539 if (attribute_flag[4] != 0)
7540 QueryColorDatabase(argument_list[4].string_reference,
7541 &image->border_color,exception);
7542 if (attribute_flag[5] != 0)
7543 QueryColorDatabase(argument_list[5].string_reference,
7544 &image->border_color,exception);
7545 if (attribute_flag[6] != 0)
7546 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7547 image=BorderImage(image,&geometry,exception);
7552 if (attribute_flag[0] != 0)
7554 flags=ParseGeometry(argument_list[0].string_reference,
7556 if ((flags & SigmaValue) == 0)
7557 geometry_info.sigma=1.0;
7559 if (attribute_flag[1] != 0)
7560 geometry_info.rho=argument_list[1].real_reference;
7561 if (attribute_flag[2] != 0)
7562 geometry_info.sigma=argument_list[2].real_reference;
7563 if (attribute_flag[3] != 0)
7564 channel=(ChannelType) argument_list[3].integer_reference;
7565 image=BlurImageChannel(image,channel,geometry_info.rho,
7566 geometry_info.sigma,exception);
7571 if (attribute_flag[0] != 0)
7572 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7573 &geometry,exception);
7574 if (attribute_flag[1] != 0)
7575 geometry.width=argument_list[1].integer_reference;
7576 if (attribute_flag[2] != 0)
7577 geometry.height=argument_list[2].integer_reference;
7578 if (attribute_flag[3] != 0)
7579 geometry.x=argument_list[3].integer_reference;
7580 if (attribute_flag[4] != 0)
7581 geometry.y=argument_list[4].integer_reference;
7582 image=ChopImage(image,&geometry,exception);
7587 if (attribute_flag[6] != 0)
7588 image->gravity=(GravityType) argument_list[6].integer_reference;
7589 if (attribute_flag[0] != 0)
7590 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7591 &geometry,exception);
7592 if (attribute_flag[1] != 0)
7593 geometry.width=argument_list[1].integer_reference;
7594 if (attribute_flag[2] != 0)
7595 geometry.height=argument_list[2].integer_reference;
7596 if (attribute_flag[3] != 0)
7597 geometry.x=argument_list[3].integer_reference;
7598 if (attribute_flag[4] != 0)
7599 geometry.y=argument_list[4].integer_reference;
7600 if (attribute_flag[5] != 0)
7602 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7603 image=CropImage(image,&geometry,exception);
7606 case 9: /* Despeckle */
7608 image=DespeckleImage(image,exception);
7613 if (attribute_flag[0] != 0)
7614 geometry_info.rho=argument_list[0].real_reference;
7615 image=EdgeImage(image,geometry_info.rho,exception);
7618 case 11: /* Emboss */
7620 if (attribute_flag[0] != 0)
7622 flags=ParseGeometry(argument_list[0].string_reference,
7624 if ((flags & SigmaValue) == 0)
7625 geometry_info.sigma=1.0;
7627 if (attribute_flag[1] != 0)
7628 geometry_info.rho=argument_list[1].real_reference;
7629 if (attribute_flag[2] != 0)
7630 geometry_info.sigma=argument_list[2].real_reference;
7631 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7635 case 12: /* Enhance */
7637 image=EnhanceImage(image,exception);
7642 image=FlipImage(image,exception);
7647 image=FlopImage(image,exception);
7650 case 15: /* Frame */
7655 if (attribute_flag[0] != 0)
7657 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7658 &geometry,exception);
7659 if ((flags & HeightValue) == 0)
7660 geometry.height=geometry.width;
7661 frame_info.width=geometry.width;
7662 frame_info.height=geometry.height;
7663 frame_info.outer_bevel=geometry.x;
7664 frame_info.inner_bevel=geometry.y;
7666 if (attribute_flag[1] != 0)
7667 frame_info.width=argument_list[1].integer_reference;
7668 if (attribute_flag[2] != 0)
7669 frame_info.height=argument_list[2].integer_reference;
7670 if (attribute_flag[3] != 0)
7671 frame_info.inner_bevel=argument_list[3].integer_reference;
7672 if (attribute_flag[4] != 0)
7673 frame_info.outer_bevel=argument_list[4].integer_reference;
7674 if (attribute_flag[5] != 0)
7675 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7677 if (attribute_flag[6] != 0)
7678 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7680 frame_info.x=(ssize_t) frame_info.width;
7681 frame_info.y=(ssize_t) frame_info.height;
7682 frame_info.width=image->columns+2*frame_info.x;
7683 frame_info.height=image->rows+2*frame_info.y;
7684 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7685 image->matte_color=fill_color;
7686 if (attribute_flag[7] != 0)
7687 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7688 image=FrameImage(image,&frame_info,exception);
7691 case 16: /* Implode */
7693 if (attribute_flag[0] == 0)
7694 argument_list[0].real_reference=0.5;
7695 if (attribute_flag[1] != 0)
7696 image->interpolate=(InterpolatePixelMethod)
7697 argument_list[1].integer_reference;
7698 image=ImplodeImage(image,argument_list[0].real_reference,
7702 case 17: /* Magnify */
7704 image=MagnifyImage(image,exception);
7707 case 18: /* MedianFilter */
7709 if (attribute_flag[0] != 0)
7711 flags=ParseGeometry(argument_list[0].string_reference,
7713 if ((flags & SigmaValue) == 0)
7714 geometry_info.sigma=1.0;
7716 if (attribute_flag[1] != 0)
7717 geometry_info.rho=argument_list[1].real_reference;
7718 if (attribute_flag[2] != 0)
7719 geometry_info.sigma=argument_list[2].real_reference;
7720 if (attribute_flag[3] != 0)
7721 channel=(ChannelType) argument_list[3].integer_reference;
7722 image=StatisticImageChannel(image,channel,MedianStatistic,
7723 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7726 case 19: /* Minify */
7728 image=MinifyImage(image,exception);
7731 case 20: /* OilPaint */
7733 if (attribute_flag[0] == 0)
7734 argument_list[0].real_reference=0.0;
7735 image=OilPaintImage(image,argument_list[0].real_reference,
7739 case 21: /* ReduceNoise */
7741 if (attribute_flag[0] != 0)
7743 flags=ParseGeometry(argument_list[0].string_reference,
7745 if ((flags & SigmaValue) == 0)
7746 geometry_info.sigma=1.0;
7748 if (attribute_flag[1] != 0)
7749 geometry_info.rho=argument_list[1].real_reference;
7750 if (attribute_flag[2] != 0)
7751 geometry_info.sigma=argument_list[2].real_reference;
7752 if (attribute_flag[3] != 0)
7753 channel=(ChannelType) argument_list[3].integer_reference;
7754 image=StatisticImageChannel(image,channel,NonpeakStatistic,
7755 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7760 if (attribute_flag[0] != 0)
7761 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7762 &geometry,exception);
7763 if (attribute_flag[1] != 0)
7764 geometry.x=argument_list[1].integer_reference;
7765 if (attribute_flag[2] != 0)
7766 geometry.y=argument_list[2].integer_reference;
7767 image=RollImage(image,geometry.x,geometry.y,exception);
7770 case 23: /* Rotate */
7772 if (attribute_flag[0] == 0)
7773 argument_list[0].real_reference=90.0;
7774 if (attribute_flag[1] != 0)
7775 QueryColorDatabase(argument_list[1].string_reference,
7776 &image->background_color,exception);
7777 if (attribute_flag[2] != 0)
7778 QueryColorDatabase(argument_list[2].string_reference,
7779 &image->background_color,exception);
7780 if (attribute_flag[3] != 0)
7781 QueryColorDatabase(argument_list[3].string_reference,
7782 &image->background_color,exception);
7783 image=RotateImage(image,argument_list[0].real_reference,exception);
7786 case 24: /* Sample */
7788 if (attribute_flag[0] != 0)
7789 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7790 &geometry,exception);
7791 if (attribute_flag[1] != 0)
7792 geometry.width=argument_list[1].integer_reference;
7793 if (attribute_flag[2] != 0)
7794 geometry.height=argument_list[2].integer_reference;
7795 image=SampleImage(image,geometry.width,geometry.height,exception);
7798 case 25: /* Scale */
7800 if (attribute_flag[0] != 0)
7801 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7802 &geometry,exception);
7803 if (attribute_flag[1] != 0)
7804 geometry.width=argument_list[1].integer_reference;
7805 if (attribute_flag[2] != 0)
7806 geometry.height=argument_list[2].integer_reference;
7807 image=ScaleImage(image,geometry.width,geometry.height,exception);
7810 case 26: /* Shade */
7812 if (attribute_flag[0] != 0)
7814 flags=ParseGeometry(argument_list[0].string_reference,
7816 if ((flags & SigmaValue) == 0)
7817 geometry_info.sigma=0.0;
7819 if (attribute_flag[1] != 0)
7820 geometry_info.rho=argument_list[1].real_reference;
7821 if (attribute_flag[2] != 0)
7822 geometry_info.sigma=argument_list[2].real_reference;
7823 image=ShadeImage(image,
7824 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7825 geometry_info.rho,geometry_info.sigma,exception);
7828 case 27: /* Sharpen */
7830 if (attribute_flag[0] != 0)
7832 flags=ParseGeometry(argument_list[0].string_reference,
7834 if ((flags & SigmaValue) == 0)
7835 geometry_info.sigma=1.0;
7837 if (attribute_flag[1] != 0)
7838 geometry_info.rho=argument_list[1].real_reference;
7839 if (attribute_flag[2] != 0)
7840 geometry_info.sigma=argument_list[2].real_reference;
7841 if (attribute_flag[3] != 0)
7842 channel=(ChannelType) argument_list[3].integer_reference;
7843 image=SharpenImageChannel(image,channel,geometry_info.rho,
7844 geometry_info.sigma,exception);
7847 case 28: /* Shear */
7849 if (attribute_flag[0] != 0)
7851 flags=ParseGeometry(argument_list[0].string_reference,
7853 if ((flags & SigmaValue) == 0)
7854 geometry_info.sigma=geometry_info.rho;
7856 if (attribute_flag[1] != 0)
7857 geometry_info.rho=argument_list[1].real_reference;
7858 if (attribute_flag[2] != 0)
7859 geometry_info.sigma=argument_list[2].real_reference;
7860 if (attribute_flag[3] != 0)
7861 QueryColorDatabase(argument_list[3].string_reference,
7862 &image->background_color,exception);
7863 if (attribute_flag[4] != 0)
7864 QueryColorDatabase(argument_list[4].string_reference,
7865 &image->background_color,exception);
7866 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7870 case 29: /* Spread */
7872 if (attribute_flag[0] == 0)
7873 argument_list[0].real_reference=1.0;
7874 image=SpreadImage(image,argument_list[0].real_reference,exception);
7877 case 30: /* Swirl */
7879 if (attribute_flag[0] == 0)
7880 argument_list[0].real_reference=50.0;
7881 if (attribute_flag[1] != 0)
7882 image->interpolate=(InterpolatePixelMethod)
7883 argument_list[1].integer_reference;
7884 image=SwirlImage(image,argument_list[0].real_reference,exception);
7887 case 31: /* Resize */
7890 if (attribute_flag[0] != 0)
7891 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7892 &geometry,exception);
7893 if (attribute_flag[1] != 0)
7894 geometry.width=argument_list[1].integer_reference;
7895 if (attribute_flag[2] != 0)
7896 geometry.height=argument_list[2].integer_reference;
7897 if (attribute_flag[3] == 0)
7898 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7899 if (attribute_flag[4] != 0)
7900 SetImageArtifact(image,"filter:support",
7901 argument_list[4].string_reference);
7902 if (attribute_flag[5] == 0)
7903 argument_list[5].real_reference=1.0;
7904 image=ResizeImage(image,geometry.width,geometry.height,
7905 (FilterTypes) argument_list[3].integer_reference,
7906 argument_list[5].real_reference,exception);
7909 case 33: /* Annotate */
7914 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7916 if (attribute_flag[0] != 0)
7921 text=InterpretImageProperties(info ? info->image_info :
7922 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7923 (void) CloneString(&draw_info->text,text);
7924 text=DestroyString(text);
7926 if (attribute_flag[1] != 0)
7927 (void) CloneString(&draw_info->font,
7928 argument_list[1].string_reference);
7929 if (attribute_flag[2] != 0)
7930 draw_info->pointsize=argument_list[2].real_reference;
7931 if (attribute_flag[3] != 0)
7932 (void) CloneString(&draw_info->density,
7933 argument_list[3].string_reference);
7934 if (attribute_flag[4] != 0)
7935 (void) QueryColorDatabase(argument_list[4].string_reference,
7936 &draw_info->undercolor,exception);
7937 if (attribute_flag[5] != 0)
7939 (void) QueryColorDatabase(argument_list[5].string_reference,
7940 &draw_info->stroke,exception);
7941 if (argument_list[5].image_reference != (Image *) NULL)
7942 draw_info->stroke_pattern=CloneImage(
7943 argument_list[5].image_reference,0,0,MagickTrue,exception);
7945 if (attribute_flag[6] != 0)
7947 (void) QueryColorDatabase(argument_list[6].string_reference,
7948 &draw_info->fill,exception);
7949 if (argument_list[6].image_reference != (Image *) NULL)
7950 draw_info->fill_pattern=CloneImage(
7951 argument_list[6].image_reference,0,0,MagickTrue,exception);
7953 if (attribute_flag[7] != 0)
7955 (void) CloneString(&draw_info->geometry,
7956 argument_list[7].string_reference);
7957 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7958 &geometry,exception);
7959 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7960 geometry_info.sigma=geometry_info.xi;
7962 if (attribute_flag[8] != 0)
7963 (void) QueryColorDatabase(argument_list[8].string_reference,
7964 &draw_info->fill,exception);
7965 if (attribute_flag[11] != 0)
7966 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7967 if (attribute_flag[25] != 0)
7972 av=(AV *) argument_list[25].array_reference;
7973 if ((av_len(av) != 3) && (av_len(av) != 5))
7975 ThrowPerlException(exception,OptionError,
7976 "affine matrix must have 4 or 6 elements",PackageName);
7979 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7980 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7981 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7982 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7983 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7984 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7986 ThrowPerlException(exception,OptionError,
7987 "affine matrix is singular",PackageName);
7990 if (av_len(av) == 5)
7992 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7993 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
7996 for (j=12; j < 17; j++)
7998 if (attribute_flag[j] == 0)
8000 value=argument_list[j].string_reference;
8001 angle=argument_list[j].real_reference;
8002 current=draw_info->affine;
8003 GetAffineMatrix(&affine);
8011 flags=ParseGeometry(value,&geometry_info);
8012 affine.tx=geometry_info.xi;
8013 affine.ty=geometry_info.psi;
8014 if ((flags & PsiValue) == 0)
8015 affine.ty=affine.tx;
8023 flags=ParseGeometry(value,&geometry_info);
8024 affine.sx=geometry_info.rho;
8025 affine.sy=geometry_info.sigma;
8026 if ((flags & SigmaValue) == 0)
8027 affine.sy=affine.sx;
8037 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8038 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8039 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8040 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8048 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8056 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8060 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8061 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8062 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8063 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8064 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8066 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8069 if (attribute_flag[9] == 0)
8070 argument_list[9].real_reference=0.0;
8071 if (attribute_flag[10] == 0)
8072 argument_list[10].real_reference=0.0;
8073 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8076 geometry[MaxTextExtent];
8078 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8079 (double) argument_list[9].real_reference+draw_info->affine.tx,
8080 (double) argument_list[10].real_reference+draw_info->affine.ty);
8081 (void) CloneString(&draw_info->geometry,geometry);
8083 if (attribute_flag[17] != 0)
8084 draw_info->stroke_width=argument_list[17].real_reference;
8085 if (attribute_flag[18] != 0)
8087 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8088 MagickTrue : MagickFalse;
8089 draw_info->stroke_antialias=draw_info->text_antialias;
8091 if (attribute_flag[19] != 0)
8092 (void) CloneString(&draw_info->family,
8093 argument_list[19].string_reference);
8094 if (attribute_flag[20] != 0)
8095 draw_info->style=(StyleType) argument_list[20].integer_reference;
8096 if (attribute_flag[21] != 0)
8097 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8098 if (attribute_flag[22] != 0)
8099 draw_info->weight=argument_list[22].integer_reference;
8100 if (attribute_flag[23] != 0)
8101 draw_info->align=(AlignType) argument_list[23].integer_reference;
8102 if (attribute_flag[24] != 0)
8103 (void) CloneString(&draw_info->encoding,
8104 argument_list[24].string_reference);
8105 if (attribute_flag[25] != 0)
8106 draw_info->fill_pattern=CloneImage(
8107 argument_list[25].image_reference,0,0,MagickTrue,exception);
8108 if (attribute_flag[26] != 0)
8109 draw_info->fill_pattern=CloneImage(
8110 argument_list[26].image_reference,0,0,MagickTrue,exception);
8111 if (attribute_flag[27] != 0)
8112 draw_info->stroke_pattern=CloneImage(
8113 argument_list[27].image_reference,0,0,MagickTrue,exception);
8114 if (attribute_flag[29] != 0)
8115 draw_info->kerning=argument_list[29].real_reference;
8116 if (attribute_flag[30] != 0)
8117 draw_info->interline_spacing=argument_list[30].real_reference;
8118 if (attribute_flag[31] != 0)
8119 draw_info->interword_spacing=argument_list[31].real_reference;
8120 if (attribute_flag[32] != 0)
8121 draw_info->direction=(DirectionType)
8122 argument_list[32].integer_reference;
8123 (void) AnnotateImage(image,draw_info);
8124 draw_info=DestroyDrawInfo(draw_info);
8127 case 34: /* ColorFloodfill */
8138 draw_info=CloneDrawInfo(info ? info->image_info :
8139 (ImageInfo *) NULL,(DrawInfo *) NULL);
8140 if (attribute_flag[0] != 0)
8141 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8142 &geometry,exception);
8143 if (attribute_flag[1] != 0)
8144 geometry.x=argument_list[1].integer_reference;
8145 if (attribute_flag[2] != 0)
8146 geometry.y=argument_list[2].integer_reference;
8147 if (attribute_flag[3] != 0)
8148 (void) QueryColorDatabase(argument_list[3].string_reference,
8149 &draw_info->fill,exception);
8150 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8153 if (attribute_flag[4] != 0)
8155 QueryMagickColor(argument_list[4].string_reference,&target,
8159 if (attribute_flag[5] != 0)
8160 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8162 if (attribute_flag[6] != 0)
8163 invert=(MagickBooleanType) argument_list[6].integer_reference;
8164 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8165 geometry.x,geometry.y,invert);
8166 draw_info=DestroyDrawInfo(draw_info);
8169 case 35: /* Composite */
8172 composite_geometry[MaxTextExtent];
8178 compose=OverCompositeOp;
8179 if (attribute_flag[0] != 0)
8180 composite_image=argument_list[0].image_reference;
8183 ThrowPerlException(exception,OptionError,
8184 "CompositeImageRequired",PackageName);
8188 Parameter Handling used for BOTH normal and tiled composition.
8190 if (attribute_flag[1] != 0) /* compose */
8191 compose=(CompositeOperator) argument_list[1].integer_reference;
8192 if (attribute_flag[6] != 0) /* opacity */
8194 if (compose != DissolveCompositeOp)
8195 (void) SetImageOpacity(composite_image,(Quantum)
8196 SiPrefixToDouble(argument_list[6].string_reference,
8219 Handle dissolve composite operator (patch by
8222 (void) CloneString(&image->geometry,
8223 argument_list[6].string_reference);
8224 opacity=(Quantum) SiPrefixToDouble(
8225 argument_list[6].string_reference,QuantumRange);
8226 if (composite_image->matte != MagickTrue)
8227 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8228 composite_view=AcquireCacheView(composite_image);
8229 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8231 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8232 composite_image->columns,1,exception);
8233 for (x=0; x < (ssize_t) composite_image->columns; x++)
8235 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8236 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8237 q+=GetPixelChannels(composite_image);
8239 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8240 if (sync == MagickFalse)
8243 composite_view=DestroyCacheView(composite_view);
8246 if (attribute_flag[9] != 0) /* "color=>" */
8247 QueryColorDatabase(argument_list[9].string_reference,
8248 &composite_image->background_color,exception);
8249 if (attribute_flag[12] != 0) /* "interpolate=>" */
8250 image->interpolate=(InterpolatePixelMethod)
8251 argument_list[12].integer_reference;
8252 if (attribute_flag[13] != 0) /* "args=>" */
8253 (void) SetImageArtifact(composite_image,"compose:args",
8254 argument_list[13].string_reference);
8255 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8256 (void) SetImageArtifact(composite_image,"compose:args",
8257 argument_list[14].string_reference);
8259 Tiling Composition (with orthogonal rotate).
8261 rotate_image=(Image *) NULL;
8262 if (attribute_flag[8] != 0) /* "rotate=>" */
8267 rotate_image=RotateImage(composite_image,
8268 argument_list[8].real_reference,exception);
8269 if (rotate_image == (Image *) NULL)
8272 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8279 Tile the composite image.
8281 if (attribute_flag[8] != 0) /* "tile=>" */
8282 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8285 (void) SetImageArtifact(composite_image,
8286 "compose:outside-overlay","false");
8287 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8288 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8290 if (attribute_flag[8] != 0) /* rotate */
8291 (void) CompositeImage(image,compose,rotate_image,x,y);
8293 (void) CompositeImage(image,compose,composite_image,x,y);
8295 if (attribute_flag[8] != 0) /* rotate */
8296 rotate_image=DestroyImage(rotate_image);
8300 Parameter Handling used used ONLY for normal composition.
8302 if (attribute_flag[5] != 0) /* gravity */
8303 image->gravity=(GravityType) argument_list[5].integer_reference;
8304 if (attribute_flag[2] != 0) /* geometry offset */
8306 SetGeometry(image,&geometry);
8307 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8309 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8312 if (attribute_flag[3] != 0) /* x offset */
8313 geometry.x=argument_list[3].integer_reference;
8314 if (attribute_flag[4] != 0) /* y offset */
8315 geometry.y=argument_list[4].integer_reference;
8316 if (attribute_flag[10] != 0) /* mask */
8318 if ((image->compose == DisplaceCompositeOp) ||
8319 (image->compose == DistortCompositeOp))
8322 Merge Y displacement into X displacement image.
8324 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8326 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8327 argument_list[10].image_reference,0,0);
8332 Set a blending mask for the composition.
8334 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8335 MagickTrue,&image->exception);
8336 (void) NegateImage(image->mask,MagickFalse);
8339 if (attribute_flag[11] != 0) /* channel */
8340 channel=(ChannelType) argument_list[11].integer_reference;
8342 Composite two images (normal composition).
8344 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8345 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8346 (double) composite_image->rows,(double) geometry.x,(double)
8348 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8350 if (attribute_flag[8] == 0) /* no rotate */
8351 CompositeImageChannel(image,channel,compose,composite_image,
8352 geometry.x,geometry.y);
8356 Position adjust rotated image then composite.
8358 geometry.x-=(ssize_t) (rotate_image->columns-
8359 composite_image->columns)/2;
8360 geometry.y-=(ssize_t) (rotate_image->rows-
8361 composite_image->rows)/2;
8362 CompositeImageChannel(image,channel,compose,rotate_image,
8363 geometry.x,geometry.y);
8364 rotate_image=DestroyImage(rotate_image);
8366 if (attribute_flag[10] != 0) /* mask */
8368 if ((image->compose == DisplaceCompositeOp) ||
8369 (image->compose == DistortCompositeOp))
8370 composite_image=DestroyImage(composite_image);
8372 image->mask=DestroyImage(image->mask);
8376 case 36: /* Contrast */
8378 if (attribute_flag[0] == 0)
8379 argument_list[0].integer_reference=0;
8380 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8381 MagickTrue : MagickFalse);
8384 case 37: /* CycleColormap */
8386 if (attribute_flag[0] == 0)
8387 argument_list[0].integer_reference=6;
8388 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8396 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8398 (void) CloneString(&draw_info->primitive,"point");
8399 if (attribute_flag[0] != 0)
8401 if (argument_list[0].integer_reference < 0)
8402 (void) CloneString(&draw_info->primitive,
8403 argument_list[0].string_reference);
8405 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8406 MagickPrimitiveOptions,argument_list[0].integer_reference));
8408 if (attribute_flag[1] != 0)
8410 if (LocaleCompare(draw_info->primitive,"path") == 0)
8412 (void) ConcatenateString(&draw_info->primitive," '");
8413 ConcatenateString(&draw_info->primitive,
8414 argument_list[1].string_reference);
8415 (void) ConcatenateString(&draw_info->primitive,"'");
8419 (void) ConcatenateString(&draw_info->primitive," ");
8420 ConcatenateString(&draw_info->primitive,
8421 argument_list[1].string_reference);
8424 if (attribute_flag[2] != 0)
8426 (void) ConcatenateString(&draw_info->primitive," ");
8427 (void) ConcatenateString(&draw_info->primitive,
8428 CommandOptionToMnemonic(MagickMethodOptions,
8429 argument_list[2].integer_reference));
8431 if (attribute_flag[3] != 0)
8433 (void) QueryColorDatabase(argument_list[3].string_reference,
8434 &draw_info->stroke,exception);
8435 if (argument_list[3].image_reference != (Image *) NULL)
8436 draw_info->stroke_pattern=CloneImage(
8437 argument_list[3].image_reference,0,0,MagickTrue,exception);
8439 if (attribute_flag[4] != 0)
8441 (void) QueryColorDatabase(argument_list[4].string_reference,
8442 &draw_info->fill,exception);
8443 if (argument_list[4].image_reference != (Image *) NULL)
8444 draw_info->fill_pattern=CloneImage(
8445 argument_list[4].image_reference,0,0,MagickTrue,exception);
8447 if (attribute_flag[5] != 0)
8448 draw_info->stroke_width=argument_list[5].real_reference;
8449 if (attribute_flag[6] != 0)
8450 (void) CloneString(&draw_info->font,
8451 argument_list[6].string_reference);
8452 if (attribute_flag[7] != 0)
8453 (void) QueryColorDatabase(argument_list[7].string_reference,
8454 &draw_info->border_color,exception);
8455 if (attribute_flag[8] != 0)
8456 draw_info->affine.tx=argument_list[8].real_reference;
8457 if (attribute_flag[9] != 0)
8458 draw_info->affine.ty=argument_list[9].real_reference;
8459 if (attribute_flag[20] != 0)
8464 av=(AV *) argument_list[20].array_reference;
8465 if ((av_len(av) != 3) && (av_len(av) != 5))
8467 ThrowPerlException(exception,OptionError,
8468 "affine matrix must have 4 or 6 elements",PackageName);
8471 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8472 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8473 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8474 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8475 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8476 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8478 ThrowPerlException(exception,OptionError,
8479 "affine matrix is singular",PackageName);
8482 if (av_len(av) == 5)
8484 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8485 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8488 for (j=10; j < 15; j++)
8490 if (attribute_flag[j] == 0)
8492 value=argument_list[j].string_reference;
8493 angle=argument_list[j].real_reference;
8494 current=draw_info->affine;
8495 GetAffineMatrix(&affine);
8503 flags=ParseGeometry(value,&geometry_info);
8504 affine.tx=geometry_info.xi;
8505 affine.ty=geometry_info.psi;
8506 if ((flags & PsiValue) == 0)
8507 affine.ty=affine.tx;
8515 flags=ParseGeometry(value,&geometry_info);
8516 affine.sx=geometry_info.rho;
8517 affine.sy=geometry_info.sigma;
8518 if ((flags & SigmaValue) == 0)
8519 affine.sy=affine.sx;
8529 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8530 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8531 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8532 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8540 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8548 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8552 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8553 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8554 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8555 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8556 draw_info->affine.tx=
8557 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8558 draw_info->affine.ty=
8559 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8561 if (attribute_flag[15] != 0)
8562 draw_info->fill_pattern=CloneImage(
8563 argument_list[15].image_reference,0,0,MagickTrue,exception);
8564 if (attribute_flag[16] != 0)
8565 draw_info->pointsize=argument_list[16].real_reference;
8566 if (attribute_flag[17] != 0)
8568 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8569 ? MagickTrue : MagickFalse;
8570 draw_info->text_antialias=draw_info->stroke_antialias;
8572 if (attribute_flag[18] != 0)
8573 (void) CloneString(&draw_info->density,
8574 argument_list[18].string_reference);
8575 if (attribute_flag[19] != 0)
8576 draw_info->stroke_width=argument_list[19].real_reference;
8577 if (attribute_flag[21] != 0)
8578 draw_info->dash_offset=argument_list[21].real_reference;
8579 if (attribute_flag[22] != 0)
8584 av=(AV *) argument_list[22].array_reference;
8585 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8586 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8587 if (draw_info->dash_pattern != (double *) NULL)
8589 for (i=0; i <= av_len(av); i++)
8590 draw_info->dash_pattern[i]=(double)
8591 SvNV(*(av_fetch(av,i,0)));
8592 draw_info->dash_pattern[i]=0.0;
8595 if (attribute_flag[23] != 0)
8596 image->interpolate=(InterpolatePixelMethod)
8597 argument_list[23].integer_reference;
8598 if ((attribute_flag[24] != 0) &&
8599 (draw_info->fill_pattern != (Image *) NULL))
8600 flags=ParsePageGeometry(draw_info->fill_pattern,
8601 argument_list[24].string_reference,
8602 &draw_info->fill_pattern->tile_offset,exception);
8603 if (attribute_flag[25] != 0)
8605 (void) ConcatenateString(&draw_info->primitive," '");
8606 (void) ConcatenateString(&draw_info->primitive,
8607 argument_list[25].string_reference);
8608 (void) ConcatenateString(&draw_info->primitive,"'");
8610 if (attribute_flag[26] != 0)
8611 draw_info->fill_pattern=CloneImage(
8612 argument_list[26].image_reference,0,0,MagickTrue,exception);
8613 if (attribute_flag[27] != 0)
8614 draw_info->stroke_pattern=CloneImage(
8615 argument_list[27].image_reference,0,0,MagickTrue,exception);
8616 if (attribute_flag[28] != 0)
8617 (void) CloneString(&draw_info->primitive,
8618 argument_list[28].string_reference);
8619 if (attribute_flag[29] != 0)
8620 draw_info->kerning=argument_list[29].real_reference;
8621 if (attribute_flag[30] != 0)
8622 draw_info->interline_spacing=argument_list[30].real_reference;
8623 if (attribute_flag[31] != 0)
8624 draw_info->interword_spacing=argument_list[31].real_reference;
8625 if (attribute_flag[32] != 0)
8626 draw_info->direction=(DirectionType)
8627 argument_list[32].integer_reference;
8628 DrawImage(image,draw_info);
8629 draw_info=DestroyDrawInfo(draw_info);
8632 case 39: /* Equalize */
8634 if (attribute_flag[0] != 0)
8635 channel=(ChannelType) argument_list[0].integer_reference;
8636 EqualizeImageChannel(image,channel);
8639 case 40: /* Gamma */
8641 if (attribute_flag[1] != 0)
8642 channel=(ChannelType) argument_list[1].integer_reference;
8643 if (attribute_flag[2] == 0)
8644 argument_list[2].real_reference=1.0;
8645 if (attribute_flag[3] == 0)
8646 argument_list[3].real_reference=1.0;
8647 if (attribute_flag[4] == 0)
8648 argument_list[4].real_reference=1.0;
8649 if (attribute_flag[0] == 0)
8651 (void) FormatLocaleString(message,MaxTextExtent,
8652 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8653 (double) argument_list[3].real_reference,
8654 (double) argument_list[4].real_reference);
8655 argument_list[0].string_reference=message;
8657 if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
8658 (void) GammaImage(image,argument_list[0].string_reference);
8660 (void) GammaImageChannel(image,channel,InterpretLocaleValue(
8661 argument_list[0].string_reference,(char **) NULL));
8669 if (attribute_flag[0] == 0)
8671 ThrowPerlException(exception,OptionError,"MapImageRequired",
8675 quantize_info=AcquireQuantizeInfo(info->image_info);
8676 if (attribute_flag[1] != 0)
8677 quantize_info->dither=(MagickBooleanType)
8678 argument_list[1].integer_reference;
8679 if (attribute_flag[2] != 0)
8680 quantize_info->dither_method=(DitherMethod)
8681 argument_list[2].integer_reference;
8682 (void) RemapImages(quantize_info,image,
8683 argument_list[0].image_reference);
8684 quantize_info=DestroyQuantizeInfo(quantize_info);
8687 case 42: /* MatteFloodfill */
8698 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8700 if (attribute_flag[0] != 0)
8701 if (attribute_flag[0] != 0)
8702 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8703 &geometry,exception);
8704 if (attribute_flag[1] != 0)
8705 geometry.x=argument_list[1].integer_reference;
8706 if (attribute_flag[2] != 0)
8707 geometry.y=argument_list[2].integer_reference;
8708 if (image->matte == MagickFalse)
8709 (void) SetImageOpacity(image,OpaqueAlpha);
8710 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8712 if (attribute_flag[4] != 0)
8713 QueryMagickColor(argument_list[4].string_reference,&target,
8715 if (attribute_flag[3] != 0)
8716 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8718 if (attribute_flag[5] != 0)
8719 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8722 if (attribute_flag[6] != 0)
8723 invert=(MagickBooleanType) argument_list[6].integer_reference;
8724 (void) FloodfillPaintImage(image,AlphaChannel,draw_info,&target,
8725 geometry.x,geometry.y,invert);
8726 draw_info=DestroyDrawInfo(draw_info);
8729 case 43: /* Modulate */
8732 modulate[MaxTextExtent];
8734 geometry_info.rho=100.0;
8735 geometry_info.sigma=100.0;
8736 geometry_info.xi=100.0;
8737 if (attribute_flag[0] != 0)
8738 (void)ParseGeometry(argument_list[0].string_reference,
8740 if (attribute_flag[1] != 0)
8741 geometry_info.xi=argument_list[1].real_reference;
8742 if (attribute_flag[2] != 0)
8743 geometry_info.sigma=argument_list[2].real_reference;
8744 if (attribute_flag[3] != 0)
8746 geometry_info.sigma=argument_list[3].real_reference;
8747 SetImageArtifact(image,"modulate:colorspace","HWB");
8749 if (attribute_flag[4] != 0)
8751 geometry_info.rho=argument_list[4].real_reference;
8752 SetImageArtifact(image,"modulate:colorspace","HSB");
8754 if (attribute_flag[5] != 0)
8756 geometry_info.sigma=argument_list[5].real_reference;
8757 SetImageArtifact(image,"modulate:colorspace","HSL");
8759 if (attribute_flag[6] != 0)
8761 geometry_info.rho=argument_list[6].real_reference;
8762 SetImageArtifact(image,"modulate:colorspace","HWB");
8764 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8765 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8766 (void) ModulateImage(image,modulate);
8769 case 44: /* Negate */
8771 if (attribute_flag[0] == 0)
8772 argument_list[0].integer_reference=0;
8773 if (attribute_flag[1] != 0)
8774 channel=(ChannelType) argument_list[1].integer_reference;
8775 (void) NegateImageChannel(image,channel,
8776 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
8779 case 45: /* Normalize */
8781 if (attribute_flag[0] != 0)
8782 channel=(ChannelType) argument_list[0].integer_reference;
8783 NormalizeImageChannel(image,channel);
8786 case 46: /* NumberColors */
8788 case 47: /* Opaque */
8797 (void) QueryMagickColor("none",&target,exception);
8798 (void) QueryMagickColor("none",&fill_color,exception);
8799 if (attribute_flag[0] != 0)
8800 (void) QueryMagickColor(argument_list[0].string_reference,
8802 if (attribute_flag[1] != 0)
8803 (void) QueryMagickColor(argument_list[1].string_reference,
8804 &fill_color,exception);
8805 if (attribute_flag[2] != 0)
8806 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8808 if (attribute_flag[3] != 0)
8809 channel=(ChannelType) argument_list[3].integer_reference;
8811 if (attribute_flag[4] != 0)
8812 invert=(MagickBooleanType) argument_list[4].integer_reference;
8813 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8817 case 48: /* Quantize */
8822 quantize_info=AcquireQuantizeInfo(info->image_info);
8823 if (attribute_flag[0] != 0)
8824 quantize_info->number_colors=(size_t)
8825 argument_list[0].integer_reference;
8826 if (attribute_flag[1] != 0)
8827 quantize_info->tree_depth=(size_t)
8828 argument_list[1].integer_reference;
8829 if (attribute_flag[2] != 0)
8830 quantize_info->colorspace=(ColorspaceType)
8831 argument_list[2].integer_reference;
8832 if (attribute_flag[3] != 0)
8833 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8834 MagickTrue : MagickFalse;
8835 if (attribute_flag[4] != 0)
8836 quantize_info->measure_error=
8837 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8838 if (attribute_flag[5] != 0)
8839 (void) QueryColorDatabase(argument_list[5].string_reference,
8840 &image->transparent_color,exception);
8841 if (attribute_flag[5] && argument_list[5].integer_reference)
8843 (void) QuantizeImages(quantize_info,image);
8846 if (attribute_flag[6] != 0)
8847 quantize_info->dither_method=(DitherMethod)
8848 argument_list[6].integer_reference;
8849 if ((image->storage_class == DirectClass) ||
8850 (image->colors > quantize_info->number_colors) ||
8851 (quantize_info->colorspace == GRAYColorspace))
8852 (void) QuantizeImage(quantize_info,image);
8854 CompressImageColormap(image);
8855 quantize_info=DestroyQuantizeInfo(quantize_info);
8858 case 49: /* Raise */
8860 if (attribute_flag[0] != 0)
8861 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8862 &geometry,exception);
8863 if (attribute_flag[1] != 0)
8864 geometry.width=argument_list[1].integer_reference;
8865 if (attribute_flag[2] != 0)
8866 geometry.height=argument_list[2].integer_reference;
8867 if (attribute_flag[3] == 0)
8868 argument_list[3].integer_reference=1;
8869 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8870 0 ? MagickTrue : MagickFalse);
8873 case 50: /* Segment */
8880 smoothing_threshold;
8885 cluster_threshold=1.0;
8886 smoothing_threshold=1.5;
8887 colorspace=RGBColorspace;
8888 verbose=MagickFalse;
8889 if (attribute_flag[0] != 0)
8891 flags=ParseGeometry(argument_list[0].string_reference,
8893 cluster_threshold=geometry_info.rho;
8894 if (flags & SigmaValue)
8895 smoothing_threshold=geometry_info.sigma;
8897 if (attribute_flag[1] != 0)
8898 cluster_threshold=argument_list[1].real_reference;
8899 if (attribute_flag[2] != 0)
8900 smoothing_threshold=argument_list[2].real_reference;
8901 if (attribute_flag[3] != 0)
8902 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8903 if (attribute_flag[4] != 0)
8904 verbose=argument_list[4].integer_reference != 0 ?
8905 MagickTrue : MagickFalse;
8906 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8907 smoothing_threshold);
8910 case 51: /* Signature */
8912 (void) SignatureImage(image);
8915 case 52: /* Solarize */
8917 geometry_info.rho=QuantumRange/2.0;
8918 if (attribute_flag[0] != 0)
8919 flags=ParseGeometry(argument_list[0].string_reference,
8921 if (attribute_flag[1] != 0)
8922 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8924 (void) SolarizeImage(image,geometry_info.rho);
8929 (void) SyncImage(image);
8932 case 54: /* Texture */
8934 if (attribute_flag[0] == 0)
8936 TextureImage(image,argument_list[0].image_reference);
8939 case 55: /* Evalute */
8941 MagickEvaluateOperator
8944 op=SetEvaluateOperator;
8945 if (attribute_flag[0] == MagickFalse)
8946 argument_list[0].real_reference=0.0;
8947 if (attribute_flag[1] != MagickFalse)
8948 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8949 if (attribute_flag[2] != MagickFalse)
8950 channel=(ChannelType) argument_list[2].integer_reference;
8951 (void) EvaluateImageChannel(image,channel,op,
8952 argument_list[0].real_reference,exception);
8955 case 56: /* Transparent */
8966 (void) QueryMagickColor("none",&target,exception);
8967 if (attribute_flag[0] != 0)
8968 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8970 opacity=TransparentAlpha;
8971 if (attribute_flag[1] != 0)
8972 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8974 if (attribute_flag[2] != 0)
8975 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8977 if (attribute_flag[3] == 0)
8978 argument_list[3].integer_reference=0;
8980 if (attribute_flag[3] != 0)
8981 invert=(MagickBooleanType) argument_list[3].integer_reference;
8982 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
8986 case 57: /* Threshold */
8991 if (attribute_flag[0] == 0)
8992 argument_list[0].string_reference="50%";
8993 if (attribute_flag[1] != 0)
8994 channel=(ChannelType) argument_list[1].integer_reference;
8995 threshold=SiPrefixToDouble(argument_list[0].string_reference,
8997 (void) BilevelImageChannel(image,channel,threshold);
9000 case 58: /* Charcoal */
9002 if (attribute_flag[0] != 0)
9004 flags=ParseGeometry(argument_list[0].string_reference,
9006 if ((flags & SigmaValue) == 0)
9007 geometry_info.sigma=1.0;
9009 if (attribute_flag[1] != 0)
9010 geometry_info.rho=argument_list[1].real_reference;
9011 if (attribute_flag[2] != 0)
9012 geometry_info.sigma=argument_list[2].real_reference;
9013 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9019 if (attribute_flag[0] != 0)
9020 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9022 image=TrimImage(image,exception);
9027 if (attribute_flag[0] != 0)
9029 flags=ParseGeometry(argument_list[0].string_reference,
9031 if ((flags & SigmaValue) == 0)
9032 geometry_info.sigma=1.0;
9034 if (attribute_flag[1] != 0)
9035 geometry_info.rho=argument_list[1].real_reference;
9036 if (attribute_flag[2] != 0)
9037 geometry_info.sigma=argument_list[2].real_reference;
9038 if (attribute_flag[3] != 0)
9039 image->interpolate=(InterpolatePixelMethod)
9040 argument_list[3].integer_reference;
9041 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9045 case 61: /* Separate */
9047 if (attribute_flag[0] != 0)
9048 channel=(ChannelType) argument_list[0].integer_reference;
9049 (void) SeparateImageChannel(image,channel);
9052 case 63: /* Stereo */
9054 if (attribute_flag[0] == 0)
9056 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9060 if (attribute_flag[1] != 0)
9061 geometry.x=argument_list[1].integer_reference;
9062 if (attribute_flag[2] != 0)
9063 geometry.y=argument_list[2].integer_reference;
9064 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9065 geometry.x,geometry.y,exception);
9068 case 64: /* Stegano */
9070 if (attribute_flag[0] == 0)
9072 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9076 if (attribute_flag[1] == 0)
9077 argument_list[1].integer_reference=0;
9078 image->offset=argument_list[1].integer_reference;
9079 image=SteganoImage(image,argument_list[0].image_reference,exception);
9082 case 65: /* Deconstruct */
9084 image=CompareImageLayers(image,CompareAnyLayer,exception);
9087 case 66: /* GaussianBlur */
9089 if (attribute_flag[0] != 0)
9091 flags=ParseGeometry(argument_list[0].string_reference,
9093 if ((flags & SigmaValue) == 0)
9094 geometry_info.sigma=1.0;
9096 if (attribute_flag[1] != 0)
9097 geometry_info.rho=argument_list[1].real_reference;
9098 if (attribute_flag[2] != 0)
9099 geometry_info.sigma=argument_list[2].real_reference;
9100 if (attribute_flag[3] != 0)
9101 channel=(ChannelType) argument_list[3].integer_reference;
9102 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9103 geometry_info.sigma,exception);
9106 case 67: /* Convolve */
9117 if (attribute_flag[0] == 0)
9119 if (attribute_flag[1] != 0)
9120 channel=(ChannelType) argument_list[1].integer_reference;
9121 if (attribute_flag[2] != 0)
9122 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9124 av=(AV *) argument_list[0].array_reference;
9125 order=(size_t) sqrt(av_len(av)+1);
9126 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9127 if (kernel == (double *) NULL)
9129 ThrowPerlException(exception,ResourceLimitFatalError,
9130 "MemoryAllocationFailed",PackageName);
9133 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9134 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9135 for ( ; j < (ssize_t) (order*order); j++)
9137 image=ConvolveImageChannel(image,channel,order,kernel,exception);
9138 kernel=(double *) RelinquishMagickMemory(kernel);
9141 case 68: /* Profile */
9156 if (attribute_flag[0] != 0)
9157 name=argument_list[0].string_reference;
9158 if (attribute_flag[2] != 0)
9159 image->rendering_intent=(RenderingIntent)
9160 argument_list[2].integer_reference;
9161 if (attribute_flag[3] != 0)
9162 image->black_point_compensation=
9163 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9164 if (attribute_flag[1] != 0)
9166 if (argument_list[1].length == 0)
9169 Remove a profile from the image.
9171 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9176 Associate user supplied profile with the image.
9178 profile=AcquireStringInfo(argument_list[1].length);
9179 SetStringInfoDatum(profile,(const unsigned char *)
9180 argument_list[1].string_reference);
9181 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9182 (size_t) GetStringInfoLength(profile),MagickFalse);
9183 profile=DestroyStringInfo(profile);
9187 Associate a profile with the image.
9190 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9191 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9192 profile_image=ReadImages(profile_info,&image->exception);
9193 if (profile_image == (Image *) NULL)
9195 ResetImageProfileIterator(profile_image);
9196 name=GetNextImageProfile(profile_image);
9197 while (name != (const char *) NULL)
9202 profile=GetImageProfile(profile_image,name);
9203 if (profile != (const StringInfo *) NULL)
9204 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9205 (size_t) GetStringInfoLength(profile),MagickFalse);
9206 name=GetNextImageProfile(profile_image);
9208 profile_image=DestroyImage(profile_image);
9209 profile_info=DestroyImageInfo(profile_info);
9212 case 69: /* UnsharpMask */
9214 if (attribute_flag[0] != 0)
9216 flags=ParseGeometry(argument_list[0].string_reference,
9218 if ((flags & SigmaValue) == 0)
9219 geometry_info.sigma=1.0;
9220 if ((flags & XiValue) == 0)
9221 geometry_info.xi=1.0;
9222 if ((flags & PsiValue) == 0)
9223 geometry_info.psi=0.5;
9225 if (attribute_flag[1] != 0)
9226 geometry_info.rho=argument_list[1].real_reference;
9227 if (attribute_flag[2] != 0)
9228 geometry_info.sigma=argument_list[2].real_reference;
9229 if (attribute_flag[3] != 0)
9230 geometry_info.xi=argument_list[3].real_reference;
9231 if (attribute_flag[4] != 0)
9232 geometry_info.psi=argument_list[4].real_reference;
9233 if (attribute_flag[5] != 0)
9234 channel=(ChannelType) argument_list[5].integer_reference;
9235 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9236 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9239 case 70: /* MotionBlur */
9241 if (attribute_flag[0] != 0)
9243 flags=ParseGeometry(argument_list[0].string_reference,
9245 if ((flags & SigmaValue) == 0)
9246 geometry_info.sigma=1.0;
9247 if ((flags & XiValue) == 0)
9248 geometry_info.xi=1.0;
9250 if (attribute_flag[1] != 0)
9251 geometry_info.rho=argument_list[1].real_reference;
9252 if (attribute_flag[2] != 0)
9253 geometry_info.sigma=argument_list[2].real_reference;
9254 if (attribute_flag[3] != 0)
9255 geometry_info.xi=argument_list[3].real_reference;
9256 if (attribute_flag[4] != 0)
9257 channel=(ChannelType) argument_list[4].integer_reference;
9258 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9259 geometry_info.sigma,geometry_info.xi,exception);
9262 case 71: /* OrderedDither */
9264 if (attribute_flag[0] == 0)
9265 argument_list[0].string_reference="o8x8";
9266 if (attribute_flag[1] != 0)
9267 channel=(ChannelType) argument_list[1].integer_reference;
9268 (void) OrderedPosterizeImageChannel(image,channel,
9269 argument_list[0].string_reference,exception);
9272 case 72: /* Shave */
9274 if (attribute_flag[0] != 0)
9275 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9276 &geometry,exception);
9277 if (attribute_flag[1] != 0)
9278 geometry.width=argument_list[1].integer_reference;
9279 if (attribute_flag[2] != 0)
9280 geometry.height=argument_list[2].integer_reference;
9281 image=ShaveImage(image,&geometry,exception);
9284 case 73: /* Level */
9292 white_point=(MagickRealType) image->columns*image->rows;
9294 if (attribute_flag[0] != 0)
9296 flags=ParseGeometry(argument_list[0].string_reference,
9298 black_point=geometry_info.rho;
9299 if ((flags & SigmaValue) != 0)
9300 white_point=geometry_info.sigma;
9301 if ((flags & XiValue) != 0)
9302 gamma=geometry_info.xi;
9303 if ((flags & PercentValue) != 0)
9305 black_point*=(double) (QuantumRange/100.0);
9306 white_point*=(double) (QuantumRange/100.0);
9308 if ((flags & SigmaValue) == 0)
9309 white_point=(double) QuantumRange-black_point;
9311 if (attribute_flag[1] != 0)
9312 black_point=argument_list[1].real_reference;
9313 if (attribute_flag[2] != 0)
9314 white_point=argument_list[2].real_reference;
9315 if (attribute_flag[3] != 0)
9316 gamma=argument_list[3].real_reference;
9317 if (attribute_flag[4] != 0)
9318 channel=(ChannelType) argument_list[4].integer_reference;
9319 if (attribute_flag[5] != 0)
9321 argument_list[0].real_reference=argument_list[5].real_reference;
9322 attribute_flag[0]=attribute_flag[5];
9324 (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
9329 if (attribute_flag[0] == 0)
9330 argument_list[0].string_reference="#1";
9331 if (attribute_flag[1] == 0)
9332 argument_list[1].integer_reference=MagickTrue;
9333 (void) ClipImagePath(image,argument_list[0].string_reference,
9334 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9337 case 75: /* AffineTransform */
9342 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9344 if (attribute_flag[0] != 0)
9349 av=(AV *) argument_list[0].array_reference;
9350 if ((av_len(av) != 3) && (av_len(av) != 5))
9352 ThrowPerlException(exception,OptionError,
9353 "affine matrix must have 4 or 6 elements",PackageName);
9356 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9357 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9358 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9359 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9360 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9361 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9363 ThrowPerlException(exception,OptionError,
9364 "affine matrix is singular",PackageName);
9367 if (av_len(av) == 5)
9369 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9370 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9373 for (j=1; j < 6; j++)
9375 if (attribute_flag[j] == 0)
9377 value=argument_list[j].string_reference;
9378 angle=argument_list[j].real_reference;
9379 current=draw_info->affine;
9380 GetAffineMatrix(&affine);
9388 flags=ParseGeometry(value,&geometry_info);
9389 affine.tx=geometry_info.xi;
9390 affine.ty=geometry_info.psi;
9391 if ((flags & PsiValue) == 0)
9392 affine.ty=affine.tx;
9400 flags=ParseGeometry(value,&geometry_info);
9401 affine.sx=geometry_info.rho;
9402 affine.sy=geometry_info.sigma;
9403 if ((flags & SigmaValue) == 0)
9404 affine.sy=affine.sx;
9414 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9415 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9416 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9417 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9425 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9433 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9437 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9438 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9439 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9440 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9441 draw_info->affine.tx=
9442 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9443 draw_info->affine.ty=
9444 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9446 if (attribute_flag[6] != 0)
9447 image->interpolate=(InterpolatePixelMethod)
9448 argument_list[6].integer_reference;
9449 if (attribute_flag[7] != 0)
9450 QueryColorDatabase(argument_list[7].string_reference,
9451 &image->background_color,exception);
9452 image=AffineTransformImage(image,&draw_info->affine,exception);
9453 draw_info=DestroyDrawInfo(draw_info);
9456 case 76: /* Difference */
9458 if (attribute_flag[0] == 0)
9460 ThrowPerlException(exception,OptionError,
9461 "ReferenceImageRequired",PackageName);
9464 if (attribute_flag[1] != 0)
9465 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9467 (void) IsImagesEqual(image,argument_list[0].image_reference);
9470 case 77: /* AdaptiveThreshold */
9472 if (attribute_flag[0] != 0)
9474 flags=ParseGeometry(argument_list[0].string_reference,
9476 if ((flags & PercentValue) != 0)
9477 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9479 if (attribute_flag[1] != 0)
9480 geometry_info.rho=argument_list[1].integer_reference;
9481 if (attribute_flag[2] != 0)
9482 geometry_info.sigma=argument_list[2].integer_reference;
9483 if (attribute_flag[3] != 0)
9484 geometry_info.xi=argument_list[3].integer_reference;;
9485 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9486 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9490 case 78: /* Resample */
9496 if (attribute_flag[0] != 0)
9498 flags=ParseGeometry(argument_list[0].string_reference,
9500 if ((flags & SigmaValue) == 0)
9501 geometry_info.sigma=geometry_info.rho;
9503 if (attribute_flag[1] != 0)
9504 geometry_info.rho=argument_list[1].real_reference;
9505 if (attribute_flag[2] != 0)
9506 geometry_info.sigma=argument_list[2].real_reference;
9507 if (attribute_flag[3] == 0)
9508 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9509 if (attribute_flag[4] == 0)
9510 SetImageArtifact(image,"filter:support",
9511 argument_list[4].string_reference);
9512 if (attribute_flag[5] != 0)
9513 argument_list[5].real_reference=1.0;
9514 width=(size_t) (geometry_info.rho*image->columns/
9515 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9516 height=(size_t) (geometry_info.sigma*image->rows/
9517 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9518 image=ResizeImage(image,width,height,(FilterTypes)
9519 argument_list[3].integer_reference,argument_list[5].real_reference,
9521 if (image != (Image *) NULL)
9523 image->x_resolution=geometry_info.rho;
9524 image->y_resolution=geometry_info.sigma;
9528 case 79: /* Describe */
9530 if (attribute_flag[0] == 0)
9531 argument_list[0].file_reference=(FILE *) NULL;
9532 if (attribute_flag[1] != 0)
9533 (void) SetImageArtifact(image,"identify:features",
9534 argument_list[1].string_reference);
9535 (void) IdentifyImage(image,argument_list[0].file_reference,
9539 case 80: /* BlackThreshold */
9541 if (attribute_flag[0] == 0)
9542 argument_list[0].string_reference="50%";
9543 if (attribute_flag[2] != 0)
9544 channel=(ChannelType) argument_list[2].integer_reference;
9545 BlackThresholdImageChannel(image,channel,
9546 argument_list[0].string_reference,exception);
9549 case 81: /* WhiteThreshold */
9551 if (attribute_flag[0] == 0)
9552 argument_list[0].string_reference="50%";
9553 if (attribute_flag[2] != 0)
9554 channel=(ChannelType) argument_list[2].integer_reference;
9555 WhiteThresholdImageChannel(image,channel,
9556 argument_list[0].string_reference,exception);
9559 case 82: /* RadialBlur */
9561 if (attribute_flag[0] != 0)
9563 flags=ParseGeometry(argument_list[0].string_reference,
9565 if ((flags & SigmaValue) == 0)
9566 geometry_info.sigma=1.0;
9568 if (attribute_flag[1] != 0)
9569 geometry_info.rho=argument_list[1].real_reference;
9570 if (attribute_flag[2] != 0)
9571 channel=(ChannelType) argument_list[2].integer_reference;
9572 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9576 case 83: /* Thumbnail */
9578 if (attribute_flag[0] != 0)
9579 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9580 &geometry,exception);
9581 if (attribute_flag[1] != 0)
9582 geometry.width=argument_list[1].integer_reference;
9583 if (attribute_flag[2] != 0)
9584 geometry.height=argument_list[2].integer_reference;
9585 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9588 case 84: /* Strip */
9590 (void) StripImage(image);
9598 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9599 if (attribute_flag[0] != 0)
9600 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9602 if (attribute_flag[1] == 0)
9603 argument_list[1].string_reference="100";
9604 image=TintImage(image,argument_list[1].string_reference,target,
9608 case 86: /* Channel */
9610 if (attribute_flag[0] != 0)
9611 channel=(ChannelType) argument_list[0].integer_reference;
9612 (void) SeparateImageChannel(image,channel);
9615 case 87: /* Splice */
9617 if (attribute_flag[0] != 0)
9618 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9619 &geometry,exception);
9620 if (attribute_flag[1] != 0)
9621 geometry.width=argument_list[1].integer_reference;
9622 if (attribute_flag[2] != 0)
9623 geometry.height=argument_list[2].integer_reference;
9624 if (attribute_flag[3] != 0)
9625 geometry.x=argument_list[3].integer_reference;
9626 if (attribute_flag[4] != 0)
9627 geometry.y=argument_list[4].integer_reference;
9628 if (attribute_flag[5] != 0)
9629 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9631 if (attribute_flag[6] != 0)
9632 (void) QueryColorDatabase(argument_list[6].string_reference,
9633 &image->background_color,exception);
9634 if (attribute_flag[7] != 0)
9635 image->gravity=(GravityType) argument_list[7].integer_reference;
9636 image=SpliceImage(image,&geometry,exception);
9639 case 88: /* Posterize */
9641 if (attribute_flag[0] == 0)
9642 argument_list[0].integer_reference=3;
9643 if (attribute_flag[1] == 0)
9644 argument_list[1].integer_reference=0;
9645 (void) PosterizeImage(image,argument_list[0].integer_reference,
9646 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9649 case 89: /* Shadow */
9651 if (attribute_flag[0] != 0)
9653 flags=ParseGeometry(argument_list[0].string_reference,
9655 if ((flags & SigmaValue) == 0)
9656 geometry_info.sigma=1.0;
9657 if ((flags & XiValue) == 0)
9658 geometry_info.xi=4.0;
9659 if ((flags & PsiValue) == 0)
9660 geometry_info.psi=4.0;
9662 if (attribute_flag[1] != 0)
9663 geometry_info.rho=argument_list[1].real_reference;
9664 if (attribute_flag[2] != 0)
9665 geometry_info.sigma=argument_list[2].real_reference;
9666 if (attribute_flag[3] != 0)
9667 geometry_info.xi=argument_list[3].integer_reference;
9668 if (attribute_flag[4] != 0)
9669 geometry_info.psi=argument_list[4].integer_reference;
9670 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9671 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9675 case 90: /* Identify */
9677 if (attribute_flag[0] == 0)
9678 argument_list[0].file_reference=(FILE *) NULL;
9679 if (attribute_flag[1] != 0)
9680 (void) SetImageArtifact(image,"identify:features",
9681 argument_list[1].string_reference);
9682 if ((attribute_flag[2] != 0) &&
9683 (argument_list[2].integer_reference != 0))
9684 (void) SetImageArtifact(image,"identify:unique","true");
9685 (void) IdentifyImage(image,argument_list[0].file_reference,
9689 case 91: /* SepiaTone */
9691 if (attribute_flag[0] == 0)
9692 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9693 image=SepiaToneImage(image,argument_list[0].real_reference,
9697 case 92: /* SigmoidalContrast */
9702 if (attribute_flag[0] != 0)
9704 flags=ParseGeometry(argument_list[0].string_reference,
9706 if ((flags & SigmaValue) == 0)
9707 geometry_info.sigma=QuantumRange/2.0;
9708 if ((flags & PercentValue) != 0)
9709 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9711 if (attribute_flag[1] != 0)
9712 geometry_info.rho=argument_list[1].real_reference;
9713 if (attribute_flag[2] != 0)
9714 geometry_info.sigma=argument_list[2].real_reference;
9715 if (attribute_flag[3] != 0)
9716 channel=(ChannelType) argument_list[3].integer_reference;
9718 if (attribute_flag[4] != 0)
9719 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9721 (void) SigmoidalContrastImageChannel(image,channel,sharpen,
9722 geometry_info.rho,geometry_info.sigma);
9725 case 93: /* Extent */
9727 if (attribute_flag[7] != 0)
9728 image->gravity=(GravityType) argument_list[7].integer_reference;
9729 if (attribute_flag[0] != 0)
9734 flags=ParseGravityGeometry(image,
9735 argument_list[0].string_reference,&geometry,exception);
9737 if (geometry.width == 0)
9738 geometry.width=image->columns;
9739 if (geometry.height == 0)
9740 geometry.height=image->rows;
9742 if (attribute_flag[1] != 0)
9743 geometry.width=argument_list[1].integer_reference;
9744 if (attribute_flag[2] != 0)
9745 geometry.height=argument_list[2].integer_reference;
9746 if (attribute_flag[3] != 0)
9747 geometry.x=argument_list[3].integer_reference;
9748 if (attribute_flag[4] != 0)
9749 geometry.y=argument_list[4].integer_reference;
9750 if (attribute_flag[5] != 0)
9751 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9753 if (attribute_flag[6] != 0)
9754 (void) QueryColorDatabase(argument_list[6].string_reference,
9755 &image->background_color,exception);
9756 image=ExtentImage(image,&geometry,exception);
9759 case 94: /* Vignette */
9761 if (attribute_flag[0] != 0)
9763 flags=ParseGeometry(argument_list[0].string_reference,
9765 if ((flags & SigmaValue) == 0)
9766 geometry_info.sigma=1.0;
9767 if ((flags & XiValue) == 0)
9768 geometry_info.xi=0.1*image->columns;
9769 if ((flags & PsiValue) == 0)
9770 geometry_info.psi=0.1*image->rows;
9772 if (attribute_flag[1] != 0)
9773 geometry_info.rho=argument_list[1].real_reference;
9774 if (attribute_flag[2] != 0)
9775 geometry_info.sigma=argument_list[2].real_reference;
9776 if (attribute_flag[3] != 0)
9777 geometry_info.xi=argument_list[3].integer_reference;
9778 if (attribute_flag[4] != 0)
9779 geometry_info.psi=argument_list[4].integer_reference;
9780 if (attribute_flag[5] != 0)
9781 (void) QueryColorDatabase(argument_list[5].string_reference,
9782 &image->background_color,exception);
9783 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9784 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9788 case 95: /* ContrastStretch */
9795 white_point=(MagickRealType) image->columns*image->rows;
9796 if (attribute_flag[0] != 0)
9798 flags=ParseGeometry(argument_list[0].string_reference,
9800 black_point=geometry_info.rho;
9801 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9803 if ((flags & PercentValue) != 0)
9805 black_point*=(double) image->columns*image->rows/100.0;
9806 white_point*=(double) image->columns*image->rows/100.0;
9808 white_point=(MagickRealType) image->columns*image->rows-
9811 if (attribute_flag[1] != 0)
9812 black_point=argument_list[1].real_reference;
9813 if (attribute_flag[2] != 0)
9814 white_point=argument_list[2].real_reference;
9815 if (attribute_flag[4] != 0)
9816 channel=(ChannelType) argument_list[4].integer_reference;
9817 (void) ContrastStretchImageChannel(image,channel,black_point,
9821 case 96: /* Sans0 */
9825 case 97: /* Sans1 */
9829 case 98: /* AdaptiveSharpen */
9831 if (attribute_flag[0] != 0)
9833 flags=ParseGeometry(argument_list[0].string_reference,
9835 if ((flags & SigmaValue) == 0)
9836 geometry_info.sigma=1.0;
9838 if (attribute_flag[1] != 0)
9839 geometry_info.rho=argument_list[1].real_reference;
9840 if (attribute_flag[2] != 0)
9841 geometry_info.sigma=argument_list[2].real_reference;
9842 if (attribute_flag[3] != 0)
9843 channel=(ChannelType) argument_list[3].integer_reference;
9844 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9845 geometry_info.sigma,exception);
9848 case 99: /* Transpose */
9850 image=TransposeImage(image,exception);
9853 case 100: /* Tranverse */
9855 image=TransverseImage(image,exception);
9858 case 101: /* AutoOrient */
9860 switch (image->orientation)
9862 case TopRightOrientation:
9864 image=FlopImage(image,exception);
9867 case BottomRightOrientation:
9869 image=RotateImage(image,180.0,exception);
9872 case BottomLeftOrientation:
9874 image=FlipImage(image,exception);
9877 case LeftTopOrientation:
9879 image=TransposeImage(image,exception);
9882 case RightTopOrientation:
9884 image=RotateImage(image,90.0,exception);
9887 case RightBottomOrientation:
9889 image=TransverseImage(image,exception);
9892 case LeftBottomOrientation:
9894 image=RotateImage(image,270.0,exception);
9902 case 102: /* AdaptiveBlur */
9904 if (attribute_flag[0] != 0)
9906 flags=ParseGeometry(argument_list[0].string_reference,
9908 if ((flags & SigmaValue) == 0)
9909 geometry_info.sigma=1.0;
9911 if (attribute_flag[1] != 0)
9912 geometry_info.rho=argument_list[1].real_reference;
9913 if (attribute_flag[2] != 0)
9914 geometry_info.sigma=argument_list[2].real_reference;
9915 if (attribute_flag[3] != 0)
9916 channel=(ChannelType) argument_list[3].integer_reference;
9917 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
9918 geometry_info.sigma,exception);
9921 case 103: /* Sketch */
9923 if (attribute_flag[0] != 0)
9925 flags=ParseGeometry(argument_list[0].string_reference,
9927 if ((flags & SigmaValue) == 0)
9928 geometry_info.sigma=1.0;
9929 if ((flags & XiValue) == 0)
9930 geometry_info.xi=1.0;
9932 if (attribute_flag[1] != 0)
9933 geometry_info.rho=argument_list[1].real_reference;
9934 if (attribute_flag[2] != 0)
9935 geometry_info.sigma=argument_list[2].real_reference;
9936 if (attribute_flag[3] != 0)
9937 geometry_info.xi=argument_list[3].real_reference;
9938 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9939 geometry_info.xi,exception);
9942 case 104: /* UniqueColors */
9944 image=UniqueImageColors(image,exception);
9947 case 105: /* AdaptiveResize */
9949 if (attribute_flag[0] != 0)
9950 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9951 &geometry,exception);
9952 if (attribute_flag[1] != 0)
9953 geometry.width=argument_list[1].integer_reference;
9954 if (attribute_flag[2] != 0)
9955 geometry.height=argument_list[2].integer_reference;
9956 if (attribute_flag[3] != 0)
9957 image->filter=(FilterTypes) argument_list[4].integer_reference;
9958 if (attribute_flag[4] != 0)
9959 SetImageArtifact(image,"filter:support",
9960 argument_list[4].string_reference);
9961 if (attribute_flag[5] != 0)
9962 image->blur=argument_list[5].real_reference;
9963 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
9967 case 106: /* ClipMask */
9969 if (attribute_flag[0] == 0)
9971 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9975 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
9976 MagickTrue,exception);
9977 (void) NegateImage(image->clip_mask,MagickFalse);
9980 case 107: /* LinearStretch */
9987 white_point=(MagickRealType) image->columns*image->rows;
9988 if (attribute_flag[0] != 0)
9990 flags=ParseGeometry(argument_list[0].string_reference,
9992 if ((flags & SigmaValue) != 0)
9993 white_point=geometry_info.sigma;
9994 if ((flags & PercentValue) != 0)
9996 black_point*=(double) image->columns*image->rows/100.0;
9997 white_point*=(double) image->columns*image->rows/100.0;
9999 if ((flags & SigmaValue) == 0)
10000 white_point=(double) image->columns*image->rows-black_point;
10002 if (attribute_flag[1] != 0)
10003 black_point=argument_list[1].real_reference;
10004 if (attribute_flag[2] != 0)
10005 white_point=argument_list[2].real_reference;
10006 (void) LinearStretchImage(image,black_point,white_point);
10009 case 109: /* Mask */
10011 if (attribute_flag[0] == 0)
10013 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10015 goto PerlException;
10017 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10018 MagickTrue,exception);
10019 (void) NegateImage(image->mask,MagickFalse);
10022 case 110: /* Polaroid */
10030 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10031 (DrawInfo *) NULL);
10032 if (attribute_flag[0] != 0)
10033 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10034 info ? info->image_info : (ImageInfo *) NULL,image,
10035 argument_list[0].string_reference));
10037 if (attribute_flag[1] != 0)
10038 angle=argument_list[1].real_reference;
10039 if (attribute_flag[2] != 0)
10040 (void) CloneString(&draw_info->font,
10041 argument_list[2].string_reference);
10042 if (attribute_flag[3] != 0)
10043 (void) QueryColorDatabase(argument_list[3].string_reference,
10044 &draw_info->stroke,exception);
10045 if (attribute_flag[4] != 0)
10046 (void) QueryColorDatabase(argument_list[4].string_reference,
10047 &draw_info->fill,exception);
10048 if (attribute_flag[5] != 0)
10049 draw_info->stroke_width=argument_list[5].real_reference;
10050 if (attribute_flag[6] != 0)
10051 draw_info->pointsize=argument_list[6].real_reference;
10052 if (attribute_flag[7] != 0)
10053 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10054 if (attribute_flag[8] != 0)
10055 (void) QueryColorDatabase(argument_list[8].string_reference,
10056 &image->background_color,exception);
10057 image=PolaroidImage(image,draw_info,angle,exception);
10058 draw_info=DestroyDrawInfo(draw_info);
10061 case 111: /* FloodfillPaint */
10072 draw_info=CloneDrawInfo(info ? info->image_info :
10073 (ImageInfo *) NULL,(DrawInfo *) NULL);
10074 if (attribute_flag[0] != 0)
10075 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10076 &geometry,exception);
10077 if (attribute_flag[1] != 0)
10078 geometry.x=argument_list[1].integer_reference;
10079 if (attribute_flag[2] != 0)
10080 geometry.y=argument_list[2].integer_reference;
10081 if (attribute_flag[3] != 0)
10082 (void) QueryColorDatabase(argument_list[3].string_reference,
10083 &draw_info->fill,exception);
10084 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10086 if (attribute_flag[4] != 0)
10087 QueryMagickColor(argument_list[4].string_reference,&target,
10089 if (attribute_flag[5] != 0)
10090 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10092 if (attribute_flag[6] != 0)
10093 channel=(ChannelType) argument_list[6].integer_reference;
10094 invert=MagickFalse;
10095 if (attribute_flag[7] != 0)
10096 invert=(MagickBooleanType) argument_list[7].integer_reference;
10097 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10098 geometry.y,invert);
10099 draw_info=DestroyDrawInfo(draw_info);
10102 case 112: /* Distort */
10114 number_coordinates;
10119 if (attribute_flag[0] == 0)
10121 method=UndefinedDistortion;
10122 if (attribute_flag[1] != 0)
10123 method=(DistortImageMethod) argument_list[1].integer_reference;
10124 av=(AV *) argument_list[0].array_reference;
10125 number_coordinates=(size_t) av_len(av)+1;
10126 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10127 sizeof(*coordinates));
10128 if (coordinates == (double *) NULL)
10130 ThrowPerlException(exception,ResourceLimitFatalError,
10131 "MemoryAllocationFailed",PackageName);
10132 goto PerlException;
10134 for (j=0; j < (ssize_t) number_coordinates; j++)
10135 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10136 virtual_pixel=UndefinedVirtualPixelMethod;
10137 if (attribute_flag[2] != 0)
10138 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10139 argument_list[2].integer_reference);
10140 image=DistortImage(image,method,number_coordinates,coordinates,
10141 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10143 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10144 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10145 coordinates=(double *) RelinquishMagickMemory(coordinates);
10148 case 113: /* Clut */
10150 if (attribute_flag[0] == 0)
10152 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10154 goto PerlException;
10156 if (attribute_flag[1] != 0)
10157 channel=(ChannelType) argument_list[1].integer_reference;
10158 (void) ClutImageChannel(image,channel,
10159 argument_list[0].image_reference);
10162 case 114: /* LiquidRescale */
10164 if (attribute_flag[0] != 0)
10165 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10166 &geometry,exception);
10167 if (attribute_flag[1] != 0)
10168 geometry.width=argument_list[1].integer_reference;
10169 if (attribute_flag[2] != 0)
10170 geometry.height=argument_list[2].integer_reference;
10171 if (attribute_flag[3] == 0)
10172 argument_list[3].real_reference=1.0;
10173 if (attribute_flag[4] == 0)
10174 argument_list[4].real_reference=0.0;
10175 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10176 argument_list[3].real_reference,argument_list[4].real_reference,
10180 case 115: /* EncipherImage */
10182 (void) EncipherImage(image,argument_list[0].string_reference,
10186 case 116: /* DecipherImage */
10188 (void) DecipherImage(image,argument_list[0].string_reference,
10192 case 117: /* Deskew */
10194 geometry_info.rho=QuantumRange/2.0;
10195 if (attribute_flag[0] != 0)
10196 flags=ParseGeometry(argument_list[0].string_reference,
10198 if (attribute_flag[1] != 0)
10199 geometry_info.rho=SiPrefixToDouble(
10200 argument_list[1].string_reference,QuantumRange);
10201 image=DeskewImage(image,geometry_info.rho,exception);
10204 case 118: /* Remap */
10209 if (attribute_flag[0] == 0)
10211 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10213 goto PerlException;
10215 quantize_info=AcquireQuantizeInfo(info->image_info);
10216 if (attribute_flag[1] != 0)
10217 quantize_info->dither=(MagickBooleanType)
10218 argument_list[1].integer_reference;
10219 if (attribute_flag[2] != 0)
10220 quantize_info->dither_method=(DitherMethod)
10221 argument_list[2].integer_reference;
10222 (void) RemapImages(quantize_info,image,
10223 argument_list[0].image_reference);
10224 quantize_info=DestroyQuantizeInfo(quantize_info);
10227 case 119: /* SparseColor */
10239 number_coordinates;
10244 if (attribute_flag[0] == 0)
10246 method=UndefinedColorInterpolate;
10247 if (attribute_flag[1] != 0)
10248 method=(SparseColorMethod) argument_list[1].integer_reference;
10249 av=(AV *) argument_list[0].array_reference;
10250 number_coordinates=(size_t) av_len(av)+1;
10251 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10252 sizeof(*coordinates));
10253 if (coordinates == (double *) NULL)
10255 ThrowPerlException(exception,ResourceLimitFatalError,
10256 "MemoryAllocationFailed",PackageName);
10257 goto PerlException;
10259 for (j=0; j < (ssize_t) number_coordinates; j++)
10260 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10261 virtual_pixel=UndefinedVirtualPixelMethod;
10262 if (attribute_flag[2] != 0)
10263 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10264 argument_list[2].integer_reference);
10265 if (attribute_flag[3] != 0)
10266 channel=(ChannelType) argument_list[3].integer_reference;
10267 image=SparseColorImage(image,channel,method,number_coordinates,
10268 coordinates,exception);
10269 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10270 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10271 coordinates=(double *) RelinquishMagickMemory(coordinates);
10274 case 120: /* Function */
10291 if (attribute_flag[0] == 0)
10293 function=UndefinedFunction;
10294 if (attribute_flag[1] != 0)
10295 function=(MagickFunction) argument_list[1].integer_reference;
10296 av=(AV *) argument_list[0].array_reference;
10297 number_parameters=(size_t) av_len(av)+1;
10298 parameters=(double *) AcquireQuantumMemory(number_parameters,
10299 sizeof(*parameters));
10300 if (parameters == (double *) NULL)
10302 ThrowPerlException(exception,ResourceLimitFatalError,
10303 "MemoryAllocationFailed",PackageName);
10304 goto PerlException;
10306 for (j=0; j < (ssize_t) number_parameters; j++)
10307 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10308 virtual_pixel=UndefinedVirtualPixelMethod;
10309 if (attribute_flag[2] != 0)
10310 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10311 argument_list[2].integer_reference);
10312 (void) FunctionImage(image,function,number_parameters,parameters,
10314 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10315 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10316 parameters=(double *) RelinquishMagickMemory(parameters);
10319 case 121: /* SelectiveBlur */
10321 if (attribute_flag[0] != 0)
10323 flags=ParseGeometry(argument_list[0].string_reference,
10325 if ((flags & SigmaValue) == 0)
10326 geometry_info.sigma=1.0;
10327 if ((flags & PercentValue) != 0)
10328 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10330 if (attribute_flag[1] != 0)
10331 geometry_info.rho=argument_list[1].real_reference;
10332 if (attribute_flag[2] != 0)
10333 geometry_info.sigma=argument_list[2].real_reference;
10334 if (attribute_flag[3] != 0)
10335 geometry_info.xi=argument_list[3].integer_reference;;
10336 if (attribute_flag[4] != 0)
10337 channel=(ChannelType) argument_list[4].integer_reference;
10338 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10339 geometry_info.sigma,geometry_info.xi,exception);
10342 case 122: /* HaldClut */
10344 if (attribute_flag[0] == 0)
10346 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10348 goto PerlException;
10350 if (attribute_flag[1] != 0)
10351 channel=(ChannelType) argument_list[1].integer_reference;
10352 (void) HaldClutImageChannel(image,channel,
10353 argument_list[0].image_reference);
10356 case 123: /* BlueShift */
10358 if (attribute_flag[0] != 0)
10359 (void) ParseGeometry(argument_list[0].string_reference,
10361 image=BlueShiftImage(image,geometry_info.rho,exception);
10364 case 124: /* ForwardFourierTransformImage */
10366 image=ForwardFourierTransformImage(image,
10367 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10371 case 125: /* InverseFourierTransformImage */
10373 image=InverseFourierTransformImage(image,image->next,
10374 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10378 case 126: /* ColorDecisionList */
10380 if (attribute_flag[0] == 0)
10381 argument_list[0].string_reference=(char *) NULL;
10382 (void) ColorDecisionListImage(image,
10383 argument_list[0].string_reference);
10386 case 127: /* AutoGamma */
10388 if (attribute_flag[0] != 0)
10389 channel=(ChannelType) argument_list[0].integer_reference;
10390 (void) AutoGammaImageChannel(image,channel);
10393 case 128: /* AutoLevel */
10395 if (attribute_flag[0] != 0)
10396 channel=(ChannelType) argument_list[0].integer_reference;
10397 (void) AutoLevelImageChannel(image,channel);
10400 case 129: /* LevelColors */
10406 (void) QueryMagickColor("#000000",&black_point,exception);
10407 (void) QueryMagickColor("#ffffff",&white_point,exception);
10408 if (attribute_flag[1] != 0)
10409 (void) QueryMagickColor(argument_list[1].string_reference,
10410 &black_point,exception);
10411 if (attribute_flag[2] != 0)
10412 (void) QueryMagickColor(argument_list[2].string_reference,
10413 &white_point,exception);
10414 if (attribute_flag[3] != 0)
10415 channel=(ChannelType) argument_list[3].integer_reference;
10416 (void) LevelColorsImageChannel(image,channel,&black_point,
10417 &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
10421 case 130: /* Clamp */
10423 if (attribute_flag[0] != 0)
10424 channel=(ChannelType) argument_list[0].integer_reference;
10425 (void) ClampImageChannel(image,channel);
10428 case 131: /* Filter */
10433 if (attribute_flag[0] == 0)
10435 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10436 if (kernel == (KernelInfo *) NULL)
10438 if (attribute_flag[1] != 0)
10439 channel=(ChannelType) argument_list[1].integer_reference;
10440 if (attribute_flag[2] != 0)
10441 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10443 image=FilterImageChannel(image,channel,kernel,exception);
10444 kernel=DestroyKernelInfo(kernel);
10447 case 132: /* BrightnessContrast */
10455 if (attribute_flag[0] != 0)
10457 flags=ParseGeometry(argument_list[0].string_reference,
10459 brightness=geometry_info.rho;
10460 if ((flags & SigmaValue) == 0)
10461 contrast=geometry_info.sigma;
10463 if (attribute_flag[1] != 0)
10464 brightness=argument_list[1].real_reference;
10465 if (attribute_flag[2] != 0)
10466 contrast=argument_list[2].real_reference;
10467 if (attribute_flag[4] != 0)
10468 channel=(ChannelType) argument_list[4].integer_reference;
10469 (void) BrightnessContrastImageChannel(image,channel,brightness,
10473 case 133: /* Morphology */
10484 if (attribute_flag[0] == 0)
10486 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10487 if (kernel == (KernelInfo *) NULL)
10489 if (attribute_flag[1] != 0)
10490 channel=(ChannelType) argument_list[1].integer_reference;
10491 method=UndefinedMorphology;
10492 if (attribute_flag[2] != 0)
10493 method=argument_list[2].integer_reference;
10495 if (attribute_flag[3] != 0)
10496 iterations=argument_list[4].integer_reference;
10497 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10499 kernel=DestroyKernelInfo(kernel);
10502 case 108: /* Recolor */
10503 case 134: /* ColorMatrix */
10517 if (attribute_flag[0] == 0)
10519 av=(AV *) argument_list[0].array_reference;
10520 order=(size_t) sqrt(av_len(av)+1);
10521 color_matrix=(double *) AcquireQuantumMemory(order,order*
10522 sizeof(*color_matrix));
10523 if (color_matrix == (double *) NULL)
10525 ThrowPerlException(exception,ResourceLimitFatalError,
10526 "MemoryAllocationFailed",PackageName);
10527 goto PerlException;
10529 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10530 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10531 for ( ; j < (ssize_t) (order*order); j++)
10532 color_matrix[j]=0.0;
10533 kernel_info=AcquireKernelInfo("1");
10534 if (kernel_info == (KernelInfo *) NULL)
10536 kernel_info->width=order;
10537 kernel_info->height=order;
10538 kernel_info->values=color_matrix;
10539 image=ColorMatrixImage(image,kernel_info,exception);
10540 kernel_info->values=(double *) NULL;
10541 kernel_info=DestroyKernelInfo(kernel_info);
10542 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10545 case 135: /* Color */
10550 (void) QueryMagickColor("none",&color,exception);
10551 if (attribute_flag[0] != 0)
10552 (void) QueryMagickColor(argument_list[0].string_reference,
10554 (void) SetImageColor(image,&color);
10557 case 136: /* Mode */
10559 if (attribute_flag[0] != 0)
10561 flags=ParseGeometry(argument_list[0].string_reference,
10563 if ((flags & SigmaValue) == 0)
10564 geometry_info.sigma=1.0;
10566 if (attribute_flag[1] != 0)
10567 geometry_info.rho=argument_list[1].real_reference;
10568 if (attribute_flag[2] != 0)
10569 geometry_info.sigma=argument_list[2].real_reference;
10570 if (attribute_flag[3] != 0)
10571 channel=(ChannelType) argument_list[3].integer_reference;
10572 image=StatisticImageChannel(image,channel,ModeStatistic,
10573 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10576 case 137: /* Statistic */
10581 statistic=UndefinedStatistic;
10582 if (attribute_flag[0] != 0)
10584 flags=ParseGeometry(argument_list[0].string_reference,
10586 if ((flags & SigmaValue) == 0)
10587 geometry_info.sigma=1.0;
10589 if (attribute_flag[1] != 0)
10590 geometry_info.rho=argument_list[1].real_reference;
10591 if (attribute_flag[2] != 0)
10592 geometry_info.sigma=argument_list[2].real_reference;
10593 if (attribute_flag[3] != 0)
10594 channel=(ChannelType) argument_list[3].integer_reference;
10595 if (attribute_flag[4] != 0)
10596 statistic=(StatisticType) argument_list[4].integer_reference;
10597 image=StatisticImageChannel(image,channel,statistic,
10598 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10602 if (next != (Image *) NULL)
10603 (void) CatchImageException(next);
10604 if (region_image != (Image *) NULL)
10609 status=CompositeImage(region_image,CopyCompositeOp,image,
10610 region_info.x,region_info.y);
10612 (void) CatchImageException(region_image);
10613 image=DestroyImage(image);
10614 image=region_image;
10616 if (image != (Image *) NULL)
10619 if (next && (next != image))
10621 image->next=next->next;
10622 DeleteImageFromRegistry(*pv,next);
10624 sv_setiv(*pv,(IV) image);
10632 if (reference_vector)
10633 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10634 InheritPerlException(exception,perl_exception);
10635 exception=DestroyExceptionInfo(exception);
10636 sv_setiv(perl_exception,(IV) number_images);
10637 SvPOK_on(perl_exception);
10638 ST(0)=sv_2mortal(perl_exception);
10643 ###############################################################################
10651 ###############################################################################
10656 Image::Magick ref=NO_INIT
10701 PERL_UNUSED_VAR(ref);
10702 PERL_UNUSED_VAR(ix);
10703 exception=AcquireExceptionInfo();
10704 perl_exception=newSVpv("",0);
10707 if (sv_isobject(ST(0)) == 0)
10709 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10711 goto PerlException;
10713 reference=SvRV(ST(0));
10714 hv=SvSTASH(reference);
10716 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10718 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10719 if (image == (Image *) NULL)
10721 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10723 goto PerlException;
10728 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10729 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10730 (void) QueryMagickColor("none",&transparent_color,exception);
10731 for (i=2; i < items; i+=2)
10733 attribute=(char *) SvPV(ST(i-1),na);
10734 switch (*attribute)
10739 if (LocaleCompare(attribute,"background") == 0)
10741 (void) QueryColorDatabase(SvPV(ST(i),na),
10742 &montage_info->background_color,exception);
10743 for (next=image; next; next=next->next)
10744 next->background_color=montage_info->background_color;
10747 if (LocaleCompare(attribute,"border") == 0)
10749 montage_info->border_width=SvIV(ST(i));
10752 if (LocaleCompare(attribute,"bordercolor") == 0)
10754 (void) QueryColorDatabase(SvPV(ST(i),na),
10755 &montage_info->border_color,exception);
10756 for (next=image; next; next=next->next)
10757 next->border_color=montage_info->border_color;
10760 if (LocaleCompare(attribute,"borderwidth") == 0)
10762 montage_info->border_width=SvIV(ST(i));
10765 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10772 if (LocaleCompare(attribute,"compose") == 0)
10774 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10775 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10778 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10782 for (next=image; next; next=next->next)
10783 next->compose=(CompositeOperator) sp;
10786 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10793 if (LocaleCompare(attribute,"fill") == 0)
10795 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10799 if (LocaleCompare(attribute,"font") == 0)
10801 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10804 if (LocaleCompare(attribute,"frame") == 0)
10810 if (IsGeometry(p) == MagickFalse)
10812 ThrowPerlException(exception,OptionError,"MissingGeometry",
10816 (void) CloneString(&montage_info->frame,p);
10818 montage_info->frame=(char *) NULL;
10821 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10828 if (LocaleCompare(attribute,"geometry") == 0)
10834 if (IsGeometry(p) == MagickFalse)
10836 ThrowPerlException(exception,OptionError,"MissingGeometry",
10840 (void) CloneString(&montage_info->geometry,p);
10842 montage_info->geometry=(char *) NULL;
10845 if (LocaleCompare(attribute,"gravity") == 0)
10850 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10851 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10854 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10858 montage_info->gravity=(GravityType) in;
10859 for (next=image; next; next=next->next)
10860 next->gravity=(GravityType) in;
10863 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10870 if (LocaleCompare(attribute,"label") == 0)
10872 for (next=image; next; next=next->next)
10873 (void) SetImageProperty(next,"label",InterpretImageProperties(
10874 info ? info->image_info : (ImageInfo *) NULL,next,
10878 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10885 if (LocaleCompare(attribute,"mattecolor") == 0)
10887 (void) QueryColorDatabase(SvPV(ST(i),na),
10888 &montage_info->matte_color,exception);
10889 for (next=image; next; next=next->next)
10890 next->matte_color=montage_info->matte_color;
10893 if (LocaleCompare(attribute,"mode") == 0)
10898 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10899 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10904 ThrowPerlException(exception,OptionError,
10905 "UnrecognizedModeType",SvPV(ST(i),na));
10910 (void) CloneString(&montage_info->frame,"15x15+3+3");
10911 montage_info->shadow=MagickTrue;
10916 montage_info->frame=(char *) NULL;
10917 montage_info->shadow=MagickFalse;
10918 montage_info->border_width=0;
10921 case ConcatenateMode:
10923 montage_info->frame=(char *) NULL;
10924 montage_info->shadow=MagickFalse;
10925 (void) CloneString(&montage_info->geometry,"+0+0");
10926 montage_info->border_width=0;
10931 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10938 if (LocaleCompare(attribute,"pointsize") == 0)
10940 montage_info->pointsize=SvIV(ST(i));
10943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10950 if (LocaleCompare(attribute,"shadow") == 0)
10952 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10953 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
10956 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10960 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
10963 if (LocaleCompare(attribute,"stroke") == 0)
10965 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
10969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10976 if (LocaleCompare(attribute,"texture") == 0)
10978 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
10981 if (LocaleCompare(attribute,"tile") == 0)
10983 char *p=SvPV(ST(i),na);
10984 if (IsGeometry(p) == MagickFalse)
10986 ThrowPerlException(exception,OptionError,"MissingGeometry",
10990 (void) CloneString(&montage_info->tile,p);
10992 montage_info->tile=(char *) NULL;
10995 if (LocaleCompare(attribute,"title") == 0)
10997 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11000 if (LocaleCompare(attribute,"transparent") == 0)
11005 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11006 for (next=image; next; next=next->next)
11007 (void) TransparentPaintImage(next,&transparent_color,
11008 TransparentAlpha,MagickFalse);
11011 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11017 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11023 image=MontageImageList(info->image_info,montage_info,image,exception);
11024 montage_info=DestroyMontageInfo(montage_info);
11025 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11026 goto PerlException;
11027 if (transparent_color.alpha != TransparentAlpha)
11028 for (next=image; next; next=next->next)
11029 (void) TransparentPaintImage(next,&transparent_color,
11030 TransparentAlpha,MagickFalse);
11031 for ( ; image; image=image->next)
11033 AddImageToRegistry(sv,image);
11035 av_push(av,sv_bless(rv,hv));
11038 exception=DestroyExceptionInfo(exception);
11039 ST(0)=av_reference;
11040 SvREFCNT_dec(perl_exception);
11044 InheritPerlException(exception,perl_exception);
11045 exception=DestroyExceptionInfo(exception);
11046 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11047 SvPOK_on(perl_exception);
11048 ST(0)=sv_2mortal(perl_exception);
11053 ###############################################################################
11061 ###############################################################################
11066 Image::Magick ref=NO_INIT
11104 PERL_UNUSED_VAR(ref);
11105 PERL_UNUSED_VAR(ix);
11106 exception=AcquireExceptionInfo();
11107 perl_exception=newSVpv("",0);
11111 if (sv_isobject(ST(0)) == 0)
11113 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11115 goto PerlException;
11117 reference=SvRV(ST(0));
11118 hv=SvSTASH(reference);
11120 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11122 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11123 if (image == (Image *) NULL)
11125 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11127 goto PerlException;
11129 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11134 for (i=2; i < items; i+=2)
11136 attribute=(char *) SvPV(ST(i-1),na);
11137 switch (*attribute)
11142 if (LocaleCompare(attribute,"frames") == 0)
11144 number_frames=SvIV(ST(i));
11147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11159 image=MorphImages(image,number_frames,exception);
11160 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11161 goto PerlException;
11162 for ( ; image; image=image->next)
11164 AddImageToRegistry(sv,image);
11166 av_push(av,sv_bless(rv,hv));
11169 exception=DestroyExceptionInfo(exception);
11170 ST(0)=av_reference;
11171 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11175 InheritPerlException(exception,perl_exception);
11176 exception=DestroyExceptionInfo(exception);
11177 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11178 SvPOK_on(perl_exception);
11179 ST(0)=sv_2mortal(perl_exception);
11184 ###############################################################################
11192 ###############################################################################
11197 Image::Magick ref=NO_INIT
11225 PERL_UNUSED_VAR(ref);
11226 PERL_UNUSED_VAR(ix);
11227 exception=AcquireExceptionInfo();
11228 perl_exception=newSVpv("",0);
11230 if (sv_isobject(ST(0)) == 0)
11232 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11234 goto PerlException;
11236 reference=SvRV(ST(0));
11237 hv=SvSTASH(reference);
11238 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11239 if (image == (Image *) NULL)
11241 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11243 goto PerlException;
11245 image=MergeImageLayers(image,MosaicLayer,exception);
11247 Create blessed Perl array for the returned image.
11250 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11252 AddImageToRegistry(sv,image);
11254 av_push(av,sv_bless(rv,hv));
11256 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11257 (void) CopyMagickString(image->filename,info->image_info->filename,
11259 SetImageInfo(info->image_info,0,&image->exception);
11260 exception=DestroyExceptionInfo(exception);
11261 SvREFCNT_dec(perl_exception);
11265 InheritPerlException(exception,perl_exception);
11266 exception=DestroyExceptionInfo(exception);
11267 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11268 SvPOK_on(perl_exception); /* return messages in string context */
11269 ST(0)=sv_2mortal(perl_exception);
11274 ###############################################################################
11282 ###############################################################################
11287 Image::Magick ref=NO_INIT
11337 PERL_UNUSED_VAR(ref);
11338 PERL_UNUSED_VAR(ix);
11339 exception=AcquireExceptionInfo();
11340 perl_exception=newSVpv("",0);
11341 package_info=(struct PackageInfo *) NULL;
11342 ac=(items < 2) ? 1 : items-1;
11343 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11345 length=(STRLEN *) NULL;
11346 if (list == (char **) NULL)
11348 ThrowPerlException(exception,ResourceLimitError,
11349 "MemoryAllocationFailed",PackageName);
11350 goto PerlException;
11353 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11354 if (length == (STRLEN *) NULL)
11356 ThrowPerlException(exception,ResourceLimitError,
11357 "MemoryAllocationFailed",PackageName);
11358 goto PerlException;
11360 if (sv_isobject(ST(0)) == 0)
11362 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11364 goto PerlException;
11366 reference=SvRV(ST(0));
11367 if (SvTYPE(reference) != SVt_PVAV)
11369 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11371 goto PerlException;
11373 av=(AV *) reference;
11374 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11376 package_info=ClonePackageInfo(info,exception);
11379 *list=(char *) (*package_info->image_info->filename ?
11380 package_info->image_info->filename : "XC:black");
11382 for (n=0, i=0; i < ac; i++)
11384 list[n]=(char *) SvPV(ST(i+1),length[n]);
11385 if ((items >= 3) && strEQcase(list[n],"blob"))
11391 blob=(void *) (SvPV(ST(i+1),length[n]));
11392 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11394 if ((items >= 3) && strEQcase(list[n],"filename"))
11396 if ((items >= 3) && strEQcase(list[n],"file"))
11405 io_info=IoIFP(sv_2io(ST(i+1)));
11406 if (io_info == (PerlIO *) NULL)
11408 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11412 file=PerlIO_findFILE(io_info);
11413 if (file == (FILE *) NULL)
11415 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11419 SetImageInfoFile(package_info->image_info,file);
11421 if ((items >= 3) && strEQcase(list[n],"magick"))
11425 list[n]=(char *) NULL;
11427 status=ExpandFilenames(&n,&list);
11428 if (status == MagickFalse)
11430 ThrowPerlException(exception,ResourceLimitError,
11431 "MemoryAllocationFailed",PackageName);
11432 goto PerlException;
11435 for (i=0; i < n; i++)
11437 (void) CopyMagickString(package_info->image_info->filename,list[i],
11439 image=PingImage(package_info->image_info,exception);
11440 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11442 if ((package_info->image_info->file != (FILE *) NULL) ||
11443 (package_info->image_info->blob != (void *) NULL))
11444 DisassociateImageStream(image);
11445 count+=GetImageListLength(image);
11446 EXTEND(sp,4*count);
11447 for (next=image; next; next=next->next)
11449 PUSHs(sv_2mortal(newSViv(next->columns)));
11450 PUSHs(sv_2mortal(newSViv(next->rows)));
11451 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11452 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11454 image=DestroyImageList(image);
11459 for (i=0; i < n; i++)
11460 if (list[i] != (char *) NULL)
11461 for (p=keep; list[i] != *p++; )
11464 list[i]=(char *) RelinquishMagickMemory(list[i]);
11469 if (package_info != (struct PackageInfo *) NULL)
11470 DestroyPackageInfo(package_info);
11471 if (list && (list != keep))
11472 list=(char **) RelinquishMagickMemory(list);
11474 keep=(char **) RelinquishMagickMemory(keep);
11476 length=(STRLEN *) RelinquishMagickMemory(length);
11477 InheritPerlException(exception,perl_exception);
11478 exception=DestroyExceptionInfo(exception);
11479 SvREFCNT_dec(perl_exception); /* throw away all errors */
11483 ###############################################################################
11491 ###############################################################################
11496 Image::Magick ref=NO_INIT
11529 PERL_UNUSED_VAR(ref);
11530 PERL_UNUSED_VAR(ix);
11531 exception=AcquireExceptionInfo();
11532 perl_exception=newSVpv("",0);
11535 if (sv_isobject(ST(0)) == 0)
11537 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11539 goto PerlException;
11541 reference=SvRV(ST(0));
11542 hv=SvSTASH(reference);
11544 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11546 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11547 if (image == (Image *) NULL)
11549 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11551 goto PerlException;
11553 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11554 preview_type=GammaPreview;
11556 preview_type=(PreviewType)
11557 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11558 for ( ; image; image=image->next)
11560 preview_image=PreviewImage(image,preview_type,exception);
11561 if (preview_image == (Image *) NULL)
11562 goto PerlException;
11563 AddImageToRegistry(sv,preview_image);
11565 av_push(av,sv_bless(rv,hv));
11568 exception=DestroyExceptionInfo(exception);
11569 ST(0)=av_reference;
11570 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11574 InheritPerlException(exception,perl_exception);
11575 exception=DestroyExceptionInfo(exception);
11576 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11577 SvPOK_on(perl_exception);
11578 ST(0)=sv_2mortal(perl_exception);
11583 ###############################################################################
11587 # Q u e r y C o l o r #
11591 ###############################################################################
11595 QueryColor(ref,...)
11596 Image::Magick ref=NO_INIT
11616 PERL_UNUSED_VAR(ref);
11617 PERL_UNUSED_VAR(ix);
11618 exception=AcquireExceptionInfo();
11619 perl_exception=newSVpv("",0);
11628 colorlist=GetColorInfoList("*",&colors,exception);
11630 for (i=0; i < (ssize_t) colors; i++)
11632 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11634 colorlist=(const ColorInfo **)
11635 RelinquishMagickMemory((ColorInfo **) colorlist);
11636 goto PerlException;
11638 EXTEND(sp,5*items);
11639 for (i=1; i < items; i++)
11641 name=(char *) SvPV(ST(i),na);
11642 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11647 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11648 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11649 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11650 if (color.colorspace == CMYKColorspace)
11651 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11652 if (color.matte != MagickFalse)
11653 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11657 InheritPerlException(exception,perl_exception);
11658 exception=DestroyExceptionInfo(exception);
11659 SvREFCNT_dec(perl_exception);
11663 ###############################################################################
11667 # Q u e r y C o l o r N a m e #
11671 ###############################################################################
11675 QueryColorname(ref,...)
11676 Image::Magick ref=NO_INIT
11685 message[MaxTextExtent];
11704 *reference; /* reference is the SV* of ref=SvIV(reference) */
11706 PERL_UNUSED_VAR(ref);
11707 PERL_UNUSED_VAR(ix);
11708 exception=AcquireExceptionInfo();
11709 perl_exception=newSVpv("",0);
11710 reference=SvRV(ST(0));
11711 av=(AV *) reference;
11712 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11714 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11715 if (image == (Image *) NULL)
11717 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11719 goto PerlException;
11722 for (i=1; i < items; i++)
11724 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11725 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11727 PUSHs(sv_2mortal(newSVpv(message,0)));
11731 InheritPerlException(exception,perl_exception);
11732 exception=DestroyExceptionInfo(exception);
11733 SvREFCNT_dec(perl_exception);
11737 ###############################################################################
11741 # Q u e r y F o n t #
11745 ###############################################################################
11750 Image::Magick ref=NO_INIT
11757 message[MaxTextExtent];
11768 volatile const TypeInfo
11771 PERL_UNUSED_VAR(ref);
11772 PERL_UNUSED_VAR(ix);
11773 exception=AcquireExceptionInfo();
11774 perl_exception=newSVpv("",0);
11783 typelist=GetTypeInfoList("*",&types,exception);
11785 for (i=0; i < (ssize_t) types; i++)
11787 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11789 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11791 goto PerlException;
11793 EXTEND(sp,10*items);
11794 for (i=1; i < items; i++)
11796 name=(char *) SvPV(ST(i),na);
11797 type_info=GetTypeInfo(name,exception);
11798 if (type_info == (TypeInfo *) NULL)
11803 if (type_info->name == (char *) NULL)
11806 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11807 if (type_info->description == (char *) NULL)
11810 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11811 if (type_info->family == (char *) NULL)
11814 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11815 if (type_info->style == UndefinedStyle)
11818 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11819 type_info->style),0)));
11820 if (type_info->stretch == UndefinedStretch)
11823 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11824 type_info->stretch),0)));
11825 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11826 type_info->weight);
11827 PUSHs(sv_2mortal(newSVpv(message,0)));
11828 if (type_info->encoding == (char *) NULL)
11831 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11832 if (type_info->foundry == (char *) NULL)
11835 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11836 if (type_info->format == (char *) NULL)
11839 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11840 if (type_info->metrics == (char *) NULL)
11843 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11844 if (type_info->glyphs == (char *) NULL)
11847 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11851 InheritPerlException(exception,perl_exception);
11852 exception=DestroyExceptionInfo(exception);
11853 SvREFCNT_dec(perl_exception);
11857 ###############################################################################
11861 # Q u e r y F o n t M e t r i c s #
11865 ###############################################################################
11869 QueryFontMetrics(ref,...)
11870 Image::Magick ref=NO_INIT
11872 queryfontmetrics = 1
11919 *reference; /* reference is the SV* of ref=SvIV(reference) */
11924 PERL_UNUSED_VAR(ref);
11925 PERL_UNUSED_VAR(ix);
11926 exception=AcquireExceptionInfo();
11927 package_info=(struct PackageInfo *) NULL;
11928 perl_exception=newSVpv("",0);
11929 reference=SvRV(ST(0));
11930 av=(AV *) reference;
11931 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11933 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11934 if (image == (Image *) NULL)
11936 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11938 goto PerlException;
11940 package_info=ClonePackageInfo(info,exception);
11941 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
11942 CloneString(&draw_info->text,"");
11943 current=draw_info->affine;
11944 GetAffineMatrix(&affine);
11947 EXTEND(sp,7*items);
11948 for (i=2; i < items; i+=2)
11950 attribute=(char *) SvPV(ST(i-1),na);
11951 switch (*attribute)
11956 if (LocaleCompare(attribute,"antialias") == 0)
11958 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
11962 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11966 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
11969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11976 if (LocaleCompare(attribute,"density") == 0)
11978 CloneString(&draw_info->density,SvPV(ST(i),na));
11981 if (LocaleCompare(attribute,"direction") == 0)
11983 draw_info->direction=(DirectionType) ParseCommandOption(
11984 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
11987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11994 if (LocaleCompare(attribute,"encoding") == 0)
11996 CloneString(&draw_info->encoding,SvPV(ST(i),na));
11999 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12006 if (LocaleCompare(attribute,"family") == 0)
12008 CloneString(&draw_info->family,SvPV(ST(i),na));
12011 if (LocaleCompare(attribute,"fill") == 0)
12014 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12015 &image->exception);
12018 if (LocaleCompare(attribute,"font") == 0)
12020 CloneString(&draw_info->font,SvPV(ST(i),na));
12023 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12030 if (LocaleCompare(attribute,"geometry") == 0)
12032 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12035 if (LocaleCompare(attribute,"gravity") == 0)
12037 draw_info->gravity=(GravityType) ParseCommandOption(
12038 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12041 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12048 if (LocaleCompare(attribute,"interline-spacing") == 0)
12050 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12051 draw_info->interline_spacing=geometry_info.rho;
12054 if (LocaleCompare(attribute,"interword-spacing") == 0)
12056 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12057 draw_info->interword_spacing=geometry_info.rho;
12060 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12067 if (LocaleCompare(attribute,"kerning") == 0)
12069 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12070 draw_info->kerning=geometry_info.rho;
12073 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12080 if (LocaleCompare(attribute,"pointsize") == 0)
12082 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12083 draw_info->pointsize=geometry_info.rho;
12086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12093 if (LocaleCompare(attribute,"rotate") == 0)
12095 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12096 affine.rx=geometry_info.rho;
12097 affine.ry=geometry_info.sigma;
12098 if ((flags & SigmaValue) == 0)
12099 affine.ry=affine.rx;
12102 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12109 if (LocaleCompare(attribute,"scale") == 0)
12111 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12112 affine.sx=geometry_info.rho;
12113 affine.sy=geometry_info.sigma;
12114 if ((flags & SigmaValue) == 0)
12115 affine.sy=affine.sx;
12118 if (LocaleCompare(attribute,"skew") == 0)
12124 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12125 x_angle=geometry_info.rho;
12126 y_angle=geometry_info.sigma;
12127 if ((flags & SigmaValue) == 0)
12129 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12130 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12133 if (LocaleCompare(attribute,"stroke") == 0)
12136 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12137 &image->exception);
12140 if (LocaleCompare(attribute,"style") == 0)
12142 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12146 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12150 draw_info->style=(StyleType) type;
12153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12160 if (LocaleCompare(attribute,"text") == 0)
12162 CloneString(&draw_info->text,SvPV(ST(i),na));
12165 if (LocaleCompare(attribute,"translate") == 0)
12167 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12168 affine.tx=geometry_info.rho;
12169 affine.ty=geometry_info.sigma;
12170 if ((flags & SigmaValue) == 0)
12171 affine.ty=affine.tx;
12174 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12181 if (LocaleCompare(attribute,"weight") == 0)
12183 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12184 draw_info->weight=(size_t) geometry_info.rho;
12187 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12194 if (LocaleCompare(attribute,"x") == 0)
12196 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12197 x=geometry_info.rho;
12200 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12207 if (LocaleCompare(attribute,"y") == 0)
12209 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12210 y=geometry_info.rho;
12213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12219 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12225 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12226 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12227 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12228 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12229 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12230 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12231 if (draw_info->geometry == (char *) NULL)
12233 draw_info->geometry=AcquireString((char *) NULL);
12234 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12235 "%.15g,%.15g",x,y);
12237 status=GetTypeMetrics(image,draw_info,&metrics);
12238 (void) CatchImageException(image);
12239 if (status == MagickFalse)
12243 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12244 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12245 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12246 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12247 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12248 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12249 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12250 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12251 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12252 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12253 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12254 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12255 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12257 draw_info=DestroyDrawInfo(draw_info);
12260 if (package_info != (struct PackageInfo *) NULL)
12261 DestroyPackageInfo(package_info);
12262 InheritPerlException(exception,perl_exception);
12263 exception=DestroyExceptionInfo(exception);
12264 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12268 ###############################################################################
12272 # 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 #
12276 ###############################################################################
12280 QueryMultilineFontMetrics(ref,...)
12281 Image::Magick ref=NO_INIT
12283 querymultilinefontmetrics = 1
12330 *reference; /* reference is the SV* of ref=SvIV(reference) */
12335 PERL_UNUSED_VAR(ref);
12336 PERL_UNUSED_VAR(ix);
12337 exception=AcquireExceptionInfo();
12338 package_info=(struct PackageInfo *) NULL;
12339 perl_exception=newSVpv("",0);
12340 reference=SvRV(ST(0));
12341 av=(AV *) reference;
12342 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12344 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12345 if (image == (Image *) NULL)
12347 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12349 goto PerlException;
12351 package_info=ClonePackageInfo(info,exception);
12352 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12353 CloneString(&draw_info->text,"");
12354 current=draw_info->affine;
12355 GetAffineMatrix(&affine);
12358 EXTEND(sp,7*items);
12359 for (i=2; i < items; i+=2)
12361 attribute=(char *) SvPV(ST(i-1),na);
12362 switch (*attribute)
12367 if (LocaleCompare(attribute,"antialias") == 0)
12369 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12373 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12377 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12380 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12387 if (LocaleCompare(attribute,"density") == 0)
12389 CloneString(&draw_info->density,SvPV(ST(i),na));
12392 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12399 if (LocaleCompare(attribute,"encoding") == 0)
12401 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12411 if (LocaleCompare(attribute,"family") == 0)
12413 CloneString(&draw_info->family,SvPV(ST(i),na));
12416 if (LocaleCompare(attribute,"fill") == 0)
12419 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12420 &image->exception);
12423 if (LocaleCompare(attribute,"font") == 0)
12425 CloneString(&draw_info->font,SvPV(ST(i),na));
12428 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12435 if (LocaleCompare(attribute,"geometry") == 0)
12437 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12440 if (LocaleCompare(attribute,"gravity") == 0)
12442 draw_info->gravity=(GravityType) ParseCommandOption(
12443 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12446 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12453 if (LocaleCompare(attribute,"pointsize") == 0)
12455 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12456 draw_info->pointsize=geometry_info.rho;
12459 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12466 if (LocaleCompare(attribute,"rotate") == 0)
12468 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12469 affine.rx=geometry_info.rho;
12470 affine.ry=geometry_info.sigma;
12471 if ((flags & SigmaValue) == 0)
12472 affine.ry=affine.rx;
12475 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12482 if (LocaleCompare(attribute,"scale") == 0)
12484 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12485 affine.sx=geometry_info.rho;
12486 affine.sy=geometry_info.sigma;
12487 if ((flags & SigmaValue) == 0)
12488 affine.sy=affine.sx;
12491 if (LocaleCompare(attribute,"skew") == 0)
12497 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12498 x_angle=geometry_info.rho;
12499 y_angle=geometry_info.sigma;
12500 if ((flags & SigmaValue) == 0)
12502 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12503 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12506 if (LocaleCompare(attribute,"stroke") == 0)
12509 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12510 &image->exception);
12513 if (LocaleCompare(attribute,"style") == 0)
12515 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12519 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12523 draw_info->style=(StyleType) type;
12526 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12533 if (LocaleCompare(attribute,"text") == 0)
12535 CloneString(&draw_info->text,SvPV(ST(i),na));
12538 if (LocaleCompare(attribute,"translate") == 0)
12540 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12541 affine.tx=geometry_info.rho;
12542 affine.ty=geometry_info.sigma;
12543 if ((flags & SigmaValue) == 0)
12544 affine.ty=affine.tx;
12547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12554 if (LocaleCompare(attribute,"weight") == 0)
12556 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12557 draw_info->weight=(size_t) geometry_info.rho;
12560 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12567 if (LocaleCompare(attribute,"x") == 0)
12569 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12570 x=geometry_info.rho;
12573 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12580 if (LocaleCompare(attribute,"y") == 0)
12582 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12583 y=geometry_info.rho;
12586 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12592 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12598 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12599 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12600 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12601 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12602 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12603 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12604 if (draw_info->geometry == (char *) NULL)
12606 draw_info->geometry=AcquireString((char *) NULL);
12607 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12608 "%.15g,%.15g",x,y);
12610 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12611 (void) CatchImageException(image);
12612 if (status == MagickFalse)
12616 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12617 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12618 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12619 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12620 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12621 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12622 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12623 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12624 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12625 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12626 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12627 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12628 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12630 draw_info=DestroyDrawInfo(draw_info);
12633 if (package_info != (struct PackageInfo *) NULL)
12634 DestroyPackageInfo(package_info);
12635 InheritPerlException(exception,perl_exception);
12636 exception=DestroyExceptionInfo(exception);
12637 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12641 ###############################################################################
12645 # Q u e r y F o r m a t #
12649 ###############################################################################
12653 QueryFormat(ref,...)
12654 Image::Magick ref=NO_INIT
12671 volatile const MagickInfo
12674 PERL_UNUSED_VAR(ref);
12675 PERL_UNUSED_VAR(ix);
12676 exception=AcquireExceptionInfo();
12677 perl_exception=newSVpv("",0);
12681 format[MaxTextExtent];
12689 format_list=GetMagickInfoList("*",&types,exception);
12691 for (i=0; i < (ssize_t) types; i++)
12693 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12694 LocaleLower(format);
12695 PUSHs(sv_2mortal(newSVpv(format,0)));
12697 format_list=(const MagickInfo **)
12698 RelinquishMagickMemory((MagickInfo *) format_list);
12699 goto PerlException;
12701 EXTEND(sp,8*items);
12702 for (i=1; i < items; i++)
12704 name=(char *) SvPV(ST(i),na);
12705 magick_info=GetMagickInfo(name,exception);
12706 if (magick_info == (const MagickInfo *) NULL)
12711 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12712 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12713 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12714 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12715 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12716 if (magick_info->description == (char *) NULL)
12719 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12720 if (magick_info->module == (char *) NULL)
12723 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12727 InheritPerlException(exception,perl_exception);
12728 exception=DestroyExceptionInfo(exception);
12729 SvREFCNT_dec(perl_exception);
12733 ###############################################################################
12737 # Q u e r y O p t i o n #
12741 ###############################################################################
12745 QueryOption(ref,...)
12746 Image::Magick ref=NO_INIT
12767 PERL_UNUSED_VAR(ref);
12768 PERL_UNUSED_VAR(ix);
12769 exception=AcquireExceptionInfo();
12770 perl_exception=newSVpv("",0);
12771 EXTEND(sp,8*items);
12772 for (i=1; i < items; i++)
12774 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12776 options=GetCommandOptions((CommandOption) option);
12777 if (options == (char **) NULL)
12781 for (j=0; options[j] != (char *) NULL; j++)
12782 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12783 options=DestroyStringList(options);
12787 InheritPerlException(exception,perl_exception);
12788 exception=DestroyExceptionInfo(exception);
12789 SvREFCNT_dec(perl_exception);
12793 ###############################################################################
12801 ###############################################################################
12806 Image::Magick ref=NO_INIT
12853 *perl_exception, /* Perl variable for storing messages */
12858 PERL_UNUSED_VAR(ref);
12859 PERL_UNUSED_VAR(ix);
12860 exception=AcquireExceptionInfo();
12861 perl_exception=newSVpv("",0);
12863 package_info=(struct PackageInfo *) NULL;
12865 ac=(items < 2) ? 1 : items-1;
12866 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12868 length=(STRLEN *) NULL;
12869 if (list == (char **) NULL)
12871 ThrowPerlException(exception,ResourceLimitError,
12872 "MemoryAllocationFailed",PackageName);
12873 goto PerlException;
12875 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12876 if (length == (STRLEN *) NULL)
12878 ThrowPerlException(exception,ResourceLimitError,
12879 "MemoryAllocationFailed",PackageName);
12880 goto PerlException;
12882 if (sv_isobject(ST(0)) == 0)
12884 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12886 goto PerlException;
12888 reference=SvRV(ST(0));
12889 hv=SvSTASH(reference);
12890 if (SvTYPE(reference) != SVt_PVAV)
12892 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12894 goto PerlException;
12896 av=(AV *) reference;
12897 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12899 package_info=ClonePackageInfo(info,exception);
12902 *list=(char *) (*package_info->image_info->filename ?
12903 package_info->image_info->filename : "XC:black");
12905 for (n=0, i=0; i < ac; i++)
12907 list[n]=(char *) SvPV(ST(i+1),length[n]);
12908 if ((items >= 3) && strEQcase(list[n],"blob"))
12914 blob=(void *) (SvPV(ST(i+1),length[n]));
12915 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12917 if ((items >= 3) && strEQcase(list[n],"filename"))
12919 if ((items >= 3) && strEQcase(list[n],"file"))
12928 io_info=IoIFP(sv_2io(ST(i+1)));
12929 if (io_info == (PerlIO *) NULL)
12931 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12935 file=PerlIO_findFILE(io_info);
12936 if (file == (FILE *) NULL)
12938 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12942 SetImageInfoFile(package_info->image_info,file);
12944 if ((items >= 3) && strEQcase(list[n],"magick"))
12948 list[n]=(char *) NULL;
12950 status=ExpandFilenames(&n,&list);
12951 if (status == MagickFalse)
12953 ThrowPerlException(exception,ResourceLimitError,
12954 "MemoryAllocationFailed",PackageName);
12955 goto PerlException;
12958 for (i=0; i < n; i++)
12960 if ((package_info->image_info->file != (FILE *) NULL) ||
12961 (package_info->image_info->blob != (void *) NULL))
12963 image=ReadImages(package_info->image_info,exception);
12964 if (image != (Image *) NULL)
12965 DisassociateImageStream(image);
12969 (void) CopyMagickString(package_info->image_info->filename,list[i],
12971 image=ReadImages(package_info->image_info,exception);
12973 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
12975 for ( ; image; image=image->next)
12977 AddImageToRegistry(sv,image);
12979 av_push(av,sv_bless(rv,hv));
12987 for (i=0; i < n; i++)
12988 if (list[i] != (char *) NULL)
12989 for (p=keep; list[i] != *p++; )
12990 if (*p == (char *) NULL)
12992 list[i]=(char *) RelinquishMagickMemory(list[i]);
12997 if (package_info != (struct PackageInfo *) NULL)
12998 DestroyPackageInfo(package_info);
12999 if (list && (list != keep))
13000 list=(char **) RelinquishMagickMemory(list);
13002 keep=(char **) RelinquishMagickMemory(keep);
13004 length=(STRLEN *) RelinquishMagickMemory(length);
13005 InheritPerlException(exception,perl_exception);
13006 exception=DestroyExceptionInfo(exception);
13007 sv_setiv(perl_exception,(IV) number_images);
13008 SvPOK_on(perl_exception);
13009 ST(0)=sv_2mortal(perl_exception);
13014 ###############################################################################
13022 ###############################################################################
13027 Image::Magick ref=NO_INIT
13050 PERL_UNUSED_VAR(ref);
13051 PERL_UNUSED_VAR(ix);
13052 exception=AcquireExceptionInfo();
13053 perl_exception=newSVpv("",0);
13054 reference=SvRV(ST(0));
13055 av=(AV *) reference;
13056 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13058 for (i=1; i < items; i++)
13059 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13060 SvPV(ST(i),na),exception);
13061 InheritPerlException(exception,perl_exception);
13062 exception=DestroyExceptionInfo(exception);
13063 SvREFCNT_dec(perl_exception); /* throw away all errors */
13067 ###############################################################################
13075 ###############################################################################
13080 Image::Magick ref=NO_INIT
13103 *reference; /* reference is the SV* of ref=SvIV(reference) */
13105 PERL_UNUSED_VAR(ref);
13106 PERL_UNUSED_VAR(ix);
13107 exception=AcquireExceptionInfo();
13108 perl_exception=newSVpv("",0);
13109 if (sv_isobject(ST(0)) == 0)
13111 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13113 goto PerlException;
13115 reference=SvRV(ST(0));
13116 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13118 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13120 for (i=2; i < items; i+=2)
13121 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13124 InheritPerlException(exception,perl_exception);
13125 exception=DestroyExceptionInfo(exception);
13126 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13127 SvPOK_on(perl_exception);
13128 ST(0)=sv_2mortal(perl_exception);
13133 ###############################################################################
13137 # S e t P i x e l #
13141 ###############################################################################
13146 Image::Magick ref=NO_INIT
13187 *reference; /* reference is the SV* of ref=SvIV(reference) */
13189 PERL_UNUSED_VAR(ref);
13190 PERL_UNUSED_VAR(ix);
13191 exception=AcquireExceptionInfo();
13192 perl_exception=newSVpv("",0);
13193 reference=SvRV(ST(0));
13194 av=(AV *) reference;
13195 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13197 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13198 if (image == (Image *) NULL)
13200 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13202 goto PerlException;
13205 channel=DefaultChannels;
13206 normalize=MagickTrue;
13209 region.width=image->columns;
13212 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13213 for (i=2; i < items; i+=2)
13215 attribute=(char *) SvPV(ST(i-1),na);
13216 switch (*attribute)
13221 if (LocaleCompare(attribute,"channel") == 0)
13226 option=ParseChannelOption(SvPV(ST(i),na));
13229 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13233 channel=(ChannelType) option;
13236 if (LocaleCompare(attribute,"color") == 0)
13238 if (SvTYPE(ST(i)) != SVt_RV)
13241 message[MaxTextExtent];
13243 (void) FormatLocaleString(message,MaxTextExtent,
13244 "invalid %.60s value",attribute);
13245 ThrowPerlException(exception,OptionError,message,
13248 av=(AV *) SvRV(ST(i));
13251 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13258 if (LocaleCompare(attribute,"geometry") == 0)
13260 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13263 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13270 if (LocaleCompare(attribute,"normalize") == 0)
13272 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13276 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13280 normalize=option != 0 ? MagickTrue : MagickFalse;
13283 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13290 if (LocaleCompare(attribute,"x") == 0)
13292 region.x=SvIV(ST(i));
13295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13302 if (LocaleCompare(attribute,"y") == 0)
13304 region.y=SvIV(ST(i));
13307 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13313 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13319 (void) SetImageStorageClass(image,DirectClass);
13320 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13321 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13322 (SvTYPE(av) != SVt_PVAV))
13334 if (normalize != MagickFalse)
13335 scale=QuantumRange;
13336 if (((GetPixelRedTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13338 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13339 av_fetch(av,i,0)))),q);
13342 if (((GetPixelGreenTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13344 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13345 av_fetch(av,i,0)))),q);
13348 if (((GetPixelBlueTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13350 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13351 av_fetch(av,i,0)))),q);
13354 if ((((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
13355 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13357 SetPixelBlack(image,ClampToQuantum(scale*
13358 SvNV(*(av_fetch(av,i,0)))),q);
13361 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) && (i <= av_len(av)))
13363 SetPixelAlpha(image,ClampToQuantum(scale*
13364 SvNV(*(av_fetch(av,i,0)))),q);
13367 (void) SyncAuthenticPixels(image,exception);
13371 InheritPerlException(exception,perl_exception);
13372 exception=DestroyExceptionInfo(exception);
13373 SvREFCNT_dec(perl_exception);
13377 ###############################################################################
13385 ###############################################################################
13390 Image::Magick ref=NO_INIT
13429 PERL_UNUSED_VAR(ref);
13430 PERL_UNUSED_VAR(ix);
13431 exception=AcquireExceptionInfo();
13432 perl_exception=newSVpv("",0);
13436 if (sv_isobject(ST(0)) == 0)
13438 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13440 goto PerlException;
13442 reference=SvRV(ST(0));
13443 hv=SvSTASH(reference);
13445 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13447 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13448 if (image == (Image *) NULL)
13450 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13452 goto PerlException;
13454 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13460 for (i=2; i < items; i+=2)
13462 attribute=(char *) SvPV(ST(i-1),na);
13463 switch (*attribute)
13468 if (LocaleCompare(attribute,"offset") == 0)
13470 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13473 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13480 if (LocaleCompare(attribute,"stack") == 0)
13482 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13486 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13492 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13498 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13504 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13506 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13507 goto PerlException;
13508 for ( ; image; image=image->next)
13510 AddImageToRegistry(sv,image);
13512 av_push(av,sv_bless(rv,hv));
13515 exception=DestroyExceptionInfo(exception);
13516 ST(0)=av_reference;
13517 SvREFCNT_dec(perl_exception);
13521 InheritPerlException(exception,perl_exception);
13522 exception=DestroyExceptionInfo(exception);
13523 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13524 SvPOK_on(perl_exception);
13525 ST(0)=sv_2mortal(perl_exception);
13530 ###############################################################################
13534 # S t a t i s t i c s #
13538 ###############################################################################
13542 Statistics(ref,...)
13543 Image::Magick ref=NO_INIT
13545 StatisticsImage = 1
13547 statisticsimage = 3
13550 #define ChannelStatistics(channel) \
13552 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13553 (double) channel_statistics[channel].depth); \
13554 PUSHs(sv_2mortal(newSVpv(message,0))); \
13555 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13556 channel_statistics[channel].minima/scale); \
13557 PUSHs(sv_2mortal(newSVpv(message,0))); \
13558 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13559 channel_statistics[channel].maxima/scale); \
13560 PUSHs(sv_2mortal(newSVpv(message,0))); \
13561 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13562 channel_statistics[channel].mean/scale); \
13563 PUSHs(sv_2mortal(newSVpv(message,0))); \
13564 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13565 channel_statistics[channel].standard_deviation/scale); \
13566 PUSHs(sv_2mortal(newSVpv(message,0))); \
13567 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13568 channel_statistics[channel].kurtosis); \
13569 PUSHs(sv_2mortal(newSVpv(message,0))); \
13570 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13571 channel_statistics[channel].skewness); \
13572 PUSHs(sv_2mortal(newSVpv(message,0))); \
13579 message[MaxTextExtent];
13582 *channel_statistics;
13603 PERL_UNUSED_VAR(ref);
13604 PERL_UNUSED_VAR(ix);
13605 exception=AcquireExceptionInfo();
13606 perl_exception=newSVpv("",0);
13608 if (sv_isobject(ST(0)) == 0)
13610 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13612 goto PerlException;
13614 reference=SvRV(ST(0));
13617 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13618 if (image == (Image *) NULL)
13620 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13622 goto PerlException;
13624 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13626 for ( ; image; image=image->next)
13628 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13629 if (channel_statistics == (ChannelStatistics *) NULL)
13632 EXTEND(sp,35*count);
13633 scale=(double) QuantumRange;
13634 ChannelStatistics(RedChannel);
13635 ChannelStatistics(GreenChannel);
13636 ChannelStatistics(BlueChannel);
13637 if (image->colorspace == CMYKColorspace)
13638 ChannelStatistics(BlackChannel);
13639 if (image->matte != MagickFalse)
13640 ChannelStatistics(AlphaChannel);
13641 channel_statistics=(ChannelStatistics *)
13642 RelinquishMagickMemory(channel_statistics);
13646 InheritPerlException(exception,perl_exception);
13647 exception=DestroyExceptionInfo(exception);
13648 SvREFCNT_dec(perl_exception);
13652 ###############################################################################
13656 # S y n c A u t h e n t i c P i x e l s #
13660 ###############################################################################
13664 SyncAuthenticPixels(ref,...)
13665 Image::Magick ref = NO_INIT
13667 Syncauthenticpixels = 1
13668 SyncImagePixels = 2
13669 syncimagepixels = 3
13688 PERL_UNUSED_VAR(ref);
13689 PERL_UNUSED_VAR(ix);
13690 exception=AcquireExceptionInfo();
13691 perl_exception=newSVpv("",0);
13692 if (sv_isobject(ST(0)) == 0)
13694 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13696 goto PerlException;
13699 reference=SvRV(ST(0));
13700 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13701 if (image == (Image *) NULL)
13703 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13705 goto PerlException;
13708 status=SyncAuthenticPixels(image,exception);
13709 if (status != MagickFalse)
13711 InheritException(exception,&image->exception);
13714 InheritPerlException(exception,perl_exception);
13715 exception=DestroyExceptionInfo(exception);
13716 SvREFCNT_dec(perl_exception); /* throw away all errors */
13720 ###############################################################################
13724 # T r a n s f o r m #
13728 ###############################################################################
13733 Image::Magick ref=NO_INIT
13771 PERL_UNUSED_VAR(ref);
13772 PERL_UNUSED_VAR(ix);
13773 exception=AcquireExceptionInfo();
13774 perl_exception=newSVpv("",0);
13778 if (sv_isobject(ST(0)) == 0)
13780 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13782 goto PerlException;
13784 reference=SvRV(ST(0));
13785 hv=SvSTASH(reference);
13787 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13789 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13790 if (image == (Image *) NULL)
13792 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13794 goto PerlException;
13796 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13800 crop_geometry=(char *) NULL;
13801 geometry=(char *) NULL;
13802 for (i=2; i < items; i+=2)
13804 attribute=(char *) SvPV(ST(i-1),na);
13805 switch (*attribute)
13810 if (LocaleCompare(attribute,"crop") == 0)
13812 crop_geometry=SvPV(ST(i),na);
13815 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13822 if (LocaleCompare(attribute,"geometry") == 0)
13824 geometry=SvPV(ST(i),na);
13827 if (LocaleCompare(attribute,"gravity") == 0)
13835 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13836 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13839 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13843 for (next=image; next; next=next->next)
13844 next->gravity=(GravityType) in;
13847 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13853 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13859 for ( ; image; image=image->next)
13861 clone=CloneImage(image,0,0,MagickTrue,exception);
13862 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13863 goto PerlException;
13864 TransformImage(&clone,crop_geometry,geometry);
13865 for ( ; clone; clone=clone->next)
13867 AddImageToRegistry(sv,clone);
13869 av_push(av,sv_bless(rv,hv));
13873 exception=DestroyExceptionInfo(exception);
13874 ST(0)=av_reference;
13875 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13879 InheritPerlException(exception,perl_exception);
13880 exception=DestroyExceptionInfo(exception);
13881 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13882 SvPOK_on(perl_exception);
13883 ST(0)=sv_2mortal(perl_exception);
13888 ###############################################################################
13896 ###############################################################################
13901 Image::Magick ref=NO_INIT
13909 filename[MaxTextExtent];
13933 PERL_UNUSED_VAR(ref);
13934 PERL_UNUSED_VAR(ix);
13935 exception=AcquireExceptionInfo();
13936 perl_exception=newSVpv("",0);
13938 package_info=(struct PackageInfo *) NULL;
13939 if (sv_isobject(ST(0)) == 0)
13941 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13943 goto PerlException;
13945 reference=SvRV(ST(0));
13946 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13947 if (image == (Image *) NULL)
13949 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13951 goto PerlException;
13953 package_info=ClonePackageInfo(info,exception);
13955 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
13958 for (i=2; i < items; i+=2)
13959 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
13961 (void) CopyMagickString(filename,package_info->image_info->filename,
13964 for (next=image; next; next=next->next)
13966 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
13967 next->scene=scene++;
13969 SetImageInfo(package_info->image_info,(unsigned int)
13970 GetImageListLength(image),&image->exception);
13971 for (next=image; next; next=next->next)
13973 (void) WriteImage(package_info->image_info,next);
13974 if (next->exception.severity >= ErrorException)
13975 InheritException(exception,&next->exception);
13976 GetImageException(next,exception);
13978 if (package_info->image_info->adjoin)
13983 if (package_info != (struct PackageInfo *) NULL)
13984 DestroyPackageInfo(package_info);
13985 InheritPerlException(exception,perl_exception);
13986 exception=DestroyExceptionInfo(exception);
13987 sv_setiv(perl_exception,(IV) number_images);
13988 SvPOK_on(perl_exception);
13989 ST(0)=sv_2mortal(perl_exception);