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-2010 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 <magick/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 MagickPI 3.14159265358979323846264338327950288419716939937510
82 #define MaxArguments 32
86 #define NumberOf(array) (sizeof(array)/sizeof(*array))
87 #define PackageName "Image::Magick"
90 #define PerlIO_importFILE(f, fl) (f)
91 #define PerlIO_findFILE(f) NULL
94 #define sv_undef PL_sv_undef
97 #define AddImageToRegistry(image) \
99 if (magick_registry != (SplayTreeInfo *) NULL) \
101 (void) AddValueToSplayTree(magick_registry,image,image); \
102 sv=newSViv((IV) image); \
106 #define DeleteImageFromRegistry(reference,image) \
108 if (magick_registry != (SplayTreeInfo *) NULL) \
110 if (GetImageReferenceCount(image) == 1) \
111 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
112 image=DestroyImage(image); \
113 sv_setiv(reference,0); \
117 #define InheritPerlException(exception,perl_exception) \
120 message[MaxTextExtent]; \
122 if ((exception)->severity != UndefinedException) \
124 (void) FormatMagickString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
125 (exception)->severity, (exception)->reason ? \
126 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
127 "Unknown", (exception)->description ? " (" : "", \
128 (exception)->description ? GetLocaleExceptionMessage( \
129 (exception)->severity,(exception)->description) : "", \
130 (exception)->description ? ")" : ""); \
131 if ((perl_exception) != (SV *) NULL) \
133 if (SvCUR(perl_exception)) \
134 sv_catpv(perl_exception,"\n"); \
135 sv_catpv(perl_exception,message); \
140 #define ThrowPerlException(exception,severity,tag,reason) \
141 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
142 tag,"`%s'",reason); \
145 Typedef and structure declarations.
149 ArrayReference = (~0),
150 RealReference = (~0)-1,
151 FileReference = (~0)-2,
152 ImageReference = (~0)-3,
153 IntegerReference = (~0)-4,
154 StringReference = (~0)-5
157 typedef struct _Arguments
197 *Image__Magick; /* data type for the Image::Magick package */
209 arguments[MaxArguments];
212 { "Comment", { {"comment", StringReference} } },
213 { "Label", { {"label", StringReference} } },
214 { "AddNoise", { {"noise", MagickNoiseOptions},
215 {"channel", MagickChannelOptions} } },
216 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
217 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
218 {"height", IntegerReference}, {"fill", StringReference},
219 {"bordercolor", StringReference}, {"color", StringReference},
220 {"compose", MagickComposeOptions} } },
221 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
222 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
223 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
224 {"height", IntegerReference}, {"x", IntegerReference},
225 {"y", IntegerReference} } },
226 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
227 {"height", IntegerReference}, {"x", IntegerReference},
228 {"y", IntegerReference}, {"fuzz", StringReference},
229 {"gravity", MagickGravityOptions} } },
231 { "Edge", { {"radius", RealReference} } },
232 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
233 {"sigma", RealReference} } },
237 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
238 {"height", IntegerReference}, {"inner", IntegerReference},
239 {"outer", IntegerReference}, {"fill", StringReference},
240 {"color", StringReference}, {"compose", MagickComposeOptions} } },
241 { "Implode", { {"amount", RealReference},
242 {"interpolate", MagickInterpolateOptions} } },
244 { "MedianFilter", { {"radius", RealReference} } },
246 { "OilPaint", { {"radius", RealReference} } },
247 { "ReduceNoise", { {"radius", RealReference} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
251 {"color", StringReference}, {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
260 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
261 {"y", RealReference}, { "fill", StringReference},
262 {"color", StringReference} } },
263 { "Spread", { {"radius", RealReference} } },
264 { "Swirl", { {"degrees", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
267 {"height", IntegerReference}, {"filter", MagickFilterOptions},
268 {"support", StringReference }, {"blur", RealReference } } },
269 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", RealReference }, {"blur", RealReference } } },
272 { "Annotate", { {"text", StringReference}, {"font", StringReference},
273 {"pointsize", RealReference}, {"density", StringReference},
274 {"undercolor", StringReference}, {"stroke", StringReference},
275 {"fill", StringReference}, {"geometry", StringReference},
276 {"pen", StringReference}, {"x", RealReference},
277 {"y", RealReference}, {"gravity", MagickGravityOptions},
278 {"translate", StringReference}, {"scale", StringReference},
279 {"rotate", RealReference}, {"skewX", RealReference},
280 {"skewY", RealReference}, {"strokewidth", RealReference},
281 {"antialias", MagickBooleanOptions}, {"family", StringReference},
282 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
283 {"weight", IntegerReference}, {"align", MagickAlignOptions},
284 {"encoding", StringReference}, {"affine", ArrayReference},
285 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
286 {"tile", ImageReference}, {"kerning", RealReference},
287 {"interline-spacing", RealReference},
288 {"interword-spacing", RealReference} } },
289 { "ColorFloodfill", { {"geometry", StringReference},
290 {"x", IntegerReference}, {"y", IntegerReference},
291 {"fill", StringReference}, {"bordercolor", StringReference},
292 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
293 { "Composite", { {"image", ImageReference},
294 {"compose", MagickComposeOptions}, {"geometry", StringReference},
295 {"x", IntegerReference}, {"y", IntegerReference},
296 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
297 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
298 {"color", StringReference}, {"mask", ImageReference},
299 {"channel", MagickChannelOptions},
300 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
301 {"blend", StringReference} } },
302 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
303 { "CycleColormap", { {"display", IntegerReference} } },
304 { "Draw", { {"primitive", MagickPrimitiveOptions},
305 {"points", StringReference}, {"method", MagickMethodOptions},
306 {"stroke", StringReference}, {"fill", StringReference},
307 {"strokewidth", RealReference}, {"font", StringReference},
308 {"bordercolor", StringReference}, {"x", RealReference},
309 {"y", RealReference}, {"translate", StringReference},
310 {"scale", StringReference}, {"rotate", RealReference},
311 {"skewX", RealReference}, {"skewY", RealReference},
312 {"tile", ImageReference}, {"pointsize", RealReference},
313 {"antialias", MagickBooleanOptions}, {"density", StringReference},
314 {"linewidth", RealReference}, {"affine", ArrayReference},
315 {"stroke-dashoffset", RealReference},
316 {"stroke-dasharray", ArrayReference},
317 {"interpolate", MagickInterpolateOptions},
318 {"origin", StringReference}, {"text", StringReference},
319 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
320 {"vector-graphics", StringReference}, {"kerning", RealReference},
321 {"interline-spacing", RealReference},
322 {"interword-spacing", RealReference} } },
323 { "Equalize", { {"channel", MagickChannelOptions} } },
324 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
325 {"red", RealReference}, {"green", RealReference},
326 {"blue", RealReference} } },
327 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
328 {"dither-method", MagickDitherOptions} } },
329 { "MatteFloodfill", { {"geometry", StringReference},
330 {"x", IntegerReference}, {"y", IntegerReference},
331 {"opacity", StringReference}, {"bordercolor", StringReference},
332 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
333 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
334 {"saturation", RealReference}, {"whiteness", RealReference},
335 {"brightness", RealReference}, {"lightness", RealReference},
336 {"blackness", RealReference} } },
337 { "Negate", { {"gray", MagickBooleanOptions},
338 {"channel", MagickChannelOptions} } },
339 { "Normalize", { {"channel", MagickChannelOptions} } },
341 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
342 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
343 {"invert", MagickBooleanOptions} } },
344 { "Quantize", { {"colors", IntegerReference},
345 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
346 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
347 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
348 {"dither-method", MagickDitherOptions} } },
349 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
350 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
351 { "Segment", { {"geometry", StringReference},
352 {"cluster-threshold", RealReference},
353 {"smoothing-threshold", RealReference},
354 {"colorspace", MagickColorspaceOptions},
355 {"verbose", MagickBooleanOptions} } },
357 { "Solarize", { {"geometry", StringReference},
358 {"threshold", StringReference} } },
360 { "Texture", { {"texture", ImageReference} } },
361 { "Evaluate", { {"value", RealReference},
362 {"operator", MagickEvaluateOptions},
363 {"channel", MagickChannelOptions} } },
364 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
365 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
366 { "Threshold", { {"threshold", StringReference},
367 {"channel", MagickChannelOptions} } },
368 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
369 {"sigma", RealReference} } },
370 { "Trim", { {"fuzz", StringReference} } },
371 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
372 {"wavelength", RealReference},
373 {"interpolate", MagickInterpolateOptions} } },
374 { "Separate", { {"channel", MagickChannelOptions} } },
376 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
377 {"y", IntegerReference} } },
378 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
380 { "GaussianBlur", { {"geometry", StringReference},
381 {"radius", RealReference}, {"sigma", RealReference},
382 {"channel", MagickChannelOptions} } },
383 { "Convolve", { {"coefficients", ArrayReference},
384 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
385 { "Profile", { {"name", StringReference}, {"profile", StringReference},
386 { "rendering-intent", MagickIntentOptions},
387 { "black-point-compensation", MagickBooleanOptions} } },
388 { "UnsharpMask", { {"geometry", StringReference},
389 {"radius", RealReference}, {"sigma", RealReference},
390 {"amount", RealReference}, {"threshold", RealReference},
391 {"channel", MagickChannelOptions} } },
392 { "MotionBlur", { {"geometry", StringReference},
393 {"radius", RealReference}, {"sigma", RealReference},
394 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
395 { "OrderedDither", { {"threshold", StringReference},
396 {"channel", MagickChannelOptions} } },
397 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
398 {"height", IntegerReference} } },
399 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
400 {"white-point", RealReference}, {"gamma", RealReference},
401 {"channel", MagickChannelOptions}, {"level", StringReference} } },
402 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
403 { "AffineTransform", { {"affine", ArrayReference},
404 {"translate", StringReference}, {"scale", StringReference},
405 {"rotate", RealReference}, {"skewX", RealReference},
406 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
407 {"background", StringReference} } },
408 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
409 { "AdaptiveThreshold", { {"geometry", StringReference},
410 {"width", IntegerReference}, {"height", IntegerReference},
411 {"offset", IntegerReference} } },
412 { "Resample", { {"density", StringReference}, {"x", RealReference},
413 {"y", RealReference}, {"filter", MagickFilterOptions},
414 {"support", RealReference }, {"blur", RealReference } } },
415 { "Describe", { {"file", FileReference} } },
416 { "BlackThreshold", { {"threshold", StringReference},
417 {"channel", MagickChannelOptions} } },
418 { "WhiteThreshold", { {"threshold", StringReference},
419 {"channel", MagickChannelOptions} } },
420 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
421 {"channel", MagickChannelOptions} } },
422 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
423 {"height", IntegerReference} } },
425 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
426 { "Channel", { {"channel", MagickChannelOptions} } },
427 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
428 {"height", IntegerReference}, {"x", IntegerReference},
429 {"y", IntegerReference}, {"fuzz", StringReference},
430 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
431 { "Posterize", { {"levels", IntegerReference},
432 {"dither", MagickBooleanOptions} } },
433 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
434 {"sigma", RealReference}, {"x", IntegerReference},
435 {"y", IntegerReference} } },
436 { "Identify", { {"file", FileReference}, {"features", StringReference},
437 {"unique", MagickBooleanOptions} } },
438 { "SepiaTone", { {"threshold", RealReference} } },
439 { "SigmoidalContrast", { {"geometry", StringReference},
440 {"contrast", RealReference}, {"mid-point", RealReference},
441 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
442 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
443 {"height", IntegerReference}, {"x", IntegerReference},
444 {"y", IntegerReference}, {"fuzz", StringReference},
445 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
446 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
447 {"sigma", RealReference}, {"x", IntegerReference},
448 {"y", IntegerReference}, {"background", StringReference} } },
449 { "ContrastStretch", { {"levels", StringReference},
450 {"black-point", RealReference},{"white-point", RealReference},
451 {"channel", MagickChannelOptions} } },
454 { "AdaptiveSharpen", { {"geometry", StringReference},
455 {"radius", RealReference}, {"sigma", RealReference},
456 {"channel", MagickChannelOptions} } },
460 { "AdaptiveBlur", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"channel", MagickChannelOptions} } },
463 { "Sketch", { {"geometry", StringReference},
464 {"radius", RealReference}, {"sigma", RealReference},
465 {"angle", RealReference} } },
467 { "AdaptiveResize", { {"geometry", StringReference},
468 {"width", IntegerReference}, {"height", IntegerReference},
469 {"filter", MagickFilterOptions}, {"support", StringReference },
470 {"blur", RealReference } } },
471 { "ClipMask", { {"mask", ImageReference} } },
472 { "LinearStretch", { {"levels", StringReference},
473 {"black-point", RealReference},{"white-point", RealReference} } },
474 { "Recolor", { {"matrix", ArrayReference} } },
475 { "Mask", { {"mask", ImageReference} } },
476 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
477 {"font", StringReference}, {"stroke", StringReference},
478 {"fill", StringReference}, {"strokewidth", RealReference},
479 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
480 {"background", StringReference} } },
481 { "FloodfillPaint", { {"geometry", StringReference},
482 {"x", IntegerReference}, {"y", IntegerReference},
483 {"fill", StringReference}, {"bordercolor", StringReference},
484 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
485 {"invert", MagickBooleanOptions} } },
486 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
487 {"virtual-pixel", MagickVirtualPixelOptions},
488 {"best-fit", MagickBooleanOptions} } },
489 { "Clut", { {"image", ImageReference},
490 {"channel", MagickChannelOptions} } },
491 { "LiquidRescale", { {"geometry", StringReference},
492 {"width", IntegerReference}, {"height", IntegerReference},
493 {"delta-x", RealReference}, {"rigidity", RealReference } } },
494 { "Encipher", { {"passphrase", StringReference} } },
495 { "Decipher", { {"passphrase", StringReference} } },
496 { "Deskew", { {"geometry", StringReference},
497 {"threshold", StringReference} } },
498 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
499 {"dither-method", MagickDitherOptions} } },
500 { "SparseColor", { {"points", ArrayReference},
501 {"method", MagickSparseColorOptions},
502 {"virtual-pixel", MagickVirtualPixelOptions},
503 {"channel", MagickChannelOptions} } },
504 { "Function", { {"parameters", ArrayReference},
505 {"function", MagickFunctionOptions},
506 {"virtual-pixel", MagickVirtualPixelOptions} } },
507 { "SelectiveBlur", { {"geometry", StringReference},
508 {"radius", RealReference}, {"sigma", RealReference},
509 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
510 { "HaldClut", { {"image", ImageReference},
511 {"channel", MagickChannelOptions} } },
512 { "BlueShift", { {"factor", StringReference} } },
513 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
514 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
515 { "ColorDecisionList", {
516 {"color-correction-collection", StringReference} } },
517 { "AutoGamma", { {"channel", MagickChannelOptions} } },
518 { "AutoLevel", { {"channel", MagickChannelOptions} } },
519 { "LevelColors", { {"invert", MagickBooleanOptions},
520 {"black-point", RealReference}, {"white-point", RealReference},
521 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
522 { "Clamp", { {"channel", MagickChannelOptions} } },
523 { "Filter", { {"kernel", StringReference},
524 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
525 { "BrightnessContrast", { {"levels", StringReference},
526 {"brightness", RealReference},{"contrast", RealReference},
527 {"channel", MagickChannelOptions} } },
528 { "Morphology", { {"kernel", StringReference},
529 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
530 {"iterations", IntegerReference} } },
534 *magick_registry = (SplayTreeInfo *) NULL;
537 Forward declarations.
540 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
543 strEQcase(const char *,const char *);
546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
550 % C l o n e P a c k a g e I n f o %
554 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
559 % The format of the ClonePackageInfo routine is:
561 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
564 % A description of each parameter follows:
566 % o info: a structure of type info.
568 % o exception: Return any errors or warnings in this structure.
571 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
572 ExceptionInfo *exception)
577 clone_info=(struct PackageInfo *) AcquireAlignedMemory(1,sizeof(*clone_info));
578 if (clone_info == (struct PackageInfo *) NULL)
580 ThrowPerlException(exception,ResourceLimitError,
581 "UnableToClonePackageInfo",PackageName);
582 return((struct PackageInfo *) NULL);
584 if (info == (struct PackageInfo *) NULL)
586 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
590 clone_info->image_info=CloneImageInfo(info->image_info);
595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
605 % constant() returns a double value for the specified name.
607 % The format of the constant routine is:
609 % double constant(char *name,long sans)
611 % A description of each parameter follows:
613 % o value: Method constant returns a double value for the specified name.
615 % o name: The name of the constant.
617 % o sans: This integer value is not used.
620 static double constant(char *name,long sans)
628 if (strEQ(name,"BlobError"))
630 if (strEQ(name,"BlobWarning"))
636 if (strEQ(name,"CacheError"))
638 if (strEQ(name,"CacheWarning"))
639 return(CacheWarning);
640 if (strEQ(name,"CoderError"))
642 if (strEQ(name,"CoderWarning"))
643 return(CoderWarning);
644 if (strEQ(name,"ConfigureError"))
645 return(ConfigureError);
646 if (strEQ(name,"ConfigureWarning"))
647 return(ConfigureWarning);
648 if (strEQ(name,"CorruptImageError"))
649 return(CorruptImageError);
650 if (strEQ(name,"CorruptImageWarning"))
651 return(CorruptImageWarning);
656 if (strEQ(name,"DelegateError"))
657 return(DelegateError);
658 if (strEQ(name,"DelegateWarning"))
659 return(DelegateWarning);
660 if (strEQ(name,"DrawError"))
662 if (strEQ(name,"DrawWarning"))
668 if (strEQ(name,"ErrorException"))
669 return(ErrorException);
670 if (strEQ(name,"ExceptionError"))
672 if (strEQ(name,"ExceptionWarning"))
673 return(CoderWarning);
678 if (strEQ(name,"FatalErrorException"))
679 return(FatalErrorException);
680 if (strEQ(name,"FileOpenError"))
681 return(FileOpenError);
682 if (strEQ(name,"FileOpenWarning"))
683 return(FileOpenWarning);
688 if (strEQ(name,"ImageError"))
690 if (strEQ(name,"ImageWarning"))
691 return(ImageWarning);
696 if (strEQ(name,"MaxRGB"))
697 return(QuantumRange);
698 if (strEQ(name,"MissingDelegateError"))
699 return(MissingDelegateError);
700 if (strEQ(name,"MissingDelegateWarning"))
701 return(MissingDelegateWarning);
702 if (strEQ(name,"ModuleError"))
704 if (strEQ(name,"ModuleWarning"))
705 return(ModuleWarning);
710 if (strEQ(name,"Opaque"))
711 return(OpaqueOpacity);
712 if (strEQ(name,"OptionError"))
714 if (strEQ(name,"OptionWarning"))
715 return(OptionWarning);
720 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
721 return(MAGICKCORE_QUANTUM_DEPTH);
722 if (strEQ(name,"QuantumDepth"))
723 return(QuantumDepth);
724 if (strEQ(name,"QuantumRange"))
725 return(QuantumRange);
730 if (strEQ(name,"ResourceLimitError"))
731 return(ResourceLimitError);
732 if (strEQ(name,"ResourceLimitWarning"))
733 return(ResourceLimitWarning);
734 if (strEQ(name,"RegistryError"))
735 return(RegistryError);
736 if (strEQ(name,"RegistryWarning"))
737 return(RegistryWarning);
742 if (strEQ(name,"StreamError"))
744 if (strEQ(name,"StreamWarning"))
745 return(StreamWarning);
746 if (strEQ(name,"Success"))
752 if (strEQ(name,"Transparent"))
753 return(TransparentOpacity);
754 if (strEQ(name,"TypeError"))
756 if (strEQ(name,"TypeWarning"))
762 if (strEQ(name,"WarningException"))
763 return(WarningException);
768 if (strEQ(name,"XServerError"))
769 return(XServerError);
770 if (strEQ(name,"XServerWarning"))
771 return(XServerWarning);
780 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
784 % D e s t r o y P a c k a g e I n f o %
788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
790 % Method DestroyPackageInfo frees a previously created info structure.
792 % The format of the DestroyPackageInfo routine is:
794 % DestroyPackageInfo(struct PackageInfo *info)
796 % A description of each parameter follows:
798 % o info: a structure of type info.
801 static void DestroyPackageInfo(struct PackageInfo *info)
803 info->image_info=DestroyImageInfo(info->image_info);
804 info=(struct PackageInfo *) RelinquishMagickMemory(info);
808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
818 % Method GetList is recursively called by SetupList to traverse the
819 % Image__Magick reference. If building an reference_vector (see SetupList),
820 % *current is the current position in *reference_vector and *last is the final
821 % entry in *reference_vector.
823 % The format of the GetList routine is:
827 % A description of each parameter follows:
829 % o info: a structure of type info.
832 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,long *current,
833 long *last,ExceptionInfo *exception)
838 if (reference == (SV *) NULL)
840 switch (SvTYPE(reference))
860 previous=(Image *) NULL;
864 for (i=0; i <= n; i++)
870 if (rv && *rv && sv_isobject(*rv))
872 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
874 if (image == (Image *) NULL)
876 if (image == previous)
878 image=CloneImage(image,0,0,MagickTrue,exception);
879 if (image == (Image *) NULL)
882 image->previous=previous;
883 *(previous ? &previous->next : &head)=image;
884 for (previous=image; previous->next; previous=previous->next) ;
892 Blessed scalar, one image.
894 image=(Image *) SvIV(reference);
895 if (image == (Image *) NULL)
897 image->previous=(Image *) NULL;
898 image->next=(Image *) NULL;
899 if (reference_vector)
901 if (*current == *last)
904 if (*reference_vector == (SV **) NULL)
905 *reference_vector=(SV **) AcquireQuantumMemory(*last,
906 sizeof(*reference_vector));
908 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
909 *last,sizeof(*reference_vector));
911 if (*reference_vector == (SV **) NULL)
913 ThrowPerlException(exception,ResourceLimitError,
914 "MemoryAllocationFailed",PackageName);
915 return((Image *) NULL);
917 (*reference_vector)[*current]=reference;
918 (*reference_vector)[++(*current)]=NULL;
925 (void) fprintf(stderr,"GetList: UnrecognizedType %ld\n",
926 (long) SvTYPE(reference));
927 return((Image *) NULL);
931 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
935 % G e t P a c k a g e I n f o %
939 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
941 % Method GetPackageInfo looks up or creates an info structure for the given
942 % Image__Magick reference. If it does create a new one, the information in
943 % package_info is used to initialize it.
945 % The format of the GetPackageInfo routine is:
947 % struct PackageInfo *GetPackageInfo(void *reference,
948 % struct PackageInfo *package_info,ExceptionInfo *exception)
950 % A description of each parameter follows:
952 % o info: a structure of type info.
954 % o exception: Return any errors or warnings in this structure.
957 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
958 struct PackageInfo *package_info,ExceptionInfo *exception)
961 message[MaxTextExtent];
969 (void) FormatMagickString(message,MaxTextExtent,"%s::package%s%lx",
970 PackageName,XS_VERSION,(long) reference);
971 sv=perl_get_sv(message,(TRUE | 0x02));
972 if (sv == (SV *) NULL)
974 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
976 return(package_info);
978 if (SvREFCNT(sv) == 0)
979 (void) SvREFCNT_inc(sv);
980 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
982 clone_info=ClonePackageInfo(package_info,exception);
983 sv_setiv(sv,(IV) clone_info);
988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
992 % S e t A t t r i b u t e %
996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
998 % SetAttribute() sets the attribute to the value in sval. This can change
999 % either or both of image or info.
1001 % The format of the SetAttribute routine is:
1003 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1004 % SV *sval,ExceptionInfo *exception)
1006 % A description of each parameter follows:
1008 % o list: a list of strings.
1010 % o string: a character string.
1014 static inline double SiPrefixToDouble(const char *string,const double interval)
1023 value=strtod(string,&q);
1025 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1027 switch (tolower((int) ((unsigned char) *q)))
1029 case '%': value*=pow(scale,0)*interval/100.0; break;
1030 case 'k': value*=pow(scale,1); break;
1031 case 'm': value*=pow(scale,2); break;
1032 case 'g': value*=pow(scale,3); break;
1033 case 't': value*=pow(scale,4); break;
1034 case 'p': value*=pow(scale,5); break;
1035 case 'e': value*=pow(scale,6); break;
1036 case 'z': value*=pow(scale,7); break;
1037 case 'y': value*=pow(scale,8); break;
1043 static inline double StringToDouble(const char *value)
1045 return(strtod(value,(char **) NULL));
1048 static inline long StringToLong(const char *value)
1050 return(strtol(value,(char **) NULL,10));
1053 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1054 const char *attribute,SV *sval,ExceptionInfo *exception)
1081 if (LocaleCompare(attribute,"adjoin") == 0)
1083 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1084 SvPV(sval,na)) : SvIV(sval);
1087 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1092 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1095 if (LocaleCompare(attribute,"alpha") == 0)
1097 sp=SvPOK(sval) ? ParseMagickOption(MagickAlphaOptions,MagickFalse,
1098 SvPV(sval,na)) : SvIV(sval);
1101 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1105 for ( ; image; image=image->next)
1106 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1109 if (LocaleCompare(attribute,"antialias") == 0)
1111 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1112 SvPV(sval,na)) : SvIV(sval);
1115 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1120 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1123 if (LocaleCompare(attribute,"area-limit") == 0)
1128 limit=MagickResourceInfinity;
1129 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1130 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1131 (void) SetMagickResourceLimit(AreaResource,limit);
1134 if (LocaleCompare(attribute,"attenuate") == 0)
1137 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1140 if (LocaleCompare(attribute,"authenticate") == 0)
1143 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1147 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1148 for ( ; image; image=image->next)
1149 SetImageProperty(image,attribute,SvPV(sval,na));
1155 if (LocaleCompare(attribute,"background") == 0)
1157 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1159 info->image_info->background_color=target_color;
1160 for ( ; image; image=image->next)
1161 image->background_color=target_color;
1164 if (LocaleCompare(attribute,"bias") == 0)
1166 for ( ; image; image=image->next)
1167 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1170 if (LocaleCompare(attribute,"blue-primary") == 0)
1172 for ( ; image; image=image->next)
1174 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1175 image->chromaticity.blue_primary.x=geometry_info.rho;
1176 image->chromaticity.blue_primary.y=geometry_info.sigma;
1177 if ((flags & SigmaValue) == 0)
1178 image->chromaticity.blue_primary.y=
1179 image->chromaticity.blue_primary.x;
1183 if (LocaleCompare(attribute,"bordercolor") == 0)
1185 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1187 info->image_info->border_color=target_color;
1188 for ( ; image; image=image->next)
1189 image->border_color=target_color;
1193 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1194 for ( ; image; image=image->next)
1195 SetImageProperty(image,attribute,SvPV(sval,na));
1201 if (LocaleCompare(attribute,"cache-threshold") == 0)
1203 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1204 SiPrefixToDouble(SvPV(sval,na),100.0));
1205 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1206 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1209 if (LocaleCompare(attribute,"clip-mask") == 0)
1214 clip_mask=(Image *) NULL;
1216 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1217 for ( ; image; image=image->next)
1218 SetImageClipMask(image,clip_mask);
1221 if (LocaleNCompare(attribute,"colormap",8) == 0)
1223 for ( ; image; image=image->next)
1231 if (image->storage_class == DirectClass)
1234 items=sscanf(attribute,"%*[^[][%ld",&i);
1235 if (i > (long) image->colors)
1237 if ((strchr(SvPV(sval,na),',') == 0) ||
1238 (strchr(SvPV(sval,na),')') != 0))
1239 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1242 color=image->colormap+i;
1243 pixel.red=color->red;
1244 pixel.green=color->green;
1245 pixel.blue=color->blue;
1246 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1247 pixel.red=geometry_info.rho;
1248 pixel.green=geometry_info.sigma;
1249 pixel.blue=geometry_info.xi;
1250 color->red=ClampToQuantum(pixel.red);
1251 color->green=ClampToQuantum(pixel.green);
1252 color->blue=ClampToQuantum(pixel.blue);
1257 if (LocaleCompare(attribute,"colorspace") == 0)
1259 sp=SvPOK(sval) ? ParseMagickOption(MagickColorspaceOptions,
1260 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1263 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1267 for ( ; image; image=image->next)
1268 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1271 if (LocaleCompare(attribute,"comment") == 0)
1273 for ( ; image; image=image->next)
1274 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1275 info ? info->image_info : (ImageInfo *) NULL,image,
1279 if (LocaleCompare(attribute,"compression") == 0)
1281 sp=SvPOK(sval) ? ParseMagickOption(MagickCompressOptions,
1282 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1285 ThrowPerlException(exception,OptionError,
1286 "UnrecognizedImageCompression",SvPV(sval,na));
1290 info->image_info->compression=(CompressionType) sp;
1291 for ( ; image; image=image->next)
1292 image->compression=(CompressionType) sp;
1296 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1297 for ( ; image; image=image->next)
1298 SetImageProperty(image,attribute,SvPV(sval,na));
1304 if (LocaleCompare(attribute,"debug") == 0)
1306 SetLogEventMask(SvPV(sval,na));
1309 if (LocaleCompare(attribute,"delay") == 0)
1311 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1312 for ( ; image; image=image->next)
1314 image->delay=(unsigned long) (geometry_info.rho+0.5);
1315 if ((flags & SigmaValue) != 0)
1316 image->ticks_per_second=(unsigned long) (geometry_info.sigma+0.5);
1320 if (LocaleCompare(attribute,"disk-limit") == 0)
1325 limit=MagickResourceInfinity;
1326 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1327 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1328 (void) SetMagickResourceLimit(DiskResource,limit);
1331 if (LocaleCompare(attribute,"density") == 0)
1333 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1335 ThrowPerlException(exception,OptionError,"MissingGeometry",
1340 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1341 for ( ; image; image=image->next)
1343 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1344 image->x_resolution=geometry_info.rho;
1345 image->y_resolution=geometry_info.sigma;
1346 if ((flags & SigmaValue) == 0)
1347 image->y_resolution=image->x_resolution;
1351 if (LocaleCompare(attribute,"depth") == 0)
1354 info->image_info->depth=SvIV(sval);
1355 for ( ; image; image=image->next)
1356 (void) SetImageDepth(image,SvIV(sval));
1359 if (LocaleCompare(attribute,"dispose") == 0)
1361 sp=SvPOK(sval) ? ParseMagickOption(MagickDisposeOptions,MagickFalse,
1362 SvPV(sval,na)) : SvIV(sval);
1365 ThrowPerlException(exception,OptionError,
1366 "UnrecognizedDisposeMethod",SvPV(sval,na));
1369 for ( ; image; image=image->next)
1370 image->dispose=(DisposeType) sp;
1373 if (LocaleCompare(attribute,"dither") == 0)
1377 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,
1378 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1381 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1385 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1389 if (LocaleCompare(attribute,"display") == 0)
1393 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1397 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1398 for ( ; image; image=image->next)
1399 SetImageProperty(image,attribute,SvPV(sval,na));
1405 if (LocaleCompare(attribute,"endian") == 0)
1407 sp=SvPOK(sval) ? ParseMagickOption(MagickEndianOptions,MagickFalse,
1408 SvPV(sval,na)) : SvIV(sval);
1411 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1416 info->image_info->endian=(EndianType) sp;
1417 for ( ; image; image=image->next)
1418 image->endian=(EndianType) sp;
1421 if (LocaleCompare(attribute,"extract") == 0)
1424 Set image extract geometry.
1426 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1430 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1431 for ( ; image; image=image->next)
1432 SetImageProperty(image,attribute,SvPV(sval,na));
1438 if (LocaleCompare(attribute,"filename") == 0)
1441 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1443 for ( ; image; image=image->next)
1444 (void) CopyMagickString(image->filename,SvPV(sval,na),
1448 if (LocaleCompare(attribute,"file") == 0)
1456 if (info == (struct PackageInfo *) NULL)
1458 io_info=IoIFP(sv_2io(sval));
1459 if (io_info == (PerlIO *) NULL)
1461 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1465 file=PerlIO_findFILE(io_info);
1466 if (file == (FILE *) NULL)
1468 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1472 SetImageInfoFile(info->image_info,file);
1475 if (LocaleCompare(attribute,"fill") == 0)
1478 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1481 if (LocaleCompare(attribute,"font") == 0)
1484 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1487 if (LocaleCompare(attribute,"foreground") == 0)
1489 if (LocaleCompare(attribute,"fuzz") == 0)
1492 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1493 for ( ; image; image=image->next)
1494 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1498 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1499 for ( ; image; image=image->next)
1500 SetImageProperty(image,attribute,SvPV(sval,na));
1506 if (LocaleCompare(attribute,"gamma") == 0)
1508 for ( ; image; image=image->next)
1509 image->gamma=SvNV(sval);
1512 if (LocaleCompare(attribute,"gravity") == 0)
1514 sp=SvPOK(sval) ? ParseMagickOption(MagickGravityOptions,MagickFalse,
1515 SvPV(sval,na)) : SvIV(sval);
1518 ThrowPerlException(exception,OptionError,
1519 "UnrecognizedGravityType",SvPV(sval,na));
1522 for ( ; image; image=image->next)
1523 image->gravity=(GravityType) sp;
1526 if (LocaleCompare(attribute,"green-primary") == 0)
1528 for ( ; image; image=image->next)
1530 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1531 image->chromaticity.green_primary.x=geometry_info.rho;
1532 image->chromaticity.green_primary.y=geometry_info.sigma;
1533 if ((flags & SigmaValue) == 0)
1534 image->chromaticity.green_primary.y=
1535 image->chromaticity.green_primary.x;
1540 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1541 for ( ; image; image=image->next)
1542 SetImageProperty(image,attribute,SvPV(sval,na));
1548 if (LocaleNCompare(attribute,"index",5) == 0)
1559 register PixelPacket
1565 for ( ; image; image=image->next)
1567 if (image->storage_class != PseudoClass)
1571 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1572 image_view=AcquireCacheView(image);
1573 p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1574 if (p != (PixelPacket *) NULL)
1576 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1577 items=sscanf(SvPV(sval,na),"%ld",&index);
1578 if ((index >= 0) && (index < (long) image->colors))
1579 *indexes=(IndexPacket) index;
1580 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1582 image_view=DestroyCacheView(image_view);
1586 if (LocaleCompare(attribute,"iterations") == 0)
1589 for ( ; image; image=image->next)
1590 image->iterations=SvIV(sval);
1593 if (LocaleCompare(attribute,"interlace") == 0)
1595 sp=SvPOK(sval) ? ParseMagickOption(MagickInterlaceOptions,MagickFalse,
1596 SvPV(sval,na)) : SvIV(sval);
1599 ThrowPerlException(exception,OptionError,
1600 "UnrecognizedInterlaceType",SvPV(sval,na));
1604 info->image_info->interlace=(InterlaceType) sp;
1605 for ( ; image; image=image->next)
1606 image->interlace=(InterlaceType) sp;
1610 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1611 for ( ; image; image=image->next)
1612 SetImageProperty(image,attribute,SvPV(sval,na));
1618 if (LocaleCompare(attribute,"label") == 0)
1620 for ( ; image; image=image->next)
1621 (void) SetImageProperty(image,"label",InterpretImageProperties(
1622 info ? info->image_info : (ImageInfo *) NULL,image,
1626 if (LocaleCompare(attribute,"loop") == 0)
1629 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1630 for ( ; image; image=image->next)
1631 SetImageProperty(image,attribute,SvPV(sval,na));
1637 if (LocaleCompare(attribute,"magick") == 0)
1640 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
1641 "%.1024s:",SvPV(sval,na));
1642 for ( ; image; image=image->next)
1643 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1646 if (LocaleCompare(attribute,"map-limit") == 0)
1651 limit=MagickResourceInfinity;
1652 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1653 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1654 (void) SetMagickResourceLimit(MapResource,limit);
1657 if (LocaleCompare(attribute,"mask") == 0)
1662 mask=(Image *) NULL;
1664 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1665 for ( ; image; image=image->next)
1666 SetImageMask(image,mask);
1669 if (LocaleCompare(attribute,"mattecolor") == 0)
1671 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1673 info->image_info->matte_color=target_color;
1674 for ( ; image; image=image->next)
1675 image->matte_color=target_color;
1678 if (LocaleCompare(attribute,"matte") == 0)
1680 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1681 SvPV(sval,na)) : SvIV(sval);
1684 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1688 for ( ; image; image=image->next)
1689 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1692 if (LocaleCompare(attribute,"memory-limit") == 0)
1697 limit=MagickResourceInfinity;
1698 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1699 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1700 (void) SetMagickResourceLimit(MemoryResource,limit);
1703 if (LocaleCompare(attribute,"monochrome") == 0)
1705 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1706 SvPV(sval,na)) : SvIV(sval);
1709 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1714 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1715 for ( ; image; image=image->next)
1716 (void) SetImageType(image,BilevelType);
1720 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1721 for ( ; image; image=image->next)
1722 SetImageProperty(image,attribute,SvPV(sval,na));
1728 if (LocaleCompare(attribute,"option") == 0)
1731 DefineImageOption(info->image_info,SvPV(sval,na));
1734 if (LocaleCompare(attribute,"orientation") == 0)
1736 sp=SvPOK(sval) ? ParseMagickOption(MagickOrientationOptions,
1737 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1740 ThrowPerlException(exception,OptionError,
1741 "UnrecognizedOrientationType",SvPV(sval,na));
1745 info->image_info->orientation=(OrientationType) sp;
1746 for ( ; image; image=image->next)
1747 image->orientation=(OrientationType) sp;
1751 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1752 for ( ; image; image=image->next)
1753 SetImageProperty(image,attribute,SvPV(sval,na));
1759 if (LocaleCompare(attribute,"page") == 0)
1764 geometry=GetPageGeometry(SvPV(sval,na));
1766 (void) CloneString(&info->image_info->page,geometry);
1767 for ( ; image; image=image->next)
1768 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1769 geometry=(char *) RelinquishMagickMemory(geometry);
1772 if (LocaleCompare(attribute,"pen") == 0)
1775 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1778 if (LocaleNCompare(attribute,"pixel",5) == 0)
1786 register IndexPacket
1789 register PixelPacket
1795 for ( ; image; image=image->next)
1797 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1801 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1802 image_view=AcquireCacheView(image);
1803 p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1804 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1805 if (p != (PixelPacket *) NULL)
1807 if ((strchr(SvPV(sval,na),',') == 0) ||
1808 (strchr(SvPV(sval,na),')') != 0))
1809 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1812 GetMagickPixelPacket(image,&pixel);
1813 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1814 pixel.red=geometry_info.rho;
1815 if ((flags & SigmaValue) != 0)
1816 pixel.green=geometry_info.sigma;
1817 if ((flags & XiValue) != 0)
1818 pixel.blue=geometry_info.xi;
1819 if ((flags & PsiValue) != 0)
1820 pixel.opacity=geometry_info.psi;
1821 if ((flags & ChiValue) != 0)
1822 pixel.index=geometry_info.chi;
1824 p->red=ClampToQuantum(pixel.red);
1825 p->green=ClampToQuantum(pixel.green);
1826 p->blue=ClampToQuantum(pixel.blue);
1827 p->opacity=ClampToQuantum(pixel.opacity);
1828 if (((image->colorspace == CMYKColorspace) ||
1829 (image->storage_class == PseudoClass)) &&
1830 (indexes != (IndexPacket *) NULL))
1831 *indexes=ClampToQuantum(pixel.index);
1832 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1834 image_view=DestroyCacheView(image_view);
1838 if (LocaleCompare(attribute,"pointsize") == 0)
1842 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1843 info->image_info->pointsize=geometry_info.rho;
1847 if (LocaleCompare(attribute,"preview") == 0)
1849 sp=SvPOK(sval) ? ParseMagickOption(MagickPreviewOptions,MagickFalse,
1850 SvPV(sval,na)) : SvIV(sval);
1853 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1858 info->image_info->preview_type=(PreviewType) sp;
1862 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1863 for ( ; image; image=image->next)
1864 SetImageProperty(image,attribute,SvPV(sval,na));
1870 if (LocaleCompare(attribute,"quality") == 0)
1873 info->image_info->quality=SvIV(sval);
1874 for ( ; image; image=image->next)
1875 image->quality=SvIV(sval);
1879 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1880 for ( ; image; image=image->next)
1881 SetImageProperty(image,attribute,SvPV(sval,na));
1887 if (LocaleCompare(attribute,"red-primary") == 0)
1889 for ( ; image; image=image->next)
1891 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1892 image->chromaticity.red_primary.x=geometry_info.rho;
1893 image->chromaticity.red_primary.y=geometry_info.sigma;
1894 if ((flags & SigmaValue) == 0)
1895 image->chromaticity.red_primary.y=
1896 image->chromaticity.red_primary.x;
1900 if (LocaleCompare(attribute,"render") == 0)
1902 sp=SvPOK(sval) ? ParseMagickOption(MagickIntentOptions,MagickFalse,
1903 SvPV(sval,na)) : SvIV(sval);
1906 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1910 for ( ; image; image=image->next)
1911 image->rendering_intent=(RenderingIntent) sp;
1914 if (LocaleCompare(attribute,"repage") == 0)
1919 for ( ; image; image=image->next)
1921 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1922 if ((flags & WidthValue) != 0)
1924 if ((flags & HeightValue) == 0)
1925 geometry.height=geometry.width;
1926 image->page.width=geometry.width;
1927 image->page.height=geometry.height;
1929 if ((flags & AspectValue) != 0)
1931 if ((flags & XValue) != 0)
1932 image->page.x+=geometry.x;
1933 if ((flags & YValue) != 0)
1934 image->page.y+=geometry.y;
1938 if ((flags & XValue) != 0)
1940 image->page.x=geometry.x;
1941 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1942 image->page.width=image->columns+geometry.x;
1944 if ((flags & YValue) != 0)
1946 image->page.y=geometry.y;
1947 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1948 image->page.height=image->rows+geometry.y;
1955 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1956 for ( ; image; image=image->next)
1957 SetImageProperty(image,attribute,SvPV(sval,na));
1963 if (LocaleCompare(attribute,"sampling-factor") == 0)
1965 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1967 ThrowPerlException(exception,OptionError,"MissingGeometry",
1972 (void) CloneString(&info->image_info->sampling_factor,
1976 if (LocaleCompare(attribute,"scene") == 0)
1978 for ( ; image; image=image->next)
1979 image->scene=SvIV(sval);
1982 if (LocaleCompare(attribute,"subimage") == 0)
1985 info->image_info->subimage=SvIV(sval);
1988 if (LocaleCompare(attribute,"subrange") == 0)
1991 info->image_info->subrange=SvIV(sval);
1994 if (LocaleCompare(attribute,"server") == 0)
1996 if (LocaleCompare(attribute,"size") == 0)
2000 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2002 ThrowPerlException(exception,OptionError,"MissingGeometry",
2006 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2010 if (LocaleCompare(attribute,"stroke") == 0)
2013 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2017 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2018 for ( ; image; image=image->next)
2019 SetImageProperty(image,attribute,SvPV(sval,na));
2025 if (LocaleCompare(attribute,"tile") == 0)
2028 (void) CloneString(&info->image_info->tile,SvPV(sval,na));
2031 if (LocaleCompare(attribute,"texture") == 0)
2034 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2037 if (LocaleCompare(attribute,"tile-offset") == 0)
2042 geometry=GetPageGeometry(SvPV(sval,na));
2044 (void) CloneString(&info->image_info->page,geometry);
2045 for ( ; image; image=image->next)
2046 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2048 geometry=(char *) RelinquishMagickMemory(geometry);
2051 if (LocaleCompare(attribute,"time-limit") == 0)
2056 limit=MagickResourceInfinity;
2057 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2058 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2059 (void) SetMagickResourceLimit(TimeResource,limit);
2062 if (LocaleCompare(attribute,"transparent-color") == 0)
2064 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2066 info->image_info->transparent_color=target_color;
2067 for ( ; image; image=image->next)
2068 image->transparent_color=target_color;
2071 if (LocaleCompare(attribute,"type") == 0)
2073 sp=SvPOK(sval) ? ParseMagickOption(MagickTypeOptions,MagickFalse,
2074 SvPV(sval,na)) : SvIV(sval);
2077 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2082 info->image_info->type=(ImageType) sp;
2083 for ( ; image; image=image->next)
2084 SetImageType(image,(ImageType) sp);
2088 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2089 for ( ; image; image=image->next)
2090 SetImageProperty(image,attribute,SvPV(sval,na));
2096 if (LocaleCompare(attribute,"units") == 0)
2098 sp=SvPOK(sval) ? ParseMagickOption(MagickResolutionOptions,
2099 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2102 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2107 info->image_info->units=(ResolutionType) sp;
2108 for ( ; image; image=image->next)
2113 units=(ResolutionType) sp;
2114 if (image->units != units)
2115 switch (image->units)
2117 case UndefinedResolution:
2118 case PixelsPerInchResolution:
2120 if (units == PixelsPerCentimeterResolution)
2122 image->x_resolution*=2.54;
2123 image->y_resolution*=2.54;
2127 case PixelsPerCentimeterResolution:
2129 if (units == PixelsPerInchResolution)
2131 image->x_resolution/=2.54;
2132 image->y_resolution/=2.54;
2142 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2143 for ( ; image; image=image->next)
2144 SetImageProperty(image,attribute,SvPV(sval,na));
2150 if (LocaleCompare(attribute,"verbose") == 0)
2152 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
2153 SvPV(sval,na)) : SvIV(sval);
2156 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2161 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2164 if (LocaleCompare(attribute,"view") == 0)
2167 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2170 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2172 sp=SvPOK(sval) ? ParseMagickOption(MagickVirtualPixelOptions,
2173 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2176 ThrowPerlException(exception,OptionError,
2177 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2181 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2182 for ( ; image; image=image->next)
2183 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2187 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2188 for ( ; image; image=image->next)
2189 SetImageProperty(image,attribute,SvPV(sval,na));
2195 if (LocaleCompare(attribute,"white-point") == 0)
2197 for ( ; image; image=image->next)
2199 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2200 image->chromaticity.white_point.x=geometry_info.rho;
2201 image->chromaticity.white_point.y=geometry_info.sigma;
2202 if ((flags & SigmaValue) == 0)
2203 image->chromaticity.white_point.y=
2204 image->chromaticity.white_point.x;
2209 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2210 for ( ; image; image=image->next)
2211 SetImageProperty(image,attribute,SvPV(sval,na));
2217 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2218 for ( ; image; image=image->next)
2219 SetImageProperty(image,attribute,SvPV(sval,na));
2226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2230 % S e t u p L i s t %
2234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2236 % Method SetupList returns the list of all the images linked by their
2237 % image->next and image->previous link lists for use with ImageMagick. If
2238 % info is non-NULL, an info structure is returned in *info. If
2239 % reference_vector is non-NULL,an array of SV* are returned in
2240 % *reference_vector. Reference_vector is used when the images are going to be
2241 % replaced with new Image*'s.
2243 % The format of the SetupList routine is:
2245 % Image *SetupList(SV *reference,struct PackageInfo **info,
2246 % SV ***reference_vector,ExceptionInfo *exception)
2248 % A description of each parameter follows:
2250 % o list: a list of strings.
2252 % o string: a character string.
2254 % o exception: Return any errors or warnings in this structure.
2257 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2258 SV ***reference_vector,ExceptionInfo *exception)
2267 if (reference_vector)
2268 *reference_vector=NULL;
2273 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2274 if (info && (SvTYPE(reference) == SVt_PVAV))
2275 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2285 % s t r E Q c a s e %
2289 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2291 % strEQcase() compares two strings and returns 0 if they are the
2292 % same or if the second string runs out first. The comparison is case
2295 % The format of the strEQcase routine is:
2297 % long strEQcase(const char *p,const char *q)
2299 % A description of each parameter follows:
2301 % o p: a character string.
2303 % o q: a character string.
2307 static long strEQcase(const char *p,const char *q)
2315 for (i=0 ; (c=(*q)) != 0; i++)
2317 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2318 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2323 return(((*q == 0) && (*p == 0)) ? i : 0);
2327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2331 % I m a g e : : M a g i c k %
2335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2339 MODULE = Image::Magick PACKAGE = Image::Magick
2344 MagickCoreGenesis("PerlMagick",MagickFalse);
2345 SetWarningHandler(NULL);
2346 SetErrorHandler(NULL);
2347 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2348 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2354 if (magick_registry != (SplayTreeInfo *) NULL)
2355 magick_registry=DestroySplayTree(magick_registry);
2356 MagickCoreTerminus();
2360 constant(name,argument)
2365 ###############################################################################
2373 ###############################################################################
2378 Image::Magick ref=NO_INIT
2402 exception=AcquireExceptionInfo();
2403 perl_exception=newSVpv("",0);
2404 package_info=(struct PackageInfo *) NULL;
2405 if (sv_isobject(ST(0)) == 0)
2407 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2411 reference=SvRV(ST(0));
2412 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2413 if (image == (Image *) NULL)
2415 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2419 package_info=ClonePackageInfo(info,exception);
2421 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2424 for (i=2; i < items; i+=2)
2425 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2427 (void) AnimateImages(package_info->image_info,image);
2428 (void) CatchImageException(image);
2429 InheritException(exception,&image->exception);
2432 if (package_info != (struct PackageInfo *) NULL)
2433 DestroyPackageInfo(package_info);
2434 InheritPerlException(exception,perl_exception);
2435 exception=DestroyExceptionInfo(exception);
2436 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2437 SvPOK_on(perl_exception);
2438 ST(0)=sv_2mortal(perl_exception);
2443 ###############################################################################
2451 ###############################################################################
2456 Image::Magick ref=NO_INIT
2494 exception=AcquireExceptionInfo();
2495 perl_exception=newSVpv("",0);
2498 if (sv_isobject(ST(0)) == 0)
2500 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2504 reference=SvRV(ST(0));
2505 hv=SvSTASH(reference);
2507 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2509 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2510 if (image == (Image *) NULL)
2512 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2516 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2521 for (i=2; i < items; i+=2)
2523 attribute=(char *) SvPV(ST(i-1),na);
2529 if (LocaleCompare(attribute,"stack") == 0)
2531 stack=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2535 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2553 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2554 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2556 for ( ; image; image=image->next)
2558 AddImageToRegistry(image);
2560 av_push(av,sv_bless(rv,hv));
2563 exception=DestroyExceptionInfo(exception);
2565 SvREFCNT_dec(perl_exception);
2569 InheritPerlException(exception,perl_exception);
2570 exception=DestroyExceptionInfo(exception);
2571 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2572 SvPOK_on(perl_exception);
2573 ST(0)=sv_2mortal(perl_exception);
2578 ###############################################################################
2586 ###############################################################################
2591 Image::Magick ref=NO_INIT
2622 exception=AcquireExceptionInfo();
2623 perl_exception=newSVpv("",0);
2624 if (sv_isobject(ST(0)) == 0)
2626 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2630 reference=SvRV(ST(0));
2631 hv=SvSTASH(reference);
2632 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2633 if (image == (Image *) NULL)
2635 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2639 image=AverageImages(image,exception);
2640 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2643 Create blessed Perl array for the returned image.
2646 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2648 AddImageToRegistry(image);
2650 av_push(av,sv_bless(rv,hv));
2652 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2653 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
2654 "average-%.*s",(int) (MaxTextExtent-9),
2655 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2656 (void) CopyMagickString(image->filename,info->image_info->filename,
2658 SetImageInfo(info->image_info,MagickFalse,exception);
2659 exception=DestroyExceptionInfo(exception);
2660 SvREFCNT_dec(perl_exception);
2664 InheritPerlException(exception,perl_exception);
2665 exception=DestroyExceptionInfo(exception);
2666 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2667 SvPOK_on(perl_exception);
2668 ST(0)=sv_2mortal(perl_exception);
2673 ###############################################################################
2677 # B l o b T o I m a g e #
2681 ###############################################################################
2685 BlobToImage(ref,...)
2686 Image::Magick ref=NO_INIT
2732 exception=AcquireExceptionInfo();
2733 perl_exception=newSVpv("",0);
2735 ac=(items < 2) ? 1 : items-1;
2736 length=(STRLEN *) NULL;
2737 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2738 if (list == (char **) NULL)
2740 ThrowPerlException(exception,ResourceLimitError,
2741 "MemoryAllocationFailed",PackageName);
2744 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2745 if (length == (STRLEN *) NULL)
2747 ThrowPerlException(exception,ResourceLimitError,
2748 "MemoryAllocationFailed",PackageName);
2751 if (sv_isobject(ST(0)) == 0)
2753 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2757 reference=SvRV(ST(0));
2758 hv=SvSTASH(reference);
2759 if (SvTYPE(reference) != SVt_PVAV)
2761 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2765 av=(AV *) reference;
2766 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2771 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2774 for (n=0, i=0; i < ac; i++)
2776 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2777 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2779 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2784 list[n]=(char *) NULL;
2786 for (i=number_images=0; i < n; i++)
2788 image=BlobToImage(info->image_info,list[i],length[i],exception);
2789 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2791 for ( ; image; image=image->next)
2793 AddImageToRegistry(image);
2795 av_push(av,sv_bless(rv,hv));
2803 for (i=0; i < n; i++)
2804 if (list[i] != (char *) NULL)
2805 for (p=keep; list[i] != *p++; )
2806 if (*p == (char *) NULL)
2808 list[i]=(char *) RelinquishMagickMemory(list[i]);
2814 list=(char **) RelinquishMagickMemory(list);
2816 length=(STRLEN *) RelinquishMagickMemory(length);
2817 InheritPerlException(exception,perl_exception);
2818 exception=DestroyExceptionInfo(exception);
2819 sv_setiv(perl_exception,(IV) number_images);
2820 SvPOK_on(perl_exception);
2821 ST(0)=sv_2mortal(perl_exception);
2826 ###############################################################################
2834 ###############################################################################
2839 Image::Magick ref=NO_INIT
2872 exception=AcquireExceptionInfo();
2873 perl_exception=newSVpv("",0);
2874 if (sv_isobject(ST(0)) == 0)
2876 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2880 reference=SvRV(ST(0));
2881 hv=SvSTASH(reference);
2882 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2883 if (image == (Image *) NULL)
2885 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2890 Create blessed Perl array for the returned image.
2893 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2895 for ( ; image; image=image->next)
2897 clone=CloneImage(image,0,0,MagickTrue,exception);
2898 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2900 AddImageToRegistry(clone);
2902 av_push(av,sv_bless(rv,hv));
2905 exception=DestroyExceptionInfo(exception);
2906 SvREFCNT_dec(perl_exception);
2910 InheritPerlException(exception,perl_exception);
2911 exception=DestroyExceptionInfo(exception);
2912 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2913 SvPOK_on(perl_exception);
2914 ST(0)=sv_2mortal(perl_exception);
2919 ###############################################################################
2927 ###############################################################################
2935 if (magick_registry != (SplayTreeInfo *) NULL)
2940 ResetSplayTreeIterator(magick_registry);
2941 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2942 while (p != (Image *) NULL)
2945 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2951 ###############################################################################
2959 ###############################################################################
2964 Image::Magick ref=NO_INIT
2993 exception=AcquireExceptionInfo();
2994 perl_exception=newSVpv("",0);
2995 if (sv_isobject(ST(0)) == 0)
2997 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3001 reference=SvRV(ST(0));
3002 hv=SvSTASH(reference);
3004 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3006 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3007 if (image == (Image *) NULL)
3009 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3013 image=CoalesceImages(image,exception);
3014 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3016 for ( ; image; image=image->next)
3018 AddImageToRegistry(image);
3020 av_push(av,sv_bless(rv,hv));
3023 exception=DestroyExceptionInfo(exception);
3025 SvREFCNT_dec(perl_exception);
3029 InheritPerlException(exception,perl_exception);
3030 exception=DestroyExceptionInfo(exception);
3031 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3032 SvPOK_on(perl_exception);
3033 ST(0)=sv_2mortal(perl_exception);
3038 ###############################################################################
3046 ###############################################################################
3051 Image::Magick ref=NO_INIT
3100 exception=AcquireExceptionInfo();
3101 perl_exception=newSVpv("",0);
3104 if (sv_isobject(ST(0)) == 0)
3106 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3110 reference=SvRV(ST(0));
3111 hv=SvSTASH(reference);
3113 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3115 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3116 if (image == (Image *) NULL)
3118 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3122 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3126 channel=DefaultChannels;
3127 reconstruct_image=image;
3128 metric=RootMeanSquaredErrorMetric;
3129 for (i=2; i < items; i+=2)
3131 attribute=(char *) SvPV(ST(i-1),na);
3137 if (LocaleCompare(attribute,"channel") == 0)
3142 option=ParseChannelOption(SvPV(ST(i),na));
3145 ThrowPerlException(exception,OptionError,
3146 "UnrecognizedType",SvPV(ST(i),na));
3149 channel=(ChannelType) option;
3152 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3159 if (LocaleCompare(attribute,"fuzz") == 0)
3161 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3171 if (LocaleCompare(attribute,"image") == 0)
3173 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3174 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3176 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3183 if (LocaleCompare(attribute,"metric") == 0)
3185 option=ParseMagickOption(MagickMetricOptions,MagickFalse,
3189 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3193 metric=(MetricType) option;
3196 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3202 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3208 difference_image=CompareImageChannels(image,reconstruct_image,channel,
3209 metric,&distortion,exception);
3210 if (difference_image != (Image *) NULL)
3212 difference_image->error.mean_error_per_pixel=distortion;
3213 AddImageToRegistry(difference_image);
3215 av_push(av,sv_bless(rv,hv));
3218 exception=DestroyExceptionInfo(exception);
3220 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3224 InheritPerlException(exception,perl_exception);
3225 exception=DestroyExceptionInfo(exception);
3226 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3227 SvPOK_on(perl_exception);
3228 ST(0)=sv_2mortal(perl_exception);
3233 ###############################################################################
3237 # C o m p a r e L a y e r s #
3241 ###############################################################################
3246 Image::Magick ref=NO_INIT
3248 CompareImageLayers = 1
3250 compareimagelayers = 3
3287 exception=AcquireExceptionInfo();
3288 perl_exception=newSVpv("",0);
3289 if (sv_isobject(ST(0)) == 0)
3291 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3295 reference=SvRV(ST(0));
3296 hv=SvSTASH(reference);
3298 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3300 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3301 if (image == (Image *) NULL)
3303 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3307 method=CompareAnyLayer;
3308 for (i=2; i < items; i+=2)
3310 attribute=(char *) SvPV(ST(i-1),na);
3316 if (LocaleCompare(attribute,"method") == 0)
3318 option=ParseMagickOption(MagickLayerOptions,MagickFalse,
3322 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3326 method=(ImageLayerMethod) option;
3329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3335 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3341 image=CompareImageLayers(image,method,exception);
3342 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3344 for ( ; image; image=image->next)
3346 AddImageToRegistry(image);
3348 av_push(av,sv_bless(rv,hv));
3351 exception=DestroyExceptionInfo(exception);
3353 SvREFCNT_dec(perl_exception);
3357 InheritPerlException(exception,perl_exception);
3358 exception=DestroyExceptionInfo(exception);
3359 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3360 SvPOK_on(perl_exception);
3361 ST(0)=sv_2mortal(perl_exception);
3366 ###############################################################################
3374 ###############################################################################
3379 Image::Magick ref=NO_INIT
3385 if (sv_isobject(ST(0)) == 0)
3386 croak("ReferenceIsNotMyType");
3387 reference=SvRV(ST(0));
3388 switch (SvTYPE(reference))
3393 message[MaxTextExtent];
3408 Array (AV *) reference
3410 (void) FormatMagickString(message,MaxTextExtent,"package%s%lx",
3411 XS_VERSION,(long) reference);
3412 hv=gv_stashpv(PackageName, FALSE);
3415 gvp=(GV **) hv_fetch(hv,message,strlen(message),FALSE);
3419 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3421 info=(struct PackageInfo *) SvIV(sv);
3422 DestroyPackageInfo(info);
3424 hv_delete(hv,message,strlen(message),G_DISCARD);
3433 Blessed scalar = (Image *) SvIV(reference)
3435 image=(Image *) SvIV(reference);
3436 if (image != (Image *) NULL)
3437 DeleteImageFromRegistry(reference,image);
3446 ###############################################################################
3454 ###############################################################################
3459 Image::Magick ref=NO_INIT
3483 exception=AcquireExceptionInfo();
3484 perl_exception=newSVpv("",0);
3485 package_info=(struct PackageInfo *) NULL;
3486 if (sv_isobject(ST(0)) == 0)
3488 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3492 reference=SvRV(ST(0));
3493 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3494 if (image == (Image *) NULL)
3496 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3500 package_info=ClonePackageInfo(info,exception);
3502 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3505 for (i=2; i < items; i+=2)
3506 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3508 (void) DisplayImages(package_info->image_info,image);
3509 (void) CatchImageException(image);
3510 InheritException(exception,&image->exception);
3513 if (package_info != (struct PackageInfo *) NULL)
3514 DestroyPackageInfo(package_info);
3515 InheritPerlException(exception,perl_exception);
3516 exception=DestroyExceptionInfo(exception);
3517 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3518 SvPOK_on(perl_exception);
3519 ST(0)=sv_2mortal(perl_exception);
3524 ###############################################################################
3532 ###############################################################################
3537 Image::Magick ref=NO_INIT
3544 #define ChannelFeatures(channel,direction) \
3546 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3547 channel_features[channel].angular_second_moment[direction]); \
3548 PUSHs(sv_2mortal(newSVpv(message,0))); \
3549 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3550 channel_features[channel].contrast[direction]); \
3551 PUSHs(sv_2mortal(newSVpv(message,0))); \
3552 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3553 channel_features[channel].contrast[direction]); \
3554 PUSHs(sv_2mortal(newSVpv(message,0))); \
3555 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3556 channel_features[channel].variance_sum_of_squares[direction]); \
3557 PUSHs(sv_2mortal(newSVpv(message,0))); \
3558 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3559 channel_features[channel].inverse_difference_moment[direction]); \
3560 PUSHs(sv_2mortal(newSVpv(message,0))); \
3561 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3562 channel_features[channel].sum_average[direction]); \
3563 PUSHs(sv_2mortal(newSVpv(message,0))); \
3564 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3565 channel_features[channel].sum_variance[direction]); \
3566 PUSHs(sv_2mortal(newSVpv(message,0))); \
3567 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3568 channel_features[channel].sum_entropy[direction]); \
3569 PUSHs(sv_2mortal(newSVpv(message,0))); \
3570 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3571 channel_features[channel].entropy[direction]); \
3572 PUSHs(sv_2mortal(newSVpv(message,0))); \
3573 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3574 channel_features[channel].difference_variance[direction]); \
3575 PUSHs(sv_2mortal(newSVpv(message,0))); \
3576 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3577 channel_features[channel].difference_entropy[direction]); \
3578 PUSHs(sv_2mortal(newSVpv(message,0))); \
3579 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3580 channel_features[channel].measure_of_correlation_1[direction]); \
3581 PUSHs(sv_2mortal(newSVpv(message,0))); \
3582 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3583 channel_features[channel].measure_of_correlation_2[direction]); \
3584 PUSHs(sv_2mortal(newSVpv(message,0))); \
3585 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3586 channel_features[channel].maximum_correlation_coefficient[direction]); \
3587 PUSHs(sv_2mortal(newSVpv(message,0))); \
3595 message[MaxTextExtent];
3627 exception=AcquireExceptionInfo();
3628 perl_exception=newSVpv("",0);
3630 if (sv_isobject(ST(0)) == 0)
3632 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3636 reference=SvRV(ST(0));
3637 hv=SvSTASH(reference);
3639 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3641 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3642 if (image == (Image *) NULL)
3644 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3648 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3650 for (i=2; i < items; i+=2)
3652 attribute=(char *) SvPV(ST(i-1),na);
3658 if (LocaleCompare(attribute,"distance") == 0)
3660 distance=StringToLong((char *) SvPV(ST(1),na));
3663 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3669 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3676 for ( ; image; image=image->next)
3678 channel_features=GetImageChannelFeatures(image,distance,
3680 if (channel_features == (ChannelFeatures *) NULL)
3683 EXTEND(sp,75*count);
3684 for (i=0; i < 4; i++)
3686 ChannelFeatures(RedChannel,i);
3687 ChannelFeatures(GreenChannel,i);
3688 ChannelFeatures(BlueChannel,i);
3689 if (image->colorspace == CMYKColorspace)
3690 ChannelFeatures(IndexChannel,i);
3691 if (image->matte != MagickFalse)
3692 ChannelFeatures(OpacityChannel,i);
3694 channel_features=(ChannelFeatures *)
3695 RelinquishMagickMemory(channel_features);
3699 InheritPerlException(exception,perl_exception);
3700 exception=DestroyExceptionInfo(exception);
3701 SvREFCNT_dec(perl_exception);
3705 ###############################################################################
3713 ###############################################################################
3718 Image::Magick ref=NO_INIT
3756 exception=AcquireExceptionInfo();
3757 perl_exception=newSVpv("",0);
3758 if (sv_isobject(ST(0)) == 0)
3760 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3764 reference=SvRV(ST(0));
3765 hv=SvSTASH(reference);
3766 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3767 if (image == (Image *) NULL)
3769 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3773 background_color=image->background_color;
3775 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3778 for (i=2; i < items; i+=2)
3780 attribute=(char *) SvPV(ST(i-1),na);
3786 if (LocaleCompare(attribute,"background") == 0)
3788 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3789 &background_color,exception);
3792 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3798 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3804 image->background_color=background_color;
3805 image=MergeImageLayers(image,FlattenLayer,exception);
3806 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3809 Create blessed Perl array for the returned image.
3812 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3814 AddImageToRegistry(image);
3816 av_push(av,sv_bless(rv,hv));
3818 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3819 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
3820 "flatten-%.*s",(int) (MaxTextExtent-9),
3821 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3822 (void) CopyMagickString(image->filename,info->image_info->filename,
3824 SetImageInfo(info->image_info,MagickFalse,exception);
3825 exception=DestroyExceptionInfo(exception);
3826 SvREFCNT_dec(perl_exception);
3830 InheritPerlException(exception,perl_exception);
3831 exception=DestroyExceptionInfo(exception);
3832 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3833 SvPOK_on(perl_exception); /* return messages in string context */
3834 ST(0)=sv_2mortal(perl_exception);
3839 ###############################################################################
3847 ###############################################################################
3852 Image::Magick ref=NO_INIT
3864 expression[MaxTextExtent];
3891 exception=AcquireExceptionInfo();
3892 perl_exception=newSVpv("",0);
3895 if (sv_isobject(ST(0)) == 0)
3897 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3901 reference=SvRV(ST(0));
3902 hv=SvSTASH(reference);
3904 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3906 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3907 if (image == (Image *) NULL)
3909 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3913 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3917 channel=DefaultChannels;
3918 (void) CopyMagickString(expression,"u",MaxTextExtent);
3920 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
3922 for (i=2; i < items; i+=2)
3924 attribute=(char *) SvPV(ST(i-1),na);
3930 if (LocaleCompare(attribute,"channel") == 0)
3935 option=ParseChannelOption(SvPV(ST(i),na));
3938 ThrowPerlException(exception,OptionError,
3939 "UnrecognizedType",SvPV(ST(i),na));
3942 channel=(ChannelType) option;
3945 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3952 if (LocaleCompare(attribute,"expression") == 0)
3954 (void) CopyMagickString(expression,SvPV(ST(i),na),
3958 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3964 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3970 image=FxImageChannel(image,channel,expression,exception);
3971 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3973 for ( ; image; image=image->next)
3975 AddImageToRegistry(image);
3977 av_push(av,sv_bless(rv,hv));
3980 exception=DestroyExceptionInfo(exception);
3982 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3986 InheritPerlException(exception,perl_exception);
3987 exception=DestroyExceptionInfo(exception);
3988 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3989 SvPOK_on(perl_exception);
3990 ST(0)=sv_2mortal(perl_exception);
3995 ###############################################################################
4003 ###############################################################################
4008 Image::Magick ref=NO_INIT
4019 color[MaxTextExtent];
4044 exception=AcquireExceptionInfo();
4045 perl_exception=newSVpv("",0);
4046 if (sv_isobject(ST(0)) == 0)
4048 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4052 reference=SvRV(ST(0));
4053 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4054 if (image == (Image *) NULL && !info)
4057 for (i=1; i < items; i++)
4059 attribute=(char *) SvPV(ST(i),na);
4066 if (LocaleCompare(attribute,"adjoin") == 0)
4069 s=newSViv((long) info->image_info->adjoin);
4070 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4073 if (LocaleCompare(attribute,"antialias") == 0)
4076 s=newSViv((long) info->image_info->antialias);
4077 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4080 if (LocaleCompare(attribute,"area") == 0)
4082 s=newSViv(GetMagickResource(AreaResource));
4083 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4086 if (LocaleCompare(attribute,"attenuate") == 0)
4091 value=GetImageProperty(image,attribute);
4092 if (value != (const char *) NULL)
4094 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4097 if (LocaleCompare(attribute,"authenticate") == 0)
4100 s=newSVpv(info->image_info->authenticate,0);
4101 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4104 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4111 if (LocaleCompare(attribute,"background") == 0)
4113 if (image == (Image *) NULL)
4115 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4116 QuantumFormat "," QuantumFormat "," QuantumFormat,
4117 image->background_color.red,image->background_color.green,
4118 image->background_color.blue,image->background_color.opacity);
4120 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4123 if (LocaleCompare(attribute,"base-columns") == 0)
4125 if (image != (Image *) NULL)
4126 s=newSViv((long) image->magick_columns);
4127 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4130 if (LocaleCompare(attribute,"base-filename") == 0)
4132 if (image != (Image *) NULL)
4133 s=newSVpv(image->magick_filename,0);
4134 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4137 if (LocaleCompare(attribute,"base-height") == 0)
4139 if (image != (Image *) NULL)
4140 s=newSViv((long) image->magick_rows);
4141 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4144 if (LocaleCompare(attribute,"base-rows") == 0)
4146 if (image != (Image *) NULL)
4147 s=newSViv((long) image->magick_rows);
4148 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4151 if (LocaleCompare(attribute,"base-width") == 0)
4153 if (image != (Image *) NULL)
4154 s=newSViv((long) image->magick_columns);
4155 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4158 if (LocaleCompare(attribute,"bias") == 0)
4160 if (image != (Image *) NULL)
4161 s=newSVnv(image->bias);
4162 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4165 if (LocaleCompare(attribute,"blue-primary") == 0)
4167 if (image == (Image *) NULL)
4169 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4170 image->chromaticity.blue_primary.x,
4171 image->chromaticity.blue_primary.y);
4173 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4176 if (LocaleCompare(attribute,"bordercolor") == 0)
4178 if (image == (Image *) NULL)
4180 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4181 QuantumFormat "," QuantumFormat "," QuantumFormat,
4182 image->border_color.red,image->border_color.green,
4183 image->border_color.blue,image->border_color.opacity);
4185 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4188 if (LocaleCompare(attribute,"bounding-box") == 0)
4191 geometry[MaxTextExtent];
4196 if (image == (Image *) NULL)
4198 page=GetImageBoundingBox(image,&image->exception);
4199 (void) FormatMagickString(geometry,MaxTextExtent,
4200 "%lux%lu%+ld%+ld",page.width,page.height,page.x,page.y);
4201 s=newSVpv(geometry,0);
4202 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4212 if (LocaleCompare(attribute,"class") == 0)
4214 if (image == (Image *) NULL)
4216 s=newSViv(image->storage_class);
4217 (void) sv_setpv(s,MagickOptionToMnemonic(MagickClassOptions,
4218 image->storage_class));
4220 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4223 if (LocaleCompare(attribute,"clip-mask") == 0)
4225 if (image != (Image *) NULL)
4230 if (image->mask == (Image *) NULL)
4232 if (image->mask != (Image *) NULL)
4234 AddImageToRegistry(image->mask);
4235 s=sv_bless(newRV(sv),SvSTASH(reference));
4238 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4241 if (LocaleCompare(attribute,"clip-path") == 0)
4243 if (image != (Image *) NULL)
4248 if (image->clip_mask == (Image *) NULL)
4250 if (image->clip_mask != (Image *) NULL)
4252 AddImageToRegistry(image->clip_mask);
4253 s=sv_bless(newRV(sv),SvSTASH(reference));
4256 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4259 if (LocaleCompare(attribute,"compression") == 0)
4261 j=info ? info->image_info->compression : image->compression;
4263 if (info->image_info->compression == UndefinedCompression)
4264 j=image->compression;
4266 (void) sv_setpv(s,MagickOptionToMnemonic(MagickCompressOptions,
4269 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4272 if (LocaleCompare(attribute,"colorspace") == 0)
4274 j=image ? image->colorspace : RGBColorspace;
4276 (void) sv_setpv(s,MagickOptionToMnemonic(MagickColorspaceOptions,
4279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4282 if (LocaleCompare(attribute,"colors") == 0)
4284 if (image != (Image *) NULL)
4285 s=newSViv((long) GetNumberColors(image,(FILE *) NULL,
4286 &image->exception));
4287 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4290 if (LocaleNCompare(attribute,"colormap",8) == 0)
4295 if (image == (Image *) NULL || !image->colormap)
4298 items=sscanf(attribute,"%*[^[][%ld",&j);
4299 if (j > (long) image->colors)
4301 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4302 QuantumFormat "," QuantumFormat "," QuantumFormat,
4303 image->colormap[j].red,image->colormap[j].green,
4304 image->colormap[j].blue,image->colormap[j].opacity);
4306 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4309 if (LocaleCompare(attribute,"columns") == 0)
4311 if (image != (Image *) NULL)
4312 s=newSViv((long) image->columns);
4313 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4316 if (LocaleCompare(attribute,"comment") == 0)
4321 value=GetImageProperty(image,attribute);
4322 if (value != (const char *) NULL)
4324 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4327 if (LocaleCompare(attribute,"copyright") == 0)
4329 s=newSVpv(GetMagickCopyright(),0);
4330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4333 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4340 if (LocaleCompare(attribute,"density") == 0)
4343 geometry[MaxTextExtent];
4345 if (image == (Image *) NULL)
4347 (void) FormatMagickString(geometry,MaxTextExtent,"%.15gx%.15g",
4348 image->x_resolution,image->y_resolution);
4349 s=newSVpv(geometry,0);
4350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4353 if (LocaleCompare(attribute,"delay") == 0)
4355 if (image != (Image *) NULL)
4356 s=newSViv((long) image->delay);
4357 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4360 if (LocaleCompare(attribute,"depth") == 0)
4362 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4363 if (image != (Image *) NULL)
4364 s=newSViv((long) GetImageDepth(image,&image->exception));
4365 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4368 if (LocaleCompare(attribute,"directory") == 0)
4370 if (image && image->directory)
4371 s=newSVpv(image->directory,0);
4372 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4375 if (LocaleCompare(attribute,"dispose") == 0)
4377 if (image == (Image *) NULL)
4380 s=newSViv(image->dispose);
4382 MagickOptionToMnemonic(MagickDisposeOptions,image->dispose));
4384 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4387 if (LocaleCompare(attribute,"disk") == 0)
4389 s=newSViv(GetMagickResource(DiskResource));
4390 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4393 if (LocaleCompare(attribute,"dither") == 0)
4396 s=newSViv((long) info->image_info->dither);
4397 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4400 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4402 if (info && info->image_info->server_name)
4403 s=newSVpv(info->image_info->server_name,0);
4404 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4407 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4414 if (LocaleCompare(attribute,"elapsed-time") == 0)
4416 if (image != (Image *) NULL)
4417 s=newSVnv(GetElapsedTime(&image->timer));
4418 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4421 if (LocaleCompare(attribute,"endian") == 0)
4423 j=info ? info->image_info->endian : image->endian;
4425 (void) sv_setpv(s,MagickOptionToMnemonic(MagickEndianOptions,j));
4427 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4430 if (LocaleCompare(attribute,"error") == 0)
4432 if (image != (Image *) NULL)
4433 s=newSVnv(image->error.mean_error_per_pixel);
4434 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4437 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4444 if (LocaleCompare(attribute,"filesize") == 0)
4446 if (image != (Image *) NULL)
4447 s=newSViv((long) GetBlobSize(image));
4448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4451 if (LocaleCompare(attribute,"filename") == 0)
4453 if (info && info->image_info->filename &&
4454 *info->image_info->filename)
4455 s=newSVpv(info->image_info->filename,0);
4456 if (image != (Image *) NULL)
4457 s=newSVpv(image->filename,0);
4458 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4461 if (LocaleCompare(attribute,"filter") == 0)
4463 s=newSViv(image->filter);
4464 (void) sv_setpv(s,MagickOptionToMnemonic(MagickFilterOptions,
4467 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4470 if (LocaleCompare(attribute,"font") == 0)
4472 if (info && info->image_info->font)
4473 s=newSVpv(info->image_info->font,0);
4474 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4477 if (LocaleCompare(attribute,"foreground") == 0)
4479 if (LocaleCompare(attribute,"format") == 0)
4484 magick_info=(const MagickInfo *) NULL;
4485 if (info && (*info->image_info->magick != '\0'))
4486 magick_info=GetMagickInfo(info->image_info->magick,exception);
4487 if (image != (Image *) NULL)
4488 magick_info=GetMagickInfo(image->magick,&image->exception);
4489 if ((magick_info != (const MagickInfo *) NULL) &&
4490 (*magick_info->description != '\0'))
4491 s=newSVpv((char *) magick_info->description,0);
4492 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4495 if (LocaleCompare(attribute,"fuzz") == 0)
4498 s=newSVnv(info->image_info->fuzz);
4499 if (image != (Image *) NULL)
4500 s=newSVnv(image->fuzz);
4501 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4511 if (LocaleCompare(attribute,"gamma") == 0)
4513 if (image != (Image *) NULL)
4514 s=newSVnv(image->gamma);
4515 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4518 if (LocaleCompare(attribute,"geometry") == 0)
4520 if (image && image->geometry)
4521 s=newSVpv(image->geometry,0);
4522 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4525 if (LocaleCompare(attribute,"gravity") == 0)
4527 s=newSViv(image->gravity);
4529 MagickOptionToMnemonic(MagickGravityOptions,image->gravity));
4531 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4534 if (LocaleCompare(attribute,"green-primary") == 0)
4536 if (image == (Image *) NULL)
4538 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4539 image->chromaticity.green_primary.x,
4540 image->chromaticity.green_primary.y);
4542 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4545 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4552 if (LocaleCompare(attribute,"height") == 0)
4554 if (image != (Image *) NULL)
4555 s=newSViv((long) image->rows);
4556 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4566 if (LocaleCompare(attribute,"icc") == 0)
4568 if (image != (Image *) NULL)
4573 profile=GetImageProfile(image,"icc");
4574 if (profile != (StringInfo *) NULL)
4575 s=newSVpv((const char *) GetStringInfoDatum(profile),
4576 GetStringInfoLength(profile));
4578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4581 if (LocaleCompare(attribute,"icm") == 0)
4583 if (image != (Image *) NULL)
4588 profile=GetImageProfile(image,"icm");
4589 if (profile != (const StringInfo *) NULL)
4590 s=newSVpv((const char *) GetStringInfoDatum(profile),
4591 GetStringInfoLength(profile));
4593 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4596 if (LocaleCompare(attribute,"id") == 0)
4598 if (image != (Image *) NULL)
4609 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
4610 status=SetImageRegistry(ImageRegistryType,key,image,
4614 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4617 if (LocaleNCompare(attribute,"index",5) == 0)
4620 name[MaxTextExtent];
4629 register const IndexPacket
4632 register const PixelPacket
4638 if (image == (Image *) NULL)
4640 if (image->storage_class != PseudoClass)
4644 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4645 image_view=AcquireCacheView(image);
4646 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4647 if (p != (const PixelPacket *) NULL)
4649 indexes=GetCacheViewVirtualIndexQueue(image_view);
4650 (void) FormatMagickString(name,MaxTextExtent,QuantumFormat,
4653 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4655 image_view=DestroyCacheView(image_view);
4658 if (LocaleCompare(attribute,"iptc") == 0)
4660 if (image != (Image *) NULL)
4665 profile=GetImageProfile(image,"iptc");
4666 if (profile != (const StringInfo *) NULL)
4667 s=newSVpv((const char *) GetStringInfoDatum(profile),
4668 GetStringInfoLength(profile));
4670 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4673 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4675 if (image != (Image *) NULL)
4676 s=newSViv((long) image->iterations);
4677 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4680 if (LocaleCompare(attribute,"interlace") == 0)
4682 j=info ? info->image_info->interlace : image->interlace;
4684 (void) sv_setpv(s,MagickOptionToMnemonic(MagickInterlaceOptions,
4687 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4690 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4697 if (LocaleCompare(attribute,"label") == 0)
4702 if (image == (Image *) NULL)
4704 value=GetImageProperty(image,"Label");
4705 if (value != (const char *) NULL)
4707 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4710 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4712 if (image != (Image *) NULL)
4713 s=newSViv((long) image->iterations);
4714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4717 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4724 if (LocaleCompare(attribute,"magick") == 0)
4726 if (info && *info->image_info->magick)
4727 s=newSVpv(info->image_info->magick,0);
4728 if (image != (Image *) NULL)
4729 s=newSVpv(image->magick,0);
4730 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4733 if (LocaleCompare(attribute,"map") == 0)
4735 s=newSViv(GetMagickResource(MapResource));
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 if (LocaleCompare(attribute,"maximum-error") == 0)
4741 if (image != (Image *) NULL)
4742 s=newSVnv(image->error.normalized_maximum_error);
4743 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4746 if (LocaleCompare(attribute,"memory") == 0)
4748 s=newSViv(GetMagickResource(MemoryResource));
4749 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4752 if (LocaleCompare(attribute,"mean-error") == 0)
4754 if (image != (Image *) NULL)
4755 s=newSVnv(image->error.normalized_mean_error);
4756 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4759 if (LocaleCompare(attribute,"mime") == 0)
4761 if (info && *info->image_info->magick)
4762 s=newSVpv(MagickToMime(info->image_info->magick),0);
4763 if (image != (Image *) NULL)
4764 s=newSVpv(MagickToMime(image->magick),0);
4765 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4768 if (LocaleCompare(attribute,"mattecolor") == 0)
4770 if (image == (Image *) NULL)
4772 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4773 QuantumFormat "," QuantumFormat "," QuantumFormat,
4774 image->matte_color.red,image->matte_color.green,
4775 image->matte_color.blue,image->matte_color.opacity);
4777 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4780 if (LocaleCompare(attribute,"matte") == 0)
4782 if (image != (Image *) NULL)
4783 s=newSViv((long) image->matte);
4784 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4787 if (LocaleCompare(attribute,"mime") == 0)
4793 if (info && *info->image_info->magick)
4794 magick=info->image_info->magick;
4795 if (image != (Image *) NULL)
4796 magick=image->magick;
4802 mime=MagickToMime(magick);
4804 mime=(char *) RelinquishMagickMemory(mime);
4806 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4809 if (LocaleCompare(attribute,"monochrome") == 0)
4811 if (image == (Image *) NULL)
4813 j=info ? info->image_info->monochrome :
4814 IsMonochromeImage(image,&image->exception);
4816 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4819 if (LocaleCompare(attribute,"montage") == 0)
4821 if (image && image->montage)
4822 s=newSVpv(image->montage,0);
4823 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4826 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4833 if (LocaleCompare(attribute,"orientation") == 0)
4835 j=info ? info->image_info->orientation : image->orientation;
4837 (void) sv_setpv(s,MagickOptionToMnemonic(MagickOrientationOptions,
4840 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4843 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4850 if (LocaleCompare(attribute,"page") == 0)
4852 if (info && info->image_info->page)
4853 s=newSVpv(info->image_info->page,0);
4854 if (image != (Image *) NULL)
4857 geometry[MaxTextExtent];
4859 (void) FormatMagickString(geometry,MaxTextExtent,
4860 "%lux%lu%+ld%+ld",image->page.width,image->page.height,
4861 image->page.x,image->page.y);
4862 s=newSVpv(geometry,0);
4864 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4867 if (LocaleCompare(attribute,"page.x") == 0)
4869 if (image != (Image *) NULL)
4870 s=newSViv((long) image->page.x);
4871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4874 if (LocaleCompare(attribute,"page.y") == 0)
4876 if (image != (Image *) NULL)
4877 s=newSViv((long) image->page.y);
4878 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4881 if (LocaleNCompare(attribute,"pixel",5) == 0)
4884 tuple[MaxTextExtent];
4893 register const PixelPacket
4896 register const IndexPacket
4899 if (image == (Image *) NULL)
4903 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4904 p=GetVirtualPixels(image,x,y,1,1,exception);
4905 indexes=GetVirtualIndexQueue(image);
4906 if (image->colorspace != CMYKColorspace)
4907 (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
4908 QuantumFormat "," QuantumFormat "," QuantumFormat,
4909 p->red,p->green,p->blue,p->opacity);
4911 (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
4912 QuantumFormat "," QuantumFormat "," QuantumFormat ","
4913 QuantumFormat,p->red,p->green,p->blue,*indexes,p->opacity);
4915 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4918 if (LocaleCompare(attribute,"pointsize") == 0)
4921 s=newSViv((long) info->image_info->pointsize);
4922 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4925 if (LocaleCompare(attribute,"preview") == 0)
4927 s=newSViv(info->image_info->preview_type);
4928 (void) sv_setpv(s,MagickOptionToMnemonic(MagickPreviewOptions,
4929 info->image_info->preview_type));
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4941 if (LocaleCompare(attribute,"quality") == 0)
4944 s=newSViv((long) info->image_info->quality);
4945 if (image != (Image *) NULL)
4946 s=newSViv((long) image->quality);
4947 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4950 if (LocaleCompare(attribute,"quantum") == 0)
4953 s=newSViv((long) MAGICKCORE_QUANTUM_DEPTH);
4954 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4957 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4964 if (LocaleCompare(attribute,"rendering-intent") == 0)
4966 s=newSViv(image->rendering_intent);
4967 (void) sv_setpv(s,MagickOptionToMnemonic(MagickIntentOptions,
4968 image->rendering_intent));
4970 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4973 if (LocaleCompare(attribute,"red-primary") == 0)
4975 if (image == (Image *) NULL)
4977 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4978 image->chromaticity.red_primary.x,
4979 image->chromaticity.red_primary.y);
4981 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4984 if (LocaleCompare(attribute,"rows") == 0)
4986 if (image != (Image *) NULL)
4987 s=newSViv((long) image->rows);
4988 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4991 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4998 if (LocaleCompare(attribute,"sampling-factor") == 0)
5000 if (info && info->image_info->sampling_factor)
5001 s=newSVpv(info->image_info->sampling_factor,0);
5002 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5005 if (LocaleCompare(attribute,"subimage") == 0)
5008 s=newSViv((long) info->image_info->subimage);
5009 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5012 if (LocaleCompare(attribute,"subrange") == 0)
5015 s=newSViv((long) info->image_info->subrange);
5016 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5021 if (info && info->image_info->server_name)
5022 s=newSVpv(info->image_info->server_name,0);
5023 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5026 if (LocaleCompare(attribute,"size") == 0)
5028 if (info && info->image_info->size)
5029 s=newSVpv(info->image_info->size,0);
5030 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5033 if (LocaleCompare(attribute,"scene") == 0)
5035 if (image != (Image *) NULL)
5036 s=newSViv((long) image->scene);
5037 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5040 if (LocaleCompare(attribute,"scenes") == 0)
5042 if (image != (Image *) NULL)
5043 s=newSViv((long) info->image_info->number_scenes);
5044 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5047 if (LocaleCompare(attribute,"signature") == 0)
5052 if (image == (Image *) NULL)
5054 (void) SignatureImage(image);
5055 value=GetImageProperty(image,"Signature");
5056 if (value != (const char *) NULL)
5058 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5061 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5068 if (LocaleCompare(attribute,"taint") == 0)
5070 if (image != (Image *) NULL)
5071 s=newSViv((long) IsTaintImage(image));
5072 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5075 if (LocaleCompare(attribute,"tile") == 0)
5077 if (info && info->image_info->tile)
5078 s=newSVpv(info->image_info->tile,0);
5079 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5082 if (LocaleCompare(attribute,"texture") == 0)
5084 if (info && info->image_info->texture)
5085 s=newSVpv(info->image_info->texture,0);
5086 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5089 if (LocaleCompare(attribute,"total-ink-density") == 0)
5091 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5092 if (image != (Image *) NULL)
5093 s=newSVnv(GetImageTotalInkDensity(image));
5094 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5097 if (LocaleCompare(attribute,"transparent-color") == 0)
5099 if (image == (Image *) NULL)
5101 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
5102 QuantumFormat "," QuantumFormat "," QuantumFormat,
5103 image->transparent_color.red,image->transparent_color.green,
5104 image->transparent_color.blue,image->transparent_color.opacity);
5106 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5109 if (LocaleCompare(attribute,"type") == 0)
5111 if (image == (Image *) NULL)
5113 j=(long) GetImageType(image,&image->exception);
5115 (void) sv_setpv(s,MagickOptionToMnemonic(MagickTypeOptions,j));
5117 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5120 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5127 if (LocaleCompare(attribute,"units") == 0)
5129 j=info ? info->image_info->units : image->units;
5131 if (info->image_info->units == UndefinedResolution)
5133 if (j == UndefinedResolution)
5134 s=newSVpv("undefined units",0);
5136 if (j == PixelsPerInchResolution)
5137 s=newSVpv("pixels / inch",0);
5139 s=newSVpv("pixels / centimeter",0);
5140 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5143 if (LocaleCompare(attribute,"user-time") == 0)
5145 if (image != (Image *) NULL)
5146 s=newSVnv(GetUserTime(&image->timer));
5147 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5150 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5157 if (LocaleCompare(attribute,"verbose") == 0)
5160 s=newSViv((long) info->image_info->verbose);
5161 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5164 if (LocaleCompare(attribute,"version") == 0)
5166 s=newSVpv(GetMagickVersion((unsigned long *) NULL),0);
5167 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5170 if (LocaleCompare(attribute,"view") == 0)
5172 if (info && info->image_info->view)
5173 s=newSVpv(info->image_info->view,0);
5174 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5177 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5179 if (image == (Image *) NULL)
5181 j=(long) GetImageVirtualPixelMethod(image);
5183 (void) sv_setpv(s,MagickOptionToMnemonic(
5184 MagickVirtualPixelOptions,j));
5186 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5196 if (LocaleCompare(attribute,"white-point") == 0)
5198 if (image == (Image *) NULL)
5200 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
5201 image->chromaticity.white_point.x,
5202 image->chromaticity.white_point.y);
5204 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5207 if (LocaleCompare(attribute,"width") == 0)
5209 if (image != (Image *) NULL)
5210 s=newSViv((long) image->columns);
5211 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5214 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5221 if (LocaleCompare(attribute,"x-resolution") == 0)
5223 if (image != (Image *) NULL)
5224 s=newSVnv(image->x_resolution);
5225 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5228 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5235 if (LocaleCompare(attribute,"y-resolution") == 0)
5237 if (image != (Image *) NULL)
5238 s=newSVnv(image->y_resolution);
5239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5242 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5249 if (image == (Image *) NULL)
5250 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5254 value=GetImageProperty(image,attribute);
5255 if (value != (const char *) NULL)
5258 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5261 if (*attribute != '%')
5262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5269 meta=InterpretImageProperties(info ? info->image_info :
5270 (ImageInfo *) NULL,image,attribute);
5272 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5273 meta=(char *) RelinquishMagickMemory(meta);
5277 exception=DestroyExceptionInfo(exception);
5278 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5282 ###############################################################################
5286 # G e t A u t h e n t i c P i x e l s #
5290 ###############################################################################
5294 GetAuthenticPixels(ref,...)
5295 Image::Magick ref = NO_INIT
5297 getauthenticpixels = 1
5327 exception=AcquireExceptionInfo();
5328 perl_exception=newSVpv("",0);
5329 if (sv_isobject(ST(0)) == 0)
5331 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5335 reference=SvRV(ST(0));
5337 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5338 if (image == (Image *) NULL)
5340 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5347 region.width=image->columns;
5350 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5351 for (i=2; i < items; i+=2)
5353 attribute=(char *) SvPV(ST(i-1),na);
5359 if (LocaleCompare(attribute,"geometry") == 0)
5361 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5364 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5371 if (LocaleCompare(attribute,"height") == 0)
5373 region.height=SvIV(ST(i));
5376 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5383 if (LocaleCompare(attribute,"x") == 0)
5385 region.x=SvIV(ST(i));
5388 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5395 if (LocaleCompare(attribute,"y") == 0)
5397 region.y=SvIV(ST(i));
5400 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5407 if (LocaleCompare(attribute,"width") == 0)
5409 region.width=SvIV(ST(i));
5412 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5418 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5419 region.height,exception);
5420 if (blob != (void *) NULL)
5424 InheritPerlException(exception,perl_exception);
5425 exception=DestroyExceptionInfo(exception);
5426 SvREFCNT_dec(perl_exception); /* throw away all errors */
5435 ###############################################################################
5439 # G e t V i r t u a l P i x e l s #
5443 ###############################################################################
5447 GetVirtualPixels(ref,...)
5448 Image::Magick ref = NO_INIT
5450 getvirtualpixels = 1
5451 AcquireImagePixels = 2
5452 acquireimagepixels = 3
5480 exception=AcquireExceptionInfo();
5481 perl_exception=newSVpv("",0);
5482 if (sv_isobject(ST(0)) == 0)
5484 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5488 reference=SvRV(ST(0));
5490 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5491 if (image == (Image *) NULL)
5493 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5500 region.width=image->columns;
5503 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5504 for (i=2; i < items; i+=2)
5506 attribute=(char *) SvPV(ST(i-1),na);
5512 if (LocaleCompare(attribute,"geometry") == 0)
5514 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5524 if (LocaleCompare(attribute,"height") == 0)
5526 region.height=SvIV(ST(i));
5529 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5536 if (LocaleCompare(attribute,"x") == 0)
5538 region.x=SvIV(ST(i));
5541 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5548 if (LocaleCompare(attribute,"y") == 0)
5550 region.y=SvIV(ST(i));
5553 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5560 if (LocaleCompare(attribute,"width") == 0)
5562 region.width=SvIV(ST(i));
5565 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5571 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5572 region.height,exception);
5573 if (blob != (void *) NULL)
5577 InheritPerlException(exception,perl_exception);
5578 exception=DestroyExceptionInfo(exception);
5579 SvREFCNT_dec(perl_exception); /* throw away all errors */
5582 RETVAL = (void *) blob;
5588 ###############################################################################
5592 # G e t A u t h e n t i c I n d e x Q u e u e #
5596 ###############################################################################
5600 GetAuthenticIndexQueue(ref,...)
5601 Image::Magick ref = NO_INIT
5603 getauthenticindexqueue = 1
5624 exception=AcquireExceptionInfo();
5625 perl_exception=newSVpv("",0);
5626 if (sv_isobject(ST(0)) == 0)
5628 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5632 reference=SvRV(ST(0));
5634 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5635 if (image == (Image *) NULL)
5637 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5642 blob=(void *) GetAuthenticIndexQueue(image);
5643 if (blob != (void *) NULL)
5647 InheritPerlException(exception,perl_exception);
5648 exception=DestroyExceptionInfo(exception);
5649 SvREFCNT_dec(perl_exception); /* throw away all errors */
5658 ###############################################################################
5662 # G e t V i r t u a l I n d e x Q u e u e #
5666 ###############################################################################
5670 GetVirtualIndexQueue(ref,...)
5671 Image::Magick ref = NO_INIT
5673 getvirtualindexqueue = 1
5692 exception=AcquireExceptionInfo();
5693 perl_exception=newSVpv("",0);
5694 if (sv_isobject(ST(0)) == 0)
5696 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5700 reference=SvRV(ST(0));
5702 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5703 if (image == (Image *) NULL)
5705 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5710 blob=(void *) GetVirtualIndexQueue(image);
5711 if (blob != (void *) NULL)
5715 InheritPerlException(exception,perl_exception);
5716 exception=DestroyExceptionInfo(exception);
5717 SvREFCNT_dec(perl_exception); /* throw away all errors */
5726 ###############################################################################
5730 # H i s t o g r a m #
5734 ###############################################################################
5739 Image::Magick ref=NO_INIT
5750 message[MaxTextExtent];
5781 exception=AcquireExceptionInfo();
5782 perl_exception=newSVpv("",0);
5784 if (sv_isobject(ST(0)) == 0)
5786 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5790 reference=SvRV(ST(0));
5791 hv=SvSTASH(reference);
5793 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
5795 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5796 if (image == (Image *) NULL)
5798 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5802 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5804 for ( ; image; image=image->next)
5806 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5807 if (histogram == (ColorPacket *) NULL)
5809 count+=number_colors;
5811 for (i=0; i < (long) number_colors; i++)
5813 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5814 histogram[i].pixel.red);
5815 PUSHs(sv_2mortal(newSVpv(message,0)));
5816 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5817 histogram[i].pixel.green);
5818 PUSHs(sv_2mortal(newSVpv(message,0)));
5819 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5820 histogram[i].pixel.blue);
5821 PUSHs(sv_2mortal(newSVpv(message,0)));
5822 if (image->colorspace == CMYKColorspace)
5824 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5825 histogram[i].index);
5826 PUSHs(sv_2mortal(newSVpv(message,0)));
5828 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5829 histogram[i].pixel.opacity);
5830 PUSHs(sv_2mortal(newSVpv(message,0)));
5831 (void) FormatMagickString(message,MaxTextExtent,"%lu",
5832 (unsigned long) histogram[i].count);
5833 PUSHs(sv_2mortal(newSVpv(message,0)));
5835 histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
5839 InheritPerlException(exception,perl_exception);
5840 exception=DestroyExceptionInfo(exception);
5841 SvREFCNT_dec(perl_exception);
5845 ###############################################################################
5853 ###############################################################################
5858 Image::Magick ref=NO_INIT
5888 register const IndexPacket
5891 register const PixelPacket
5902 *reference; /* reference is the SV* of ref=SvIV(reference) */
5904 exception=AcquireExceptionInfo();
5905 perl_exception=newSVpv("",0);
5906 reference=SvRV(ST(0));
5907 av=(AV *) reference;
5908 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
5910 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5911 if (image == (Image *) NULL)
5913 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5917 channel=DefaultChannels;
5918 normalize=MagickTrue;
5921 region.width=image->columns;
5924 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5925 for (i=2; i < items; i+=2)
5927 attribute=(char *) SvPV(ST(i-1),na);
5933 if (LocaleCompare(attribute,"channel") == 0)
5938 option=ParseChannelOption(SvPV(ST(i),na));
5941 ThrowPerlException(exception,OptionError,"UnrecognizedType",
5945 channel=(ChannelType) option;
5948 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5955 if (LocaleCompare(attribute,"geometry") == 0)
5957 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5960 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5967 if (LocaleCompare(attribute,"normalize") == 0)
5969 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
5973 ThrowPerlException(exception,OptionError,"UnrecognizedType",
5977 normalize=option != 0 ? MagickTrue : MagickFalse;
5980 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5987 if (LocaleCompare(attribute,"x") == 0)
5989 region.x=SvIV(ST(i));
5992 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5999 if (LocaleCompare(attribute,"y") == 0)
6001 region.y=SvIV(ST(i));
6004 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6010 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6016 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6017 if (p == (const PixelPacket *) NULL)
6024 indexes=GetVirtualIndexQueue(image);
6026 if (normalize != MagickFalse)
6027 scale=1.0/QuantumRange;
6028 if ((channel & RedChannel) != 0)
6029 PUSHs(sv_2mortal(newSVnv(scale*p->red)));
6030 if ((channel & GreenChannel) != 0)
6031 PUSHs(sv_2mortal(newSVnv(scale*p->green)));
6032 if ((channel & BlueChannel) != 0)
6033 PUSHs(sv_2mortal(newSVnv(scale*p->blue)));
6034 if (((channel & IndexChannel) != 0) &&
6035 (image->colorspace == CMYKColorspace))
6036 PUSHs(sv_2mortal(newSVnv(scale*(*indexes))));
6037 if ((channel & OpacityChannel) != 0)
6038 PUSHs(sv_2mortal(newSVnv(scale*p->opacity)));
6042 InheritPerlException(exception,perl_exception);
6043 exception=DestroyExceptionInfo(exception);
6044 SvREFCNT_dec(perl_exception);
6048 ###############################################################################
6052 # G e t P i x e l s #
6056 ###############################################################################
6061 Image::Magick ref=NO_INIT
6100 *reference; /* reference is the SV* of ref=SvIV(reference) */
6102 exception=AcquireExceptionInfo();
6103 perl_exception=newSVpv("",0);
6104 reference=SvRV(ST(0));
6105 av=(AV *) reference;
6106 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6108 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6109 if (image == (Image *) NULL)
6111 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6116 if (image->matte != MagickFalse)
6118 if (image->colorspace == CMYKColorspace)
6121 if (image->matte != MagickFalse)
6124 normalize=MagickFalse;
6127 region.width=image->columns;
6130 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6131 for (i=2; i < items; i+=2)
6133 attribute=(char *) SvPV(ST(i-1),na);
6139 if (LocaleCompare(attribute,"geometry") == 0)
6141 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6144 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6151 if (LocaleCompare(attribute,"height") == 0)
6153 region.height=SvIV(ST(i));
6156 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6163 if (LocaleCompare(attribute,"map") == 0)
6168 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6175 if (LocaleCompare(attribute,"normalize") == 0)
6177 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6181 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6185 normalize=option != 0 ? MagickTrue : MagickFalse;
6188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6195 if (LocaleCompare(attribute,"width") == 0)
6197 region.width=SvIV(ST(i));
6200 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6207 if (LocaleCompare(attribute,"x") == 0)
6209 region.x=SvIV(ST(i));
6212 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6219 if (LocaleCompare(attribute,"y") == 0)
6221 region.y=SvIV(ST(i));
6224 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6230 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6236 if (normalize != MagickFalse)
6241 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6242 region.height*sizeof(*pixels));
6243 if (pixels == (float *) NULL)
6245 ThrowPerlException(exception,ResourceLimitError,
6246 "MemoryAllocationFailed",PackageName);
6249 status=ExportImagePixels(image,region.x,region.y,region.width,
6250 region.height,map,FloatPixel,pixels,exception);
6251 if (status == MagickFalse)
6255 EXTEND(sp,strlen(map)*region.width*region.height);
6256 for (i=0; i < (long) (strlen(map)*region.width*region.height); i++)
6257 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6259 pixels=(float *) RelinquishMagickMemory(pixels);
6266 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6267 region.height*sizeof(*pixels));
6268 if (pixels == (Quantum *) NULL)
6270 ThrowPerlException(exception,ResourceLimitError,
6271 "MemoryAllocationFailed",PackageName);
6274 status=ExportImagePixels(image,region.x,region.y,region.width,
6275 region.height,map,QuantumPixel,pixels,exception);
6276 if (status == MagickFalse)
6280 EXTEND(sp,strlen(map)*region.width*region.height);
6281 for (i=0; i < (long) (strlen(map)*region.width*region.height); i++)
6282 PUSHs(sv_2mortal(newSViv(pixels[i])));
6284 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6288 InheritPerlException(exception,perl_exception);
6289 exception=DestroyExceptionInfo(exception);
6290 SvREFCNT_dec(perl_exception);
6294 ###############################################################################
6298 # I m a g e T o B l o b #
6302 ###############################################################################
6306 ImageToBlob(ref,...)
6307 Image::Magick ref=NO_INIT
6316 filename[MaxTextExtent];
6345 exception=AcquireExceptionInfo();
6346 perl_exception=newSVpv("",0);
6347 package_info=(struct PackageInfo *) NULL;
6348 if (sv_isobject(ST(0)) == 0)
6350 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6354 reference=SvRV(ST(0));
6355 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6356 if (image == (Image *) NULL)
6358 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6362 package_info=ClonePackageInfo(info,exception);
6363 for (i=2; i < items; i+=2)
6364 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6365 (void) CopyMagickString(filename,package_info->image_info->filename,
6368 for (next=image; next; next=next->next)
6370 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6371 next->scene=scene++;
6373 SetImageInfo(package_info->image_info,MagickTrue,&image->exception);
6374 EXTEND(sp,(long) GetImageListLength(image));
6375 for ( ; image; image=image->next)
6378 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6379 if (blob != (char *) NULL)
6381 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6382 blob=(unsigned char *) RelinquishMagickMemory(blob);
6384 if (package_info->image_info->adjoin)
6389 if (package_info != (struct PackageInfo *) NULL)
6390 DestroyPackageInfo(package_info);
6391 InheritPerlException(exception,perl_exception);
6392 exception=DestroyExceptionInfo(exception);
6393 SvREFCNT_dec(perl_exception); /* throw away all errors */
6397 ###############################################################################
6405 ###############################################################################
6410 Image::Magick ref=NO_INIT
6414 OptimizeImageLayers = 3
6416 optimizeimagelayers = 5
6461 exception=AcquireExceptionInfo();
6462 perl_exception=newSVpv("",0);
6463 if (sv_isobject(ST(0)) == 0)
6465 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6469 reference=SvRV(ST(0));
6470 hv=SvSTASH(reference);
6472 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6474 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6475 if (image == (Image *) NULL)
6477 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6481 compose=image->compose;
6483 method=OptimizeLayer;
6484 for (i=2; i < items; i+=2)
6486 attribute=(char *) SvPV(ST(i-1),na);
6492 if (LocaleCompare(attribute,"compose") == 0)
6494 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
6495 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6498 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6502 compose=(CompositeOperator) sp;
6505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6512 if (LocaleCompare(attribute,"dither") == 0)
6514 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
6515 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
6518 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6522 dither=(MagickBooleanType) sp;
6525 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6532 if (LocaleCompare(attribute,"method") == 0)
6534 option=ParseMagickOption(MagickLayerOptions,MagickFalse,
6538 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6542 method=(ImageLayerMethod) option;
6545 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6551 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6557 layers=(Image *) NULL;
6560 case CompareAnyLayer:
6561 case CompareClearLayer:
6562 case CompareOverlayLayer:
6565 layers=CompareImageLayers(image,method,exception);
6572 layers=MergeImageLayers(image,method,exception);
6577 layers=DisposeImages(image,exception);
6580 case OptimizeImageLayer:
6582 layers=OptimizeImageLayers(image,exception);
6585 case OptimizePlusLayer:
6587 layers=OptimizePlusImageLayers(image,exception);
6590 case OptimizeTransLayer:
6592 OptimizeImageTransparency(image,exception);
6593 InheritException(&(image->exception),exception);
6596 case RemoveDupsLayer:
6598 RemoveDuplicateLayers(&image,exception);
6599 InheritException(&(image->exception),exception);
6602 case RemoveZeroLayer:
6604 RemoveZeroDelayLayers(&image,exception);
6605 InheritException(&(image->exception),exception);
6614 General Purpose, GIF Animation Optimizer.
6616 layers=CoalesceImages(image,exception);
6617 if (layers == (Image *) NULL)
6619 InheritException(&(layers->exception),exception);
6621 layers=OptimizeImageLayers(image,exception);
6622 if (layers == (Image *) NULL)
6624 InheritException(&(layers->exception),exception);
6625 image=DestroyImageList(image);
6627 layers=(Image *) NULL;
6628 OptimizeImageTransparency(image,exception);
6629 InheritException(&(image->exception),exception);
6630 quantize_info=AcquireQuantizeInfo(info->image_info);
6631 (void) RemapImages(quantize_info,image,(Image *) NULL);
6632 quantize_info=DestroyQuantizeInfo(quantize_info);
6635 case CompositeLayer:
6644 Split image sequence at the first 'NULL:' image.
6647 while (source != (Image *) NULL)
6649 source=GetNextImageInList(source);
6650 if ((source != (Image *) NULL) &&
6651 (LocaleCompare(source->magick,"NULL") == 0))
6654 if (source != (Image *) NULL)
6656 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6657 (GetNextImageInList(source) == (Image *) NULL))
6658 source=(Image *) NULL;
6662 Separate the two lists, junk the null: image.
6664 source=SplitImageList(source->previous);
6665 DeleteImageFromList(&source);
6668 if (source == (Image *) NULL)
6670 (void) ThrowMagickException(exception,GetMagickModule(),
6671 OptionError,"MissingNullSeparator","layers Composite");
6675 Adjust offset with gravity and virtual canvas.
6677 SetGeometry(image,&geometry);
6678 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6679 geometry.width=source->page.width != 0 ? source->page.width :
6681 geometry.height=source->page.height != 0 ? source->page.height :
6683 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6684 image->columns,image->page.height != 0 ? image->page.height :
6685 image->rows,image->gravity,&geometry);
6686 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6687 source=DestroyImageList(source);
6688 InheritException(&(image->exception),exception);
6692 if (layers != (Image *) NULL)
6694 InheritException(&(layers->exception),exception);
6697 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6699 for ( ; image; image=image->next)
6701 AddImageToRegistry(image);
6703 av_push(av,sv_bless(rv,hv));
6706 exception=DestroyExceptionInfo(exception);
6708 SvREFCNT_dec(perl_exception);
6712 InheritPerlException(exception,perl_exception);
6713 exception=DestroyExceptionInfo(exception);
6714 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6715 SvPOK_on(perl_exception);
6716 ST(0)=sv_2mortal(perl_exception);
6721 ###############################################################################
6725 # M a g i c k T o M i m e #
6729 ###############################################################################
6733 MagickToMime(ref,name)
6734 Image::Magick ref=NO_INIT
6743 mime=MagickToMime(name);
6744 RETVAL=newSVpv(mime,0);
6745 mime=(char *) RelinquishMagickMemory(mime);
6751 ###############################################################################
6759 ###############################################################################
6764 Image::Magick ref=NO_INIT
6801 MedianFilterImage = 36
6807 ReduceNoiseImage = 42
6833 ColorFloodfillImage= 68
6839 CycleColormapImage = 74
6849 MatteFloodfillImage= 84
6857 NumberColorsImage = 92
6867 SignatureImage = 102
6877 TransparentImage = 112
6879 ThresholdImage = 114
6893 DeconstructImage = 130
6895 GaussianBlurImage = 132
6901 UnsharpMaskImage = 138
6903 MotionBlurImage = 140
6905 OrderedDitherImage = 142
6912 AffineTransform = 149
6913 AffineTransformImage = 150
6915 DifferenceImage = 152
6916 AdaptiveThreshold = 153
6917 AdaptiveThresholdImage = 154
6922 BlackThreshold = 159
6923 BlackThresholdImage= 160
6924 WhiteThreshold = 161
6925 WhiteThresholdImage= 162
6927 RadialBlurImage = 164
6929 ThumbnailImage = 166
6939 PosterizeImage = 176
6945 SepiaToneImage = 182
6946 SigmoidalContrast = 183
6947 SigmoidalContrastImage = 184
6952 ContrastStretch = 189
6953 ContrastStretchImage = 190
6958 AdaptiveSharpen = 195
6959 AdaptiveSharpenImage = 196
6961 TransposeImage = 198
6963 TransverseImage = 200
6965 AutoOrientImage = 202
6967 AdaptiveBlurImage = 204
6971 UniqueColorsImage = 208
6972 AdaptiveResize = 209
6973 AdaptiveResizeImage= 210
6977 LinearStretchImage = 214
6984 FloodfillPaint = 221
6985 FloodfillPaintImage= 222
6991 LiquidRescaleImage = 228
7001 SparseColorImage = 238
7005 SelectiveBlurImage = 242
7009 BlueShiftImage = 246
7010 ForwardFourierTransform = 247
7011 ForwardFourierTransformImage = 248
7012 InverseFourierTransform = 249
7013 InverseFourierTransformImage = 250
7014 ColorDecisionList = 251
7015 ColorDecisionListImage = 252
7017 AutoGammaImage = 254
7019 AutoLevelImage = 256
7021 LevelColorsImage = 258
7026 BrightnessContrast = 263
7027 BrightnessContrastImage = 264
7029 MorphologyImage = 266
7038 attribute_flag[MaxArguments],
7039 message[MaxTextExtent];
7099 argument_list[MaxArguments];
7101 exception=AcquireExceptionInfo();
7102 perl_exception=newSVpv("",0);
7103 reference_vector=NULL;
7107 if (sv_isobject(ST(0)) == 0)
7109 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7113 reference=SvRV(ST(0));
7114 region_info.width=0;
7115 region_info.height=0;
7118 region_image=(Image *) NULL;
7119 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7120 if (ix && (ix != 666))
7123 Called as Method(...)
7126 rp=(&Methods[ix-1]);
7132 Called as Mogrify("Method",...)
7134 attribute=(char *) SvPV(ST(1),na);
7137 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7138 attribute=(char *) SvPV(ST(2),na);
7141 for (rp=Methods; ; rp++)
7143 if (rp >= EndOf(Methods))
7145 ThrowPerlException(exception,OptionError,
7146 "UnrecognizedPerlMagickMethod",attribute);
7149 if (strEQcase(attribute,rp->name))
7155 if (image == (Image *) NULL)
7157 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7160 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7161 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7162 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7178 pp=(Arguments *) NULL;
7186 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7188 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7190 if (strEQcase(attribute,qq->method) > longest)
7193 longest=strEQcase(attribute,qq->method);
7196 if (pp == (Arguments *) NULL)
7198 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7200 goto continue_outer_loop;
7202 al=(&argument_list[pp-rp->arguments]);
7205 case ArrayReference:
7207 if (SvTYPE(sv) != SVt_RV)
7209 (void) FormatMagickString(message,MaxTextExtent,
7210 "invalid %.60s value",pp->method);
7211 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7212 goto continue_outer_loop;
7214 al->array_reference=SvRV(sv);
7219 al->real_reference=SvNV(sv);
7224 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7227 case ImageReference:
7229 if (!sv_isobject(sv) ||
7230 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7231 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7233 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7239 case IntegerReference:
7241 al->long_reference=SvIV(sv);
7244 case StringReference:
7246 al->string_reference=(char *) SvPV(sv,al->length);
7247 if (sv_isobject(sv))
7248 al->image_reference=SetupList(aTHX_ SvRV(sv),
7249 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7255 Is a string; look up name.
7257 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7259 al->string_reference=(char *) SvPV(sv,al->length);
7260 al->long_reference=(-1);
7263 al->long_reference=ParseMagickOption((MagickOption) pp->type,
7264 MagickFalse,SvPV(sv,na));
7265 if (pp->type == MagickChannelOptions)
7266 al->long_reference=ParseChannelOption(SvPV(sv,na));
7267 if ((al->long_reference < 0) && ((al->long_reference=SvIV(sv)) <= 0))
7269 (void) FormatMagickString(message,MaxTextExtent,
7270 "invalid %.60s value",pp->method);
7271 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7272 goto continue_outer_loop;
7277 attribute_flag[pp-rp->arguments]++;
7278 continue_outer_loop: ;
7280 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7281 pv=reference_vector;
7282 SetGeometryInfo(&geometry_info);
7283 channel=DefaultChannels;
7284 for (next=image; next; next=next->next)
7287 SetGeometry(image,&geometry);
7288 if ((region_info.width*region_info.height) != 0)
7291 image=CropImage(image,®ion_info,exception);
7297 (void) FormatMagickString(message,MaxTextExtent,"%ld",(long) ix);
7298 ThrowPerlException(exception,OptionError,
7299 "UnrecognizedPerlMagickMethod",message);
7302 case 1: /* Comment */
7304 if (attribute_flag[0] == 0)
7305 argument_list[0].string_reference=(char *) NULL;
7306 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7307 info ? info->image_info : (ImageInfo *) NULL,image,
7308 argument_list[0].string_reference));
7313 if (attribute_flag[0] == 0)
7314 argument_list[0].string_reference=(char *) NULL;
7315 (void) SetImageProperty(image,"label",InterpretImageProperties(
7316 info ? info->image_info : (ImageInfo *) NULL,image,
7317 argument_list[0].string_reference));
7320 case 3: /* AddNoise */
7322 if (attribute_flag[0] == 0)
7323 argument_list[0].long_reference=UniformNoise;
7324 if (attribute_flag[1] != 0)
7325 channel=(ChannelType) argument_list[1].long_reference;
7326 image=AddNoiseImageChannel(image,channel,(NoiseType)
7327 argument_list[0].long_reference,exception);
7330 case 4: /* Colorize */
7335 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7336 if (attribute_flag[0] != 0)
7337 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7339 if (attribute_flag[1] == 0)
7340 argument_list[1].string_reference="100%";
7341 image=ColorizeImage(image,argument_list[1].string_reference,target,
7345 case 5: /* Border */
7349 if (attribute_flag[0] != 0)
7351 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7352 &geometry,exception);
7353 if ((flags & HeightValue) == 0)
7354 geometry.height=geometry.width;
7356 if (attribute_flag[1] != 0)
7357 geometry.width=argument_list[1].long_reference;
7358 if (attribute_flag[2] != 0)
7359 geometry.height=argument_list[2].long_reference;
7360 if (attribute_flag[3] != 0)
7361 QueryColorDatabase(argument_list[3].string_reference,
7362 &image->border_color,exception);
7363 if (attribute_flag[4] != 0)
7364 QueryColorDatabase(argument_list[4].string_reference,
7365 &image->border_color,exception);
7366 if (attribute_flag[5] != 0)
7367 QueryColorDatabase(argument_list[5].string_reference,
7368 &image->border_color,exception);
7369 if (attribute_flag[6] != 0)
7370 image->compose=(CompositeOperator) argument_list[6].long_reference;
7371 image=BorderImage(image,&geometry,exception);
7376 if (attribute_flag[0] != 0)
7378 flags=ParseGeometry(argument_list[0].string_reference,
7380 if ((flags & SigmaValue) == 0)
7381 geometry_info.sigma=1.0;
7383 if (attribute_flag[1] != 0)
7384 geometry_info.rho=argument_list[1].real_reference;
7385 if (attribute_flag[2] != 0)
7386 geometry_info.sigma=argument_list[2].real_reference;
7387 if (attribute_flag[3] != 0)
7388 channel=(ChannelType) argument_list[3].long_reference;
7389 image=BlurImageChannel(image,channel,geometry_info.rho,
7390 geometry_info.sigma,exception);
7395 if (attribute_flag[0] != 0)
7396 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7397 &geometry,exception);
7398 if (attribute_flag[1] != 0)
7399 geometry.width=argument_list[1].long_reference;
7400 if (attribute_flag[2] != 0)
7401 geometry.height=argument_list[2].long_reference;
7402 if (attribute_flag[3] != 0)
7403 geometry.x=argument_list[3].long_reference;
7404 if (attribute_flag[4] != 0)
7405 geometry.y=argument_list[4].long_reference;
7406 image=ChopImage(image,&geometry,exception);
7411 if (attribute_flag[6] != 0)
7412 image->gravity=(GravityType) argument_list[6].long_reference;
7413 if (attribute_flag[0] != 0)
7414 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7415 &geometry,exception);
7416 if (attribute_flag[1] != 0)
7417 geometry.width=argument_list[1].long_reference;
7418 if (attribute_flag[2] != 0)
7419 geometry.height=argument_list[2].long_reference;
7420 if (attribute_flag[3] != 0)
7421 geometry.x=argument_list[3].long_reference;
7422 if (attribute_flag[4] != 0)
7423 geometry.y=argument_list[4].long_reference;
7424 if (attribute_flag[5] != 0)
7426 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7427 image=CropImage(image,&geometry,exception);
7430 case 9: /* Despeckle */
7432 image=DespeckleImage(image,exception);
7437 if (attribute_flag[0] != 0)
7438 geometry_info.rho=argument_list[0].real_reference;
7439 image=EdgeImage(image,geometry_info.rho,exception);
7442 case 11: /* Emboss */
7444 if (attribute_flag[0] != 0)
7446 flags=ParseGeometry(argument_list[0].string_reference,
7448 if ((flags & SigmaValue) == 0)
7449 geometry_info.sigma=1.0;
7451 if (attribute_flag[1] != 0)
7452 geometry_info.rho=argument_list[1].real_reference;
7453 if (attribute_flag[2] != 0)
7454 geometry_info.sigma=argument_list[2].real_reference;
7455 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7459 case 12: /* Enhance */
7461 image=EnhanceImage(image,exception);
7466 image=FlipImage(image,exception);
7471 image=FlopImage(image,exception);
7474 case 15: /* Frame */
7479 if (attribute_flag[0] != 0)
7481 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7482 &geometry,exception);
7483 if ((flags & HeightValue) == 0)
7484 geometry.height=geometry.width;
7485 frame_info.width=geometry.width;
7486 frame_info.height=geometry.height;
7487 frame_info.outer_bevel=geometry.x;
7488 frame_info.inner_bevel=geometry.y;
7490 if (attribute_flag[1] != 0)
7491 frame_info.width=argument_list[1].long_reference;
7492 if (attribute_flag[2] != 0)
7493 frame_info.height=argument_list[2].long_reference;
7494 if (attribute_flag[3] != 0)
7495 frame_info.inner_bevel=argument_list[3].long_reference;
7496 if (attribute_flag[4] != 0)
7497 frame_info.outer_bevel=argument_list[4].long_reference;
7498 if (attribute_flag[5] != 0)
7499 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7501 if (attribute_flag[6] != 0)
7502 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7504 frame_info.x=(long) frame_info.width;
7505 frame_info.y=(long) frame_info.height;
7506 frame_info.width=image->columns+2*frame_info.x;
7507 frame_info.height=image->rows+2*frame_info.y;
7508 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7509 image->matte_color=fill_color;
7510 if (attribute_flag[7] != 0)
7511 image->compose=(CompositeOperator) argument_list[7].long_reference;
7512 image=FrameImage(image,&frame_info,exception);
7515 case 16: /* Implode */
7517 if (attribute_flag[0] == 0)
7518 argument_list[0].real_reference=0.5;
7519 if (attribute_flag[1] != 0)
7520 image->interpolate=(InterpolatePixelMethod)
7521 argument_list[1].long_reference;
7522 image=ImplodeImage(image,argument_list[0].real_reference,
7526 case 17: /* Magnify */
7528 image=MagnifyImage(image,exception);
7531 case 18: /* MedianFilter */
7533 if (attribute_flag[0] == 0)
7534 argument_list[0].real_reference=0.0;
7535 image=MedianFilterImage(image,argument_list[0].real_reference,
7539 case 19: /* Minify */
7541 image=MinifyImage(image,exception);
7544 case 20: /* OilPaint */
7546 if (attribute_flag[0] == 0)
7547 argument_list[0].real_reference=0.0;
7548 image=OilPaintImage(image,argument_list[0].real_reference,
7552 case 21: /* ReduceNoise */
7554 if (attribute_flag[0] == 0)
7555 argument_list[0].real_reference=0.0;
7556 image=ReduceNoiseImage(image,argument_list[0].real_reference,
7562 if (attribute_flag[0] != 0)
7563 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7564 &geometry,exception);
7565 if (attribute_flag[1] != 0)
7566 geometry.x=argument_list[1].long_reference;
7567 if (attribute_flag[2] != 0)
7568 geometry.y=argument_list[2].long_reference;
7569 image=RollImage(image,geometry.x,geometry.y,exception);
7572 case 23: /* Rotate */
7574 if (attribute_flag[0] == 0)
7575 argument_list[0].real_reference=90.0;
7576 if (attribute_flag[1] != 0)
7577 QueryColorDatabase(argument_list[1].string_reference,
7578 &image->background_color,exception);
7579 if (attribute_flag[2] != 0)
7580 QueryColorDatabase(argument_list[2].string_reference,
7581 &image->background_color,exception);
7582 if (attribute_flag[3] != 0)
7583 QueryColorDatabase(argument_list[3].string_reference,
7584 &image->background_color,exception);
7585 image=RotateImage(image,argument_list[0].real_reference,exception);
7588 case 24: /* Sample */
7590 if (attribute_flag[0] != 0)
7591 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7592 &geometry,exception);
7593 if (attribute_flag[1] != 0)
7594 geometry.width=argument_list[1].long_reference;
7595 if (attribute_flag[2] != 0)
7596 geometry.height=argument_list[2].long_reference;
7597 image=SampleImage(image,geometry.width,geometry.height,exception);
7600 case 25: /* Scale */
7602 if (attribute_flag[0] != 0)
7603 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7604 &geometry,exception);
7605 if (attribute_flag[1] != 0)
7606 geometry.width=argument_list[1].long_reference;
7607 if (attribute_flag[2] != 0)
7608 geometry.height=argument_list[2].long_reference;
7609 image=ScaleImage(image,geometry.width,geometry.height,exception);
7612 case 26: /* Shade */
7614 if (attribute_flag[0] != 0)
7616 flags=ParseGeometry(argument_list[0].string_reference,
7618 if ((flags & SigmaValue) == 0)
7619 geometry_info.sigma=0.0;
7621 if (attribute_flag[1] != 0)
7622 geometry_info.rho=argument_list[1].real_reference;
7623 if (attribute_flag[2] != 0)
7624 geometry_info.sigma=argument_list[2].real_reference;
7625 image=ShadeImage(image,
7626 argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse,
7627 geometry_info.rho,geometry_info.sigma,exception);
7630 case 27: /* Sharpen */
7632 if (attribute_flag[0] != 0)
7634 flags=ParseGeometry(argument_list[0].string_reference,
7636 if ((flags & SigmaValue) == 0)
7637 geometry_info.sigma=1.0;
7639 if (attribute_flag[1] != 0)
7640 geometry_info.rho=argument_list[1].real_reference;
7641 if (attribute_flag[2] != 0)
7642 geometry_info.sigma=argument_list[2].real_reference;
7643 if (attribute_flag[3] != 0)
7644 channel=(ChannelType) argument_list[3].long_reference;
7645 image=SharpenImageChannel(image,channel,geometry_info.rho,
7646 geometry_info.sigma,exception);
7649 case 28: /* Shear */
7651 if (attribute_flag[0] != 0)
7653 flags=ParseGeometry(argument_list[0].string_reference,
7655 if ((flags & SigmaValue) == 0)
7656 geometry_info.sigma=geometry_info.rho;
7658 if (attribute_flag[1] != 0)
7659 geometry_info.rho=argument_list[1].real_reference;
7660 if (attribute_flag[2] != 0)
7661 geometry_info.sigma=argument_list[2].real_reference;
7662 if (attribute_flag[3] != 0)
7663 QueryColorDatabase(argument_list[3].string_reference,
7664 &image->background_color,exception);
7665 if (attribute_flag[4] != 0)
7666 QueryColorDatabase(argument_list[4].string_reference,
7667 &image->background_color,exception);
7668 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7672 case 29: /* Spread */
7674 if (attribute_flag[0] == 0)
7675 argument_list[0].real_reference=1.0;
7676 image=SpreadImage(image,argument_list[0].real_reference,exception);
7679 case 30: /* Swirl */
7681 if (attribute_flag[0] == 0)
7682 argument_list[0].real_reference=50.0;
7683 if (attribute_flag[1] != 0)
7684 image->interpolate=(InterpolatePixelMethod)
7685 argument_list[1].long_reference;
7686 image=SwirlImage(image,argument_list[0].real_reference,exception);
7689 case 31: /* Resize */
7692 if (attribute_flag[0] != 0)
7693 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7694 &geometry,exception);
7695 if (attribute_flag[1] != 0)
7696 geometry.width=argument_list[1].long_reference;
7697 if (attribute_flag[2] != 0)
7698 geometry.height=argument_list[2].long_reference;
7699 if (attribute_flag[3] == 0)
7700 argument_list[3].long_reference=(long) UndefinedFilter;
7701 if (attribute_flag[4] != 0)
7702 SetImageArtifact(image,"filter:support",
7703 argument_list[4].string_reference);
7704 if (attribute_flag[5] == 0)
7705 argument_list[5].real_reference=1.0;
7706 image=ResizeImage(image,geometry.width,geometry.height,
7707 (FilterTypes) argument_list[3].long_reference,
7708 argument_list[5].real_reference,exception);
7711 case 33: /* Annotate */
7716 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7718 if (attribute_flag[0] != 0)
7723 text=InterpretImageProperties(info ? info->image_info :
7724 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7725 (void) CloneString(&draw_info->text,text);
7726 text=DestroyString(text);
7728 if (attribute_flag[1] != 0)
7729 (void) CloneString(&draw_info->font,
7730 argument_list[1].string_reference);
7731 if (attribute_flag[2] != 0)
7732 draw_info->pointsize=argument_list[2].real_reference;
7733 if (attribute_flag[3] != 0)
7734 (void) CloneString(&draw_info->density,
7735 argument_list[3].string_reference);
7736 if (attribute_flag[4] != 0)
7737 (void) QueryColorDatabase(argument_list[4].string_reference,
7738 &draw_info->undercolor,exception);
7739 if (attribute_flag[5] != 0)
7741 (void) QueryColorDatabase(argument_list[5].string_reference,
7742 &draw_info->stroke,exception);
7743 if (argument_list[5].image_reference != (Image *) NULL)
7744 draw_info->stroke_pattern=CloneImage(
7745 argument_list[5].image_reference,0,0,MagickTrue,exception);
7747 if (attribute_flag[6] != 0)
7749 (void) QueryColorDatabase(argument_list[6].string_reference,
7750 &draw_info->fill,exception);
7751 if (argument_list[6].image_reference != (Image *) NULL)
7752 draw_info->fill_pattern=CloneImage(
7753 argument_list[6].image_reference,0,0,MagickTrue,exception);
7755 if (attribute_flag[7] != 0)
7757 (void) CloneString(&draw_info->geometry,
7758 argument_list[7].string_reference);
7759 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7760 &geometry,exception);
7761 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7762 geometry_info.sigma=geometry_info.xi;
7764 if (attribute_flag[8] != 0)
7765 (void) QueryColorDatabase(argument_list[8].string_reference,
7766 &draw_info->fill,exception);
7767 if (attribute_flag[11] != 0)
7768 draw_info->gravity=(GravityType) argument_list[11].long_reference;
7769 if (attribute_flag[25] != 0)
7774 av=(AV *) argument_list[25].array_reference;
7775 if ((av_len(av) != 3) && (av_len(av) != 5))
7777 ThrowPerlException(exception,OptionError,
7778 "affine matrix must have 4 or 6 elements",PackageName);
7781 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7782 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7783 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7784 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7785 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7786 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7788 ThrowPerlException(exception,OptionError,
7789 "affine matrix is singular",PackageName);
7792 if (av_len(av) == 5)
7794 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7795 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
7798 for (j=12; j < 17; j++)
7800 if (attribute_flag[j] == 0)
7802 value=argument_list[j].string_reference;
7803 angle=argument_list[j].real_reference;
7804 current=draw_info->affine;
7805 GetAffineMatrix(&affine);
7813 flags=ParseGeometry(value,&geometry_info);
7814 affine.tx=geometry_info.xi;
7815 affine.ty=geometry_info.psi;
7816 if ((flags & PsiValue) == 0)
7817 affine.ty=affine.tx;
7825 flags=ParseGeometry(value,&geometry_info);
7826 affine.sx=geometry_info.rho;
7827 affine.sy=geometry_info.sigma;
7828 if ((flags & SigmaValue) == 0)
7829 affine.sy=affine.sx;
7839 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
7840 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
7841 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
7842 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
7850 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
7858 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
7862 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
7863 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
7864 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
7865 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
7866 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
7868 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
7871 if (attribute_flag[9] == 0)
7872 argument_list[9].real_reference=0.0;
7873 if (attribute_flag[10] == 0)
7874 argument_list[10].real_reference=0.0;
7875 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
7878 geometry[MaxTextExtent];
7880 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
7881 (double) argument_list[9].real_reference+draw_info->affine.tx,
7882 (double) argument_list[10].real_reference+draw_info->affine.ty);
7883 (void) CloneString(&draw_info->geometry,geometry);
7885 if (attribute_flag[17] != 0)
7886 draw_info->stroke_width=argument_list[17].real_reference;
7887 if (attribute_flag[18] != 0)
7889 draw_info->text_antialias=argument_list[18].long_reference != 0 ?
7890 MagickTrue : MagickFalse;
7891 draw_info->stroke_antialias=draw_info->text_antialias;
7893 if (attribute_flag[19] != 0)
7894 (void) CloneString(&draw_info->family,
7895 argument_list[19].string_reference);
7896 if (attribute_flag[20] != 0)
7897 draw_info->style=(StyleType) argument_list[20].long_reference;
7898 if (attribute_flag[21] != 0)
7899 draw_info->stretch=(StretchType) argument_list[21].long_reference;
7900 if (attribute_flag[22] != 0)
7901 draw_info->weight=argument_list[22].long_reference;
7902 if (attribute_flag[23] != 0)
7903 draw_info->align=(AlignType) argument_list[23].long_reference;
7904 if (attribute_flag[24] != 0)
7905 (void) CloneString(&draw_info->encoding,
7906 argument_list[24].string_reference);
7907 if (attribute_flag[25] != 0)
7908 draw_info->fill_pattern=CloneImage(
7909 argument_list[25].image_reference,0,0,MagickTrue,exception);
7910 if (attribute_flag[26] != 0)
7911 draw_info->fill_pattern=CloneImage(
7912 argument_list[26].image_reference,0,0,MagickTrue,exception);
7913 if (attribute_flag[27] != 0)
7914 draw_info->stroke_pattern=CloneImage(
7915 argument_list[27].image_reference,0,0,MagickTrue,exception);
7916 if (attribute_flag[29] != 0)
7917 draw_info->kerning=argument_list[29].real_reference;
7918 if (attribute_flag[30] != 0)
7919 draw_info->interline_spacing=argument_list[30].real_reference;
7920 if (attribute_flag[31] != 0)
7921 draw_info->interword_spacing=argument_list[31].real_reference;
7922 (void) AnnotateImage(image,draw_info);
7923 draw_info=DestroyDrawInfo(draw_info);
7926 case 34: /* ColorFloodfill */
7937 draw_info=CloneDrawInfo(info ? info->image_info :
7938 (ImageInfo *) NULL,(DrawInfo *) NULL);
7939 if (attribute_flag[0] != 0)
7940 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7941 &geometry,exception);
7942 if (attribute_flag[1] != 0)
7943 geometry.x=argument_list[1].long_reference;
7944 if (attribute_flag[2] != 0)
7945 geometry.y=argument_list[2].long_reference;
7946 if (attribute_flag[3] != 0)
7947 (void) QueryColorDatabase(argument_list[3].string_reference,
7948 &draw_info->fill,exception);
7949 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
7952 if (attribute_flag[4] != 0)
7954 QueryMagickColor(argument_list[4].string_reference,&target,
7958 if (attribute_flag[5] != 0)
7959 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
7961 if (attribute_flag[6] != 0)
7962 invert=(MagickBooleanType) argument_list[6].long_reference;
7963 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
7964 geometry.x,geometry.y,invert);
7965 draw_info=DestroyDrawInfo(draw_info);
7968 case 35: /* Composite */
7971 composite_geometry[MaxTextExtent];
7977 compose=OverCompositeOp;
7978 if (attribute_flag[0] != 0)
7979 composite_image=argument_list[0].image_reference;
7982 ThrowPerlException(exception,OptionError,
7983 "CompositeImageRequired",PackageName);
7987 Parameter Handling used for BOTH normal and tiled composition.
7989 if (attribute_flag[1] != 0) /* compose */
7990 compose=(CompositeOperator) argument_list[1].long_reference;
7991 if (attribute_flag[6] != 0) /* opacity */
7993 if (compose != DissolveCompositeOp)
7994 (void) SetImageOpacity(composite_image,(Quantum) (QuantumRange-
7995 SiPrefixToDouble(argument_list[6].string_reference,
8011 register PixelPacket
8018 Handle dissolve composite operator (patch by
8021 (void) CloneString(&image->geometry,
8022 argument_list[6].string_reference);
8023 opacity=(Quantum) (QuantumRange-SiPrefixToDouble(
8024 argument_list[6].string_reference,QuantumRange));
8025 if (composite_image->matte != MagickTrue)
8026 (void) SetImageOpacity(composite_image,OpaqueOpacity);
8027 composite_view=AcquireCacheView(composite_image);
8028 for (y=0; y < (long) composite_image->rows ; y++)
8030 q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
8031 composite_image->columns,1,exception);
8032 for (x=0; x < (long) composite_image->columns; x++)
8034 if (q->opacity == OpaqueOpacity)
8035 q->opacity=ClampToQuantum(opacity);
8038 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8039 if (sync == MagickFalse)
8042 composite_view=DestroyCacheView(composite_view);
8045 if (attribute_flag[9] != 0) /* "color=>" */
8046 QueryColorDatabase(argument_list[9].string_reference,
8047 &composite_image->background_color,exception);
8048 if (attribute_flag[12] != 0) /* "interpolate=>" */
8049 image->interpolate=(InterpolatePixelMethod)
8050 argument_list[12].long_reference;
8051 if (attribute_flag[13] != 0) /* "args=>" */
8052 (void) SetImageArtifact(composite_image,"compose:args",
8053 argument_list[13].string_reference);
8054 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8055 (void) SetImageArtifact(composite_image,"compose:args",
8056 argument_list[14].string_reference);
8058 Tiling Composition (with orthogonal rotate).
8060 rotate_image=(Image *) NULL;
8061 if (attribute_flag[8] != 0) /* "rotate=>" */
8066 rotate_image=RotateImage(composite_image,
8067 argument_list[8].real_reference,exception);
8068 if (rotate_image == (Image *) NULL)
8071 if (attribute_flag[7] && argument_list[7].long_reference) /* tile */
8078 Tile the composite image.
8080 if (attribute_flag[8] != 0) /* "tile=>" */
8081 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8084 (void) SetImageArtifact(composite_image,
8085 "compose:outside-overlay","false");
8086 for (y=0; y < (long) image->rows; y+=composite_image->rows)
8087 for (x=0; x < (long) image->columns; x+=composite_image->columns)
8089 if (attribute_flag[8] != 0) /* rotate */
8090 (void) CompositeImage(image,compose,rotate_image,x,y);
8092 (void) CompositeImage(image,compose,composite_image,x,y);
8094 if (attribute_flag[8] != 0) /* rotate */
8095 rotate_image=DestroyImage(rotate_image);
8099 Parameter Handling used used ONLY for normal composition.
8101 if (attribute_flag[5] != 0) /* gravity */
8102 image->gravity=(GravityType) argument_list[5].long_reference;
8103 if (attribute_flag[2] != 0) /* geometry offset */
8105 SetGeometry(image,&geometry);
8106 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8108 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8111 if (attribute_flag[3] != 0) /* x offset */
8112 geometry.x=argument_list[3].long_reference;
8113 if (attribute_flag[4] != 0) /* y offset */
8114 geometry.y=argument_list[4].long_reference;
8115 if (attribute_flag[10] != 0) /* mask */
8117 if ((image->compose == DisplaceCompositeOp) ||
8118 (image->compose == DistortCompositeOp))
8121 Merge Y displacement into X displacement image.
8123 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8125 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8126 argument_list[10].image_reference,0,0);
8131 Set a blending mask for the composition.
8133 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8134 MagickTrue,&image->exception);
8135 (void) NegateImage(image->mask,MagickFalse);
8138 if (attribute_flag[11] != 0) /* channel */
8139 channel=(ChannelType) argument_list[11].long_reference;
8141 Composite two images (normal composition).
8143 (void) FormatMagickString(composite_geometry,MaxTextExtent,
8144 "%lux%lu%+ld%+ld",composite_image->columns,composite_image->rows,
8145 geometry.x,geometry.y);
8146 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8148 if (attribute_flag[8] == 0) /* no rotate */
8149 CompositeImageChannel(image,channel,compose,composite_image,
8150 geometry.x,geometry.y);
8154 Position adjust rotated image then composite.
8156 geometry.x-=(long) (rotate_image->columns-
8157 composite_image->columns)/2;
8158 geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
8159 CompositeImageChannel(image,channel,compose,rotate_image,
8160 geometry.x,geometry.y);
8161 rotate_image=DestroyImage(rotate_image);
8163 if (attribute_flag[10] != 0) /* mask */
8165 if ((image->compose == DisplaceCompositeOp) ||
8166 (image->compose == DistortCompositeOp))
8167 composite_image=DestroyImage(composite_image);
8169 image->mask=DestroyImage(image->mask);
8173 case 36: /* Contrast */
8175 if (attribute_flag[0] == 0)
8176 argument_list[0].long_reference=0;
8177 (void) ContrastImage(image,argument_list[0].long_reference != 0 ?
8178 MagickTrue : MagickFalse);
8181 case 37: /* CycleColormap */
8183 if (attribute_flag[0] == 0)
8184 argument_list[0].long_reference=6;
8185 (void) CycleColormapImage(image,argument_list[0].long_reference);
8193 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8195 (void) CloneString(&draw_info->primitive,"point");
8196 if (attribute_flag[0] != 0)
8198 if (argument_list[0].long_reference < 0)
8199 (void) CloneString(&draw_info->primitive,
8200 argument_list[0].string_reference);
8202 (void) CloneString(&draw_info->primitive,MagickOptionToMnemonic(
8203 MagickPrimitiveOptions,argument_list[0].long_reference));
8205 if (attribute_flag[1] != 0)
8207 if (LocaleCompare(draw_info->primitive,"path") == 0)
8209 (void) ConcatenateString(&draw_info->primitive," '");
8210 ConcatenateString(&draw_info->primitive,
8211 argument_list[1].string_reference);
8212 (void) ConcatenateString(&draw_info->primitive,"'");
8216 (void) ConcatenateString(&draw_info->primitive," ");
8217 ConcatenateString(&draw_info->primitive,
8218 argument_list[1].string_reference);
8221 if (attribute_flag[2] != 0)
8223 (void) ConcatenateString(&draw_info->primitive," ");
8224 (void) ConcatenateString(&draw_info->primitive,
8225 MagickOptionToMnemonic(MagickMethodOptions,
8226 argument_list[2].long_reference));
8228 if (attribute_flag[3] != 0)
8230 (void) QueryColorDatabase(argument_list[3].string_reference,
8231 &draw_info->stroke,exception);
8232 if (argument_list[3].image_reference != (Image *) NULL)
8233 draw_info->stroke_pattern=CloneImage(
8234 argument_list[3].image_reference,0,0,MagickTrue,exception);
8236 if (attribute_flag[4] != 0)
8238 (void) QueryColorDatabase(argument_list[4].string_reference,
8239 &draw_info->fill,exception);
8240 if (argument_list[4].image_reference != (Image *) NULL)
8241 draw_info->fill_pattern=CloneImage(
8242 argument_list[4].image_reference,0,0,MagickTrue,exception);
8244 if (attribute_flag[5] != 0)
8245 draw_info->stroke_width=argument_list[5].real_reference;
8246 if (attribute_flag[6] != 0)
8247 (void) CloneString(&draw_info->font,
8248 argument_list[6].string_reference);
8249 if (attribute_flag[7] != 0)
8250 (void) QueryColorDatabase(argument_list[7].string_reference,
8251 &draw_info->border_color,exception);
8252 if (attribute_flag[8] != 0)
8253 draw_info->affine.tx=argument_list[8].real_reference;
8254 if (attribute_flag[9] != 0)
8255 draw_info->affine.ty=argument_list[9].real_reference;
8256 if (attribute_flag[20] != 0)
8261 av=(AV *) argument_list[20].array_reference;
8262 if ((av_len(av) != 3) && (av_len(av) != 5))
8264 ThrowPerlException(exception,OptionError,
8265 "affine matrix must have 4 or 6 elements",PackageName);
8268 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8269 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8270 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8271 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8272 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8273 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8275 ThrowPerlException(exception,OptionError,
8276 "affine matrix is singular",PackageName);
8279 if (av_len(av) == 5)
8281 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8282 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8285 for (j=10; j < 15; j++)
8287 if (attribute_flag[j] == 0)
8289 value=argument_list[j].string_reference;
8290 angle=argument_list[j].real_reference;
8291 current=draw_info->affine;
8292 GetAffineMatrix(&affine);
8300 flags=ParseGeometry(value,&geometry_info);
8301 affine.tx=geometry_info.xi;
8302 affine.ty=geometry_info.psi;
8303 if ((flags & PsiValue) == 0)
8304 affine.ty=affine.tx;
8312 flags=ParseGeometry(value,&geometry_info);
8313 affine.sx=geometry_info.rho;
8314 affine.sy=geometry_info.sigma;
8315 if ((flags & SigmaValue) == 0)
8316 affine.sy=affine.sx;
8326 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8327 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8328 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8329 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8337 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8345 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8349 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8350 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8351 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8352 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8353 draw_info->affine.tx=
8354 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8355 draw_info->affine.ty=
8356 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8358 if (attribute_flag[15] != 0)
8359 draw_info->fill_pattern=CloneImage(
8360 argument_list[15].image_reference,0,0,MagickTrue,exception);
8361 if (attribute_flag[16] != 0)
8362 draw_info->pointsize=argument_list[16].real_reference;
8363 if (attribute_flag[17] != 0)
8365 draw_info->stroke_antialias=argument_list[17].long_reference != 0
8366 ? MagickTrue : MagickFalse;
8367 draw_info->text_antialias=draw_info->stroke_antialias;
8369 if (attribute_flag[18] != 0)
8370 (void) CloneString(&draw_info->density,
8371 argument_list[18].string_reference);
8372 if (attribute_flag[19] != 0)
8373 draw_info->stroke_width=argument_list[19].real_reference;
8374 if (attribute_flag[21] != 0)
8375 draw_info->dash_offset=argument_list[21].real_reference;
8376 if (attribute_flag[22] != 0)
8381 av=(AV *) argument_list[22].array_reference;
8382 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8383 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8384 if (draw_info->dash_pattern != (double *) NULL)
8386 for (i=0; i <= av_len(av); i++)
8387 draw_info->dash_pattern[i]=(double)
8388 SvNV(*(av_fetch(av,i,0)));
8389 draw_info->dash_pattern[i]=0.0;
8392 if (attribute_flag[23] != 0)
8393 image->interpolate=(InterpolatePixelMethod)
8394 argument_list[23].long_reference;
8395 if ((attribute_flag[24] != 0) &&
8396 (draw_info->fill_pattern != (Image *) NULL))
8397 flags=ParsePageGeometry(draw_info->fill_pattern,
8398 argument_list[24].string_reference,
8399 &draw_info->fill_pattern->tile_offset,exception);
8400 if (attribute_flag[25] != 0)
8402 (void) ConcatenateString(&draw_info->primitive," '");
8403 (void) ConcatenateString(&draw_info->primitive,
8404 argument_list[25].string_reference);
8405 (void) ConcatenateString(&draw_info->primitive,"'");
8407 if (attribute_flag[26] != 0)
8408 draw_info->fill_pattern=CloneImage(
8409 argument_list[26].image_reference,0,0,MagickTrue,exception);
8410 if (attribute_flag[27] != 0)
8411 draw_info->stroke_pattern=CloneImage(
8412 argument_list[27].image_reference,0,0,MagickTrue,exception);
8413 if (attribute_flag[28] != 0)
8414 (void) CloneString(&draw_info->primitive,
8415 argument_list[28].string_reference);
8416 if (attribute_flag[29] != 0)
8417 draw_info->kerning=argument_list[29].real_reference;
8418 if (attribute_flag[30] != 0)
8419 draw_info->interline_spacing=argument_list[30].real_reference;
8420 if (attribute_flag[31] != 0)
8421 draw_info->interword_spacing=argument_list[31].real_reference;
8422 DrawImage(image,draw_info);
8423 draw_info=DestroyDrawInfo(draw_info);
8426 case 39: /* Equalize */
8428 if (attribute_flag[0] != 0)
8429 channel=(ChannelType) argument_list[0].long_reference;
8430 EqualizeImageChannel(image,channel);
8433 case 40: /* Gamma */
8435 if (attribute_flag[1] != 0)
8436 channel=(ChannelType) argument_list[1].long_reference;
8437 if (attribute_flag[2] == 0)
8438 argument_list[2].real_reference=1.0;
8439 if (attribute_flag[3] == 0)
8440 argument_list[3].real_reference=1.0;
8441 if (attribute_flag[4] == 0)
8442 argument_list[4].real_reference=1.0;
8443 if (attribute_flag[0] == 0)
8445 (void) FormatMagickString(message,MaxTextExtent,
8446 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8447 (double) argument_list[3].real_reference,
8448 (double) argument_list[4].real_reference);
8449 argument_list[0].string_reference=message;
8451 if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
8452 (void) GammaImage(image,argument_list[0].string_reference);
8454 (void) GammaImageChannel(image,channel,
8455 StringToDouble(argument_list[0].string_reference));
8463 if (attribute_flag[0] == 0)
8465 ThrowPerlException(exception,OptionError,"MapImageRequired",
8469 quantize_info=AcquireQuantizeInfo(info->image_info);
8470 if (attribute_flag[1] != 0)
8471 quantize_info->dither=(MagickBooleanType)
8472 argument_list[1].long_reference;
8473 if (attribute_flag[2] != 0)
8474 quantize_info->dither_method=(DitherMethod)
8475 argument_list[2].long_reference;
8476 (void) RemapImages(quantize_info,image,
8477 argument_list[0].image_reference);
8478 quantize_info=DestroyQuantizeInfo(quantize_info);
8481 case 42: /* MatteFloodfill */
8492 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8494 if (attribute_flag[0] != 0)
8495 if (attribute_flag[0] != 0)
8496 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8497 &geometry,exception);
8498 if (attribute_flag[1] != 0)
8499 geometry.x=argument_list[1].long_reference;
8500 if (attribute_flag[2] != 0)
8501 geometry.y=argument_list[2].long_reference;
8502 if (image->matte == MagickFalse)
8503 (void) SetImageOpacity(image,OpaqueOpacity);
8504 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8506 if (attribute_flag[4] != 0)
8507 QueryMagickColor(argument_list[4].string_reference,&target,
8509 if (attribute_flag[3] != 0)
8510 target.opacity=SiPrefixToDouble(argument_list[3].string_reference,
8512 if (attribute_flag[5] != 0)
8513 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8516 if (attribute_flag[6] != 0)
8517 invert=(MagickBooleanType) argument_list[6].long_reference;
8518 (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
8519 geometry.x,geometry.y,invert);
8520 draw_info=DestroyDrawInfo(draw_info);
8523 case 43: /* Modulate */
8526 modulate[MaxTextExtent];
8531 colorspace=image->colorspace;
8532 geometry_info.rho=100.0;
8533 geometry_info.sigma=100.0;
8534 geometry_info.xi=100.0;
8535 if (attribute_flag[0] != 0)
8536 (void)ParseGeometry(argument_list[0].string_reference,
8538 if (attribute_flag[1] != 0)
8539 geometry_info.xi=argument_list[1].real_reference;
8540 if (attribute_flag[2] != 0)
8541 geometry_info.sigma=argument_list[2].real_reference;
8542 if (attribute_flag[3] != 0)
8544 (void) SetImageColorspace(image,HWBColorspace);
8545 geometry_info.sigma=argument_list[3].real_reference;
8547 if (attribute_flag[4] != 0)
8548 geometry_info.rho=argument_list[4].real_reference;
8549 if (attribute_flag[5] != 0)
8551 (void) SetImageColorspace(image,HSLColorspace);
8552 geometry_info.sigma=argument_list[5].real_reference;
8554 if (attribute_flag[6] != 0)
8556 (void) SetImageColorspace(image,HWBColorspace);
8557 geometry_info.rho=argument_list[6].real_reference;
8559 (void) FormatMagickString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8560 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8561 (void) ModulateImage(image,modulate);
8562 (void) SetImageColorspace(image,colorspace);
8565 case 44: /* Negate */
8567 if (attribute_flag[0] == 0)
8568 argument_list[0].long_reference=0;
8569 if (attribute_flag[1] != 0)
8570 channel=(ChannelType) argument_list[1].long_reference;
8571 (void) NegateImageChannel(image,channel,
8572 argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse);
8575 case 45: /* Normalize */
8577 if (attribute_flag[0] != 0)
8578 channel=(ChannelType) argument_list[0].long_reference;
8579 NormalizeImageChannel(image,channel);
8582 case 46: /* NumberColors */
8584 case 47: /* Opaque */
8593 (void) QueryMagickColor("none",&target,exception);
8594 (void) QueryMagickColor("none",&fill_color,exception);
8595 if (attribute_flag[0] != 0)
8596 (void) QueryMagickColor(argument_list[0].string_reference,
8598 if (attribute_flag[1] != 0)
8599 (void) QueryMagickColor(argument_list[1].string_reference,
8600 &fill_color,exception);
8601 if (attribute_flag[2] != 0)
8602 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8604 if (attribute_flag[3] != 0)
8605 channel=(ChannelType) argument_list[3].long_reference;
8607 if (attribute_flag[4] != 0)
8608 invert=(MagickBooleanType) argument_list[4].long_reference;
8609 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8613 case 48: /* Quantize */
8618 quantize_info=AcquireQuantizeInfo(info->image_info);
8619 if (attribute_flag[0] != 0)
8620 quantize_info->number_colors=(unsigned long)
8621 argument_list[0].long_reference;
8622 if (attribute_flag[1] != 0)
8623 quantize_info->tree_depth=(unsigned long)
8624 argument_list[1].long_reference;
8625 if (attribute_flag[2] != 0)
8626 quantize_info->colorspace=(ColorspaceType)
8627 argument_list[2].long_reference;
8628 if (attribute_flag[3] != 0)
8629 quantize_info->dither=argument_list[3].long_reference != 0 ?
8630 MagickTrue : MagickFalse;
8631 if (attribute_flag[4] != 0)
8632 quantize_info->measure_error=
8633 argument_list[4].long_reference != 0 ? MagickTrue : MagickFalse;
8634 if (attribute_flag[5] != 0)
8635 (void) QueryColorDatabase(argument_list[5].string_reference,
8636 &image->transparent_color,exception);
8637 if (attribute_flag[5] && argument_list[5].long_reference)
8639 (void) QuantizeImages(quantize_info,image);
8642 if (attribute_flag[6] != 0)
8643 quantize_info->dither_method=(DitherMethod)
8644 argument_list[6].long_reference;
8645 if ((image->storage_class == DirectClass) ||
8646 (image->colors > quantize_info->number_colors) ||
8647 (quantize_info->colorspace == GRAYColorspace))
8648 (void) QuantizeImage(quantize_info,image);
8650 CompressImageColormap(image);
8651 quantize_info=DestroyQuantizeInfo(quantize_info);
8654 case 49: /* Raise */
8656 if (attribute_flag[0] != 0)
8657 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8658 &geometry,exception);
8659 if (attribute_flag[1] != 0)
8660 geometry.width=argument_list[1].long_reference;
8661 if (attribute_flag[2] != 0)
8662 geometry.height=argument_list[2].long_reference;
8663 if (attribute_flag[3] == 0)
8664 argument_list[3].long_reference=1;
8665 (void) RaiseImage(image,&geometry,argument_list[3].long_reference !=
8666 0 ? MagickTrue : MagickFalse);
8669 case 50: /* Segment */
8676 smoothing_threshold;
8681 cluster_threshold=1.0;
8682 smoothing_threshold=1.5;
8683 colorspace=RGBColorspace;
8684 verbose=MagickFalse;
8685 if (attribute_flag[0] != 0)
8687 flags=ParseGeometry(argument_list[0].string_reference,
8689 cluster_threshold=geometry_info.rho;
8690 if (flags & SigmaValue)
8691 smoothing_threshold=geometry_info.sigma;
8693 if (attribute_flag[1] != 0)
8694 cluster_threshold=argument_list[1].real_reference;
8695 if (attribute_flag[2] != 0)
8696 smoothing_threshold=argument_list[2].real_reference;
8697 if (attribute_flag[3] != 0)
8698 colorspace=(ColorspaceType) argument_list[3].long_reference;
8699 if (attribute_flag[4] != 0)
8700 verbose=argument_list[4].long_reference != 0 ?
8701 MagickTrue : MagickFalse;
8702 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8703 smoothing_threshold);
8706 case 51: /* Signature */
8708 (void) SignatureImage(image);
8711 case 52: /* Solarize */
8713 geometry_info.rho=QuantumRange/2.0;
8714 if (attribute_flag[0] != 0)
8715 flags=ParseGeometry(argument_list[0].string_reference,
8717 if (attribute_flag[1] != 0)
8718 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8720 (void) SolarizeImage(image,geometry_info.rho);
8725 (void) SyncImage(image);
8728 case 54: /* Texture */
8730 if (attribute_flag[0] == 0)
8732 TextureImage(image,argument_list[0].image_reference);
8735 case 55: /* Evalute */
8737 MagickEvaluateOperator
8740 op=SetEvaluateOperator;
8741 if (attribute_flag[0] == MagickFalse)
8742 argument_list[0].real_reference=0.0;
8743 if (attribute_flag[1] != MagickFalse)
8744 op=(MagickEvaluateOperator) argument_list[1].long_reference;
8745 if (attribute_flag[2] != MagickFalse)
8746 channel=(ChannelType) argument_list[2].long_reference;
8747 (void) EvaluateImageChannel(image,channel,op,
8748 argument_list[0].real_reference,exception);
8751 case 56: /* Transparent */
8762 (void) QueryMagickColor("none",&target,exception);
8763 if (attribute_flag[0] != 0)
8764 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8766 opacity=TransparentOpacity;
8767 if (attribute_flag[1] != 0)
8768 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8770 if (attribute_flag[2] != 0)
8771 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8773 if (attribute_flag[3] == 0)
8774 argument_list[3].long_reference=0;
8776 if (attribute_flag[3] != 0)
8777 invert=(MagickBooleanType) argument_list[3].long_reference;
8778 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
8782 case 57: /* Threshold */
8787 if (attribute_flag[0] == 0)
8788 argument_list[0].string_reference="50%";
8789 if (attribute_flag[1] != 0)
8790 channel=(ChannelType) argument_list[1].long_reference;
8791 threshold=SiPrefixToDouble(argument_list[0].string_reference,
8793 (void) BilevelImageChannel(image,channel,threshold);
8796 case 58: /* Charcoal */
8798 if (attribute_flag[0] != 0)
8800 flags=ParseGeometry(argument_list[0].string_reference,
8802 if ((flags & SigmaValue) == 0)
8803 geometry_info.sigma=1.0;
8805 if (attribute_flag[1] != 0)
8806 geometry_info.rho=argument_list[1].real_reference;
8807 if (attribute_flag[2] != 0)
8808 geometry_info.sigma=argument_list[2].real_reference;
8809 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
8815 if (attribute_flag[0] != 0)
8816 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
8818 image=TrimImage(image,exception);
8823 if (attribute_flag[0] != 0)
8825 flags=ParseGeometry(argument_list[0].string_reference,
8827 if ((flags & SigmaValue) == 0)
8828 geometry_info.sigma=1.0;
8830 if (attribute_flag[1] != 0)
8831 geometry_info.rho=argument_list[1].real_reference;
8832 if (attribute_flag[2] != 0)
8833 geometry_info.sigma=argument_list[2].real_reference;
8834 if (attribute_flag[3] != 0)
8835 image->interpolate=(InterpolatePixelMethod)
8836 argument_list[3].long_reference;
8837 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
8841 case 61: /* Separate */
8843 if (attribute_flag[0] != 0)
8844 channel=(ChannelType) argument_list[0].long_reference;
8845 (void) SeparateImageChannel(image,channel);
8848 case 63: /* Stereo */
8850 if (attribute_flag[0] == 0)
8852 ThrowPerlException(exception,OptionError,"StereoImageRequired",
8856 if (attribute_flag[1] != 0)
8857 geometry.x=argument_list[1].long_reference;
8858 if (attribute_flag[2] != 0)
8859 geometry.y=argument_list[2].long_reference;
8860 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
8861 geometry.x,geometry.y,exception);
8864 case 64: /* Stegano */
8866 if (attribute_flag[0] == 0)
8868 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
8872 if (attribute_flag[1] == 0)
8873 argument_list[1].long_reference=0;
8874 image->offset=argument_list[1].long_reference;
8875 image=SteganoImage(image,argument_list[0].image_reference,exception);
8878 case 65: /* Deconstruct */
8880 image=DeconstructImages(image,exception);
8883 case 66: /* GaussianBlur */
8885 if (attribute_flag[0] != 0)
8887 flags=ParseGeometry(argument_list[0].string_reference,
8889 if ((flags & SigmaValue) == 0)
8890 geometry_info.sigma=1.0;
8892 if (attribute_flag[1] != 0)
8893 geometry_info.rho=argument_list[1].real_reference;
8894 if (attribute_flag[2] != 0)
8895 geometry_info.sigma=argument_list[2].real_reference;
8896 if (attribute_flag[3] != 0)
8897 channel=(ChannelType) argument_list[3].long_reference;
8898 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
8899 geometry_info.sigma,exception);
8902 case 67: /* Convolve */
8913 if (attribute_flag[0] == 0)
8915 if (attribute_flag[1] != 0)
8916 channel=(ChannelType) argument_list[1].long_reference;
8917 if (attribute_flag[2] != 0)
8918 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
8920 av=(AV *) argument_list[0].array_reference;
8921 order=(unsigned long) sqrt(av_len(av)+1);
8922 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
8923 if (kernel == (double *) NULL)
8925 ThrowPerlException(exception,ResourceLimitFatalError,
8926 "MemoryAllocationFailed",PackageName);
8929 for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
8930 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
8931 for ( ; j < (long) (order*order); j++)
8933 image=ConvolveImageChannel(image,channel,order,kernel,exception);
8934 kernel=(double *) RelinquishMagickMemory(kernel);
8937 case 68: /* Profile */
8952 if (attribute_flag[0] != 0)
8953 name=argument_list[0].string_reference;
8954 if (attribute_flag[2] != 0)
8955 image->rendering_intent=(RenderingIntent)
8956 argument_list[2].long_reference;
8957 if (attribute_flag[3] != 0)
8958 image->black_point_compensation=
8959 argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse;
8960 if (attribute_flag[1] != 0)
8962 if (argument_list[1].length == 0)
8965 Remove a profile from the image.
8967 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
8972 Associate user supplied profile with the image.
8974 profile=AcquireStringInfo(argument_list[1].length);
8975 SetStringInfoDatum(profile,(const unsigned char *)
8976 argument_list[1].string_reference);
8977 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
8978 (unsigned long) GetStringInfoLength(profile),MagickFalse);
8979 profile=DestroyStringInfo(profile);
8983 Associate a profile with the image.
8986 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
8987 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
8988 profile_image=ReadImages(profile_info,&image->exception);
8989 if (profile_image == (Image *) NULL)
8991 ResetImageProfileIterator(profile_image);
8992 name=GetNextImageProfile(profile_image);
8993 while (name != (const char *) NULL)
8998 profile=GetImageProfile(profile_image,name);
8999 if (profile != (const StringInfo *) NULL)
9000 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9001 (unsigned long) GetStringInfoLength(profile),MagickFalse);
9002 name=GetNextImageProfile(profile_image);
9004 profile_image=DestroyImage(profile_image);
9005 profile_info=DestroyImageInfo(profile_info);
9008 case 69: /* UnsharpMask */
9010 if (attribute_flag[0] != 0)
9012 flags=ParseGeometry(argument_list[0].string_reference,
9014 if ((flags & SigmaValue) == 0)
9015 geometry_info.sigma=1.0;
9016 if ((flags & XiValue) == 0)
9017 geometry_info.xi=1.0;
9018 if ((flags & PsiValue) == 0)
9019 geometry_info.psi=0.5;
9021 if (attribute_flag[1] != 0)
9022 geometry_info.rho=argument_list[1].real_reference;
9023 if (attribute_flag[2] != 0)
9024 geometry_info.sigma=argument_list[2].real_reference;
9025 if (attribute_flag[3] != 0)
9026 geometry_info.xi=argument_list[3].real_reference;
9027 if (attribute_flag[4] != 0)
9028 geometry_info.psi=argument_list[4].real_reference;
9029 if (attribute_flag[5] != 0)
9030 channel=(ChannelType) argument_list[5].long_reference;
9031 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9032 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9035 case 70: /* MotionBlur */
9037 if (attribute_flag[0] != 0)
9039 flags=ParseGeometry(argument_list[0].string_reference,
9041 if ((flags & SigmaValue) == 0)
9042 geometry_info.sigma=1.0;
9043 if ((flags & XiValue) == 0)
9044 geometry_info.xi=1.0;
9046 if (attribute_flag[1] != 0)
9047 geometry_info.rho=argument_list[1].real_reference;
9048 if (attribute_flag[2] != 0)
9049 geometry_info.sigma=argument_list[2].real_reference;
9050 if (attribute_flag[3] != 0)
9051 geometry_info.xi=argument_list[3].real_reference;
9052 if (attribute_flag[4] != 0)
9053 channel=(ChannelType) argument_list[4].long_reference;
9054 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9055 geometry_info.sigma,geometry_info.xi,exception);
9058 case 71: /* OrderedDither */
9060 if (attribute_flag[0] == 0)
9061 argument_list[0].string_reference="o8x8";
9062 if (attribute_flag[1] != 0)
9063 channel=(ChannelType) argument_list[1].long_reference;
9064 (void) OrderedPosterizeImageChannel(image,channel,
9065 argument_list[0].string_reference,exception);
9068 case 72: /* Shave */
9070 if (attribute_flag[0] != 0)
9071 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9072 &geometry,exception);
9073 if (attribute_flag[1] != 0)
9074 geometry.width=argument_list[1].long_reference;
9075 if (attribute_flag[2] != 0)
9076 geometry.height=argument_list[2].long_reference;
9077 image=ShaveImage(image,&geometry,exception);
9080 case 73: /* Level */
9088 white_point=(MagickRealType) image->columns*image->rows;
9090 if (attribute_flag[0] != 0)
9092 flags=ParseGeometry(argument_list[0].string_reference,
9094 black_point=geometry_info.rho;
9095 if ((flags & SigmaValue) != 0)
9096 white_point=geometry_info.sigma;
9097 if ((flags & XiValue) != 0)
9098 gamma=geometry_info.xi;
9099 if ((flags & PercentValue) != 0)
9101 black_point*=(double) (QuantumRange/100.0);
9102 white_point*=(double) (QuantumRange/100.0);
9104 if ((flags & SigmaValue) == 0)
9105 white_point=(double) QuantumRange-black_point;
9107 if (attribute_flag[1] != 0)
9108 black_point=argument_list[1].real_reference;
9109 if (attribute_flag[2] != 0)
9110 white_point=argument_list[2].real_reference;
9111 if (attribute_flag[3] != 0)
9112 gamma=argument_list[3].real_reference;
9113 if (attribute_flag[4] != 0)
9114 channel=(ChannelType) argument_list[4].long_reference;
9115 if (attribute_flag[5] != 0)
9117 argument_list[0].real_reference=argument_list[5].real_reference;
9118 attribute_flag[0]=attribute_flag[5];
9120 (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
9125 if (attribute_flag[0] == 0)
9126 argument_list[0].string_reference="#1";
9127 if (attribute_flag[1] == 0)
9128 argument_list[1].long_reference=MagickTrue;
9129 (void) ClipImagePath(image,argument_list[0].string_reference,
9130 argument_list[1].long_reference != 0 ? MagickTrue : MagickFalse);
9133 case 75: /* AffineTransform */
9138 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9140 if (attribute_flag[0] != 0)
9145 av=(AV *) argument_list[0].array_reference;
9146 if ((av_len(av) != 3) && (av_len(av) != 5))
9148 ThrowPerlException(exception,OptionError,
9149 "affine matrix must have 4 or 6 elements",PackageName);
9152 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9153 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9154 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9155 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9156 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9157 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9159 ThrowPerlException(exception,OptionError,
9160 "affine matrix is singular",PackageName);
9163 if (av_len(av) == 5)
9165 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9166 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9169 for (j=1; j < 6; j++)
9171 if (attribute_flag[j] == 0)
9173 value=argument_list[j].string_reference;
9174 angle=argument_list[j].real_reference;
9175 current=draw_info->affine;
9176 GetAffineMatrix(&affine);
9184 flags=ParseGeometry(value,&geometry_info);
9185 affine.tx=geometry_info.xi;
9186 affine.ty=geometry_info.psi;
9187 if ((flags & PsiValue) == 0)
9188 affine.ty=affine.tx;
9196 flags=ParseGeometry(value,&geometry_info);
9197 affine.sx=geometry_info.rho;
9198 affine.sy=geometry_info.sigma;
9199 if ((flags & SigmaValue) == 0)
9200 affine.sy=affine.sx;
9210 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9211 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9212 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9213 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9221 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9229 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9233 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9234 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9235 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9236 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9237 draw_info->affine.tx=
9238 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9239 draw_info->affine.ty=
9240 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9242 if (attribute_flag[6] != 0)
9243 image->interpolate=(InterpolatePixelMethod)
9244 argument_list[6].long_reference;
9245 if (attribute_flag[7] != 0)
9246 QueryColorDatabase(argument_list[7].string_reference,
9247 &image->background_color,exception);
9248 image=AffineTransformImage(image,&draw_info->affine,exception);
9249 draw_info=DestroyDrawInfo(draw_info);
9252 case 76: /* Difference */
9254 if (attribute_flag[0] == 0)
9256 ThrowPerlException(exception,OptionError,
9257 "ReferenceImageRequired",PackageName);
9260 if (attribute_flag[1] != 0)
9261 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9263 (void) IsImagesEqual(image,argument_list[0].image_reference);
9266 case 77: /* AdaptiveThreshold */
9268 if (attribute_flag[0] != 0)
9270 flags=ParseGeometry(argument_list[0].string_reference,
9272 if ((flags & PercentValue) != 0)
9273 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9275 if (attribute_flag[1] != 0)
9276 geometry_info.rho=argument_list[1].long_reference;
9277 if (attribute_flag[2] != 0)
9278 geometry_info.sigma=argument_list[2].long_reference;
9279 if (attribute_flag[3] != 0)
9280 geometry_info.xi=argument_list[3].long_reference;;
9281 image=AdaptiveThresholdImage(image,(unsigned long) geometry_info.rho,
9282 (unsigned long) geometry_info.sigma,(long) geometry_info.xi,
9286 case 78: /* Resample */
9292 if (attribute_flag[0] != 0)
9294 flags=ParseGeometry(argument_list[0].string_reference,
9296 if ((flags & SigmaValue) == 0)
9297 geometry_info.sigma=geometry_info.rho;
9299 if (attribute_flag[1] != 0)
9300 geometry_info.rho=argument_list[1].real_reference;
9301 if (attribute_flag[2] != 0)
9302 geometry_info.sigma=argument_list[2].real_reference;
9303 if (attribute_flag[3] == 0)
9304 argument_list[3].long_reference=(long) UndefinedFilter;
9305 if (attribute_flag[4] == 0)
9306 SetImageArtifact(image,"filter:support",
9307 argument_list[4].string_reference);
9308 if (attribute_flag[5] != 0)
9309 argument_list[5].real_reference=1.0;
9310 width=(unsigned long) (geometry_info.rho*image->columns/
9311 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9312 height=(unsigned long) (geometry_info.sigma*image->rows/
9313 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9314 image=ResizeImage(image,width,height,(FilterTypes)
9315 argument_list[3].long_reference,argument_list[5].real_reference,
9317 if (image != (Image *) NULL)
9319 image->x_resolution=geometry_info.rho;
9320 image->y_resolution=geometry_info.sigma;
9324 case 79: /* Describe */
9326 if (attribute_flag[0] == 0)
9327 argument_list[0].file_reference=(FILE *) NULL;
9328 if (attribute_flag[1] != 0)
9329 (void) SetImageArtifact(image,"identify:features",
9330 argument_list[1].string_reference);
9331 (void) IdentifyImage(image,argument_list[0].file_reference,
9335 case 80: /* BlackThreshold */
9337 if (attribute_flag[0] == 0)
9338 argument_list[0].string_reference="50%";
9339 if (attribute_flag[2] != 0)
9340 channel=(ChannelType) argument_list[2].long_reference;
9341 BlackThresholdImageChannel(image,channel,
9342 argument_list[0].string_reference,exception);
9345 case 81: /* WhiteThreshold */
9347 if (attribute_flag[0] == 0)
9348 argument_list[0].string_reference="50%";
9349 if (attribute_flag[2] != 0)
9350 channel=(ChannelType) argument_list[2].long_reference;
9351 WhiteThresholdImageChannel(image,channel,
9352 argument_list[0].string_reference,exception);
9355 case 82: /* RadialBlur */
9357 if (attribute_flag[0] != 0)
9359 flags=ParseGeometry(argument_list[0].string_reference,
9361 if ((flags & SigmaValue) == 0)
9362 geometry_info.sigma=1.0;
9364 if (attribute_flag[1] != 0)
9365 geometry_info.rho=argument_list[1].real_reference;
9366 if (attribute_flag[2] != 0)
9367 channel=(ChannelType) argument_list[2].long_reference;
9368 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9372 case 83: /* Thumbnail */
9374 if (attribute_flag[0] != 0)
9375 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9376 &geometry,exception);
9377 if (attribute_flag[1] != 0)
9378 geometry.width=argument_list[1].long_reference;
9379 if (attribute_flag[2] != 0)
9380 geometry.height=argument_list[2].long_reference;
9381 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9384 case 84: /* Strip */
9386 (void) StripImage(image);
9394 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9395 if (attribute_flag[0] != 0)
9396 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9398 if (attribute_flag[1] == 0)
9399 argument_list[1].string_reference="100";
9400 image=TintImage(image,argument_list[1].string_reference,target,
9404 case 86: /* Channel */
9406 if (attribute_flag[0] != 0)
9407 channel=(ChannelType) argument_list[0].long_reference;
9408 (void) SeparateImageChannel(image,channel);
9411 case 87: /* Splice */
9413 if (attribute_flag[0] != 0)
9414 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9415 &geometry,exception);
9416 if (attribute_flag[1] != 0)
9417 geometry.width=argument_list[1].long_reference;
9418 if (attribute_flag[2] != 0)
9419 geometry.height=argument_list[2].long_reference;
9420 if (attribute_flag[3] != 0)
9421 geometry.x=argument_list[3].long_reference;
9422 if (attribute_flag[4] != 0)
9423 geometry.y=argument_list[4].long_reference;
9424 if (attribute_flag[5] != 0)
9425 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9427 if (attribute_flag[6] != 0)
9428 (void) QueryColorDatabase(argument_list[6].string_reference,
9429 &image->background_color,exception);
9430 if (attribute_flag[7] != 0)
9431 image->gravity=(GravityType) argument_list[7].long_reference;
9432 image=SpliceImage(image,&geometry,exception);
9435 case 88: /* Posterize */
9437 if (attribute_flag[0] == 0)
9438 argument_list[0].long_reference=3;
9439 if (attribute_flag[1] == 0)
9440 argument_list[1].long_reference=0;
9441 (void) PosterizeImage(image,argument_list[0].long_reference,
9442 argument_list[1].long_reference ? MagickTrue : MagickFalse);
9445 case 89: /* Shadow */
9447 if (attribute_flag[0] != 0)
9449 flags=ParseGeometry(argument_list[0].string_reference,
9451 if ((flags & SigmaValue) == 0)
9452 geometry_info.sigma=1.0;
9453 if ((flags & XiValue) == 0)
9454 geometry_info.xi=4.0;
9455 if ((flags & PsiValue) == 0)
9456 geometry_info.psi=4.0;
9458 if (attribute_flag[1] != 0)
9459 geometry_info.rho=argument_list[1].real_reference;
9460 if (attribute_flag[2] != 0)
9461 geometry_info.sigma=argument_list[2].real_reference;
9462 if (attribute_flag[3] != 0)
9463 geometry_info.xi=argument_list[3].long_reference;
9464 if (attribute_flag[4] != 0)
9465 geometry_info.psi=argument_list[4].long_reference;
9466 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9467 (long) (geometry_info.xi+0.5),(long) (geometry_info.psi+0.5),
9471 case 90: /* Identify */
9473 if (attribute_flag[0] == 0)
9474 argument_list[0].file_reference=(FILE *) NULL;
9475 if (attribute_flag[1] != 0)
9476 (void) SetImageArtifact(image,"identify:features",
9477 argument_list[1].string_reference);
9478 if ((attribute_flag[2] != 0) &&
9479 (argument_list[2].long_reference != 0))
9480 (void) SetImageArtifact(image,"identify:unique","true");
9481 (void) IdentifyImage(image,argument_list[0].file_reference,
9485 case 91: /* SepiaTone */
9487 if (attribute_flag[0] == 0)
9488 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9489 image=SepiaToneImage(image,argument_list[0].real_reference,
9493 case 92: /* SigmoidalContrast */
9498 if (attribute_flag[0] != 0)
9500 flags=ParseGeometry(argument_list[0].string_reference,
9502 if ((flags & SigmaValue) == 0)
9503 geometry_info.sigma=QuantumRange/2.0;
9504 if ((flags & PercentValue) != 0)
9505 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9507 if (attribute_flag[1] != 0)
9508 geometry_info.rho=argument_list[1].real_reference;
9509 if (attribute_flag[2] != 0)
9510 geometry_info.sigma=argument_list[2].real_reference;
9511 if (attribute_flag[3] != 0)
9512 channel=(ChannelType) argument_list[3].long_reference;
9514 if (attribute_flag[4] != 0)
9515 sharpen=argument_list[4].long_reference != 0 ? MagickTrue :
9517 (void) SigmoidalContrastImageChannel(image,channel,sharpen,
9518 geometry_info.rho,geometry_info.sigma);
9521 case 93: /* Extent */
9523 if (attribute_flag[7] != 0)
9524 image->gravity=(GravityType) argument_list[7].long_reference;
9525 if (attribute_flag[0] != 0)
9530 flags=ParseGravityGeometry(image,
9531 argument_list[0].string_reference,&geometry,exception);
9532 if (geometry.width == 0)
9533 geometry.width=image->columns;
9534 if (geometry.height == 0)
9535 geometry.height=image->rows;
9536 geometry.x=(-geometry.x);
9537 geometry.y=(-geometry.y);
9539 if (attribute_flag[1] != 0)
9540 geometry.width=argument_list[1].long_reference;
9541 if (attribute_flag[2] != 0)
9542 geometry.height=argument_list[2].long_reference;
9543 if (attribute_flag[3] != 0)
9544 geometry.x=argument_list[3].long_reference;
9545 if (attribute_flag[4] != 0)
9546 geometry.y=argument_list[4].long_reference;
9547 if (attribute_flag[5] != 0)
9548 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9550 if (attribute_flag[6] != 0)
9551 (void) QueryColorDatabase(argument_list[6].string_reference,
9552 &image->background_color,exception);
9553 image=ExtentImage(image,&geometry,exception);
9556 case 94: /* Vignette */
9558 if (attribute_flag[0] != 0)
9560 flags=ParseGeometry(argument_list[0].string_reference,
9562 if ((flags & SigmaValue) == 0)
9563 geometry_info.sigma=1.0;
9564 if ((flags & XiValue) == 0)
9565 geometry_info.xi=0.1*image->columns;
9566 if ((flags & PsiValue) == 0)
9567 geometry_info.psi=0.1*image->rows;
9569 if (attribute_flag[1] != 0)
9570 geometry_info.rho=argument_list[1].real_reference;
9571 if (attribute_flag[2] != 0)
9572 geometry_info.sigma=argument_list[2].real_reference;
9573 if (attribute_flag[3] != 0)
9574 geometry_info.xi=argument_list[3].long_reference;
9575 if (attribute_flag[4] != 0)
9576 geometry_info.psi=argument_list[4].long_reference;
9577 if (attribute_flag[5] != 0)
9578 (void) QueryColorDatabase(argument_list[5].string_reference,
9579 &image->background_color,exception);
9580 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9581 (long) (geometry_info.xi+0.5),(long) (geometry_info.psi+0.5),
9585 case 95: /* ContrastStretch */
9592 white_point=(MagickRealType) image->columns*image->rows;
9593 if (attribute_flag[0] != 0)
9595 flags=ParseGeometry(argument_list[0].string_reference,
9597 black_point=geometry_info.rho;
9598 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9600 if ((flags & PercentValue) != 0)
9602 black_point*=(double) image->columns*image->rows/100.0;
9603 white_point*=(double) image->columns*image->rows/100.0;
9605 white_point=(MagickRealType) image->columns*image->rows-
9608 if (attribute_flag[1] != 0)
9609 black_point=argument_list[1].real_reference;
9610 if (attribute_flag[2] != 0)
9611 white_point=argument_list[2].real_reference;
9612 if (attribute_flag[4] != 0)
9613 channel=(ChannelType) argument_list[4].long_reference;
9614 (void) ContrastStretchImageChannel(image,channel,black_point,
9618 case 96: /* Sans0 */
9622 case 97: /* Sans1 */
9626 case 98: /* AdaptiveSharpen */
9628 if (attribute_flag[0] != 0)
9630 flags=ParseGeometry(argument_list[0].string_reference,
9632 if ((flags & SigmaValue) == 0)
9633 geometry_info.sigma=1.0;
9635 if (attribute_flag[1] != 0)
9636 geometry_info.rho=argument_list[1].real_reference;
9637 if (attribute_flag[2] != 0)
9638 geometry_info.sigma=argument_list[2].real_reference;
9639 if (attribute_flag[3] != 0)
9640 channel=(ChannelType) argument_list[3].long_reference;
9641 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9642 geometry_info.sigma,exception);
9645 case 99: /* Transpose */
9647 image=TransposeImage(image,exception);
9650 case 100: /* Tranverse */
9652 image=TransverseImage(image,exception);
9655 case 101: /* AutoOrient */
9657 switch (image->orientation)
9659 case TopRightOrientation:
9661 image=FlopImage(image,exception);
9664 case BottomRightOrientation:
9666 image=RotateImage(image,180.0,exception);
9669 case BottomLeftOrientation:
9671 image=FlipImage(image,exception);
9674 case LeftTopOrientation:
9676 image=TransposeImage(image,exception);
9679 case RightTopOrientation:
9681 image=RotateImage(image,90.0,exception);
9684 case RightBottomOrientation:
9686 image=TransverseImage(image,exception);
9689 case LeftBottomOrientation:
9691 image=RotateImage(image,270.0,exception);
9699 case 102: /* AdaptiveBlur */
9701 if (attribute_flag[0] != 0)
9703 flags=ParseGeometry(argument_list[0].string_reference,
9705 if ((flags & SigmaValue) == 0)
9706 geometry_info.sigma=1.0;
9708 if (attribute_flag[1] != 0)
9709 geometry_info.rho=argument_list[1].real_reference;
9710 if (attribute_flag[2] != 0)
9711 geometry_info.sigma=argument_list[2].real_reference;
9712 if (attribute_flag[3] != 0)
9713 channel=(ChannelType) argument_list[3].long_reference;
9714 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
9715 geometry_info.sigma,exception);
9718 case 103: /* Sketch */
9720 if (attribute_flag[0] != 0)
9722 flags=ParseGeometry(argument_list[0].string_reference,
9724 if ((flags & SigmaValue) == 0)
9725 geometry_info.sigma=1.0;
9726 if ((flags & XiValue) == 0)
9727 geometry_info.xi=1.0;
9729 if (attribute_flag[1] != 0)
9730 geometry_info.rho=argument_list[1].real_reference;
9731 if (attribute_flag[2] != 0)
9732 geometry_info.sigma=argument_list[2].real_reference;
9733 if (attribute_flag[3] != 0)
9734 geometry_info.xi=argument_list[3].real_reference;
9735 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9736 geometry_info.xi,exception);
9739 case 104: /* UniqueColors */
9741 image=UniqueImageColors(image,exception);
9744 case 105: /* AdaptiveResize */
9746 if (attribute_flag[0] != 0)
9747 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9748 &geometry,exception);
9749 if (attribute_flag[1] != 0)
9750 geometry.width=argument_list[1].long_reference;
9751 if (attribute_flag[2] != 0)
9752 geometry.height=argument_list[2].long_reference;
9753 if (attribute_flag[3] != 0)
9754 image->filter=(FilterTypes) argument_list[4].long_reference;
9755 if (attribute_flag[4] != 0)
9756 SetImageArtifact(image,"filter:support",
9757 argument_list[4].string_reference);
9758 if (attribute_flag[5] != 0)
9759 image->blur=argument_list[5].real_reference;
9760 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
9764 case 106: /* ClipMask */
9766 if (attribute_flag[0] == 0)
9768 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9772 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
9773 MagickTrue,exception);
9774 (void) NegateImage(image->clip_mask,MagickFalse);
9777 case 107: /* LinearStretch */
9784 white_point=(MagickRealType) image->columns*image->rows;
9785 if (attribute_flag[0] != 0)
9787 flags=ParseGeometry(argument_list[0].string_reference,
9789 if ((flags & SigmaValue) != 0)
9790 white_point=geometry_info.sigma;
9791 if ((flags & PercentValue) != 0)
9793 black_point*=(double) image->columns*image->rows/100.0;
9794 white_point*=(double) image->columns*image->rows/100.0;
9796 if ((flags & SigmaValue) == 0)
9797 white_point=(double) image->columns*image->rows-black_point;
9799 if (attribute_flag[1] != 0)
9800 black_point=argument_list[1].real_reference;
9801 if (attribute_flag[2] != 0)
9802 white_point=argument_list[2].real_reference;
9803 (void) LinearStretchImage(image,black_point,white_point);
9806 case 108: /* Recolor */
9817 if (attribute_flag[0] == 0)
9819 av=(AV *) argument_list[0].array_reference;
9820 order=(unsigned long) sqrt(av_len(av)+1);
9821 color_matrix=(double *) AcquireQuantumMemory(order,order*
9822 sizeof(*color_matrix));
9823 if (color_matrix == (double *) NULL)
9825 ThrowPerlException(exception,ResourceLimitFatalError,
9826 "MemoryAllocationFailed",PackageName);
9829 for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
9830 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
9831 for ( ; j < (long) (order*order); j++)
9832 color_matrix[j]=0.0;
9833 image=RecolorImage(image,order,color_matrix,exception);
9834 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
9837 case 109: /* Mask */
9839 if (attribute_flag[0] == 0)
9841 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9845 image->mask=CloneImage(argument_list[0].image_reference,0,0,
9846 MagickTrue,exception);
9847 (void) NegateImage(image->mask,MagickFalse);
9850 case 110: /* Polaroid */
9858 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9860 if (attribute_flag[0] != 0)
9861 (void) SetImageProperty(image,"caption",InterpretImageProperties(
9862 info ? info->image_info : (ImageInfo *) NULL,image,
9863 argument_list[0].string_reference));
9865 if (attribute_flag[1] != 0)
9866 angle=argument_list[1].real_reference;
9867 if (attribute_flag[2] != 0)
9868 (void) CloneString(&draw_info->font,
9869 argument_list[2].string_reference);
9870 if (attribute_flag[3] != 0)
9871 (void) QueryColorDatabase(argument_list[3].string_reference,
9872 &draw_info->stroke,exception);
9873 if (attribute_flag[4] != 0)
9874 (void) QueryColorDatabase(argument_list[4].string_reference,
9875 &draw_info->fill,exception);
9876 if (attribute_flag[5] != 0)
9877 draw_info->stroke_width=argument_list[5].real_reference;
9878 if (attribute_flag[6] != 0)
9879 draw_info->pointsize=argument_list[6].real_reference;
9880 if (attribute_flag[7] != 0)
9881 draw_info->gravity=(GravityType) argument_list[7].long_reference;
9882 if (attribute_flag[8] != 0)
9883 (void) QueryColorDatabase(argument_list[8].string_reference,
9884 &image->background_color,exception);
9885 image=PolaroidImage(image,draw_info,angle,exception);
9886 draw_info=DestroyDrawInfo(draw_info);
9889 case 111: /* FloodfillPaint */
9900 draw_info=CloneDrawInfo(info ? info->image_info :
9901 (ImageInfo *) NULL,(DrawInfo *) NULL);
9902 if (attribute_flag[0] != 0)
9903 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9904 &geometry,exception);
9905 if (attribute_flag[1] != 0)
9906 geometry.x=argument_list[1].long_reference;
9907 if (attribute_flag[2] != 0)
9908 geometry.y=argument_list[2].long_reference;
9909 if (attribute_flag[3] != 0)
9910 (void) QueryColorDatabase(argument_list[3].string_reference,
9911 &draw_info->fill,exception);
9912 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
9914 if (attribute_flag[4] != 0)
9915 QueryMagickColor(argument_list[4].string_reference,&target,
9917 if (attribute_flag[5] != 0)
9918 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9920 if (attribute_flag[6] != 0)
9921 channel=(ChannelType) argument_list[6].long_reference;
9923 if (attribute_flag[7] != 0)
9924 invert=(MagickBooleanType) argument_list[7].long_reference;
9925 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
9927 draw_info=DestroyDrawInfo(draw_info);
9930 case 112: /* Distort */
9947 if (attribute_flag[0] == 0)
9949 method=UndefinedDistortion;
9950 if (attribute_flag[1] != 0)
9951 method=(DistortImageMethod) argument_list[1].long_reference;
9952 av=(AV *) argument_list[0].array_reference;
9953 number_coordinates=(unsigned long) av_len(av)+1;
9954 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
9955 sizeof(*coordinates));
9956 if (coordinates == (double *) NULL)
9958 ThrowPerlException(exception,ResourceLimitFatalError,
9959 "MemoryAllocationFailed",PackageName);
9962 for (j=0; j < (long) number_coordinates; j++)
9963 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
9964 virtual_pixel=UndefinedVirtualPixelMethod;
9965 if (attribute_flag[2] != 0)
9966 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
9967 argument_list[2].long_reference);
9968 image=DistortImage(image,method,number_coordinates,coordinates,
9969 argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse,
9971 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
9972 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
9973 coordinates=(double *) RelinquishMagickMemory(coordinates);
9976 case 113: /* Clut */
9978 if (attribute_flag[0] == 0)
9980 ThrowPerlException(exception,OptionError,"ClutImageRequired",
9984 if (attribute_flag[1] != 0)
9985 channel=(ChannelType) argument_list[1].long_reference;
9986 (void) ClutImageChannel(image,channel,
9987 argument_list[0].image_reference);
9990 case 114: /* LiquidRescale */
9992 if (attribute_flag[0] != 0)
9993 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9994 &geometry,exception);
9995 if (attribute_flag[1] != 0)
9996 geometry.width=argument_list[1].long_reference;
9997 if (attribute_flag[2] != 0)
9998 geometry.height=argument_list[2].long_reference;
9999 if (attribute_flag[3] == 0)
10000 argument_list[3].real_reference=1.0;
10001 if (attribute_flag[4] == 0)
10002 argument_list[4].real_reference=0.0;
10003 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10004 argument_list[3].real_reference,argument_list[4].real_reference,
10008 case 115: /* EncipherImage */
10010 (void) EncipherImage(image,argument_list[0].string_reference,
10014 case 116: /* DecipherImage */
10016 (void) DecipherImage(image,argument_list[0].string_reference,
10020 case 117: /* Deskew */
10022 geometry_info.rho=QuantumRange/2.0;
10023 if (attribute_flag[0] != 0)
10024 flags=ParseGeometry(argument_list[0].string_reference,
10026 if (attribute_flag[1] != 0)
10027 geometry_info.rho=SiPrefixToDouble(
10028 argument_list[1].string_reference,QuantumRange);
10029 image=DeskewImage(image,geometry_info.rho,exception);
10032 case 118: /* Remap */
10037 if (attribute_flag[0] == 0)
10039 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10041 goto PerlException;
10043 quantize_info=AcquireQuantizeInfo(info->image_info);
10044 if (attribute_flag[1] != 0)
10045 quantize_info->dither=(MagickBooleanType)
10046 argument_list[1].long_reference;
10047 if (attribute_flag[2] != 0)
10048 quantize_info->dither_method=(DitherMethod)
10049 argument_list[2].long_reference;
10050 (void) RemapImages(quantize_info,image,
10051 argument_list[0].image_reference);
10052 quantize_info=DestroyQuantizeInfo(quantize_info);
10055 case 119: /* SparseColor */
10067 number_coordinates;
10072 if (attribute_flag[0] == 0)
10074 method=UndefinedColorInterpolate;
10075 if (attribute_flag[1] != 0)
10076 method=(SparseColorMethod) argument_list[1].long_reference;
10077 av=(AV *) argument_list[0].array_reference;
10078 number_coordinates=(unsigned long) av_len(av)+1;
10079 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10080 sizeof(*coordinates));
10081 if (coordinates == (double *) NULL)
10083 ThrowPerlException(exception,ResourceLimitFatalError,
10084 "MemoryAllocationFailed",PackageName);
10085 goto PerlException;
10087 for (j=0; j < (long) number_coordinates; j++)
10088 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10089 virtual_pixel=UndefinedVirtualPixelMethod;
10090 if (attribute_flag[2] != 0)
10091 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10092 argument_list[2].long_reference);
10093 if (attribute_flag[3] != 0)
10094 channel=(ChannelType) argument_list[3].long_reference;
10095 image=SparseColorImage(image,channel,method,number_coordinates,
10096 coordinates,exception);
10097 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10098 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10099 coordinates=(double *) RelinquishMagickMemory(coordinates);
10102 case 120: /* Function */
10119 if (attribute_flag[0] == 0)
10121 function=UndefinedFunction;
10122 if (attribute_flag[1] != 0)
10123 function=(MagickFunction) argument_list[1].long_reference;
10124 av=(AV *) argument_list[0].array_reference;
10125 number_parameters=(unsigned long) av_len(av)+1;
10126 parameters=(double *) AcquireQuantumMemory(number_parameters,
10127 sizeof(*parameters));
10128 if (parameters == (double *) NULL)
10130 ThrowPerlException(exception,ResourceLimitFatalError,
10131 "MemoryAllocationFailed",PackageName);
10132 goto PerlException;
10134 for (j=0; j < (long) number_parameters; j++)
10135 parameters[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].long_reference);
10140 (void) FunctionImage(image,function,number_parameters,parameters,
10142 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10143 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10144 parameters=(double *) RelinquishMagickMemory(parameters);
10147 case 121: /* SelectiveBlur */
10149 if (attribute_flag[0] != 0)
10151 flags=ParseGeometry(argument_list[0].string_reference,
10153 if ((flags & SigmaValue) == 0)
10154 geometry_info.sigma=1.0;
10155 if ((flags & PercentValue) != 0)
10156 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10158 if (attribute_flag[1] != 0)
10159 geometry_info.rho=argument_list[1].real_reference;
10160 if (attribute_flag[2] != 0)
10161 geometry_info.sigma=argument_list[2].real_reference;
10162 if (attribute_flag[3] != 0)
10163 geometry_info.xi=argument_list[3].long_reference;;
10164 if (attribute_flag[4] != 0)
10165 channel=(ChannelType) argument_list[4].long_reference;
10166 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10167 geometry_info.sigma,geometry_info.xi,exception);
10170 case 122: /* HaldClut */
10172 if (attribute_flag[0] == 0)
10174 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10176 goto PerlException;
10178 if (attribute_flag[1] != 0)
10179 channel=(ChannelType) argument_list[1].long_reference;
10180 (void) HaldClutImageChannel(image,channel,
10181 argument_list[0].image_reference);
10184 case 123: /* BlueShift */
10186 if (attribute_flag[0] != 0)
10187 (void) ParseGeometry(argument_list[0].string_reference,
10189 image=BlueShiftImage(image,geometry_info.rho,exception);
10192 case 124: /* ForwardFourierTransformImage */
10194 image=ForwardFourierTransformImage(image,
10195 argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse,
10199 case 125: /* InverseFourierTransformImage */
10201 image=InverseFourierTransformImage(image,image->next,
10202 argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse,
10206 case 126: /* ColorDecisionList */
10208 if (attribute_flag[0] == 0)
10209 argument_list[0].string_reference=(char *) NULL;
10210 (void) ColorDecisionListImage(image,
10211 argument_list[0].string_reference);
10214 case 127: /* AutoGamma */
10216 if (attribute_flag[0] != 0)
10217 channel=(ChannelType) argument_list[0].long_reference;
10218 (void) AutoGammaImageChannel(image,channel);
10221 case 128: /* AutoLevel */
10223 if (attribute_flag[0] != 0)
10224 channel=(ChannelType) argument_list[0].long_reference;
10225 (void) AutoLevelImageChannel(image,channel);
10228 case 129: /* LevelColors */
10234 (void) QueryMagickColor("#000000",&black_point,exception);
10235 (void) QueryMagickColor("#ffffff",&black_point,exception);
10236 if (attribute_flag[1] != 0)
10237 (void) QueryMagickColor(argument_list[1].string_reference,
10238 &black_point,exception);
10239 if (attribute_flag[2] != 0)
10240 (void) QueryMagickColor(argument_list[2].string_reference,
10241 &white_point,exception);
10242 if (attribute_flag[3] != 0)
10243 channel=(ChannelType) argument_list[3].long_reference;
10244 (void) LevelColorsImageChannel(image,channel,&black_point,
10245 &white_point,argument_list[0].long_reference != 0 ? MagickTrue :
10249 case 130: /* Clamp */
10251 if (attribute_flag[0] != 0)
10252 channel=(ChannelType) argument_list[0].long_reference;
10253 (void) ClampImageChannel(image,channel);
10256 case 131: /* Filter */
10261 if (attribute_flag[0] == 0)
10263 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10264 if (kernel == (KernelInfo *) NULL)
10266 if (attribute_flag[1] != 0)
10267 channel=(ChannelType) argument_list[1].long_reference;
10268 if (attribute_flag[2] != 0)
10269 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10271 image=FilterImageChannel(image,channel,kernel,exception);
10272 kernel=DestroyKernelInfo(kernel);
10275 case 132: /* BrightnessContrast */
10283 if (attribute_flag[0] != 0)
10285 flags=ParseGeometry(argument_list[0].string_reference,
10287 brightness=geometry_info.rho;
10288 if ((flags & SigmaValue) == 0)
10289 contrast=geometry_info.sigma;
10291 if (attribute_flag[1] != 0)
10292 brightness=argument_list[1].real_reference;
10293 if (attribute_flag[2] != 0)
10294 contrast=argument_list[2].real_reference;
10295 if (attribute_flag[4] != 0)
10296 channel=(ChannelType) argument_list[4].long_reference;
10297 (void) BrightnessContrastImageChannel(image,channel,brightness,
10301 case 133: /* Morphology */
10312 if (attribute_flag[0] == 0)
10314 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10315 if (kernel == (KernelInfo *) NULL)
10317 if (attribute_flag[1] != 0)
10318 channel=(ChannelType) argument_list[1].long_reference;
10319 method=UndefinedMorphology;
10320 if (attribute_flag[2] != 0)
10321 method=argument_list[2].long_reference;
10323 if (attribute_flag[3] != 0)
10324 iterations=argument_list[4].long_reference;
10325 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10327 kernel=DestroyKernelInfo(kernel);
10331 if (next != (Image *) NULL)
10332 (void) CatchImageException(next);
10333 if (region_image != (Image *) NULL)
10338 status=CompositeImage(region_image,CopyCompositeOp,image,
10339 region_info.x,region_info.y);
10340 (void) CatchImageException(region_image);
10341 image=DestroyImage(image);
10342 image=region_image;
10344 if (image != (Image *) NULL)
10347 if (next && (next != image))
10349 image->next=next->next;
10350 DeleteImageFromRegistry(*pv,next);
10352 sv_setiv(*pv,(IV) image);
10360 if (reference_vector)
10361 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10362 InheritPerlException(exception,perl_exception);
10363 exception=DestroyExceptionInfo(exception);
10364 sv_setiv(perl_exception,(IV) number_images);
10365 SvPOK_on(perl_exception);
10366 ST(0)=sv_2mortal(perl_exception);
10371 ###############################################################################
10379 ###############################################################################
10384 Image::Magick ref=NO_INIT
10429 exception=AcquireExceptionInfo();
10430 perl_exception=newSVpv("",0);
10432 if (sv_isobject(ST(0)) == 0)
10434 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10436 goto PerlException;
10438 reference=SvRV(ST(0));
10439 hv=SvSTASH(reference);
10441 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10443 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10444 if (image == (Image *) NULL)
10446 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10448 goto PerlException;
10453 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10454 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10455 (void) QueryMagickColor("none",&transparent_color,exception);
10456 for (i=2; i < items; i+=2)
10458 attribute=(char *) SvPV(ST(i-1),na);
10459 switch (*attribute)
10464 if (LocaleCompare(attribute,"background") == 0)
10466 (void) QueryColorDatabase(SvPV(ST(i),na),
10467 &montage_info->background_color,exception);
10468 for (next=image; next; next=next->next)
10469 next->background_color=montage_info->background_color;
10472 if (LocaleCompare(attribute,"border") == 0)
10474 montage_info->border_width=SvIV(ST(i));
10477 if (LocaleCompare(attribute,"bordercolor") == 0)
10479 (void) QueryColorDatabase(SvPV(ST(i),na),
10480 &montage_info->border_color,exception);
10481 for (next=image; next; next=next->next)
10482 next->border_color=montage_info->border_color;
10485 if (LocaleCompare(attribute,"borderwidth") == 0)
10487 montage_info->border_width=SvIV(ST(i));
10490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10497 if (LocaleCompare(attribute,"compose") == 0)
10499 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
10500 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10503 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10507 for (next=image; next; next=next->next)
10508 next->compose=(CompositeOperator) sp;
10511 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10518 if (LocaleCompare(attribute,"fill") == 0)
10520 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10524 if (LocaleCompare(attribute,"font") == 0)
10526 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10529 if (LocaleCompare(attribute,"frame") == 0)
10535 if (IsGeometry(p) == MagickFalse)
10537 ThrowPerlException(exception,OptionError,"MissingGeometry",
10541 (void) CloneString(&montage_info->frame,p);
10543 montage_info->frame=(char *) NULL;
10546 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10553 if (LocaleCompare(attribute,"geometry") == 0)
10559 if (IsGeometry(p) == MagickFalse)
10561 ThrowPerlException(exception,OptionError,"MissingGeometry",
10565 (void) CloneString(&montage_info->geometry,p);
10567 montage_info->geometry=(char *) NULL;
10570 if (LocaleCompare(attribute,"gravity") == 0)
10575 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
10576 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10579 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10583 montage_info->gravity=(GravityType) in;
10584 for (next=image; next; next=next->next)
10585 next->gravity=(GravityType) in;
10588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10595 if (LocaleCompare(attribute,"label") == 0)
10597 for (next=image; next; next=next->next)
10598 (void) SetImageProperty(next,"label",InterpretImageProperties(
10599 info ? info->image_info : (ImageInfo *) NULL,next,
10603 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10610 if (LocaleCompare(attribute,"mattecolor") == 0)
10612 (void) QueryColorDatabase(SvPV(ST(i),na),
10613 &montage_info->matte_color,exception);
10614 for (next=image; next; next=next->next)
10615 next->matte_color=montage_info->matte_color;
10618 if (LocaleCompare(attribute,"mode") == 0)
10623 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10624 ParseMagickOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10629 ThrowPerlException(exception,OptionError,
10630 "UnrecognizedModeType",SvPV(ST(i),na));
10635 (void) CloneString(&montage_info->frame,"15x15+3+3");
10636 montage_info->shadow=MagickTrue;
10641 montage_info->frame=(char *) NULL;
10642 montage_info->shadow=MagickFalse;
10643 montage_info->border_width=0;
10646 case ConcatenateMode:
10648 montage_info->frame=(char *) NULL;
10649 montage_info->shadow=MagickFalse;
10650 (void) CloneString(&montage_info->geometry,"+0+0");
10651 montage_info->border_width=0;
10656 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10663 if (LocaleCompare(attribute,"pointsize") == 0)
10665 montage_info->pointsize=SvIV(ST(i));
10668 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10675 if (LocaleCompare(attribute,"shadow") == 0)
10677 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
10678 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
10681 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10685 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
10688 if (LocaleCompare(attribute,"stroke") == 0)
10690 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
10694 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10701 if (LocaleCompare(attribute,"texture") == 0)
10703 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
10706 if (LocaleCompare(attribute,"tile") == 0)
10708 char *p=SvPV(ST(i),na);
10709 if (IsGeometry(p) == MagickFalse)
10711 ThrowPerlException(exception,OptionError,"MissingGeometry",
10715 (void) CloneString(&montage_info->tile,p);
10717 montage_info->tile=(char *) NULL;
10720 if (LocaleCompare(attribute,"title") == 0)
10722 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
10725 if (LocaleCompare(attribute,"transparent") == 0)
10730 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
10731 for (next=image; next; next=next->next)
10732 (void) TransparentPaintImage(next,&transparent_color,
10733 TransparentOpacity,MagickFalse);
10736 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10742 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10748 image=MontageImageList(info->image_info,montage_info,image,exception);
10749 montage_info=DestroyMontageInfo(montage_info);
10750 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
10751 goto PerlException;
10752 if (transparent_color.opacity != TransparentOpacity)
10753 for (next=image; next; next=next->next)
10754 (void) TransparentPaintImage(next,&transparent_color,
10755 TransparentOpacity,MagickFalse);
10756 for ( ; image; image=image->next)
10758 AddImageToRegistry(image);
10760 av_push(av,sv_bless(rv,hv));
10763 exception=DestroyExceptionInfo(exception);
10764 ST(0)=av_reference;
10765 SvREFCNT_dec(perl_exception);
10769 InheritPerlException(exception,perl_exception);
10770 exception=DestroyExceptionInfo(exception);
10771 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
10772 SvPOK_on(perl_exception);
10773 ST(0)=sv_2mortal(perl_exception);
10778 ###############################################################################
10786 ###############################################################################
10791 Image::Magick ref=NO_INIT
10829 exception=AcquireExceptionInfo();
10830 perl_exception=newSVpv("",0);
10833 if (sv_isobject(ST(0)) == 0)
10835 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10837 goto PerlException;
10839 reference=SvRV(ST(0));
10840 hv=SvSTASH(reference);
10842 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10844 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10845 if (image == (Image *) NULL)
10847 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10849 goto PerlException;
10851 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10856 for (i=2; i < items; i+=2)
10858 attribute=(char *) SvPV(ST(i-1),na);
10859 switch (*attribute)
10864 if (LocaleCompare(attribute,"frames") == 0)
10866 number_frames=SvIV(ST(i));
10869 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10875 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10881 image=MorphImages(image,number_frames,exception);
10882 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
10883 goto PerlException;
10884 for ( ; image; image=image->next)
10886 AddImageToRegistry(image);
10888 av_push(av,sv_bless(rv,hv));
10891 exception=DestroyExceptionInfo(exception);
10892 ST(0)=av_reference;
10893 SvREFCNT_dec(perl_exception); /* can't return warning messages */
10897 InheritPerlException(exception,perl_exception);
10898 exception=DestroyExceptionInfo(exception);
10899 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
10900 SvPOK_on(perl_exception);
10901 ST(0)=sv_2mortal(perl_exception);
10906 ###############################################################################
10914 ###############################################################################
10919 Image::Magick ref=NO_INIT
10947 exception=AcquireExceptionInfo();
10948 perl_exception=newSVpv("",0);
10949 if (sv_isobject(ST(0)) == 0)
10951 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10953 goto PerlException;
10955 reference=SvRV(ST(0));
10956 hv=SvSTASH(reference);
10957 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10958 if (image == (Image *) NULL)
10960 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10962 goto PerlException;
10964 image=MergeImageLayers(image,MosaicLayer,exception);
10966 Create blessed Perl array for the returned image.
10969 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10971 AddImageToRegistry(image);
10973 av_push(av,sv_bless(rv,hv));
10975 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10976 (void) CopyMagickString(image->filename,info->image_info->filename,
10978 SetImageInfo(info->image_info,MagickFalse,&image->exception);
10979 exception=DestroyExceptionInfo(exception);
10980 SvREFCNT_dec(perl_exception);
10984 InheritPerlException(exception,perl_exception);
10985 exception=DestroyExceptionInfo(exception);
10986 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
10987 SvPOK_on(perl_exception); /* return messages in string context */
10988 ST(0)=sv_2mortal(perl_exception);
10993 ###############################################################################
11001 ###############################################################################
11006 Image::Magick ref=NO_INIT
11059 exception=AcquireExceptionInfo();
11060 perl_exception=newSVpv("",0);
11061 package_info=(struct PackageInfo *) NULL;
11062 ac=(items < 2) ? 1 : items-1;
11063 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11065 length=(STRLEN *) NULL;
11066 if (list == (char **) NULL)
11068 ThrowPerlException(exception,ResourceLimitError,
11069 "MemoryAllocationFailed",PackageName);
11070 goto PerlException;
11073 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11074 if (length == (STRLEN *) NULL)
11076 ThrowPerlException(exception,ResourceLimitError,
11077 "MemoryAllocationFailed",PackageName);
11078 goto PerlException;
11080 if (sv_isobject(ST(0)) == 0)
11082 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11084 goto PerlException;
11086 reference=SvRV(ST(0));
11087 hv=SvSTASH(reference);
11088 if (SvTYPE(reference) != SVt_PVAV)
11090 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11092 goto PerlException;
11094 av=(AV *) reference;
11095 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11097 package_info=ClonePackageInfo(info,exception);
11100 *list=(char *) (*package_info->image_info->filename ?
11101 package_info->image_info->filename : "XC:black");
11103 for (n=0, i=0; i < ac; i++)
11105 list[n]=(char *) SvPV(ST(i+1),length[n]);
11106 if ((items >= 3) && strEQcase(list[n],"blob"))
11112 blob=(void *) (SvPV(ST(i+1),length[n]));
11113 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11115 if ((items >= 3) && strEQcase(list[n],"filename"))
11117 if ((items >= 3) && strEQcase(list[n],"file"))
11126 io_info=IoIFP(sv_2io(ST(i+1)));
11127 if (io_info == (PerlIO *) NULL)
11129 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11133 file=PerlIO_findFILE(io_info);
11134 if (file == (FILE *) NULL)
11136 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11140 SetImageInfoFile(package_info->image_info,file);
11142 if ((items >= 3) && strEQcase(list[n],"magick"))
11146 list[n]=(char *) NULL;
11148 status=ExpandFilenames(&n,&list);
11149 if (status == MagickFalse)
11151 ThrowPerlException(exception,ResourceLimitError,
11152 "MemoryAllocationFailed",PackageName);
11153 goto PerlException;
11156 for (i=0; i < n; i++)
11158 (void) CopyMagickString(package_info->image_info->filename,list[i],
11160 image=PingImage(package_info->image_info,exception);
11161 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11163 if ((package_info->image_info->file != (FILE *) NULL) ||
11164 (package_info->image_info->blob != (void *) NULL))
11165 DisassociateImageStream(image);
11166 count+=GetImageListLength(image);
11167 EXTEND(sp,4*count);
11168 for (next=image; next; next=next->next)
11170 PUSHs(sv_2mortal(newSViv(next->columns)));
11171 PUSHs(sv_2mortal(newSViv(next->rows)));
11172 PUSHs(sv_2mortal(newSViv((unsigned long) GetBlobSize(next))));
11173 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11175 image=DestroyImageList(image);
11180 for (i=0; i < n; i++)
11181 if (list[i] != (char *) NULL)
11182 for (p=keep; list[i] != *p++; )
11185 list[i]=(char *) RelinquishMagickMemory(list[i]);
11190 if (package_info != (struct PackageInfo *) NULL)
11191 DestroyPackageInfo(package_info);
11192 if (list && (list != keep))
11193 list=(char **) RelinquishMagickMemory(list);
11195 keep=(char **) RelinquishMagickMemory(keep);
11197 length=(STRLEN *) RelinquishMagickMemory(length);
11198 InheritPerlException(exception,perl_exception);
11199 exception=DestroyExceptionInfo(exception);
11200 SvREFCNT_dec(perl_exception); /* throw away all errors */
11204 ###############################################################################
11212 ###############################################################################
11217 Image::Magick ref=NO_INIT
11250 exception=AcquireExceptionInfo();
11251 perl_exception=newSVpv("",0);
11253 if (sv_isobject(ST(0)) == 0)
11255 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11257 goto PerlException;
11259 reference=SvRV(ST(0));
11260 hv=SvSTASH(reference);
11262 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11264 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11265 if (image == (Image *) NULL)
11267 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11269 goto PerlException;
11271 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11272 preview_type=GammaPreview;
11274 preview_type=(PreviewType)
11275 ParseMagickOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11276 for ( ; image; image=image->next)
11278 preview_image=PreviewImage(image,preview_type,exception);
11279 if (preview_image == (Image *) NULL)
11280 goto PerlException;
11281 AddImageToRegistry(preview_image);
11283 av_push(av,sv_bless(rv,hv));
11286 exception=DestroyExceptionInfo(exception);
11287 ST(0)=av_reference;
11288 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11292 InheritPerlException(exception,perl_exception);
11293 exception=DestroyExceptionInfo(exception);
11294 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11295 SvPOK_on(perl_exception);
11296 ST(0)=sv_2mortal(perl_exception);
11301 ###############################################################################
11305 # Q u e r y C o l o r #
11309 ###############################################################################
11313 QueryColor(ref,...)
11314 Image::Magick ref=NO_INIT
11334 exception=AcquireExceptionInfo();
11335 perl_exception=newSVpv("",0);
11344 colorlist=GetColorInfoList("*",&colors,exception);
11346 for (i=0; i < (long) colors; i++)
11348 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11350 colorlist=(const ColorInfo **)
11351 RelinquishMagickMemory((ColorInfo **) colorlist);
11352 goto PerlException;
11354 EXTEND(sp,5*items);
11355 for (i=1; i < items; i++)
11357 name=(char *) SvPV(ST(i),na);
11358 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11363 PUSHs(sv_2mortal(newSViv((unsigned long) (color.red+0.5))));
11364 PUSHs(sv_2mortal(newSViv((unsigned long) (color.green+0.5))));
11365 PUSHs(sv_2mortal(newSViv((unsigned long) (color.blue+0.5))));
11366 if (color.matte != MagickFalse)
11367 PUSHs(sv_2mortal(newSViv((unsigned long) (color.opacity+0.5))));
11368 if (color.colorspace == CMYKColorspace)
11369 PUSHs(sv_2mortal(newSViv((unsigned long) (color.index+0.5))));
11373 InheritPerlException(exception,perl_exception);
11374 exception=DestroyExceptionInfo(exception);
11375 SvREFCNT_dec(perl_exception);
11379 ###############################################################################
11383 # Q u e r y C o l o r N a m e #
11387 ###############################################################################
11391 QueryColorname(ref,...)
11392 Image::Magick ref=NO_INIT
11401 message[MaxTextExtent];
11420 *reference; /* reference is the SV* of ref=SvIV(reference) */
11422 exception=AcquireExceptionInfo();
11423 perl_exception=newSVpv("",0);
11424 reference=SvRV(ST(0));
11425 av=(AV *) reference;
11426 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11428 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11429 if (image == (Image *) NULL)
11431 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11433 goto PerlException;
11436 for (i=1; i < items; i++)
11438 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11439 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11441 PUSHs(sv_2mortal(newSVpv(message,0)));
11445 InheritPerlException(exception,perl_exception);
11446 exception=DestroyExceptionInfo(exception);
11447 SvREFCNT_dec(perl_exception);
11451 ###############################################################################
11455 # Q u e r y F o n t #
11459 ###############################################################################
11464 Image::Magick ref=NO_INIT
11471 message[MaxTextExtent];
11482 volatile const TypeInfo
11485 exception=AcquireExceptionInfo();
11486 perl_exception=newSVpv("",0);
11495 typelist=GetTypeInfoList("*",&types,exception);
11497 for (i=0; i < (long) types; i++)
11499 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11501 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11503 goto PerlException;
11505 EXTEND(sp,10*items);
11506 for (i=1; i < items; i++)
11508 name=(char *) SvPV(ST(i),na);
11509 type_info=GetTypeInfo(name,exception);
11510 if (type_info == (TypeInfo *) NULL)
11515 if (type_info->name == (char *) NULL)
11518 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11519 if (type_info->description == (char *) NULL)
11522 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11523 if (type_info->family == (char *) NULL)
11526 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11527 if (type_info->style == UndefinedStyle)
11530 PUSHs(sv_2mortal(newSVpv(MagickOptionToMnemonic(MagickStyleOptions,
11531 type_info->style),0)));
11532 if (type_info->stretch == UndefinedStretch)
11535 PUSHs(sv_2mortal(newSVpv(MagickOptionToMnemonic(MagickStretchOptions,
11536 type_info->stretch),0)));
11537 (void) FormatMagickString(message,MaxTextExtent,"%lu",type_info->weight);
11538 PUSHs(sv_2mortal(newSVpv(message,0)));
11539 if (type_info->encoding == (char *) NULL)
11542 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11543 if (type_info->foundry == (char *) NULL)
11546 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11547 if (type_info->format == (char *) NULL)
11550 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11551 if (type_info->metrics == (char *) NULL)
11554 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11555 if (type_info->glyphs == (char *) NULL)
11558 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11562 InheritPerlException(exception,perl_exception);
11563 exception=DestroyExceptionInfo(exception);
11564 SvREFCNT_dec(perl_exception);
11568 ###############################################################################
11572 # Q u e r y F o n t M e t r i c s #
11576 ###############################################################################
11580 QueryFontMetrics(ref,...)
11581 Image::Magick ref=NO_INIT
11583 queryfontmetrics = 1
11630 *reference; /* reference is the SV* of ref=SvIV(reference) */
11635 exception=AcquireExceptionInfo();
11636 package_info=(struct PackageInfo *) NULL;
11637 perl_exception=newSVpv("",0);
11638 reference=SvRV(ST(0));
11639 av=(AV *) reference;
11640 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11642 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11643 if (image == (Image *) NULL)
11645 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11647 goto PerlException;
11649 package_info=ClonePackageInfo(info,exception);
11650 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
11651 CloneString(&draw_info->text,"");
11652 current=draw_info->affine;
11653 GetAffineMatrix(&affine);
11656 EXTEND(sp,7*items);
11657 for (i=2; i < items; i+=2)
11659 attribute=(char *) SvPV(ST(i-1),na);
11660 switch (*attribute)
11665 if (LocaleCompare(attribute,"antialias") == 0)
11667 type=ParseMagickOption(MagickBooleanOptions,MagickFalse,
11671 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11675 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
11678 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11685 if (LocaleCompare(attribute,"density") == 0)
11687 CloneString(&draw_info->density,SvPV(ST(i),na));
11690 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11697 if (LocaleCompare(attribute,"encoding") == 0)
11699 CloneString(&draw_info->encoding,SvPV(ST(i),na));
11702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11709 if (LocaleCompare(attribute,"family") == 0)
11711 CloneString(&draw_info->family,SvPV(ST(i),na));
11714 if (LocaleCompare(attribute,"fill") == 0)
11717 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
11718 &image->exception);
11721 if (LocaleCompare(attribute,"font") == 0)
11723 CloneString(&draw_info->font,SvPV(ST(i),na));
11726 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11733 if (LocaleCompare(attribute,"geometry") == 0)
11735 CloneString(&draw_info->geometry,SvPV(ST(i),na));
11738 if (LocaleCompare(attribute,"gravity") == 0)
11740 draw_info->gravity=(GravityType) ParseMagickOption(
11741 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11744 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11751 if (LocaleCompare(attribute,"interline-spacing") == 0)
11753 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11754 draw_info->interline_spacing=geometry_info.rho;
11757 if (LocaleCompare(attribute,"interword-spacing") == 0)
11759 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11760 draw_info->interword_spacing=geometry_info.rho;
11763 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11770 if (LocaleCompare(attribute,"kerning") == 0)
11772 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11773 draw_info->kerning=geometry_info.rho;
11776 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11783 if (LocaleCompare(attribute,"pointsize") == 0)
11785 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11786 draw_info->pointsize=geometry_info.rho;
11789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11796 if (LocaleCompare(attribute,"rotate") == 0)
11798 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11799 affine.rx=geometry_info.rho;
11800 affine.ry=geometry_info.sigma;
11801 if ((flags & SigmaValue) == 0)
11802 affine.ry=affine.rx;
11805 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11812 if (LocaleCompare(attribute,"scale") == 0)
11814 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11815 affine.sx=geometry_info.rho;
11816 affine.sy=geometry_info.sigma;
11817 if ((flags & SigmaValue) == 0)
11818 affine.sy=affine.sx;
11821 if (LocaleCompare(attribute,"skew") == 0)
11827 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11828 x_angle=geometry_info.rho;
11829 y_angle=geometry_info.sigma;
11830 if ((flags & SigmaValue) == 0)
11832 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
11833 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
11836 if (LocaleCompare(attribute,"stroke") == 0)
11839 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
11840 &image->exception);
11843 if (LocaleCompare(attribute,"style") == 0)
11845 type=ParseMagickOption(MagickStyleOptions,MagickFalse,
11849 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11853 draw_info->style=(StyleType) type;
11856 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11863 if (LocaleCompare(attribute,"text") == 0)
11865 CloneString(&draw_info->text,SvPV(ST(i),na));
11868 if (LocaleCompare(attribute,"translate") == 0)
11870 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11871 affine.tx=geometry_info.rho;
11872 affine.ty=geometry_info.sigma;
11873 if ((flags & SigmaValue) == 0)
11874 affine.ty=affine.tx;
11877 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11884 if (LocaleCompare(attribute,"weight") == 0)
11886 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11887 draw_info->weight=(unsigned long) geometry_info.rho;
11890 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11897 if (LocaleCompare(attribute,"x") == 0)
11899 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11900 x=geometry_info.rho;
11903 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11910 if (LocaleCompare(attribute,"y") == 0)
11912 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11913 y=geometry_info.rho;
11916 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11922 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11928 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
11929 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
11930 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
11931 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
11932 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
11933 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
11934 if (draw_info->geometry == (char *) NULL)
11936 draw_info->geometry=AcquireString((char *) NULL);
11937 (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
11938 "%.15g,%.15g",x,y);
11940 status=GetTypeMetrics(image,draw_info,&metrics);
11941 (void) CatchImageException(image);
11942 if (status == MagickFalse)
11946 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
11947 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
11948 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
11949 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
11950 PUSHs(sv_2mortal(newSVnv(metrics.width)));
11951 PUSHs(sv_2mortal(newSVnv(metrics.height)));
11952 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
11953 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
11954 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
11955 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
11956 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
11957 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
11958 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
11960 draw_info=DestroyDrawInfo(draw_info);
11963 if (package_info != (struct PackageInfo *) NULL)
11964 DestroyPackageInfo(package_info);
11965 InheritPerlException(exception,perl_exception);
11966 exception=DestroyExceptionInfo(exception);
11967 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11971 ###############################################################################
11975 # 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 #
11979 ###############################################################################
11983 QueryMultilineFontMetrics(ref,...)
11984 Image::Magick ref=NO_INIT
11986 querymultilinefontmetrics = 1
12033 *reference; /* reference is the SV* of ref=SvIV(reference) */
12038 exception=AcquireExceptionInfo();
12039 package_info=(struct PackageInfo *) NULL;
12040 perl_exception=newSVpv("",0);
12041 reference=SvRV(ST(0));
12042 av=(AV *) reference;
12043 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12045 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12046 if (image == (Image *) NULL)
12048 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12050 goto PerlException;
12052 package_info=ClonePackageInfo(info,exception);
12053 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12054 CloneString(&draw_info->text,"");
12055 current=draw_info->affine;
12056 GetAffineMatrix(&affine);
12059 EXTEND(sp,7*items);
12060 for (i=2; i < items; i+=2)
12062 attribute=(char *) SvPV(ST(i-1),na);
12063 switch (*attribute)
12068 if (LocaleCompare(attribute,"antialias") == 0)
12070 type=ParseMagickOption(MagickBooleanOptions,MagickFalse,
12074 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12078 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12081 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12088 if (LocaleCompare(attribute,"density") == 0)
12090 CloneString(&draw_info->density,SvPV(ST(i),na));
12093 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12100 if (LocaleCompare(attribute,"encoding") == 0)
12102 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12105 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12112 if (LocaleCompare(attribute,"family") == 0)
12114 CloneString(&draw_info->family,SvPV(ST(i),na));
12117 if (LocaleCompare(attribute,"fill") == 0)
12120 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12121 &image->exception);
12124 if (LocaleCompare(attribute,"font") == 0)
12126 CloneString(&draw_info->font,SvPV(ST(i),na));
12129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12136 if (LocaleCompare(attribute,"geometry") == 0)
12138 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12141 if (LocaleCompare(attribute,"gravity") == 0)
12143 draw_info->gravity=(GravityType) ParseMagickOption(
12144 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12154 if (LocaleCompare(attribute,"pointsize") == 0)
12156 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12157 draw_info->pointsize=geometry_info.rho;
12160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12167 if (LocaleCompare(attribute,"rotate") == 0)
12169 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12170 affine.rx=geometry_info.rho;
12171 affine.ry=geometry_info.sigma;
12172 if ((flags & SigmaValue) == 0)
12173 affine.ry=affine.rx;
12176 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12183 if (LocaleCompare(attribute,"scale") == 0)
12185 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12186 affine.sx=geometry_info.rho;
12187 affine.sy=geometry_info.sigma;
12188 if ((flags & SigmaValue) == 0)
12189 affine.sy=affine.sx;
12192 if (LocaleCompare(attribute,"skew") == 0)
12198 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12199 x_angle=geometry_info.rho;
12200 y_angle=geometry_info.sigma;
12201 if ((flags & SigmaValue) == 0)
12203 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12204 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12207 if (LocaleCompare(attribute,"stroke") == 0)
12210 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12211 &image->exception);
12214 if (LocaleCompare(attribute,"style") == 0)
12216 type=ParseMagickOption(MagickStyleOptions,MagickFalse,
12220 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12224 draw_info->style=(StyleType) type;
12227 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12234 if (LocaleCompare(attribute,"text") == 0)
12236 CloneString(&draw_info->text,SvPV(ST(i),na));
12239 if (LocaleCompare(attribute,"translate") == 0)
12241 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12242 affine.tx=geometry_info.rho;
12243 affine.ty=geometry_info.sigma;
12244 if ((flags & SigmaValue) == 0)
12245 affine.ty=affine.tx;
12248 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12255 if (LocaleCompare(attribute,"weight") == 0)
12257 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12258 draw_info->weight=(unsigned long) geometry_info.rho;
12261 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12268 if (LocaleCompare(attribute,"x") == 0)
12270 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12271 x=geometry_info.rho;
12274 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12281 if (LocaleCompare(attribute,"y") == 0)
12283 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12284 y=geometry_info.rho;
12287 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12293 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12299 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12300 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12301 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12302 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12303 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12304 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12305 if (draw_info->geometry == (char *) NULL)
12307 draw_info->geometry=AcquireString((char *) NULL);
12308 (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
12309 "%.15g,%.15g",x,y);
12311 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12312 (void) CatchImageException(image);
12313 if (status == MagickFalse)
12317 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12318 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12319 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12320 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12321 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12322 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12323 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12324 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12325 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12326 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12327 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12328 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12329 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12331 draw_info=DestroyDrawInfo(draw_info);
12334 if (package_info != (struct PackageInfo *) NULL)
12335 DestroyPackageInfo(package_info);
12336 InheritPerlException(exception,perl_exception);
12337 exception=DestroyExceptionInfo(exception);
12338 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12342 ###############################################################################
12346 # Q u e r y F o r m a t #
12350 ###############################################################################
12354 QueryFormat(ref,...)
12355 Image::Magick ref=NO_INIT
12372 volatile const MagickInfo
12375 exception=AcquireExceptionInfo();
12376 perl_exception=newSVpv("",0);
12380 format[MaxTextExtent];
12388 format_list=GetMagickInfoList("*",&types,exception);
12390 for (i=0; i < (long) types; i++)
12392 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12393 LocaleLower(format);
12394 PUSHs(sv_2mortal(newSVpv(format,0)));
12396 format_list=(const MagickInfo **)
12397 RelinquishMagickMemory((MagickInfo *) format_list);
12398 goto PerlException;
12400 EXTEND(sp,8*items);
12401 for (i=1; i < items; i++)
12403 name=(char *) SvPV(ST(i),na);
12404 magick_info=GetMagickInfo(name,exception);
12405 if (magick_info == (const MagickInfo *) NULL)
12410 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12411 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12412 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12413 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12414 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12415 if (magick_info->description == (char *) NULL)
12418 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12419 if (magick_info->module == (char *) NULL)
12422 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12426 InheritPerlException(exception,perl_exception);
12427 exception=DestroyExceptionInfo(exception);
12428 SvREFCNT_dec(perl_exception);
12432 ###############################################################################
12436 # Q u e r y O p t i o n #
12440 ###############################################################################
12444 QueryOption(ref,...)
12445 Image::Magick ref=NO_INIT
12466 exception=AcquireExceptionInfo();
12467 perl_exception=newSVpv("",0);
12468 EXTEND(sp,8*items);
12469 for (i=1; i < items; i++)
12471 option=ParseMagickOption(MagickListOptions,MagickFalse,(char *)
12473 options=GetMagickOptions((MagickOption) option);
12474 if (options == (char **) NULL)
12478 for (j=0; options[j] != (char *) NULL; j++)
12479 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12480 options=DestroyStringList(options);
12485 InheritPerlException(exception,perl_exception);
12486 exception=DestroyExceptionInfo(exception);
12487 SvREFCNT_dec(perl_exception);
12491 ###############################################################################
12499 ###############################################################################
12504 Image::Magick ref=NO_INIT
12551 *perl_exception, /* Perl variable for storing messages */
12556 exception=AcquireExceptionInfo();
12557 perl_exception=newSVpv("",0);
12558 package_info=(struct PackageInfo *) NULL;
12560 ac=(items < 2) ? 1 : items-1;
12561 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12563 length=(STRLEN *) NULL;
12564 if (list == (char **) NULL)
12566 ThrowPerlException(exception,ResourceLimitError,
12567 "MemoryAllocationFailed",PackageName);
12568 goto PerlException;
12570 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12571 if (length == (STRLEN *) NULL)
12573 ThrowPerlException(exception,ResourceLimitError,
12574 "MemoryAllocationFailed",PackageName);
12575 goto PerlException;
12577 if (sv_isobject(ST(0)) == 0)
12579 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12581 goto PerlException;
12583 reference=SvRV(ST(0));
12584 hv=SvSTASH(reference);
12585 if (SvTYPE(reference) != SVt_PVAV)
12587 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12589 goto PerlException;
12591 av=(AV *) reference;
12592 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12594 package_info=ClonePackageInfo(info,exception);
12597 *list=(char *) (*package_info->image_info->filename ?
12598 package_info->image_info->filename : "XC:black");
12600 for (n=0, i=0; i < ac; i++)
12602 list[n]=(char *) SvPV(ST(i+1),length[n]);
12603 if ((items >= 3) && strEQcase(list[n],"blob"))
12609 blob=(void *) (SvPV(ST(i+1),length[n]));
12610 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12612 if ((items >= 3) && strEQcase(list[n],"filename"))
12614 if ((items >= 3) && strEQcase(list[n],"file"))
12623 io_info=IoIFP(sv_2io(ST(i+1)));
12624 if (io_info == (PerlIO *) NULL)
12626 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12630 file=PerlIO_findFILE(io_info);
12631 if (file == (FILE *) NULL)
12633 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12637 SetImageInfoFile(package_info->image_info,file);
12639 if ((items >= 3) && strEQcase(list[n],"magick"))
12643 list[n]=(char *) NULL;
12645 status=ExpandFilenames(&n,&list);
12646 if (status == MagickFalse)
12648 ThrowPerlException(exception,ResourceLimitError,
12649 "MemoryAllocationFailed",PackageName);
12650 goto PerlException;
12653 for (i=0; i < n; i++)
12655 if ((package_info->image_info->file != (FILE *) NULL) ||
12656 (package_info->image_info->blob != (void *) NULL))
12658 image=ReadImages(package_info->image_info,exception);
12659 if (image != (Image *) NULL)
12660 DisassociateImageStream(image);
12664 (void) CopyMagickString(package_info->image_info->filename,list[i],
12666 image=ReadImages(package_info->image_info,exception);
12668 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
12670 for ( ; image; image=image->next)
12672 AddImageToRegistry(image);
12674 av_push(av,sv_bless(rv,hv));
12682 for (i=0; i < n; i++)
12683 if (list[i] != (char *) NULL)
12684 for (p=keep; list[i] != *p++; )
12685 if (*p == (char *) NULL)
12687 list[i]=(char *) RelinquishMagickMemory(list[i]);
12692 if (package_info != (struct PackageInfo *) NULL)
12693 DestroyPackageInfo(package_info);
12694 if (list && (list != keep))
12695 list=(char **) RelinquishMagickMemory(list);
12697 keep=(char **) RelinquishMagickMemory(keep);
12699 length=(STRLEN *) RelinquishMagickMemory(length);
12700 InheritPerlException(exception,perl_exception);
12701 exception=DestroyExceptionInfo(exception);
12702 sv_setiv(perl_exception,(IV) number_images);
12703 SvPOK_on(perl_exception);
12704 ST(0)=sv_2mortal(perl_exception);
12709 ###############################################################################
12717 ###############################################################################
12722 Image::Magick ref=NO_INIT
12745 exception=AcquireExceptionInfo();
12746 perl_exception=newSVpv("",0);
12747 reference=SvRV(ST(0));
12748 av=(AV *) reference;
12749 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12751 for (i=1; i < items; i++)
12752 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
12753 SvPV(ST(i),na),exception);
12754 InheritPerlException(exception,perl_exception);
12755 exception=DestroyExceptionInfo(exception);
12756 SvREFCNT_dec(perl_exception); /* throw away all errors */
12760 ###############################################################################
12768 ###############################################################################
12773 Image::Magick ref=NO_INIT
12796 *reference; /* reference is the SV* of ref=SvIV(reference) */
12798 exception=AcquireExceptionInfo();
12799 perl_exception=newSVpv("",0);
12800 if (sv_isobject(ST(0)) == 0)
12802 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12804 goto PerlException;
12806 reference=SvRV(ST(0));
12807 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12809 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
12811 for (i=2; i < items; i+=2)
12812 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
12815 InheritPerlException(exception,perl_exception);
12816 exception=DestroyExceptionInfo(exception);
12817 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
12818 SvPOK_on(perl_exception);
12819 ST(0)=sv_2mortal(perl_exception);
12824 ###############################################################################
12828 # S e t P i x e l #
12832 ###############################################################################
12837 Image::Magick ref=NO_INIT
12867 register IndexPacket
12873 register PixelPacket
12881 *reference; /* reference is the SV* of ref=SvIV(reference) */
12883 exception=AcquireExceptionInfo();
12884 perl_exception=newSVpv("",0);
12885 reference=SvRV(ST(0));
12886 av=(AV *) reference;
12887 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12889 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12890 if (image == (Image *) NULL)
12892 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12894 goto PerlException;
12897 channel=DefaultChannels;
12898 normalize=MagickTrue;
12901 region.width=image->columns;
12904 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
12905 for (i=2; i < items; i+=2)
12907 attribute=(char *) SvPV(ST(i-1),na);
12908 switch (*attribute)
12913 if (LocaleCompare(attribute,"channel") == 0)
12918 option=ParseChannelOption(SvPV(ST(i),na));
12921 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12925 channel=(ChannelType) option;
12928 if (LocaleCompare(attribute,"color") == 0)
12930 if (SvTYPE(ST(i)) != SVt_RV)
12933 message[MaxTextExtent];
12935 (void) FormatMagickString(message,MaxTextExtent,
12936 "invalid %.60s value",attribute);
12937 ThrowPerlException(exception,OptionError,message,
12940 av=(AV *) SvRV(ST(i));
12943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12950 if (LocaleCompare(attribute,"geometry") == 0)
12952 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
12955 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12962 if (LocaleCompare(attribute,"normalize") == 0)
12964 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
12968 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12972 normalize=option != 0 ? MagickTrue : MagickFalse;
12975 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12982 if (LocaleCompare(attribute,"x") == 0)
12984 region.x=SvIV(ST(i));
12987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12994 if (LocaleCompare(attribute,"y") == 0)
12996 region.y=SvIV(ST(i));
12999 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13011 (void) SetImageStorageClass(image,DirectClass);
13012 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13013 if ((q == (PixelPacket *) NULL) || (av == (AV *) NULL))
13024 indexes=GetAuthenticIndexQueue(image);
13026 if (normalize != MagickFalse)
13027 scale=QuantumRange;
13028 if (((channel & RedChannel) != 0) && (i <= av_len(av)))
13030 q->red=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13033 if (((channel & GreenChannel) != 0) && (i <= av_len(av)))
13035 q->green=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13038 if (((channel & BlueChannel) != 0) && (i <= av_len(av)))
13040 q->blue=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13043 if ((((channel & IndexChannel) != 0) &&
13044 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13046 *indexes=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13049 if (((channel & OpacityChannel) != 0) && (i <= av_len(av)))
13051 q->opacity=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13054 (void) SyncAuthenticPixels(image,exception);
13058 InheritPerlException(exception,perl_exception);
13059 exception=DestroyExceptionInfo(exception);
13060 SvREFCNT_dec(perl_exception);
13064 ###############################################################################
13068 # S t a t i s t i c s #
13072 ###############################################################################
13076 Statistics(ref,...)
13077 Image::Magick ref=NO_INIT
13079 StatisticsImage = 1
13081 statisticsimage = 3
13084 #define ChannelStatistics(channel) \
13086 (void) FormatMagickString(message,MaxTextExtent,"%lu", \
13087 channel_statistics[channel].depth); \
13088 PUSHs(sv_2mortal(newSVpv(message,0))); \
13089 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13090 channel_statistics[channel].minima/scale); \
13091 PUSHs(sv_2mortal(newSVpv(message,0))); \
13092 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13093 channel_statistics[channel].maxima/scale); \
13094 PUSHs(sv_2mortal(newSVpv(message,0))); \
13095 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13096 channel_statistics[channel].mean/scale); \
13097 PUSHs(sv_2mortal(newSVpv(message,0))); \
13098 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13099 channel_statistics[channel].standard_deviation/scale); \
13100 PUSHs(sv_2mortal(newSVpv(message,0))); \
13101 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13102 channel_statistics[channel].kurtosis); \
13103 PUSHs(sv_2mortal(newSVpv(message,0))); \
13104 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13105 channel_statistics[channel].skewness); \
13106 PUSHs(sv_2mortal(newSVpv(message,0))); \
13113 message[MaxTextExtent];
13116 *channel_statistics;
13141 exception=AcquireExceptionInfo();
13142 perl_exception=newSVpv("",0);
13144 if (sv_isobject(ST(0)) == 0)
13146 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13148 goto PerlException;
13150 reference=SvRV(ST(0));
13151 hv=SvSTASH(reference);
13153 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13155 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13156 if (image == (Image *) NULL)
13158 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13160 goto PerlException;
13162 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13164 for ( ; image; image=image->next)
13166 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13167 if (channel_statistics == (ChannelStatistics *) NULL)
13170 EXTEND(sp,35*count);
13171 scale=(double) QuantumRange;
13172 ChannelStatistics(RedChannel);
13173 ChannelStatistics(GreenChannel);
13174 ChannelStatistics(BlueChannel);
13175 if (image->colorspace == CMYKColorspace)
13176 ChannelStatistics(IndexChannel);
13177 if (image->matte != MagickFalse)
13178 ChannelStatistics(OpacityChannel);
13179 channel_statistics=(ChannelStatistics *)
13180 RelinquishMagickMemory(channel_statistics);
13184 InheritPerlException(exception,perl_exception);
13185 exception=DestroyExceptionInfo(exception);
13186 SvREFCNT_dec(perl_exception);
13190 ###############################################################################
13194 # S y n c A u t h e n t i c P i x e l s #
13198 ###############################################################################
13202 SyncAuthenticPixels(ref,...)
13203 Image::Magick ref = NO_INIT
13205 Syncauthenticpixels = 1
13206 SyncImagePixels = 2
13207 syncimagepixels = 3
13226 exception=AcquireExceptionInfo();
13227 perl_exception=newSVpv("",0);
13229 if (sv_isobject(ST(0)) == 0)
13231 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13233 goto PerlException;
13236 reference=SvRV(ST(0));
13237 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13238 if (image == (Image *) NULL)
13240 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13242 goto PerlException;
13245 status=SyncAuthenticPixels(image,exception);
13246 if (status != MagickFalse)
13248 InheritException(exception,&image->exception);
13251 InheritPerlException(exception,perl_exception);
13252 exception=DestroyExceptionInfo(exception);
13253 SvREFCNT_dec(perl_exception); /* throw away all errors */
13257 ###############################################################################
13261 # T r a n s f o r m #
13265 ###############################################################################
13270 Image::Magick ref=NO_INIT
13308 exception=AcquireExceptionInfo();
13309 perl_exception=newSVpv("",0);
13312 if (sv_isobject(ST(0)) == 0)
13314 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13316 goto PerlException;
13318 reference=SvRV(ST(0));
13319 hv=SvSTASH(reference);
13321 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13323 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13324 if (image == (Image *) NULL)
13326 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13328 goto PerlException;
13330 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13334 crop_geometry=(char *) NULL;
13335 geometry=(char *) NULL;
13336 for (i=2; i < items; i+=2)
13338 attribute=(char *) SvPV(ST(i-1),na);
13339 switch (*attribute)
13344 if (LocaleCompare(attribute,"crop") == 0)
13346 crop_geometry=SvPV(ST(i),na);
13349 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13356 if (LocaleCompare(attribute,"geometry") == 0)
13358 geometry=SvPV(ST(i),na);
13361 if (LocaleCompare(attribute,"gravity") == 0)
13369 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
13370 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13373 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13377 for (next=image; next; next=next->next)
13378 next->gravity=(GravityType) in;
13381 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13387 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13393 for ( ; image; image=image->next)
13395 clone=CloneImage(image,0,0,MagickTrue,exception);
13396 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13397 goto PerlException;
13398 TransformImage(&clone,crop_geometry,geometry);
13399 for ( ; clone; clone=clone->next)
13401 AddImageToRegistry(clone);
13403 av_push(av,sv_bless(rv,hv));
13407 exception=DestroyExceptionInfo(exception);
13408 ST(0)=av_reference;
13409 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13413 InheritPerlException(exception,perl_exception);
13414 exception=DestroyExceptionInfo(exception);
13415 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13416 SvPOK_on(perl_exception);
13417 ST(0)=sv_2mortal(perl_exception);
13422 ###############################################################################
13430 ###############################################################################
13435 Image::Magick ref=NO_INIT
13443 filename[MaxTextExtent];
13467 exception=AcquireExceptionInfo();
13468 perl_exception=newSVpv("",0);
13470 package_info=(struct PackageInfo *) NULL;
13471 if (sv_isobject(ST(0)) == 0)
13473 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13475 goto PerlException;
13477 reference=SvRV(ST(0));
13478 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13479 if (image == (Image *) NULL)
13481 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13483 goto PerlException;
13485 package_info=ClonePackageInfo(info,exception);
13487 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
13490 for (i=2; i < items; i+=2)
13491 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
13493 (void) CopyMagickString(filename,package_info->image_info->filename,
13496 for (next=image; next; next=next->next)
13498 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
13499 next->scene=scene++;
13501 SetImageInfo(package_info->image_info,MagickTrue,&image->exception);
13502 for (next=image; next; next=next->next)
13504 (void) WriteImage(package_info->image_info,next);
13505 if (next->exception.severity >= ErrorException)
13506 InheritException(exception,&next->exception);
13507 GetImageException(next,exception);
13509 if (package_info->image_info->adjoin)
13514 if (package_info != (struct PackageInfo *) NULL)
13515 DestroyPackageInfo(package_info);
13516 InheritPerlException(exception,perl_exception);
13517 exception=DestroyExceptionInfo(exception);
13518 sv_setiv(perl_exception,(IV) number_images);
13519 SvPOK_on(perl_exception);
13520 ST(0)=sv_2mortal(perl_exception);